Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / supervised_user / child_accounts / child_account_service_android.cc
blob0642bd4ff5b2b1533851163b11b32b1a71f5e988
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
3 // found in the LICENSE file.
5 #include "chrome/browser/supervised_user/child_accounts/child_account_service_android.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h"
10 #include "chrome/browser/supervised_user/child_accounts/child_account_service_factory.h"
11 #include "jni/ChildAccountService_jni.h"
13 namespace {
15 bool g_is_child_account = false;
16 bool g_has_child_account_status = false;
18 } // namespace
20 jboolean IsChildAccountDetectionEnabled(JNIEnv* env, jobject obj) {
21 return ChildAccountService::IsChildAccountDetectionEnabled();
24 jboolean GetIsChildAccount(JNIEnv* env, jobject obj) {
25 ProfileManager* profile_manager = g_browser_process->profile_manager();
26 return profile_manager->GetLastUsedProfile()->IsChild();
29 void SetIsChildAccount(JNIEnv* env, jobject obj, jboolean is_child) {
30 VLOG(1) << "OnChildAccountSigninComplete";
32 // If the browser process has not been created yet, store the child account
33 // status and return it later in GetJavaChildAccountStatus().
34 if (!g_browser_process) {
35 g_has_child_account_status = true;
36 g_is_child_account = is_child;
37 return;
40 ProfileManager* profile_manager = g_browser_process->profile_manager();
41 Profile* profile = profile_manager->GetLastUsedProfile();
42 ChildAccountServiceFactory::GetForProfile(profile)
43 ->SetIsChildAccount(is_child);
46 bool GetJavaChildAccountStatus(bool* is_child_account) {
47 if (!g_has_child_account_status)
48 return false;
50 *is_child_account = g_is_child_account;
51 g_has_child_account_status = false;
52 return true;
55 void ChildStatusInvalidationReceived() {
56 JNIEnv* env = base::android::AttachCurrentThread();
57 Java_ChildAccountService_onInvalidationReceived(env);
60 bool RegisterChildAccountService(JNIEnv* env) {
61 return RegisterNativesImpl(env);