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 #include "chrome/browser/supervised_user/child_accounts/child_account_service_an droid.h" | 5 #include "chrome/browser/supervised_user/child_accounts/child_account_service_an droid.h" |
6 | 6 |
7 #include "base/android/callback_android.h" | |
8 #include "base/bind.h" | |
9 | |
7 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" | 12 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" |
13 #include "chrome/browser/supervised_user/child_accounts/child_account_service_fa ctory.h" | |
10 #include "jni/ChildAccountService_jni.h" | 14 #include "jni/ChildAccountService_jni.h" |
11 | 15 |
12 using base::android::JavaParamRef; | 16 using base::android::JavaParamRef; |
17 using base::android::JavaRef; | |
18 using base::android::RunCallbackAndroid; | |
19 using base::android::ScopedJavaGlobalRef; | |
13 | 20 |
14 jboolean IsChildAccount(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { | 21 jboolean IsChildAccount(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { |
15 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 22 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
16 return profile_manager->GetLastUsedProfile()->IsChild(); | 23 return profile_manager->GetLastUsedProfile()->IsChild(); |
17 } | 24 } |
18 | 25 |
19 bool RegisterChildAccountService(JNIEnv* env) { | 26 bool RegisterChildAccountService(JNIEnv* env) { |
20 return RegisterNativesImpl(env); | 27 return RegisterNativesImpl(env); |
21 } | 28 } |
29 | |
30 void ListenForChildStatusReceived(JNIEnv* env, | |
31 const JavaParamRef<jclass>& jcaller, | |
32 const JavaParamRef<jobject>& callback) { | |
33 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
34 ChildAccountService* service = ChildAccountServiceFactory::GetForProfile( | |
35 profile_manager->GetLastUsedProfile()); | |
36 // Needed to disambiguate RunCallbackAndroid | |
37 void (*runCallback)(const JavaRef<jobject>&, bool) = &RunCallbackAndroid; | |
38 // TODO(http://crbug/692591) Should use base::BindOnce, but | |
Bernhard Bauer
2017/02/15 18:40:09
Nit: Use HTTPS, and crbug.com :D
aberent
2017/02/15 18:56:24
Done.
| |
39 // AddChildStatusReceivedCallback won't yet accept a BindOnce. | |
40 service->AddChildStatusReceivedCallback( | |
41 base::Bind(runCallback, ScopedJavaGlobalRef<jobject>(callback), true)); | |
42 } | |
OLD | NEW |