Java Code Examples for org.chromium.sync.signin.ChromeSigninController#get()
The following examples show how to use
org.chromium.sync.signin.ChromeSigninController#get() .
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: GoogleServicesManager.java From delion with Apache License 2.0 | 5 votes |
private GoogleServicesManager(Context context) { try { TraceEvent.begin("GoogleServicesManager.GoogleServicesManager"); ThreadUtils.assertOnUiThread(); // We should store the application context, as we outlive any activity which may create // us. mContext = context.getApplicationContext(); mChromeSigninController = ChromeSigninController.get(mContext); mSigninHelper = SigninHelper.get(mContext); // The sign out flow starts by clearing the signed in user in the ChromeSigninController // on the Java side, and then performs a sign out on the native side. If there is a // crash on the native side then the signin state may get out of sync. Make sure that // the native side is signed out if the Java side doesn't have a currently signed in // user. SigninManager signinManager = SigninManager.get(mContext); if (!mChromeSigninController.isSignedIn() && signinManager.isSignedInOnNative()) { Log.w(TAG, "Signed in state got out of sync, forcing native sign out"); signinManager.signOut(); } // Initialize sync. SyncController.get(context); ApplicationStatus.registerApplicationStateListener(this); } finally { TraceEvent.end("GoogleServicesManager.GoogleServicesManager"); } }
Example 2
Source File: AccountManagementFragment.java From delion with Apache License 2.0 | 5 votes |
public void update() { final Context context = getActivity(); if (context == null) return; if (getPreferenceScreen() != null) getPreferenceScreen().removeAll(); ChromeSigninController signInController = ChromeSigninController.get(context); if (!signInController.isSignedIn()) { // The AccountManagementFragment can only be shown when the user is signed in. If the // user is signed out, exit the fragment. getActivity().finish(); return; } addPreferencesFromResource(R.xml.account_management_preferences); String signedInAccountName = ChromeSigninController.get(getActivity()).getSignedInAccountName(); String fullName = getCachedUserName(signedInAccountName); if (TextUtils.isEmpty(fullName)) { fullName = ProfileDownloader.getCachedFullName(Profile.getLastUsedProfile()); } if (TextUtils.isEmpty(fullName)) fullName = signedInAccountName; getActivity().setTitle(fullName); configureSignOutSwitch(); configureAddAccountPreference(); configureChildAccountPreferences(); configureSyncSettings(); configureGoogleActivityControls(); updateAccountsList(); }
Example 3
Source File: SigninHelper.java From delion with Apache License 2.0 | 5 votes |
private SigninHelper(Context context) { mContext = context; mProfileSyncService = ProfileSyncService.get(); mSigninManager = SigninManager.get(mContext); mAccountTrackerService = AccountTrackerService.get(mContext); mOAuth2TokenService = OAuth2TokenService.getForProfile(Profile.getLastUsedProfile()); mChromeSigninController = ChromeSigninController.get(mContext); }
Example 4
Source File: SyncController.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
private SyncController(Context context) { mContext = context; mChromeSigninController = ChromeSigninController.get(mContext); mSyncStatusHelper = SyncStatusHelper.get(context); mSyncStatusHelper.registerSyncSettingsChangedObserver(this); mProfileSyncService = ProfileSyncService.get(mContext); mProfileSyncService.addSyncStateChangedListener(this); setupSessionSyncId(); mChromeSigninController.ensureGcmIsInitialized(); }
Example 5
Source File: SyncController.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
private SyncController(Context context) { mContext = context; mChromeSigninController = ChromeSigninController.get(mContext); mSyncStatusHelper = SyncStatusHelper.get(context); mSyncStatusHelper.registerSyncSettingsChangedObserver(this); mProfileSyncService = ProfileSyncService.get(mContext); mProfileSyncService.addSyncStateChangedListener(this); setupSessionSyncId(); mChromeSigninController.ensureGcmIsInitialized(); }
Example 6
Source File: SignInPreference.java From delion with Apache License 2.0 | 4 votes |
/** * Updates the title, summary, and image based on the current sign-in state. */ private void update() { String title; String summary; String fragment; Account account = ChromeSigninController.get(getContext()).getSignedInUser(); if (account == null) { title = getContext().getString(R.string.sign_in_to_chrome); summary = getContext().getString(R.string.sign_in_to_chrome_summary); fragment = null; } else { summary = SyncPreference.getSyncStatusSummary(getContext()); fragment = AccountManagementFragment.class.getName(); title = AccountManagementFragment.getCachedUserName(account.name); if (title == null) { final Profile profile = Profile.getLastUsedProfile(); String cachedName = ProfileDownloader.getCachedFullName(profile); Bitmap cachedBitmap = ProfileDownloader.getCachedAvatar(profile); if (TextUtils.isEmpty(cachedName) || cachedBitmap == null) { AccountManagementFragment.startFetchingAccountInformation( getContext(), profile, account.name); } title = TextUtils.isEmpty(cachedName) ? account.name : cachedName; } } setTitle(title); setSummary(summary); setFragment(fragment); updateSyncStatusIcon(); ChromeSigninController signinController = ChromeSigninController.get(getContext()); boolean enabled = signinController.isSignedIn() || SigninManager.get(getContext()).isSignInAllowed(); if (mViewEnabled != enabled) { mViewEnabled = enabled; notifyChanged(); } if (!enabled) setFragment(null); if (SigninManager.get(getContext()).isSigninDisabledByPolicy()) { setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId()); } else { Resources resources = getContext().getResources(); Bitmap bitmap = AccountManagementFragment.getUserPicture( signinController.getSignedInAccountName(), resources); setIcon(new BitmapDrawable(resources, bitmap)); } setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (!AccountSigninActivity.startIfAllowed( getContext(), SigninAccessPoint.SETTINGS)) { return false; } setEnabled(false); return true; } }); }
Example 7
Source File: SyncController.java From delion with Apache License 2.0 | 4 votes |
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() {} }); }