summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-19 02:19:44 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-19 02:19:44 +0000
commitf260e670f9426590e0fb571e86610aa009431acf (patch)
tree467028bed23ac621eabd85c762ca0686a227861d /sync
parent88be3cd4a72a1d65b1424f8d44d9b24c9c482e8d (diff)
downloadchromium_src-f260e670f9426590e0fb571e86610aa009431acf.zip
chromium_src-f260e670f9426590e0fb571e86610aa009431acf.tar.gz
chromium_src-f260e670f9426590e0fb571e86610aa009431acf.tar.bz2
Fixed fetching of OAuth2 tokens through the MockAccountManager.
The native side requests oauth2 tokens without an activity. The intent started to ask for permission in these cases must have the Intent.FLAG_ACTIVITY_NEW_TASK flag. Additionally, when a response bundle has an intent but has no activity then start the intent using the main context. BUG=261458 Review URL: https://chromiumcodereview.appspot.com/19699005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
index b79abcf..da16fae 100644
--- a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
+++ b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
@@ -238,7 +238,8 @@ public class MockAccountManager implements AccountManagerDelegate {
} else {
Log.d(TAG, "getAuthTokenFuture: Account " + ah.getAccount() +
" is asking for permission for " + authTokenType);
- final Intent intent = newGrantCredentialsPermissionIntent(true, account, authTokenType);
+ final Intent intent = newGrantCredentialsPermissionIntent(
+ activity != null, account, authTokenType);
return runTask(mExecutor,
new AccountManagerAuthTokenTask(activity, handler, callback,
account, authTokenType,
@@ -495,10 +496,13 @@ public class MockAccountManager implements AccountManagerDelegate {
try {
Bundle bundle = mCallable.call();
Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);
- if (intent != null && mActivity != null) {
- // Since the user provided an Activity we will silently start intents we see.
- // Starting activity and waiting for it to finish.
- waitForActivity(mActivity, intent);
+ if (intent != null) {
+ // Start the intent activity and wait for it to finish.
+ if (mActivity != null) {
+ waitForActivity(mActivity, intent);
+ } else {
+ waitForActivity(mContext, intent);
+ }
if (mAccountAuthTokenPreparation == null) {
throw new IllegalStateException("No account preparation ready for " +
mAccount + ", authTokenType = " + mAuthTokenType +