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.content.Context; | 7 import android.content.Context; |
| 8 | 8 |
| 9 import com.google.android.gms.auth.GoogleAuthException; | |
| 10 import com.google.android.gms.auth.GoogleAuthUtil; | |
| 11 | |
| 9 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
| 10 import org.chromium.base.VisibleForTesting; | 13 import org.chromium.base.VisibleForTesting; |
| 11 | 14 |
| 15 import java.io.IOException; | |
| 16 | |
| 12 /** | 17 /** |
| 13 * Returns a stable id that can be used to identify a Google Account. This | 18 * Returns a stable id that can be used to identify a Google Account. This |
| 14 * id does not change if the email address associated to the account changes, | 19 * id does not change if the email address associated to the account changes, |
| 15 * nor does it change depending on whether the email has dots or varying | 20 * nor does it change depending on whether the email has dots or varying |
| 16 * capitalization. | 21 * capitalization. |
| 17 */ | 22 */ |
| 18 public abstract class AccountIdProvider { | 23 public abstract class AccountIdProvider { |
| 19 private static AccountIdProvider sProvider; | 24 private static AccountIdProvider sProvider; |
| 20 | 25 |
| 21 /** | 26 /** |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 44 | 49 |
| 45 /** | 50 /** |
| 46 * Gets the global account Id provider. | 51 * Gets the global account Id provider. |
| 47 */ | 52 */ |
| 48 public static AccountIdProvider getInstance() { | 53 public static AccountIdProvider getInstance() { |
| 49 ThreadUtils.assertOnUiThread(); | 54 ThreadUtils.assertOnUiThread(); |
| 50 return sProvider; | 55 return sProvider; |
| 51 } | 56 } |
| 52 | 57 |
| 53 /** | 58 /** |
| 59 * Gets the Google Account Id Provider. | |
| 60 */ | |
| 61 public static AccountIdProvider getGoogleAccountIdProvider() { | |
| 62 return new AccountIdProvider() { | |
| 63 @Override | |
| 64 public String getAccountId(Context ctx, String accountName) { | |
| 65 try { | |
| 66 return GoogleAuthUtil.getAccountId(ctx, accountName); | |
| 67 } catch (IOException | GoogleAuthException ex) { | |
| 68 return null; | |
| 69 } | |
| 70 } | |
| 71 }; | |
| 72 } | |
|
Roger Tawa OOO till Jul 10th
2015/08/12 15:28:46
What is the reason for moving this code? If the i
gogerald1
2015/08/13 18:12:12
Acknowledged.
| |
| 73 | |
| 74 /** | |
| 54 * For testing purposes only, allows to set the provider even if it has alre ady been | 75 * For testing purposes only, allows to set the provider even if it has alre ady been |
| 55 * initialized. | 76 * initialized. |
| 56 */ | 77 */ |
| 57 @VisibleForTesting | 78 @VisibleForTesting |
| 58 public static void setInstanceForTest(AccountIdProvider provider) { | 79 public static void setInstanceForTest(AccountIdProvider provider) { |
| 59 sProvider = provider; | 80 sProvider = provider; |
| 60 } | 81 } |
| 61 } | 82 } |
| 62 | 83 |
| OLD | NEW |