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

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

Issue 213823004: Calls FireRefreshTokenRevoked if an account is removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused varible. Created 6 years, 9 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 2e5daa80fbd2633bdb4f86a550669fd4ac23207a..8144e21710b258719c535c589576b58be08f9bb3 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
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.signin;
import android.accounts.Account;
import android.app.Activity;
import android.content.Context;
+import android.preference.PreferenceManager;
import android.util.Log;
import org.chromium.base.CalledByNative;
@@ -16,9 +17,12 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.sync.signin.AccountManagerHelper;
import org.chromium.sync.signin.ChromeSigninController;
+import java.util.Arrays;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import java.util.HashSet;
+import java.util.Set;
import javax.annotation.Nullable;
@@ -32,6 +36,7 @@ import javax.annotation.Nullable;
public final class OAuth2TokenService {
private static final String TAG = "OAuth2TokenService";
+ private static final String STORED_ACCOUNTS_KEY = "google.services.stored_accounts";
public interface OAuth2TokenServiceObserver {
void onRefreshTokenAvailable(Account account);
@@ -202,9 +207,10 @@ public final class OAuth2TokenService {
ThreadUtils.assertOnUiThread();
String currentlySignedInAccount =
ChromeSigninController.get(context).getSignedInAccountName();
- String[] accounts = getAccounts(context);
+ String[] accounts = getStoredAccounts(context);
nativeValidateAccounts(
mNativeProfileOAuth2TokenService, accounts, currentlySignedInAccount);
+ saveStoredAccounts(context, getAccounts(context));
}
/**
@@ -262,6 +268,20 @@ public final class OAuth2TokenService {
}
}
+ private String[] getStoredAccounts(Context context) {
+ Set<String> accounts =
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .getStringSet(STORED_ACCOUNTS_KEY, null);
+ return accounts == null ? new String[]{} :
+ accounts.toArray(new String[accounts.size()]);
+ }
+
+ private void saveStoredAccounts(Context context, String[] accounts) {
+ Set<String> set = new HashSet<String>(Arrays.asList(accounts));
+ PreferenceManager.getDefaultSharedPreferences(context).edit().
+ putStringSet(STORED_ACCOUNTS_KEY, set);
+ }
+
private static native Object nativeGetForProfile(Profile profile);
private static native void nativeOAuth2TokenFetched(
String authToken, boolean result, long nativeCallback);

Powered by Google App Engine
This is Rietveld 408576698