From 84cc8aefc84b7c7f79cb7ae0098a54c60bca8a25 Mon Sep 17 00:00:00 2001 From: maxbogue Date: Thu, 9 Oct 2014 09:59:07 -0700 Subject: Make all auth requests notification-driven. Previously, when having authentication issues on Android (for example, if the user changed their password), Chrome would pop-up a dialog asking the user to sign in again. This was bad, because part of the auth flow has a link to a website where you can do account recovery, but that would just kick you back into the auth pop-up in an infinite loop. Also it was intrusive to the user and against Android best practices. Additionally, on dev builds of Chromium, it could result in an annoying stream of permission request pop-ups dominating the screen. Now, in both cases, the auth request is handled by generating a notification that the user must activate before losing control of the screen. BUG=302608 Review URL: https://codereview.chromium.org/627543002 Cr-Commit-Position: refs/heads/master@{#298911} --- .../org/chromium/sync/signin/AccountManagerHelper.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'sync') diff --git a/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java b/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java index be76287..03df234 100644 --- a/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java +++ b/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java @@ -13,7 +13,6 @@ import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.app.Activity; import android.content.Context; -import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; @@ -51,6 +50,9 @@ public class AccountManagerHelper { private Context mApplicationContext; + /** + * A simple callback for getAuthToken. + */ public interface GetAuthTokenCallback { /** * Invoked on the UI thread once a token has been provided by the AccountManager. @@ -162,7 +164,7 @@ public class AccountManagerHelper { @Deprecated public String getAuthTokenFromBackground(Account account, String authTokenType) { AccountManagerFuture future = mAccountManager.getAuthToken(account, - authTokenType, false, null, null); + authTokenType, true, null, null); AtomicBoolean errorEncountered = new AtomicBoolean(false); return getAuthTokenInner(future, errorEncountered); } @@ -219,16 +221,6 @@ public class AccountManagerHelper { try { Bundle result = future.getResult(); if (result != null) { - if (result.containsKey(AccountManager.KEY_INTENT)) { - Log.d(TAG, "Starting intent to get auth credentials"); - // Need to start intent to get credentials - Intent intent = result.getParcelable(AccountManager.KEY_INTENT); - int flags = intent.getFlags(); - flags |= Intent.FLAG_ACTIVITY_NEW_TASK; - intent.setFlags(flags); - mApplicationContext.startActivity(intent); - return null; - } return result.getString(AccountManager.KEY_AUTHTOKEN); } else { Log.w(TAG, "Auth token - getAuthToken returned null"); @@ -254,7 +246,7 @@ public class AccountManagerHelper { account, authTokenType, null, activity, null, null); } else { future = mAccountManager.getAuthToken( - account, authTokenType, false, null, null); + account, authTokenType, true, null, null); } final AccountManagerFuture finalFuture = future; errorEncountered.set(false); -- cgit v1.1