Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.signin; | 5 package org.chromium.chrome.browser.signin; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 | 9 |
| 10 import com.google.android.gms.auth.GoogleAuthException; | 10 import com.google.android.gms.auth.GoogleAuthException; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 return null; | 50 return null; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Returns whether the AccountIdProvider can be used. | 55 * Returns whether the AccountIdProvider can be used. |
| 56 * Since the AccountIdProvider queries Google Play services, this basically checks whether | 56 * Since the AccountIdProvider queries Google Play services, this basically checks whether |
| 57 * Google Play services is available. | 57 * Google Play services is available. |
| 58 * | 58 * |
| 59 * @param activity If an activity is provided, it will be used to show a Mod al Dialog notifying | 59 * @param activity If an activity is provided, it will be used to show a Mod al Dialog notifying |
| 60 * the user to update Google Play services, else a System notification is sh own. | 60 * the user to update Google Play services, else a System notification is sh own. |
|
Ian Wen
2016/01/04 03:55:31
You should update this javadoc as well.
| |
| 61 */ | 61 */ |
| 62 public boolean canBeUsed(Context ctx, @Nullable Activity activity) { | 62 public boolean canBeUsed(Context ctx, @Nullable Activity activity) { |
| 63 UserRecoverableErrorHandler errorHandler = activity != null | 63 return ExternalAuthUtils.getInstance().canUseGooglePlayServices(ctx, |
| 64 ? new UserRecoverableErrorHandler.ModalDialog(activity) | 64 new UserRecoverableErrorHandler.Silent()); |
| 65 : new UserRecoverableErrorHandler.SystemNotification(); | |
| 66 return ExternalAuthUtils.getInstance().canUseGooglePlayServices(ctx, err orHandler); | |
| 67 } | 65 } |
| 68 | 66 |
| 69 /** | 67 /** |
| 70 * Gets the global account Id provider. | 68 * Gets the global account Id provider. |
| 71 */ | 69 */ |
| 72 public static AccountIdProvider getInstance() { | 70 public static AccountIdProvider getInstance() { |
| 73 ThreadUtils.assertOnUiThread(); | 71 ThreadUtils.assertOnUiThread(); |
| 74 if (sProvider == null) sProvider = new AccountIdProvider(); | 72 if (sProvider == null) sProvider = new AccountIdProvider(); |
| 75 return sProvider; | 73 return sProvider; |
| 76 } | 74 } |
| 77 | 75 |
| 78 /** | 76 /** |
| 79 * For testing purposes only, allows to set the provider even if it has alre ady been | 77 * For testing purposes only, allows to set the provider even if it has alre ady been |
| 80 * initialized. | 78 * initialized. |
| 81 */ | 79 */ |
| 82 @VisibleForTesting | 80 @VisibleForTesting |
| 83 public static void setInstanceForTest(AccountIdProvider provider) { | 81 public static void setInstanceForTest(AccountIdProvider provider) { |
| 84 ThreadUtils.assertOnUiThread(); | 82 ThreadUtils.assertOnUiThread(); |
| 85 sProvider = provider; | 83 sProvider = provider; |
| 86 } | 84 } |
| 87 } | 85 } |
| 88 | 86 |
| OLD | NEW |