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.base.annotations.CalledByNative; | |
12 import org.chromium.components.signin.AccountManagerHelper; | 13 import org.chromium.components.signin.AccountManagerHelper; |
13 | 14 |
14 /** | 15 /** |
15 * This class serves as a simple interface for querying the child account inform ation. | 16 * 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 | 17 * 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 | 18 * asynchronous and queries the system directly for the information and the sync hronous |
18 * side assuming it has been set correctly already. | 19 * isChildAccount() which asks the native side assuming it has been set correctl y already. |
19 * | 20 * |
20 * The former method is used by ForcedSigninProcessor and FirstRunFlowSequencer to detect child | 21 * The former method is used by ForcedSigninProcessor and FirstRunFlowSequencer to detect child |
21 * accounts since the native side is only activated on signing in. | 22 * 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 | 23 * 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. | 24 * responsibility for monitoring changes and taking a suitable action. |
25 * | |
26 * The class also provides an interface through which a client can listen for ch ild account status | |
27 * changes. When the SupervisedUserContentProvider forces sign-in it waits for a status change | |
28 * before querying the URL filters. | |
24 */ | 29 */ |
25 public class ChildAccountService { | 30 public class ChildAccountService { |
26 private ChildAccountService() { | 31 private ChildAccountService() { |
27 // Only for static usage. | 32 // Only for static usage. |
28 } | 33 } |
29 | 34 |
30 /** | 35 /** |
31 * Checks for the presence of child accounts on the device. | 36 * Checks for the presence of child accounts on the device. |
32 * | 37 * |
33 * @param callback A callback which will be called with the result. | 38 * @param callback A callback which will be called with the result. |
(...skipping 16 matching lines...) Expand all Loading... | |
50 /** | 55 /** |
51 * Returns the previously determined value of whether there is a child accou nt on the device. | 56 * 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. | 57 * Should only be called after the native library and profile have been load ed. |
53 * | 58 * |
54 * @return The previously determined value of whether there is a child accou nt on the device. | 59 * @return The previously determined value of whether there is a child accou nt on the device. |
55 */ | 60 */ |
56 public static boolean isChildAccount() { | 61 public static boolean isChildAccount() { |
57 return nativeIsChildAccount(); | 62 return nativeIsChildAccount(); |
58 } | 63 } |
59 | 64 |
65 public static void listenForStatusChange(Runnable callback) { | |
Bernhard Bauer
2017/02/15 15:09:37
Javadoc for public methods. In particular, when an
aberent
2017/02/15 18:34:46
Done.
| |
66 nativeListenForChildStatusReceived(callback); | |
67 } | |
68 | |
69 @CalledByNative | |
70 private static void childStatusReceived(Runnable callback) { | |
71 callback.run(); | |
72 } | |
73 | |
60 private static native boolean nativeIsChildAccount(); | 74 private static native boolean nativeIsChildAccount(); |
75 | |
76 private static native void nativeListenForChildStatusReceived(Runnable callb ack); | |
61 } | 77 } |
OLD | NEW |