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

Side by Side Diff: chrome/browser/supervised_user/child_accounts/child_account_service_android.cc

Issue 1341423005: ChildAccountService[Java] delegates everything to native side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@child
Patch Set: nits Created 5 years, 3 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
« no previous file with comments | « chrome/browser/supervised_user/child_accounts/child_account_service_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile_manager.h" 8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" 9 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h"
10 #include "chrome/browser/supervised_user/child_accounts/child_account_service_fa ctory.h"
11 #include "jni/ChildAccountService_jni.h" 10 #include "jni/ChildAccountService_jni.h"
12 11
13 namespace {
14
15 bool g_is_child_account = false;
16 bool g_has_child_account_status = false;
17
18 } // namespace
19
20 jboolean IsChildAccountDetectionEnabled(JNIEnv* env, 12 jboolean IsChildAccountDetectionEnabled(JNIEnv* env,
21 const JavaParamRef<jobject>& obj) { 13 const JavaParamRef<jclass>& jcaller) {
22 return ChildAccountService::IsChildAccountDetectionEnabled(); 14 return ChildAccountService::IsChildAccountDetectionEnabled();
23 } 15 }
24 16
25 jboolean GetIsChildAccount(JNIEnv* env, const JavaParamRef<jobject>& obj) { 17 jboolean IsChildAccount(JNIEnv* env, const JavaParamRef<jclass>& jcaller) {
26 ProfileManager* profile_manager = g_browser_process->profile_manager(); 18 ProfileManager* profile_manager = g_browser_process->profile_manager();
27 return profile_manager->GetLastUsedProfile()->IsChild(); 19 return profile_manager->GetLastUsedProfile()->IsChild();
28 } 20 }
29 21
30 void SetIsChildAccount(JNIEnv* env,
31 const JavaParamRef<jobject>& obj,
32 jboolean is_child) {
33 VLOG(1) << "OnChildAccountSigninComplete";
34
35 // If the browser process has not been created yet, store the child account
36 // status and return it later in GetJavaChildAccountStatus().
37 if (!g_browser_process) {
38 g_has_child_account_status = true;
39 g_is_child_account = is_child;
40 return;
41 }
42
43 ProfileManager* profile_manager = g_browser_process->profile_manager();
44 Profile* profile = profile_manager->GetLastUsedProfile();
45 ChildAccountServiceFactory::GetForProfile(profile)
46 ->SetIsChildAccount(is_child);
47 }
48
49 bool GetJavaChildAccountStatus(bool* is_child_account) {
50 if (!g_has_child_account_status)
51 return false;
52
53 *is_child_account = g_is_child_account;
54 g_has_child_account_status = false;
55 return true;
56 }
57
58 void ChildStatusInvalidationReceived() {
59 JNIEnv* env = base::android::AttachCurrentThread();
60 Java_ChildAccountService_onInvalidationReceived(env);
61 }
62
63 bool RegisterChildAccountService(JNIEnv* env) { 22 bool RegisterChildAccountService(JNIEnv* env) {
64 return RegisterNativesImpl(env); 23 return RegisterNativesImpl(env);
65 } 24 }
OLDNEW
« no previous file with comments | « chrome/browser/supervised_user/child_accounts/child_account_service_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698