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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 void SigninManagerAndroid::MergeSessionCompleted( | 263 void SigninManagerAndroid::MergeSessionCompleted( |
264 const std::string& account_id, | 264 const std::string& account_id, |
265 const GoogleServiceAuthError& error) { | 265 const GoogleServiceAuthError& error) { |
266 merge_session_helper_->RemoveObserver(this); | 266 merge_session_helper_->RemoveObserver(this); |
267 merge_session_helper_.reset(); | 267 merge_session_helper_.reset(); |
268 } | 268 } |
269 | 269 |
270 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { | 270 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { |
271 SigninManagerBase* signin_manager = | 271 SigninManagerBase* signin_manager = |
272 SigninManagerFactory::GetForProfile(profile_); | 272 SigninManagerFactory::GetForProfile(profile_); |
273 if (switches::IsNewProfileManagement()) { | 273 // Just fire the events and let the Account Reconcilor handles everything. |
274 // New Mirror code path that just fires the events and let the | |
275 // Account Reconcilor handles everything. | |
276 AndroidProfileOAuth2TokenService* token_service = | 274 AndroidProfileOAuth2TokenService* token_service = |
277 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 275 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
278 profile_); | 276 profile_); |
279 const std::string& primary_acct = | 277 const std::string& primary_acct = |
280 signin_manager->GetAuthenticatedAccountId(); | 278 signin_manager->GetAuthenticatedAccountId(); |
281 token_service->ValidateAccounts(primary_acct, true); | 279 token_service->ValidateAccounts(primary_acct, true); |
282 | |
283 } else { | |
284 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser " | |
285 " Manually calling MergeSessionHelper"; | |
286 // Old code path that doesn't depend on the new Account Reconcilor. | |
287 // We manually login. | |
288 | |
289 ProfileOAuth2TokenService* token_service = | |
290 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | |
291 merge_session_helper_.reset(new MergeSessionHelper( | |
292 token_service, GaiaConstants::kChromeSource, | |
293 profile_->GetRequestContext(), this)); | |
294 merge_session_helper_->LogIn(signin_manager->GetAuthenticatedAccountId()); | |
295 } | |
296 } | 280 } |
297 | 281 |
298 jboolean SigninManagerAndroid::IsSigninAllowedByPolicy(JNIEnv* env, | 282 jboolean SigninManagerAndroid::IsSigninAllowedByPolicy(JNIEnv* env, |
299 jobject obj) { | 283 jobject obj) { |
300 return SigninManagerFactory::GetForProfile(profile_)->IsSigninAllowed(); | 284 return SigninManagerFactory::GetForProfile(profile_)->IsSigninAllowed(); |
301 } | 285 } |
302 | 286 |
303 jboolean SigninManagerAndroid::IsSignedInOnNative(JNIEnv* env, jobject obj) { | 287 jboolean SigninManagerAndroid::IsSignedInOnNative(JNIEnv* env, jobject obj) { |
304 return SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated(); | 288 return SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated(); |
305 } | 289 } |
(...skipping 15 matching lines...) Expand all Loading... |
321 jstring j_username) { | 305 jstring j_username) { |
322 #if defined(ENABLE_CONFIGURATION_POLICY) | 306 #if defined(ENABLE_CONFIGURATION_POLICY) |
323 std::string username = | 307 std::string username = |
324 base::android::ConvertJavaStringToUTF8(env, j_username); | 308 base::android::ConvertJavaStringToUTF8(env, j_username); |
325 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); | 309 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); |
326 #else | 310 #else |
327 return false; | 311 return false; |
328 #endif | 312 #endif |
329 } | 313 } |
330 | 314 |
331 static jboolean IsNewProfileManagementEnabled(JNIEnv* env, jclass clazz) { | |
332 return switches::IsNewProfileManagement(); | |
333 } | |
334 | |
335 // static | 315 // static |
336 bool SigninManagerAndroid::Register(JNIEnv* env) { | 316 bool SigninManagerAndroid::Register(JNIEnv* env) { |
337 return RegisterNativesImpl(env); | 317 return RegisterNativesImpl(env); |
338 } | 318 } |
OLD | NEW |