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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 8698001: sync: change semantics (and name) of SigninManager::GetUsername (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: first Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sync/signin_manager.h » ('j') | chrome/browser/sync/signin_manager.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 5f428119fbf24d09b51683a0b796e1789c4f7093..c2b5949679bef1418b9edd00327b215956d8085c 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -146,7 +146,7 @@ bool ProfileSyncService::AreCredentialsAvailable() {
}
// CrOS user is always logged in. Chrome uses signin_ to check logged in.
- if (!cros_user_.empty() || !signin_->GetUsername().empty()) {
+ if (!cros_user_.empty() || !signin_->GetAuthenticatedUsername().empty()) {
// TODO(chron): Verify CrOS unit test behavior.
return profile()->GetTokenService() &&
profile()->GetTokenService()->HasTokenForService(
@@ -176,17 +176,7 @@ void ProfileSyncService::Initialize() {
if (!HasSyncSetupCompleted())
DisableForUser(); // Clean up in case of previous crash / setup abort.
- // In Chrome, we integrate a SigninManager which works with the sync
- // setup wizard to kick off the TokenService. CrOS does its own plumbing
- // for the TokenService in login and does not normally rely on signin_,
- // so only initialize this if the token service has not been initialized
- // (e.g. the browser crashed or is being debugged).
- if (cros_user_.empty() ||
- !profile_->GetTokenService()->Initialized()) {
- // Will load tokens from DB and broadcast Token events after.
- // Note: We rely on signin_ != NULL unless !cros_user_.empty().
- signin_->Initialize(profile_);
- }
+ signin_->Initialize(profile_);
TryStart();
}
@@ -279,7 +269,8 @@ void ProfileSyncService::InitSettings() {
SyncCredentials ProfileSyncService::GetCredentials() {
SyncCredentials credentials;
- credentials.email = cros_user_.empty() ? signin_->GetUsername() : cros_user_;
+ credentials.email = cros_user_.empty() ?
+ signin_->GetAuthenticatedUsername() : cros_user_;
DCHECK(!credentials.email.empty());
TokenService* service = profile_->GetTokenService();
credentials.sync_token = service->GetTokenForService(
@@ -1065,22 +1056,11 @@ void ProfileSyncService::OnUserSubmittedAuth(
auth_start_time_ = base::TimeTicks::Now();
- if (!signin_->IsInitialized()) {
- // In ChromeOS we sign in during login, so we do not initialize signin_.
- // If this function gets called, we need to re-authenticate (e.g. for
- // two factor signin), so initialize signin_ here.
- signin_->Initialize(profile_);
- }
-
if (!access_code.empty()) {
signin_->ProvideSecondFactorAccessCode(access_code);
return;
}
- if (!signin_->GetUsername().empty()) {
- signin_->ClearInMemoryData();
- }
-
// The user has submitted credentials, which indicates they don't
// want to suppress start up anymore.
sync_prefs_.SetStartSuppressed(false);
@@ -1450,12 +1430,13 @@ void ProfileSyncService::Observe(int type,
break;
}
case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: {
- // If not in Chrome OS, and we have a username without tokens,
- // the user will need to signin again, so sign out.
+ // If not in auto-start / Chrome OS mode, and we have a username
+ // without tokens, the user will need to signin again. NotifyObservers to
+ // trigger errors in the UI that will allow the user to re-login.
if (cros_user_.empty() &&
- !signin_->GetUsername().empty() &&
+ !signin_->GetAuthenticatedUsername().empty() &&
!AreCredentialsAvailable()) {
- DisableForUser();
+ NotifyObservers();
Andrew T Wilson (Slow) 2011/11/28 04:54:02 I'm not entirely sure why it's now OK to NotifyObs
tim (not reviewing) 2011/12/05 21:24:50 I'm in the same boat here, honestly. In fact I'm n
lipalani1 2011/12/05 21:40:44 I assumed this meant the following: If we have an
}
break;
}
@@ -1519,8 +1500,9 @@ void ProfileSyncService::UnsuppressAndStart() {
sync_prefs_.SetStartSuppressed(false);
// Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess
// is never called for some clients.
- if (signin_->GetUsername().empty()) {
- signin_->SetUsername(sync_prefs_.GetGoogleServicesUsername());
+ if (signin_->GetAuthenticatedUsername().empty()) {
+ signin_->SetAuthenticatedUsername(
+ sync_prefs_.GetGoogleServicesUsername());
}
TryStart();
}
« no previous file with comments | « no previous file | chrome/browser/sync/signin_manager.h » ('j') | chrome/browser/sync/signin_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698