Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "chrome/browser/android/signin/signin_manager_android.h" | 7 #include "chrome/browser/android/signin/signin_manager_android.h" |
| 8 | 8 |
| 9 #include "base/android/callback_android.h" | |
| 9 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
| 11 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 12 #include "base/bind.h" | 13 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 } | 292 } |
| 292 | 293 |
| 293 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 294 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 294 SigninManagerAndroid* signin_manager_android = | 295 SigninManagerAndroid* signin_manager_android = |
| 295 new SigninManagerAndroid(env, obj); | 296 new SigninManagerAndroid(env, obj); |
| 296 return reinterpret_cast<intptr_t>(signin_manager_android); | 297 return reinterpret_cast<intptr_t>(signin_manager_android); |
| 297 } | 298 } |
| 298 | 299 |
| 299 static jboolean ShouldLoadPolicyForUser( | 300 static jboolean ShouldLoadPolicyForUser( |
| 300 JNIEnv* env, | 301 JNIEnv* env, |
| 301 const JavaParamRef<jobject>& obj, | 302 const JavaParamRef<jclass>& clazz, |
| 302 const JavaParamRef<jstring>& j_username) { | 303 const JavaParamRef<jstring>& j_username) { |
| 303 std::string username = | 304 std::string username = |
| 304 base::android::ConvertJavaStringToUTF8(env, j_username); | 305 base::android::ConvertJavaStringToUTF8(env, j_username); |
| 305 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); | 306 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); |
| 306 } | 307 } |
| 307 | 308 |
| 309 namespace { | |
|
Bernhard Bauer
2016/06/03 08:50:06
Move to this the existing anonymous namespace at t
PEConn
2016/06/27 09:34:33
Done.
| |
| 310 | |
| 311 void UserManagementDomainFetched( | |
| 312 base::android::ScopedJavaGlobalRef<jobject> callback, | |
| 313 const std::string& dm_token, const std::string& client_id) { | |
| 314 base::android::ScopedJavaLocalRef<jstring> j_domain = | |
| 315 base::android::ConvertUTF8ToJavaString( | |
| 316 base::android::AttachCurrentThread(), | |
| 317 dm_token); | |
| 318 | |
| 319 base::android::RunCallbackAndroid(callback, j_domain); | |
|
Bernhard Bauer
2016/06/03 08:50:07
As discussed offline, this should be a boolean |is
PEConn
2016/06/27 09:34:33
Done.
| |
| 320 } | |
| 321 | |
| 322 } // namespace | |
| 323 | |
| 324 static void FetchUserManagementDomain( | |
| 325 JNIEnv* env, | |
| 326 const JavaParamRef<jclass>& clazz, | |
| 327 const JavaParamRef<jstring>& j_username, | |
| 328 const JavaParamRef<jobject>& j_callback) { | |
| 329 base::android::ScopedJavaGlobalRef<jobject> callback(env, j_callback); | |
| 330 | |
| 331 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
| 332 std::string username = | |
| 333 base::android::ConvertJavaStringToUTF8(env, j_username); | |
| 334 policy::UserPolicySigninService* service = | |
| 335 policy::UserPolicySigninServiceFactory::GetForProfile(profile); | |
| 336 service->RegisterForPolicy( | |
|
Bernhard Bauer
2016/06/03 08:50:07
You are sure that registering for policy without u
Bernhard Bauer
2016/06/29 10:51:26
^^^
PEConn
2016/06/30 09:26:44
In RegisterForPolicy, the CloudPolicyClient (which
| |
| 337 username, AccountTrackerServiceFactory::GetForProfile(profile) | |
| 338 ->FindAccountInfoByEmail(username) | |
| 339 .account_id, | |
| 340 base::Bind(&UserManagementDomainFetched, callback)); | |
| 341 } | |
| 342 | |
| 308 // static | 343 // static |
| 309 bool SigninManagerAndroid::Register(JNIEnv* env) { | 344 bool SigninManagerAndroid::Register(JNIEnv* env) { |
| 310 return RegisterNativesImpl(env); | 345 return RegisterNativesImpl(env); |
| 311 } | 346 } |
| OLD | NEW |