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

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: remove the event Created 7 years, 1 month 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_client.h" 31 #include "chrome/browser/policy/cloud/cloud_policy_client.h"
29 #include "chrome/browser/policy/cloud/cloud_policy_core.h" 32 #include "chrome/browser/policy/cloud/cloud_policy_core.h"
30 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 33 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 197
195 // All the Profile data has been wiped. Clear the last signed in username as 198 // All the Profile data has been wiped. Clear the last signed in username as
196 // well, so that the next signin doesn't trigger the acount change dialog. 199 // well, so that the next signin doesn't trigger the acount change dialog.
197 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); 200 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername);
198 201
199 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(), 202 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(),
200 java_signin_manager_.obj()); 203 java_signin_manager_.obj());
201 } 204 }
202 205
203 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { 206 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) {
204 // AutoLogin deletes itself. 207 if (profiles::IsNewProfileManagementEnabled()) {
205 GoogleAutoLoginHelper* autoLogin = new GoogleAutoLoginHelper(profile_); 208 // New Mirror code path that just fires the events and let the
206 autoLogin->LogIn(); 209 // Account Reconcilor handles everything.
210
211 AndroidProfileOAuth2TokenService* token_service =
212 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
213
214 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser "
215 "Firing RefreshTokenAvailable";
216
217 // The first account we merge should always be the primiary
218 // account. The rest will just be whatever order the account manager
219 // inform us.
220 std::string primary_acct = token_service->GetPrimaryAccountId();
221 token_service->FireRefreshTokenAvailable(primary_acct);
222
223 std::vector<std::string> ids = token_service->GetAccounts();
224
225 for (std::vector<std::string>::iterator it = ids.begin();
226 it != ids.end(); it++) {
227 if (*it != primary_acct) {
228 token_service->FireRefreshTokenAvailable(*it);
229 }
230 }
Roger Tawa OOO till Jul 10th 2013/11/21 16:02:32 Given the changes in android_profile_oauth2_token_
acleung1 2013/11/26 09:28:31 Less duplicated code. I like that. Done.
231 } else {
232 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser "
233 " Manually calling GoogleAutoLoginHelper";
234 // Old code path that doesn't depend on the new Account Reconcilor.
235 // We manually login.
236
237 // AutoLogin deletes itself.
238 GoogleAutoLoginHelper* autoLogin = new GoogleAutoLoginHelper(profile_);
239 autoLogin->LogIn();
240 }
207 } 241 }
208 242
209 static int Init(JNIEnv* env, jobject obj) { 243 static int Init(JNIEnv* env, jobject obj) {
210 SigninManagerAndroid* signin_manager_android = 244 SigninManagerAndroid* signin_manager_android =
211 new SigninManagerAndroid(env, obj); 245 new SigninManagerAndroid(env, obj);
212 return reinterpret_cast<jint>(signin_manager_android); 246 return reinterpret_cast<jint>(signin_manager_android);
213 } 247 }
214 248
215 static jboolean ShouldLoadPolicyForUser(JNIEnv* env, 249 static jboolean ShouldLoadPolicyForUser(JNIEnv* env,
216 jobject obj, 250 jobject obj,
217 jstring j_username) { 251 jstring j_username) {
218 #if defined(ENABLE_CONFIGURATION_POLICY) 252 #if defined(ENABLE_CONFIGURATION_POLICY)
219 std::string username = 253 std::string username =
220 base::android::ConvertJavaStringToUTF8(env, j_username); 254 base::android::ConvertJavaStringToUTF8(env, j_username);
221 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); 255 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username);
222 #else 256 #else
223 return false; 257 return false;
224 #endif 258 #endif
225 } 259 }
226 260
227 // static 261 // static
228 bool SigninManagerAndroid::Register(JNIEnv* env) { 262 bool SigninManagerAndroid::Register(JNIEnv* env) {
229 return RegisterNativesImpl(env); 263 return RegisterNativesImpl(env);
230 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698