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

Side by Side Diff: chrome/browser/android/signin/signin_manager_android.cc

Issue 63253003: Fix issues with token refresh in AccountReconcilor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 7 years 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 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/profiles/profiles_state.h"
20 #include "chrome/browser/signin/google_auto_login_helper.h" 21 #include "chrome/browser/signin/google_auto_login_helper.h"
22 #include "chrome/browser/signin/profile_oauth2_token_service.h"
23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
21 #include "chrome/browser/signin/signin_manager.h" 24 #include "chrome/browser/signin/signin_manager.h"
22 #include "chrome/browser/signin/signin_manager_factory.h" 25 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
24 #include "jni/SigninManager_jni.h" 27 #include "jni/SigninManager_jni.h"
25 28
26 #if defined(ENABLE_CONFIGURATION_POLICY) 29 #if defined(ENABLE_CONFIGURATION_POLICY)
27 #include "chrome/browser/policy/browser_policy_connector.h" 30 #include "chrome/browser/policy/browser_policy_connector.h"
28 #include "chrome/browser/policy/cloud/cloud_policy_core.h" 31 #include "chrome/browser/policy/cloud/cloud_policy_core.h"
29 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 32 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
30 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" 33 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 201
199 // All the Profile data has been wiped. Clear the last signed in username as 202 // All the Profile data has been wiped. Clear the last signed in username as
200 // well, so that the next signin doesn't trigger the acount change dialog. 203 // well, so that the next signin doesn't trigger the acount change dialog.
201 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); 204 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername);
202 205
203 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(), 206 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(),
204 java_signin_manager_.obj()); 207 java_signin_manager_.obj());
205 } 208 }
206 209
207 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { 210 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) {
208 // AutoLogin deletes itself. 211 if (profiles::IsNewProfileManagementEnabled()) {
209 GoogleAutoLoginHelper* autoLogin = new GoogleAutoLoginHelper(profile_); 212 // New Mirror code path that just fires the events and let the
210 autoLogin->LogIn(); 213 // Account Reconcilor handles everything.
214 AndroidProfileOAuth2TokenService* token_service =
215 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
216 const std::string& primary_acct = token_service->GetPrimaryAccountId();
217 const std::vector<std::string>& ids = token_service->GetAccounts();
218 token_service->ValidateAccounts(primary_acct, ids);
219
220 } else {
221 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser "
222 " Manually calling GoogleAutoLoginHelper";
223 // Old code path that doesn't depend on the new Account Reconcilor.
224 // We manually login.
225
226 // AutoLogin deletes itself.
227 GoogleAutoLoginHelper* autoLogin = new GoogleAutoLoginHelper(profile_);
228 autoLogin->LogIn();
229 }
211 } 230 }
212 231
213 static jlong Init(JNIEnv* env, jobject obj) { 232 static jlong Init(JNIEnv* env, jobject obj) {
214 SigninManagerAndroid* signin_manager_android = 233 SigninManagerAndroid* signin_manager_android =
215 new SigninManagerAndroid(env, obj); 234 new SigninManagerAndroid(env, obj);
216 return reinterpret_cast<intptr_t>(signin_manager_android); 235 return reinterpret_cast<intptr_t>(signin_manager_android);
217 } 236 }
218 237
219 static jboolean ShouldLoadPolicyForUser(JNIEnv* env, 238 static jboolean ShouldLoadPolicyForUser(JNIEnv* env,
220 jobject obj, 239 jobject obj,
221 jstring j_username) { 240 jstring j_username) {
222 #if defined(ENABLE_CONFIGURATION_POLICY) 241 #if defined(ENABLE_CONFIGURATION_POLICY)
223 std::string username = 242 std::string username =
224 base::android::ConvertJavaStringToUTF8(env, j_username); 243 base::android::ConvertJavaStringToUTF8(env, j_username);
225 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); 244 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username);
226 #else 245 #else
227 return false; 246 return false;
228 #endif 247 #endif
229 } 248 }
230 249
231 // static 250 // static
232 bool SigninManagerAndroid::Register(JNIEnv* env) { 251 bool SigninManagerAndroid::Register(JNIEnv* env) {
233 return RegisterNativesImpl(env); 252 return RegisterNativesImpl(env);
234 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698