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/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 | 96 |
| 97 SigninManagerAndroid::~SigninManagerAndroid() {} | 97 SigninManagerAndroid::~SigninManagerAndroid() {} |
| 98 | 98 |
| 99 void SigninManagerAndroid::CheckPolicyBeforeSignIn(JNIEnv* env, | 99 void SigninManagerAndroid::CheckPolicyBeforeSignIn(JNIEnv* env, |
| 100 jobject obj, | 100 jobject obj, |
| 101 jstring username) { | 101 jstring username) { |
| 102 #if defined(ENABLE_CONFIGURATION_POLICY) | 102 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 103 username_ = base::android::ConvertJavaStringToUTF8(env, username); | 103 username_ = base::android::ConvertJavaStringToUTF8(env, username); |
| 104 policy::UserPolicySigninService* service = | 104 policy::UserPolicySigninService* service = |
| 105 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); | 105 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); |
| 106 std::string account_id = AccountTrackerServiceFactory::GetForProfile(profile_) | |
| 107 ->FindAccountInfoByEmail(username_) | |
| 108 .account_id; | |
| 109 if (account_id.empty()) | |
| 110 account_id = username_; | |
|
Roger Tawa OOO till Jul 10th
2015/08/12 15:28:46
Under what cases would we want to use username as
gogerald1
2015/08/13 18:12:12
In this simple solution, services may need OAuth2T
| |
| 106 service->RegisterForPolicy( | 111 service->RegisterForPolicy( |
| 107 base::android::ConvertJavaStringToUTF8(env, username), | 112 username_, account_id, |
| 108 base::Bind(&SigninManagerAndroid::OnPolicyRegisterDone, | 113 base::Bind(&SigninManagerAndroid::OnPolicyRegisterDone, |
| 109 weak_factory_.GetWeakPtr())); | 114 weak_factory_.GetWeakPtr())); |
| 110 #else | 115 #else |
| 111 // This shouldn't be called when ShouldLoadPolicyForUser() is false. | 116 // This shouldn't be called when ShouldLoadPolicyForUser() is false. |
| 112 NOTREACHED(); | 117 NOTREACHED(); |
| 113 base::android::ScopedJavaLocalRef<jstring> domain; | 118 base::android::ScopedJavaLocalRef<jstring> domain; |
| 114 Java_SigninManager_onPolicyCheckedBeforeSignIn(env, | 119 Java_SigninManager_onPolicyCheckedBeforeSignIn(env, |
| 115 java_signin_manager_.obj(), | 120 java_signin_manager_.obj(), |
| 116 domain.obj()); | 121 domain.obj()); |
| 117 #endif | 122 #endif |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); | 310 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); |
| 306 #else | 311 #else |
| 307 return false; | 312 return false; |
| 308 #endif | 313 #endif |
| 309 } | 314 } |
| 310 | 315 |
| 311 // static | 316 // static |
| 312 bool SigninManagerAndroid::Register(JNIEnv* env) { | 317 bool SigninManagerAndroid::Register(JNIEnv* env) { |
| 313 return RegisterNativesImpl(env); | 318 return RegisterNativesImpl(env); |
| 314 } | 319 } |
| OLD | NEW |