Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/childaccounts/ChildAccountService.java

Issue 2784353002: Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Fix tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.app.Activity; 8 import android.app.Activity;
9 import android.content.Context; 9 import android.content.Context;
10 10
11 import org.chromium.base.Callback; 11 import org.chromium.base.Callback;
12 import org.chromium.base.ContextUtils;
13 import org.chromium.base.ThreadUtils; 12 import org.chromium.base.ThreadUtils;
14 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.CalledByNative;
15 import org.chromium.components.signin.AccountManagerHelper; 14 import org.chromium.components.signin.AccountManagerHelper;
16 import org.chromium.ui.base.WindowAndroid; 15 import org.chromium.ui.base.WindowAndroid;
17 16
18 /** 17 /**
19 * This class serves as a simple interface for querying the child account inform ation. It has two 18 * This class serves as a simple interface for querying the child account inform ation. It has two
20 * methods for querying the child account information; checkHasChildAccount(...) which is 19 * methods for querying the child account information; checkHasChildAccount(...) which is
21 * asynchronous and queries the system directly for the information and the sync hronous 20 * asynchronous and queries the system directly for the information and the sync hronous
22 * isChildAccount() which asks the native side assuming it has been set correctl y already. 21 * isChildAccount() which asks the native side assuming it has been set correctl y already.
(...skipping 12 matching lines...) Expand all
35 // Only for static usage. 34 // Only for static usage.
36 } 35 }
37 36
38 /** 37 /**
39 * Checks for the presence of child accounts on the device. 38 * Checks for the presence of child accounts on the device.
40 * 39 *
41 * @param callback A callback which will be called with the result. 40 * @param callback A callback which will be called with the result.
42 */ 41 */
43 public static void checkHasChildAccount(Context context, final Callback<Bool ean> callback) { 42 public static void checkHasChildAccount(Context context, final Callback<Bool ean> callback) {
44 ThreadUtils.assertOnUiThread(); 43 ThreadUtils.assertOnUiThread();
45 final AccountManagerHelper helper = AccountManagerHelper.get(context); 44 final AccountManagerHelper helper = AccountManagerHelper.get();
46 helper.getGoogleAccounts(new Callback<Account[]>() { 45 helper.getGoogleAccounts(new Callback<Account[]>() {
47 @Override 46 @Override
48 public void onResult(Account[] accounts) { 47 public void onResult(Account[] accounts) {
49 if (accounts.length != 1) { 48 if (accounts.length != 1) {
50 callback.onResult(false); 49 callback.onResult(false);
51 } else { 50 } else {
52 helper.checkChildAccount(accounts[0], callback); 51 helper.checkChildAccount(accounts[0], callback);
53 } 52 }
54 } 53 }
55 }); 54 });
(...skipping 27 matching lines...) Expand all
83 ThreadUtils.postOnUiThread(new Runnable() { 82 ThreadUtils.postOnUiThread(new Runnable() {
84 @Override 83 @Override
85 public void run() { 84 public void run() {
86 nativeOnReauthenticationResult(nativeCallback, false); 85 nativeOnReauthenticationResult(nativeCallback, false);
87 } 86 }
88 }); 87 });
89 return; 88 return;
90 } 89 }
91 90
92 Account account = AccountManagerHelper.createAccountFromName(accountName ); 91 Account account = AccountManagerHelper.createAccountFromName(accountName );
93 AccountManagerHelper.get(ContextUtils.getApplicationContext()) 92 AccountManagerHelper.get().updateCredentials(account, activity, new Call back<Boolean>() {
94 .updateCredentials(account, activity, new Callback<Boolean>() { 93 @Override
95 @Override 94 public void onResult(Boolean result) {
96 public void onResult(Boolean result) { 95 nativeOnReauthenticationResult(nativeCallback, result);
97 nativeOnReauthenticationResult(nativeCallback, result); 96 }
98 } 97 });
99 });
100 } 98 }
101 99
102 private static native boolean nativeIsChildAccount(); 100 private static native boolean nativeIsChildAccount();
103 101
104 private static native void nativeListenForChildStatusReceived(Callback<Boole an> callback); 102 private static native void nativeListenForChildStatusReceived(Callback<Boole an> callback);
105 103
106 private static native void nativeOnReauthenticationResult( 104 private static native void nativeOnReauthenticationResult(
107 long callbackPtr, boolean reauthSuccessful); 105 long callbackPtr, boolean reauthSuccessful);
108 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698