| 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 "chrome/browser/android/signin/signin_manager_android.h" | 5 #include "chrome/browser/android/signin/signin_manager_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" | 20 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" |
| 21 #include "chrome/browser/signin/google_auto_login_helper.h" | |
| 22 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 21 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 24 #include "chrome/browser/signin/signin_manager.h" | 23 #include "chrome/browser/signin/signin_manager.h" |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 24 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/profile_management_switches.h" | 26 #include "chrome/common/profile_management_switches.h" |
| 28 #include "jni/SigninManager_jni.h" | 27 #include "jni/SigninManager_jni.h" |
| 29 | 28 |
| 30 #if defined(ENABLE_CONFIGURATION_POLICY) | 29 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 31 #include "chrome/browser/policy/browser_policy_connector.h" | 30 #include "chrome/browser/policy/browser_policy_connector.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 model->RemoveAll(); | 198 model->RemoveAll(); |
| 200 | 199 |
| 201 // All the Profile data has been wiped. Clear the last signed in username as | 200 // All the Profile data has been wiped. Clear the last signed in username as |
| 202 // well, so that the next signin doesn't trigger the acount change dialog. | 201 // well, so that the next signin doesn't trigger the acount change dialog. |
| 203 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); | 202 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); |
| 204 | 203 |
| 205 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(), | 204 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(), |
| 206 java_signin_manager_.obj()); | 205 java_signin_manager_.obj()); |
| 207 } | 206 } |
| 208 | 207 |
| 208 void SigninManagerAndroid::MergeSessionCompleted( |
| 209 const std::string& account_id, |
| 210 const GoogleServiceAuthError& error) { |
| 211 merge_session_helper_.reset(); |
| 212 } |
| 213 |
| 209 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { | 214 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { |
| 210 if (switches::IsNewProfileManagement()) { | 215 if (switches::IsNewProfileManagement()) { |
| 211 // New Mirror code path that just fires the events and let the | 216 // New Mirror code path that just fires the events and let the |
| 212 // Account Reconcilor handles everything. | 217 // Account Reconcilor handles everything. |
| 213 AndroidProfileOAuth2TokenService* token_service = | 218 AndroidProfileOAuth2TokenService* token_service = |
| 214 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 219 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
| 215 profile_); | 220 profile_); |
| 216 const std::string& primary_acct = token_service->GetPrimaryAccountId(); | 221 const std::string& primary_acct = token_service->GetPrimaryAccountId(); |
| 217 const std::vector<std::string>& ids = token_service->GetAccounts(); | 222 const std::vector<std::string>& ids = token_service->GetAccounts(); |
| 218 token_service->ValidateAccounts(primary_acct, ids); | 223 token_service->ValidateAccounts(primary_acct, ids); |
| 219 | 224 |
| 220 } else { | 225 } else { |
| 221 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser " | 226 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser " |
| 222 " Manually calling GoogleAutoLoginHelper"; | 227 " Manually calling GoogleAutoLoginHelper"; |
| 223 // Old code path that doesn't depend on the new Account Reconcilor. | 228 // Old code path that doesn't depend on the new Account Reconcilor. |
| 224 // We manually login. | 229 // We manually login. |
| 225 | 230 |
| 226 // AutoLogin deletes itself. | 231 merge_session_helper_.reset(new GoogleAutoLoginHelper(profile_, this)); |
| 227 GoogleAutoLoginHelper* autoLogin = new GoogleAutoLoginHelper(profile_); | 232 merge_session_helper_->LogIn(); |
| 228 autoLogin->LogIn(); | |
| 229 } | 233 } |
| 230 } | 234 } |
| 231 | 235 |
| 232 static jlong Init(JNIEnv* env, jobject obj) { | 236 static jlong Init(JNIEnv* env, jobject obj) { |
| 233 SigninManagerAndroid* signin_manager_android = | 237 SigninManagerAndroid* signin_manager_android = |
| 234 new SigninManagerAndroid(env, obj); | 238 new SigninManagerAndroid(env, obj); |
| 235 return reinterpret_cast<intptr_t>(signin_manager_android); | 239 return reinterpret_cast<intptr_t>(signin_manager_android); |
| 236 } | 240 } |
| 237 | 241 |
| 238 static jboolean ShouldLoadPolicyForUser(JNIEnv* env, | 242 static jboolean ShouldLoadPolicyForUser(JNIEnv* env, |
| 239 jobject obj, | 243 jobject obj, |
| 240 jstring j_username) { | 244 jstring j_username) { |
| 241 #if defined(ENABLE_CONFIGURATION_POLICY) | 245 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 242 std::string username = | 246 std::string username = |
| 243 base::android::ConvertJavaStringToUTF8(env, j_username); | 247 base::android::ConvertJavaStringToUTF8(env, j_username); |
| 244 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); | 248 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); |
| 245 #else | 249 #else |
| 246 return false; | 250 return false; |
| 247 #endif | 251 #endif |
| 248 } | 252 } |
| 249 | 253 |
| 250 // static | 254 // static |
| 251 bool SigninManagerAndroid::Register(JNIEnv* env) { | 255 bool SigninManagerAndroid::Register(JNIEnv* env) { |
| 252 return RegisterNativesImpl(env); | 256 return RegisterNativesImpl(env); |
| 253 } | 257 } |
| OLD | NEW |