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/bind.h" | |
8 | |
7 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" | 11 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" |
12 #include "chrome/browser/supervised_user/child_accounts/child_account_service_fa ctory.h" | |
10 #include "jni/ChildAccountService_jni.h" | 13 #include "jni/ChildAccountService_jni.h" |
11 | 14 |
12 using base::android::JavaParamRef; | 15 using base::android::JavaParamRef; |
16 using base::android::ScopedJavaGlobalRef; | |
13 | 17 |
14 jboolean IsChildAccount(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { | 18 jboolean IsChildAccount(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { |
15 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 19 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
16 return profile_manager->GetLastUsedProfile()->IsChild(); | 20 return profile_manager->GetLastUsedProfile()->IsChild(); |
17 } | 21 } |
18 | 22 |
19 bool RegisterChildAccountService(JNIEnv* env) { | 23 bool RegisterChildAccountService(JNIEnv* env) { |
20 return RegisterNativesImpl(env); | 24 return RegisterNativesImpl(env); |
21 } | 25 } |
26 | |
27 void ListenForChildStatusReceived(JNIEnv* env, | |
28 const JavaParamRef<jclass>& jcaller, | |
29 const JavaParamRef<jobject>& callback) { | |
30 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
31 ChildAccountService* service = ChildAccountServiceFactory::GetForProfile( | |
32 profile_manager->GetLastUsedProfile()); | |
33 service->AddChildStatusReceivedCallback( | |
34 base::Bind(&Java_ChildAccountService_childStatusReceived, env, | |
Bernhard Bauer
2017/02/15 15:09:38
Don't hold on to the JNIEnv* by binding it into th
aberent
2017/02/15 18:34:46
Actually switched to binding RunCallbackAndroid, w
| |
35 ScopedJavaGlobalRef<jobject>(callback))); | |
36 } | |
OLD | NEW |