OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.sync.signin; | 5 package org.chromium.sync.signin; |
6 | 6 |
7 | 7 |
8 import com.google.common.annotations.VisibleForTesting; | 8 import com.google.common.annotations.VisibleForTesting; |
9 | 9 |
10 import android.accounts.Account; | 10 import android.accounts.Account; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 Account[] accounts = mAccountManager.getAccountsByType(GOOGLE_ACCOUNT_TY
PE); | 129 Account[] accounts = mAccountManager.getAccountsByType(GOOGLE_ACCOUNT_TY
PE); |
130 for (Account account : accounts) { | 130 for (Account account : accounts) { |
131 if (account.name.equals(accountName)) { | 131 if (account.name.equals(accountName)) { |
132 return account; | 132 return account; |
133 } | 133 } |
134 } | 134 } |
135 return null; | 135 return null; |
136 } | 136 } |
137 | 137 |
138 /** | 138 /** |
| 139 * Returns whether the accounts exists. |
| 140 */ |
| 141 public boolean hasAccountForName(String accountName) { |
| 142 return getAccountFromName(accountName) != null; |
| 143 } |
| 144 |
| 145 /** |
139 * @return Whether or not there is an account authenticator for Google accou
nts. | 146 * @return Whether or not there is an account authenticator for Google accou
nts. |
140 */ | 147 */ |
141 public boolean hasGoogleAccountAuthenticator() { | 148 public boolean hasGoogleAccountAuthenticator() { |
142 AuthenticatorDescription[] descs = mAccountManager.getAuthenticatorTypes
(); | 149 AuthenticatorDescription[] descs = mAccountManager.getAuthenticatorTypes
(); |
143 for (AuthenticatorDescription desc : descs) { | 150 for (AuthenticatorDescription desc : descs) { |
144 if (GOOGLE_ACCOUNT_TYPE.equals(desc.type)) return true; | 151 if (GOOGLE_ACCOUNT_TYPE.equals(desc.type)) return true; |
145 } | 152 } |
146 return false; | 153 return false; |
147 } | 154 } |
148 | 155 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 null, account, authTokenType, callback, numTries, errorEncountered,
null); | 343 null, account, authTokenType, callback, numTries, errorEncountered,
null); |
337 } | 344 } |
338 | 345 |
339 /** | 346 /** |
340 * Removes an auth token from the AccountManager's cache. | 347 * Removes an auth token from the AccountManager's cache. |
341 */ | 348 */ |
342 public void invalidateAuthToken(String authToken) { | 349 public void invalidateAuthToken(String authToken) { |
343 mAccountManager.invalidateAuthToken(GOOGLE_ACCOUNT_TYPE, authToken); | 350 mAccountManager.invalidateAuthToken(GOOGLE_ACCOUNT_TYPE, authToken); |
344 } | 351 } |
345 } | 352 } |
OLD | NEW |