diff options
author | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 18:33:50 +0000 |
---|---|---|
committer | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 18:33:50 +0000 |
commit | 619f6c31dc1b61ec8a0bb95eca968cc45832a580 (patch) | |
tree | 94bf3cce97a8a97f8861aca66b3f9de4bcf4aae0 /sync | |
parent | 9f333c23e43332e4e6e6f0e9123315c67cc031db (diff) | |
download | chromium_src-619f6c31dc1b61ec8a0bb95eca968cc45832a580.zip chromium_src-619f6c31dc1b61ec8a0bb95eca968cc45832a580.tar.gz chromium_src-619f6c31dc1b61ec8a0bb95eca968cc45832a580.tar.bz2 |
Add way to tell if device can add google accounts
Need to know if the device supports adding google accounts.
BUG=235076
Review URL: https://chromiumcodereview.appspot.com/14314011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
4 files changed, 30 insertions, 0 deletions
diff --git a/sync/android/java/src/org/chromium/sync/signin/AccountManagerDelegate.java b/sync/android/java/src/org/chromium/sync/signin/AccountManagerDelegate.java index 88ec210..e855e19 100644 --- a/sync/android/java/src/org/chromium/sync/signin/AccountManagerDelegate.java +++ b/sync/android/java/src/org/chromium/sync/signin/AccountManagerDelegate.java @@ -7,6 +7,7 @@ package org.chromium.sync.signin; import android.accounts.Account; import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; +import android.accounts.AuthenticatorDescription; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.app.Activity; @@ -49,4 +50,6 @@ public interface AccountManagerDelegate { Activity activity, AccountManagerCallback<Bundle> callback, Handler handler); String peekAuthToken(Account account, String authTokenType); + + AuthenticatorDescription[] getAuthenticatorTypes(); } 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 2c3441a..ce3e171 100644 --- a/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java +++ b/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java @@ -10,6 +10,7 @@ import com.google.common.annotations.VisibleForTesting; import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AccountManagerFuture; +import android.accounts.AuthenticatorDescription; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.app.Activity; @@ -134,6 +135,17 @@ public class AccountManagerHelper { } /** + * @return Whether or not there is an account authenticator for Google accounts. + */ + public boolean hasGoogleAccountAuthenticator() { + AuthenticatorDescription[] descs = mAccountManager.getAuthenticatorTypes(); + for (AuthenticatorDescription desc : descs) { + if (GOOGLE_ACCOUNT_TYPE.equals(desc.type)) return true; + } + return false; + } + + /** * Gets the auth token synchronously. * * - Assumes that the account is a valid account. diff --git a/sync/android/java/src/org/chromium/sync/signin/SystemAccountManagerDelegate.java b/sync/android/java/src/org/chromium/sync/signin/SystemAccountManagerDelegate.java index 13e3962..96b94bb 100644 --- a/sync/android/java/src/org/chromium/sync/signin/SystemAccountManagerDelegate.java +++ b/sync/android/java/src/org/chromium/sync/signin/SystemAccountManagerDelegate.java @@ -8,6 +8,7 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; +import android.accounts.AuthenticatorDescription; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.app.Activity; @@ -102,4 +103,9 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate { public String peekAuthToken(Account account, String authTokenType) { return mAccountManager.peekAuthToken(account, authTokenType); } + + @Override + public AuthenticatorDescription[] getAuthenticatorTypes() { + return mAccountManager.getAuthenticatorTypes(); + } } 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 d293918..9c4a41d 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 @@ -8,6 +8,7 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; +import android.accounts.AuthenticatorDescription; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.app.Activity; @@ -294,6 +295,14 @@ public class MockAccountManager implements AccountManagerDelegate { } } + @Override + public AuthenticatorDescription[] getAuthenticatorTypes() { + AuthenticatorDescription googleAuthenticator = new AuthenticatorDescription( + AccountManagerHelper.GOOGLE_ACCOUNT_TYPE, "p1", 0, 0, 0, 0); + + return new AuthenticatorDescription[] { googleAuthenticator }; + } + public void prepareAllowAppPermission(Account account, String authTokenType) { addPreparedAppPermission(new AccountAuthTokenPreparation(account, authTokenType, true)); } |