private void doSignIn() { Log.d(TAG, "Committing the sign-in process now"); assert mSignInAccount != null; // Cache the signed-in account name. ChromeSigninController.get(mContext).setSignedInAccountName(mSignInAccount.name); // Tell the native side that sign-in has completed. // This will trigger NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL. nativeOnSignInCompleted(mNativeSigninManagerAndroid, mSignInAccount.name); // Register for invalidations. InvalidationController invalidationController = InvalidationController.get(mContext); invalidationController.setRegisteredTypes(mSignInAccount, true, new HashSet<ModelType>()); // Sign-in to sync. ProfileSyncService profileSyncService = ProfileSyncService.get(mContext); if (SyncStatusHelper.get(mContext).isSyncEnabled(mSignInAccount) && !profileSyncService.hasSyncSetupCompleted()) { profileSyncService.setSetupInProgress(true); profileSyncService.syncSignIn(); } if (mSignInObserver != null) mSignInObserver.onSigninComplete(); // All done, cleanup. Log.d(TAG, "Signin done"); mSignInActivity = null; mSignInAccount = null; mSignInObserver = null; }