Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3961)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/signin/OAuth2TokenService.java

Issue 1256283002: GAIA ID migration for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: full version Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/signin/OAuth2TokenService.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/OAuth2TokenService.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/OAuth2TokenService.java
index 7f6737d1fddc239855f021c9003c76f11162601a..c5c0d14dc0481235a7718cc184ece19d9d322835 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/OAuth2TokenService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/OAuth2TokenService.java
@@ -100,19 +100,19 @@ public final class OAuth2TokenService {
}
/**
- * Called by native to list the activite accounts in the OS.
+ * Called by native to list the activite account names in the OS.
*/
@VisibleForTesting
@CalledByNative
- public static String[] getSystemAccounts(Context context) {
+ public static String[] getSystemAccountNames(Context context) {
AccountManagerHelper accountManagerHelper = AccountManagerHelper.get(context);
java.util.List<String> accountNames = accountManagerHelper.getGoogleAccountNames();
return accountNames.toArray(new String[accountNames.size()]);
}
/**
- * Called by native to list the accounts with OAuth2 refresh tokens.
- * This can differ from getSystemAccounts as the user add/remove accounts
+ * Called by native to list the accounts Id with OAuth2 refresh tokens.
+ * This can differ from getSystemAccountNames as the user add/remove accounts
* from the OS. validateAccounts should be called to keep these two
* in sync.
*/
@@ -229,9 +229,60 @@ public final class OAuth2TokenService {
}
}
+ /**
+ * Private class to pend accounts validation when system accounts have not been seeded
+ * into AccountTrackerService. It listens onSystemAccountsSeedingComplete to finish pending
+ * validation.
+ */
+ private static class PendingAccountsValidation
+ implements AccountTrackerService.SystemAccountsSeedingObserver {
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:22 Do we need this class, or could OAuth2TokenService
gogerald1 2015/08/18 01:14:26 Done. Move it to OAuth2TokenService to make class
+ private static PendingAccountsValidation sPendingAccountsValidation;
+ private static long sNativeOAuth2TokenService;
+
+ private Context mContext;
+ private boolean mForceNotifications;
+ private boolean mHasPendingAccountsValidation = false;
+
+ public static PendingAccountsValidation get(
+ Context context, long nativeOAuth2TokenService) {
+ if (sPendingAccountsValidation == null) {
+ sPendingAccountsValidation = new PendingAccountsValidation();
+ AccountTrackerService.get(context).observeSystemAccountsSeeding(
+ sPendingAccountsValidation);
+ sNativeOAuth2TokenService = nativeOAuth2TokenService;
+ }
+
+ return sPendingAccountsValidation;
+ }
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:22 Why do we need a singleton PendingAccountsValidati
gogerald1 2015/08/18 01:14:26 Done.
+
+ public void pendValidation(Context context, boolean forceNotifications) {
+ mContext = context;
+ mForceNotifications = forceNotifications;
+ mHasPendingAccountsValidation = true;
+ if (AccountTrackerService.get(context).isSystemAccountsSeeded()) {
+ onSystemAccountsSeedingComplete();
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:22 Should mHasPendingAccountsValidation be set to fal
gogerald1 2015/08/18 01:14:26 onSystemAccountsSeedingComplete() will do that
+ }
+ }
+
+ public synchronized void onSystemAccountsSeedingComplete() {
+ if (mHasPendingAccountsValidation) {
+ mHasPendingAccountsValidation = false;
+ OAuth2TokenService.getForProfile(Profile.getLastUsedProfile())
+ .nativeValidateAccounts(sNativeOAuth2TokenService,
+ ChromeSigninController.get(mContext).getSignedInAccountName(),
+ mForceNotifications);
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:22 Make a shared function for this. Lines 270-273 du
gogerald1 2015/08/18 01:14:26 Done.
+ }
+ }
+ }
+
@CalledByNative
public void validateAccounts(Context context, boolean forceNotifications) {
ThreadUtils.assertOnUiThread();
+ if (!AccountTrackerService.get(context).isSystemAccountsSeeded()) {
+ PendingAccountsValidation.get(context, mNativeOAuth2TokenServiceDelegateAndroid)
+ .pendValidation(context, forceNotifications);
+ return;
+ }
String currentlySignedInAccount =
ChromeSigninController.get(context).getSignedInAccountName();
nativeValidateAccounts(mNativeOAuth2TokenServiceDelegateAndroid, currentlySignedInAccount,

Powered by Google App Engine
This is Rietveld 408576698