Search in sources :

Example 11 with ProfileSyncService

use of org.chromium.chrome.browser.sync.ProfileSyncService in project AndroidChromium by JackyAndroid.

the class ChromeActivity method createContextReporterIfNeeded.

private void createContextReporterIfNeeded() {
    if (mContextReporter != null || getActivityTab() == null)
        return;
    final SyncController syncController = SyncController.get(this);
    final ProfileSyncService syncService = ProfileSyncService.get();
    if (syncController != null && syncController.isSyncingUrlsWithKeystorePassphrase()) {
        assert syncService != null;
        mContextReporter = ((ChromeApplication) getApplicationContext()).createGsaHelper().getContextReporter(this);
        if (mSyncStateChangedListener != null) {
            syncService.removeSyncStateChangedListener(mSyncStateChangedListener);
            mSyncStateChangedListener = null;
        }
        return;
    } else {
        ContextReporter.reportSyncStatus(syncService);
    }
    if (mSyncStateChangedListener == null && syncService != null) {
        mSyncStateChangedListener = new ProfileSyncService.SyncStateChangedListener() {

            @Override
            public void syncStateChanged() {
                createContextReporterIfNeeded();
            }
        };
        syncService.addSyncStateChangedListener(mSyncStateChangedListener);
    }
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService) SyncController(org.chromium.chrome.browser.sync.SyncController)

Example 12 with ProfileSyncService

use of org.chromium.chrome.browser.sync.ProfileSyncService in project AndroidChromium by JackyAndroid.

the class InvalidationController method ensureStartedAndUpdateRegisteredTypes.

/**
     * Updates the sync invalidation types that the client is registered for based on the preferred
     * sync types.  Starts the client if needed.
     */
public void ensureStartedAndUpdateRegisteredTypes() {
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService == null)
        return;
    mStarted = true;
    // Ensure GCM has been initialized.
    ensureGcmIsInitialized();
    // Do not apply changes to {@link #mSessionInvalidationsEnabled} yet because the timer task
    // may be scheduled far into the future.
    mEnableSessionInvalidationsTimer.resume();
    HashSet<Integer> typesToRegister = new HashSet<Integer>();
    typesToRegister.addAll(syncService.getPreferredDataTypes());
    if (!mSessionInvalidationsEnabled) {
        typesToRegister.remove(ModelType.SESSIONS);
        typesToRegister.remove(ModelType.FAVICON_TRACKING);
        typesToRegister.remove(ModelType.FAVICON_IMAGES);
    }
    Intent registerIntent = InvalidationIntentProtocol.createRegisterIntent(ChromeSigninController.get(mContext).getSignedInUser(), typesToRegister);
    registerIntent.setClass(mContext, InvalidationClientService.getRegisteredClass());
    mContext.startService(registerIntent);
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService) Intent(android.content.Intent) HashSet(java.util.HashSet)

Aggregations

ProfileSyncService (org.chromium.chrome.browser.sync.ProfileSyncService)12 SigninManager (org.chromium.chrome.browser.signin.SigninManager)2 Account (android.accounts.Account)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 Preference (android.preference.Preference)1 SpannableString (android.text.SpannableString)1 HashSet (java.util.HashSet)1 SavePasswordsPreferences (org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences)1 SyncController (org.chromium.chrome.browser.sync.SyncController)1 Tab (org.chromium.chrome.browser.tab.Tab)1 PassphraseType (org.chromium.components.sync.PassphraseType)1