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

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

Issue 2695113002: [Webview, Child Accounts] Automatically sign in to Chrome if needed. (Closed)
Patch Set: Respond to comments Created 3 years, 10 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 #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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698