Java Code Examples for org.chromium.base.ApplicationStatus#registerStateListenerForAllActivities()

The following examples show how to use org.chromium.base.ApplicationStatus#registerStateListenerForAllActivities() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChromeBrowserInitializer.java    From delion with Apache License 2.0 6 votes vote down vote up
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, mApplication);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)) {
        ChromeWebApkHost.init();
    }

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
Example 2
Source File: MultiWindowUtils.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the activity to use when handling "open in other window" or "move to other window".
 * Returns null if the current activity doesn't support opening/moving tabs to another activity.
 */
public Class<? extends Activity> getOpenInOtherWindowActivity(Activity current) {

    if (current instanceof ChromeTabbedActivity2) {
        // If a second ChromeTabbedActivity is created, MultiWindowUtils needs to listen for
        // activity state changes to facilitate determining which ChromeTabbedActivity should
        // be used for intents.
        ApplicationStatus.registerStateListenerForAllActivities(sInstance.get());
        return ChromeTabbedActivity.class;
    } else if (current instanceof ChromeTabbedActivity) {
        mTabbedActivity2TaskRunning = true;
        ApplicationStatus.registerStateListenerForAllActivities(sInstance.get());
        return ChromeTabbedActivity2.class;
    } else {
        return null;
    }
}
 
Example 3
Source File: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    ChromeWebApkHost.init();

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
Example 4
Source File: MultiWindowUtils.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the activity to use when handling "open in other window" or "move to other window".
 * Returns null if the current activity doesn't support opening/moving tabs to another activity.
 */
public Class<? extends Activity> getOpenInOtherWindowActivity(Activity current) {

    if (current instanceof ChromeTabbedActivity2) {
        // If a second ChromeTabbedActivity is created, MultiWindowUtils needs to listen for
        // activity state changes to facilitate determining which ChromeTabbedActivity should
        // be used for intents.
        ApplicationStatus.registerStateListenerForAllActivities(sInstance.get());
        return ChromeTabbedActivity.class;
    } else if (current instanceof ChromeTabbedActivity) {
        mTabbedActivity2TaskRunning = true;
        ApplicationStatus.registerStateListenerForAllActivities(sInstance.get());
        return ChromeTabbedActivity2.class;
    } else {
        return null;
    }
}
 
Example 5
Source File: ChromeBrowserInitializer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    ChromeWebApkHost.init();

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
Example 6
Source File: VrShellDelegate.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private VrShellDelegate(ChromeActivity activity, VrClassesWrapper wrapper) {
    mActivity = activity;
    mVrClassesWrapper = wrapper;
    // If an activity isn't resumed at the point, it must have been paused.
    mPaused = ApplicationStatus.getStateForActivity(activity) != ActivityState.RESUMED;
    updateVrSupportLevel();
    mNativeVrShellDelegate = nativeInit();
    mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency();
    mEnterVrHandler = new Handler();
    Choreographer.getInstance().postFrameCallback(new FrameCallback() {
        @Override
        public void doFrame(long frameTimeNanos) {
            if (mNativeVrShellDelegate == 0) return;
            Display display =
                    ((WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE))
                            .getDefaultDisplay();
            nativeUpdateVSyncInterval(
                    mNativeVrShellDelegate, frameTimeNanos, 1.0d / display.getRefreshRate());
        }
    });
    ApplicationStatus.registerStateListenerForAllActivities(this);
}
 
Example 7
Source File: MultiWindowUtils.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the activity to use when handling "open in other window" or "move to other window".
 * Returns null if the current activity doesn't support opening/moving tabs to another activity.
 */
public Class<? extends Activity> getOpenInOtherWindowActivity(Activity current) {

    if (current instanceof ChromeTabbedActivity2) {
        // If a second ChromeTabbedActivity is created, MultiWindowUtils needs to listen for
        // activity state changes to facilitate determining which ChromeTabbedActivity should
        // be used for intents.
        ApplicationStatus.registerStateListenerForAllActivities(sInstance.get());
        return ChromeTabbedActivity.class;
    } else if (current instanceof ChromeTabbedActivity) {
        mTabbedActivity2TaskRunning = true;
        ApplicationStatus.registerStateListenerForAllActivities(sInstance.get());
        return ChromeTabbedActivity2.class;
    } else {
        return null;
    }
}
 
Example 8
Source File: OfflinePageTabObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static void ensureObserverMapInitialized() {
    if (sObservers != null) return;
    sObservers = new HashMap<>();
    ApplicationStatus.registerStateListenerForAllActivities(new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState != ActivityState.DESTROYED) return;
            OfflinePageTabObserver observer = sObservers.remove(activity);
            if (observer == null) return;
            observer.destroy();
        }
    });
}
 
Example 9
Source File: TabWindowManager.java    From delion with Apache License 2.0 4 votes vote down vote up
private TabWindowManager() {
    ApplicationStatus.registerStateListenerForAllActivities(this);

    for (int i = 0; i < MAX_SIMULTANEOUS_SELECTORS; i++) mSelectors.add(null);
}
 
Example 10
Source File: SyncController.java    From delion with Apache License 2.0 4 votes vote down vote up
private SyncController(Context context) {
    mContext = context;
    mChromeSigninController = ChromeSigninController.get(mContext);
    AndroidSyncSettings.registerObserver(context, this);
    mProfileSyncService = ProfileSyncService.get();
    mProfileSyncService.addSyncStateChangedListener(this);
    mProfileSyncService.setMasterSyncEnabledProvider(
            new ProfileSyncService.MasterSyncEnabledProvider() {
                public boolean isMasterSyncEnabled() {
                    return AndroidSyncSettings.isMasterSyncEnabled(mContext);
                }
            });

    setSessionsId();

    // Create the SyncNotificationController.
    mSyncNotificationController = new SyncNotificationController(
            mContext, PassphraseActivity.class, AccountManagementFragment.class);
    mProfileSyncService.addSyncStateChangedListener(mSyncNotificationController);

    updateSyncStateFromAndroid();

    // When the application gets paused, tell sync to flush the directory to disk.
    ApplicationStatus.registerStateListenerForAllActivities(new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState == ActivityState.PAUSED) {
                mProfileSyncService.flushDirectory();
            }
        }
    });

    GmsCoreSyncListener gmsCoreSyncListener =
            ((ChromeApplication) context.getApplicationContext()).createGmsCoreSyncListener();
    if (gmsCoreSyncListener != null) {
        mProfileSyncService.addSyncStateChangedListener(gmsCoreSyncListener);
    }

    SigninManager.get(mContext).addSignInStateObserver(new SigninManager.SignInStateObserver() {
        @Override
        public void onSignedIn() {
            mProfileSyncService.requestStart();
        }

        @Override
        public void onSignedOut() {}
    });
}
 
Example 11
Source File: TabWindowManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private TabWindowManager() {
    ApplicationStatus.registerStateListenerForAllActivities(this);

    for (int i = 0; i < MAX_SIMULTANEOUS_SELECTORS; i++) mSelectors.add(null);
}
 
Example 12
Source File: SyncController.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private SyncController(Context context) {
    mContext = context;
    mChromeSigninController = ChromeSigninController.get(mContext);
    AndroidSyncSettings.registerObserver(context, this);
    mProfileSyncService = ProfileSyncService.get();
    mProfileSyncService.addSyncStateChangedListener(this);
    mProfileSyncService.setMasterSyncEnabledProvider(
            new ProfileSyncService.MasterSyncEnabledProvider() {
                public boolean isMasterSyncEnabled() {
                    return AndroidSyncSettings.isMasterSyncEnabled(mContext);
                }
            });

    setSessionsId();

    // Create the SyncNotificationController.
    mSyncNotificationController = new SyncNotificationController(
            mContext, PassphraseActivity.class, AccountManagementFragment.class);
    mProfileSyncService.addSyncStateChangedListener(mSyncNotificationController);

    updateSyncStateFromAndroid();

    // When the application gets paused, tell sync to flush the directory to disk.
    ApplicationStatus.registerStateListenerForAllActivities(new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState == ActivityState.PAUSED) {
                mProfileSyncService.flushDirectory();
            }
        }
    });

    GmsCoreSyncListener gmsCoreSyncListener =
            ((ChromeApplication) context.getApplicationContext()).createGmsCoreSyncListener();
    if (gmsCoreSyncListener != null) {
        mProfileSyncService.addSyncStateChangedListener(gmsCoreSyncListener);
    }

    SigninManager.get(mContext).addSignInStateObserver(new SigninManager.SignInStateObserver() {
        @Override
        public void onSignedIn() {
            mProfileSyncService.requestStart();
        }

        @Override
        public void onSignedOut() {}
    });
}
 
Example 13
Source File: TabWindowManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private TabWindowManager() {
    ApplicationStatus.registerStateListenerForAllActivities(this);

    for (int i = 0; i < MAX_SIMULTANEOUS_SELECTORS; i++) mSelectors.add(null);
}
 
Example 14
Source File: SyncController.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private SyncController(Context context) {
    mContext = context;
    mChromeSigninController = ChromeSigninController.get();
    AndroidSyncSettings.registerObserver(context, this);
    mProfileSyncService = ProfileSyncService.get();
    mProfileSyncService.addSyncStateChangedListener(this);
    mProfileSyncService.setMasterSyncEnabledProvider(
            new ProfileSyncService.MasterSyncEnabledProvider() {
                @Override
                public boolean isMasterSyncEnabled() {
                    return AndroidSyncSettings.isMasterSyncEnabled(mContext);
                }
            });

    setSessionsId();

    // Create the SyncNotificationController.
    mSyncNotificationController = new SyncNotificationController(
            mContext, PassphraseActivity.class, AccountManagementFragment.class);
    mProfileSyncService.addSyncStateChangedListener(mSyncNotificationController);

    updateSyncStateFromAndroid();

    // When the application gets paused, tell sync to flush the directory to disk.
    ApplicationStatus.registerStateListenerForAllActivities(new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState == ActivityState.PAUSED) {
                mProfileSyncService.flushDirectory();
            }
        }
    });

    GmsCoreSyncListener gmsCoreSyncListener = AppHooks.get().createGmsCoreSyncListener();
    if (gmsCoreSyncListener != null) {
        mProfileSyncService.addSyncStateChangedListener(gmsCoreSyncListener);
    }

    SigninManager.get(mContext).addSignInStateObserver(new SigninManager.SignInStateObserver() {
        @Override
        public void onSignedIn() {
            mProfileSyncService.requestStart();
        }

        @Override
        public void onSignedOut() {}
    });
}