OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.accounts.AccountManagerCallback; | |
9 import android.accounts.AccountManagerFuture; | |
10 import android.accounts.AuthenticatorDescription; | 8 import android.accounts.AuthenticatorDescription; |
11 import android.os.Bundle; | |
12 import android.os.Handler; | |
13 | 9 |
14 import org.chromium.base.Callback; | 10 import org.chromium.base.Callback; |
15 | 11 |
16 /** | 12 /** |
17 * Wrapper around the Android account manager, to facilitate dependency injectio
n during testing. | 13 * Wrapper around the Android account manager, to facilitate dependency injectio
n during testing. |
18 */ | 14 */ |
19 public interface AccountManagerDelegate { | 15 public interface AccountManagerDelegate { |
20 /** | 16 /** |
21 * This method is deprecated; please use the asynchronous version below inst
ead. | 17 * This method is deprecated; please use the asynchronous version below inst
ead. |
22 * | 18 * |
23 * See http://crbug.com/517697 for details. | 19 * See http://crbug.com/517697 for details. |
24 */ | 20 */ |
25 Account[] getAccountsByType(String type); | 21 Account[] getAccountsByType(String type); |
26 | 22 |
| 23 /** |
| 24 * Get all the accounts for a given {@code type}. |
| 25 */ |
27 void getAccountsByType(String type, Callback<Account[]> callback); | 26 void getAccountsByType(String type, Callback<Account[]> callback); |
28 | 27 |
29 AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenT
ype, | 28 /** |
30 boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback,
Handler handler); | 29 * @param account The {@link Account} for which the auth token is requested. |
| 30 * @param authTokenScope The scope of the authToken being requested. |
| 31 * @return The auth token fetched from the authenticator. |
| 32 * The authenticator can throw an {@link AuthException} to indicate a failur
e in fetching the |
| 33 * auth token perhaps due to a transient error or when user intervention is
required (like |
| 34 * confirming the credentials) which is expressed as an {@link Intent} to th
e handler. |
| 35 * This should only be called on a background thread. |
| 36 */ |
| 37 String getAuthToken(Account account, String authTokenScope) throws AuthExcep
tion; |
31 | 38 |
| 39 /** |
| 40 * Invalidate the {@code authToken} associated with account type {@code acco
untType}. |
| 41 */ |
32 void invalidateAuthToken(String accountType, String authToken); | 42 void invalidateAuthToken(String accountType, String authToken); |
33 | 43 |
| 44 /** |
| 45 * Get all the available authenticator types. |
| 46 */ |
34 AuthenticatorDescription[] getAuthenticatorTypes(); | 47 AuthenticatorDescription[] getAuthenticatorTypes(); |
35 | 48 |
| 49 /** |
| 50 * Check whether the {@code account} has all the features listed in {@code f
eatures}. |
| 51 */ |
36 void hasFeatures(Account account, String[] features, Callback<Boolean> callb
ack); | 52 void hasFeatures(Account account, String[] features, Callback<Boolean> callb
ack); |
37 } | 53 } |
OLD | NEW |