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

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 Created 8 years, 12 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 void SigninManager::SignOut() { 180 void SigninManager::SignOut() {
181 if (!profile_) 181 if (!profile_)
182 return; 182 return;
183 183
184 ClearTransientSigninData(); 184 ClearTransientSigninData();
185 authenticated_username_.clear(); 185 authenticated_username_.clear();
186 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); 186 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
187 profile_->GetPrefs()->ClearPref(prefs::kSyncUsingOAuth); 187 profile_->GetPrefs()->ClearPref(prefs::kSyncUsingOAuth);
188 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
189 profile_->GetTokenService()->ResetCredentialsInMemory(); 188 profile_->GetTokenService()->ResetCredentialsInMemory();
190 profile_->GetTokenService()->EraseTokensFromDB(); 189 profile_->GetTokenService()->EraseTokensFromDB();
191 } 190 }
192 191
193 void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) { 192 void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) {
194 DCHECK(!browser_sync::IsUsingOAuth()); 193 DCHECK(!browser_sync::IsUsingOAuth());
195 last_result_ = result; 194 last_result_ = result;
196 // Make a request for the canonical email address. 195 // Make a request for the canonical email address.
197 client_login_->StartGetUserInfo(result.lsid, kGetInfoEmailKey); 196 client_login_->StartGetUserInfo(result.lsid, kGetInfoEmailKey);
198 } 197 }
199 198
200 // NOTE: GetUserInfo is a ClientLogin request similar to OAuth's userinfo 199 // NOTE: GetUserInfo is a ClientLogin request similar to OAuth's userinfo
201 void SigninManager::OnGetUserInfoSuccess(const std::string& key, 200 void SigninManager::OnGetUserInfoSuccess(const std::string& key,
202 const std::string& value) { 201 const std::string& value) {
203 DCHECK(!browser_sync::IsUsingOAuth()); 202 DCHECK(!browser_sync::IsUsingOAuth());
204 DCHECK(key == kGetInfoEmailKey); 203 DCHECK(key == kGetInfoEmailKey);
205 DCHECK(authenticated_username_.empty() || authenticated_username_ == value); 204 DCHECK(authenticated_username_.empty() || authenticated_username_ == value);
206 205
207 authenticated_username_ = value; 206 authenticated_username_ = value;
208 possibly_invalid_username_.clear(); 207 possibly_invalid_username_.clear();
209 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 208 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
210 authenticated_username_); 209 authenticated_username_);
211 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, false); 210 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, false);
212 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
213 211
214 GoogleServiceSigninSuccessDetails details(authenticated_username_, 212 GoogleServiceSigninSuccessDetails details(authenticated_username_,
215 password_); 213 password_);
216 content::NotificationService::current()->Notify( 214 content::NotificationService::current()->Notify(
217 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 215 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
218 content::Source<Profile>(profile_), 216 content::Source<Profile>(profile_),
219 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); 217 content::Details<const GoogleServiceSigninSuccessDetails>(&details));
220 218
221 password_.clear(); // Don't need it anymore. 219 password_.clear(); // Don't need it anymore.
222 220
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // If |SignOut()| was called between the login start and |OnUserInfoSucess()|, 304 // If |SignOut()| was called between the login start and |OnUserInfoSucess()|,
307 // then the OAuth credentials would have been cleared. 305 // then the OAuth credentials would have been cleared.
308 if (!token_service->HasOAuthCredentials()) 306 if (!token_service->HasOAuthCredentials())
309 return; 307 return;
310 308
311 DVLOG(1) << "Sync signin for " << email << " is complete."; 309 DVLOG(1) << "Sync signin for " << email << " is complete.";
312 authenticated_username_ = email; 310 authenticated_username_ = email;
313 profile_->GetPrefs()->SetString( 311 profile_->GetPrefs()->SetString(
314 prefs::kGoogleServicesUsername, authenticated_username_); 312 prefs::kGoogleServicesUsername, authenticated_username_);
315 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, true); 313 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, true);
316 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
317 314
318 DCHECK(password_.empty()); 315 DCHECK(password_.empty());
319 GoogleServiceSigninSuccessDetails details(authenticated_username_, ""); 316 GoogleServiceSigninSuccessDetails details(authenticated_username_, "");
320 content::NotificationService::current()->Notify( 317 content::NotificationService::current()->Notify(
321 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 318 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
322 content::Source<Profile>(profile_), 319 content::Source<Profile>(profile_),
323 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); 320 content::Details<const GoogleServiceSigninSuccessDetails>(&details));
324 321
325 DCHECK(token_service->HasOAuthCredentials()); 322 DCHECK(token_service->HasOAuthCredentials());
326 token_service->StartFetchingOAuthTokens(); 323 token_service->StartFetchingOAuthTokens();
(...skipping 22 matching lines...) Expand all
349 profile_->GetRequestContext())); 346 profile_->GetRequestContext()));
350 } 347 }
351 348
352 client_login_->StartMergeSession(tok_details->token()); 349 client_login_->StartMergeSession(tok_details->token());
353 350
354 // We only want to do this once per sign-in. 351 // We only want to do this once per sign-in.
355 CleanupNotificationRegistration(); 352 CleanupNotificationRegistration();
356 } 353 }
357 #endif 354 #endif
358 } 355 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | chrome/browser/sync/sync_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698