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.childaccounts; | 5 package org.chromium.chrome.browser.childaccounts; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.content.Context; | 8 import android.content.Context; |
9 | 9 |
10 import org.chromium.base.Callback; | 10 import org.chromium.base.Callback; |
11 import org.chromium.base.ThreadUtils; | 11 import org.chromium.base.ThreadUtils; |
12 import org.chromium.components.signin.AccountManagerHelper; | 12 import org.chromium.components.signin.AccountManagerHelper; |
13 | 13 |
14 /** | 14 /** |
15 * This class serves as a simple interface for querying the child account inform
ation. | 15 * This class serves as a simple interface for querying the child account inform
ation. It has two |
16 * It has two methods namely, checkHasChildAccount(...) which is asynchronous an
d queries the | 16 * methods for querying the child account information; checkHasChildAccount(...)
which is |
17 * system directly for the information and the synchronous isChildAccount() whic
h asks the native | 17 * asynchronous and queries the system directly for the information and the sync
hronous |
18 * side assuming it has been set correctly already. | 18 * isChildAccount() which asks the native side assuming it has been set correctl
y already. |
19 * | 19 * |
20 * The former method is used by ForcedSigninProcessor and FirstRunFlowSequencer
to detect child | 20 * The former method is used by ForcedSigninProcessor and FirstRunFlowSequencer
to detect child |
21 * accounts since the native side is only activated on signing in. | 21 * accounts since the native side is only activated on signing in. Once signed i
n by the |
22 * Once signed in by the ForcedSigninProcessor, the ChildAccountInfoFetcher will
notify the native | 22 * ForcedSigninProcessor, the ChildAccountInfoFetcher will notify the native sid
e and also takes |
23 * side and also takes responsibility for monitoring changes and taking a suitab
le action. | 23 * responsibility for monitoring changes and taking a suitable action. |
| 24 * |
| 25 * The class also provides an interface through which a client can listen for ch
ild account status |
| 26 * changes. When the SupervisedUserContentProvider forces sign-in it waits for a
status change |
| 27 * before querying the URL filters. |
24 */ | 28 */ |
25 public class ChildAccountService { | 29 public class ChildAccountService { |
26 private ChildAccountService() { | 30 private ChildAccountService() { |
27 // Only for static usage. | 31 // Only for static usage. |
28 } | 32 } |
29 | 33 |
30 /** | 34 /** |
31 * Checks for the presence of child accounts on the device. | 35 * Checks for the presence of child accounts on the device. |
32 * | 36 * |
33 * @param callback A callback which will be called with the result. | 37 * @param callback A callback which will be called with the result. |
(...skipping 16 matching lines...) Expand all Loading... |
50 /** | 54 /** |
51 * Returns the previously determined value of whether there is a child accou
nt on the device. | 55 * Returns the previously determined value of whether there is a child accou
nt on the device. |
52 * Should only be called after the native library and profile have been load
ed. | 56 * Should only be called after the native library and profile have been load
ed. |
53 * | 57 * |
54 * @return The previously determined value of whether there is a child accou
nt on the device. | 58 * @return The previously determined value of whether there is a child accou
nt on the device. |
55 */ | 59 */ |
56 public static boolean isChildAccount() { | 60 public static boolean isChildAccount() { |
57 return nativeIsChildAccount(); | 61 return nativeIsChildAccount(); |
58 } | 62 } |
59 | 63 |
| 64 /** |
| 65 * Set a callback to be called the next time a child account status change i
s received |
| 66 * @param callback the callback to be called when the status changes. |
| 67 */ |
| 68 public static void listenForStatusChange(Callback<Boolean> callback) { |
| 69 nativeListenForChildStatusReceived(callback); |
| 70 } |
| 71 |
60 private static native boolean nativeIsChildAccount(); | 72 private static native boolean nativeIsChildAccount(); |
| 73 |
| 74 private static native void nativeListenForChildStatusReceived(Callback<Boole
an> callback); |
61 } | 75 } |
OLD | NEW |