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

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

Issue 110373007: Delay loading the NTP after sign in until MergeSession has been performed in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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 | Annotate | Revision Log
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/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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 model->RemoveAll(); 200 model->RemoveAll();
202 201
203 // 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
204 // 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.
205 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); 204 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername);
206 205
207 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(), 206 Java_SigninManager_onProfileDataWiped(base::android::AttachCurrentThread(),
208 java_signin_manager_.obj()); 207 java_signin_manager_.obj());
209 } 208 }
210 209
210 void SigninManagerAndroid::MergeSessionCompleted(
211 const std::string& account_id,
212 const GoogleServiceAuthError& error) {
213 merge_session_helper_.reset();
214 }
215
211 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { 216 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) {
212 if (switches::IsNewProfileManagement()) { 217 if (switches::IsNewProfileManagement()) {
213 // New Mirror code path that just fires the events and let the 218 // New Mirror code path that just fires the events and let the
214 // Account Reconcilor handles everything. 219 // Account Reconcilor handles everything.
215 AndroidProfileOAuth2TokenService* token_service = 220 AndroidProfileOAuth2TokenService* token_service =
216 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 221 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
217 profile_); 222 profile_);
218 const std::string& primary_acct = token_service->GetPrimaryAccountId(); 223 const std::string& primary_acct = token_service->GetPrimaryAccountId();
219 const std::vector<std::string>& ids = token_service->GetAccounts(); 224 const std::vector<std::string>& ids = token_service->GetAccounts();
220 token_service->ValidateAccounts(primary_acct, ids); 225 token_service->ValidateAccounts(primary_acct, ids);
221 226
222 } else { 227 } else {
223 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser " 228 DVLOG(1) << "SigninManagerAndroid::LogInSignedInUser "
224 " Manually calling GoogleAutoLoginHelper"; 229 " Manually calling GoogleAutoLoginHelper";
225 // Old code path that doesn't depend on the new Account Reconcilor. 230 // Old code path that doesn't depend on the new Account Reconcilor.
226 // We manually login. 231 // We manually login.
227 232
228 // AutoLogin deletes itself. 233 merge_session_helper_.reset(new GoogleAutoLoginHelper(profile_, this));
229 GoogleAutoLoginHelper* autoLogin = new GoogleAutoLoginHelper(profile_); 234 merge_session_helper_->LogIn();
230 autoLogin->LogIn();
231 } 235 }
232 } 236 }
233 237
234 static jlong Init(JNIEnv* env, jobject obj) { 238 static jlong Init(JNIEnv* env, jobject obj) {
235 SigninManagerAndroid* signin_manager_android = 239 SigninManagerAndroid* signin_manager_android =
236 new SigninManagerAndroid(env, obj); 240 new SigninManagerAndroid(env, obj);
237 return reinterpret_cast<intptr_t>(signin_manager_android); 241 return reinterpret_cast<intptr_t>(signin_manager_android);
238 } 242 }
239 243
240 static jboolean ShouldLoadPolicyForUser(JNIEnv* env, 244 static jboolean ShouldLoadPolicyForUser(JNIEnv* env,
241 jobject obj, 245 jobject obj,
242 jstring j_username) { 246 jstring j_username) {
243 #if defined(ENABLE_CONFIGURATION_POLICY) 247 #if defined(ENABLE_CONFIGURATION_POLICY)
244 std::string username = 248 std::string username =
245 base::android::ConvertJavaStringToUTF8(env, j_username); 249 base::android::ConvertJavaStringToUTF8(env, j_username);
246 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); 250 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username);
247 #else 251 #else
248 return false; 252 return false;
249 #endif 253 #endif
250 } 254 }
251 255
252 // static 256 // static
253 bool SigninManagerAndroid::Register(JNIEnv* env) { 257 bool SigninManagerAndroid::Register(JNIEnv* env) {
254 return RegisterNativesImpl(env); 258 return RegisterNativesImpl(env);
255 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698