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

Side by Side Diff: chrome/browser/sync/signin_manager.cc

Issue 8198007: Remove PrefService::ScheduleSavePersistentPrefs and SavePersistentPrefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 9 years, 2 months 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/signin_manager.h" 5 #include "chrome/browser/sync/signin_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/net/gaia/token_service.h" 9 #include "chrome/browser/net/gaia/token_service.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 CleanupNotificationRegistration(); 169 CleanupNotificationRegistration();
170 170
171 client_login_.reset(); 171 client_login_.reset();
172 last_result_ = ClientLoginResult(); 172 last_result_ = ClientLoginResult();
173 username_.clear(); 173 username_.clear();
174 oauth_username_.clear(); 174 oauth_username_.clear();
175 password_.clear(); 175 password_.clear();
176 had_two_factor_error_ = false; 176 had_two_factor_error_ = false;
177 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); 177 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
178 profile_->GetPrefs()->ClearPref(prefs::kSyncUsingOAuth); 178 profile_->GetPrefs()->ClearPref(prefs::kSyncUsingOAuth);
179 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
180 profile_->GetTokenService()->ResetCredentialsInMemory(); 179 profile_->GetTokenService()->ResetCredentialsInMemory();
181 profile_->GetTokenService()->EraseTokensFromDB(); 180 profile_->GetTokenService()->EraseTokensFromDB();
182 } 181 }
183 182
184 void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) { 183 void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) {
185 DCHECK(!browser_sync::IsUsingOAuth()); 184 DCHECK(!browser_sync::IsUsingOAuth());
186 last_result_ = result; 185 last_result_ = result;
187 // Make a request for the canonical email address. 186 // Make a request for the canonical email address.
188 client_login_->StartGetUserInfo(result.lsid, kGetInfoEmailKey); 187 client_login_->StartGetUserInfo(result.lsid, kGetInfoEmailKey);
189 } 188 }
190 189
191 // NOTE: GetUserInfo is a ClientLogin request similar to OAuth's userinfo 190 // NOTE: GetUserInfo is a ClientLogin request similar to OAuth's userinfo
192 void SigninManager::OnGetUserInfoSuccess(const std::string& key, 191 void SigninManager::OnGetUserInfoSuccess(const std::string& key,
193 const std::string& value) { 192 const std::string& value) {
194 DCHECK(!browser_sync::IsUsingOAuth()); 193 DCHECK(!browser_sync::IsUsingOAuth());
195 DCHECK(key == kGetInfoEmailKey); 194 DCHECK(key == kGetInfoEmailKey);
196 195
197 username_ = value; 196 username_ = value;
198 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, username_); 197 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, username_);
199 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, false); 198 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, false);
200 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
201 199
202 GoogleServiceSigninSuccessDetails details(username_, password_); 200 GoogleServiceSigninSuccessDetails details(username_, password_);
203 NotificationService::current()->Notify( 201 NotificationService::current()->Notify(
204 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 202 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
205 Source<Profile>(profile_), 203 Source<Profile>(profile_),
206 Details<const GoogleServiceSigninSuccessDetails>(&details)); 204 Details<const GoogleServiceSigninSuccessDetails>(&details));
207 205
208 password_.clear(); // Don't need it anymore. 206 password_.clear(); // Don't need it anymore.
209 207
210 profile_->GetTokenService()->UpdateCredentials(last_result_); 208 profile_->GetTokenService()->UpdateCredentials(last_result_);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // If |SignOut()| was called between the login start and |OnUserInfoSucess()|, 291 // If |SignOut()| was called between the login start and |OnUserInfoSucess()|,
294 // then the OAuth credentials would have been cleared. 292 // then the OAuth credentials would have been cleared.
295 if (!token_service->HasOAuthCredentials()) 293 if (!token_service->HasOAuthCredentials())
296 return; 294 return;
297 295
298 VLOG(1) << "Sync signin for " << email << " is complete."; 296 VLOG(1) << "Sync signin for " << email << " is complete.";
299 oauth_username_ = email; 297 oauth_username_ = email;
300 profile_->GetPrefs()->SetString( 298 profile_->GetPrefs()->SetString(
301 prefs::kGoogleServicesUsername, oauth_username_); 299 prefs::kGoogleServicesUsername, oauth_username_);
302 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, true); 300 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, true);
303 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
304 301
305 DCHECK(password_.empty()); 302 DCHECK(password_.empty());
306 GoogleServiceSigninSuccessDetails details(oauth_username_, ""); 303 GoogleServiceSigninSuccessDetails details(oauth_username_, "");
307 NotificationService::current()->Notify( 304 NotificationService::current()->Notify(
308 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 305 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
309 Source<Profile>(profile_), 306 Source<Profile>(profile_),
310 Details<const GoogleServiceSigninSuccessDetails>(&details)); 307 Details<const GoogleServiceSigninSuccessDetails>(&details));
311 308
312 DCHECK(token_service->HasOAuthCredentials()); 309 DCHECK(token_service->HasOAuthCredentials());
313 token_service->StartFetchingOAuthTokens(); 310 token_service->StartFetchingOAuthTokens();
(...skipping 22 matching lines...) Expand all
336 profile_->GetRequestContext())); 333 profile_->GetRequestContext()));
337 } 334 }
338 335
339 client_login_->StartMergeSession(tok_details->token()); 336 client_login_->StartMergeSession(tok_details->token());
340 337
341 // We only want to do this once per sign-in. 338 // We only want to do this once per sign-in.
342 CleanupNotificationRegistration(); 339 CleanupNotificationRegistration();
343 } 340 }
344 #endif 341 #endif
345 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698