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

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

Issue 8760019: Make the change in ProfileSyncService such that it declares success (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 | « chrome/browser/sync/profile_sync_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service.cc
===================================================================
--- chrome/browser/sync/profile_sync_service.cc (revision 112357)
+++ chrome/browser/sync/profile_sync_service.cc (working copy)
@@ -84,7 +84,21 @@
static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute.
+static const char* kRelevantTokenServices[] = {
+ GaiaConstants::kSyncService,
+ GaiaConstants::kGaiaOAuth2LoginRefreshToken};
+static const int kRelevantTokenServicesCount =
+ arraysize(kRelevantTokenServices);
+// Helper to check if the given token service is relevant for sync.
+static bool IsTokenServiceRelevant(const std::string& service) {
+ for (int i = 0; i < kRelevantTokenServicesCount; ++i) {
+ if (service == kRelevantTokenServices[i])
+ return true;
+ }
+ return false;
+}
+
bool ShouldShowActionOnUI(
const browser_sync::SyncProtocolError& error) {
return (error.action != browser_sync::UNKNOWN_ACTION &&
@@ -141,18 +155,27 @@
}
bool ProfileSyncService::AreCredentialsAvailable() {
+ return AreCredentialsAvailable(false);
+}
+
+bool ProfileSyncService::AreCredentialsAvailable(
+ bool check_oauth_login_token) {
if (IsManaged()) {
return false;
}
// CrOS user is always logged in. Chrome uses signin_ to check logged in.
- if (!cros_user_.empty() || !signin_->GetUsername().empty()) {
- // TODO(chron): Verify CrOS unit test behavior.
- return profile()->GetTokenService() &&
- profile()->GetTokenService()->HasTokenForService(
- browser_sync::SyncServiceName());
- }
- return false;
+ if (cros_user_.empty() && signin_->GetUsername().empty())
+ return false;
+
+ TokenService* token_service = profile()->GetTokenService();
+ if (!token_service)
+ return false;
+
+ // TODO(chron): Verify CrOS unit test behavior.
+ if (!token_service->HasTokenForService(browser_sync::SyncServiceName()))
+ return false;
+ return !check_oauth_login_token || token_service->HasOAuthLoginToken();
}
void ProfileSyncService::Initialize() {
@@ -1442,13 +1465,22 @@
break;
}
case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: {
- GoogleServiceAuthError error(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- UpdateAuthErrorState(error);
+ TokenService::TokenRequestFailedDetails token_details =
Andrew T Wilson (Slow) 2011/12/02 00:52:35 I'd change this to const TokenService::TokenReques
Munjal (Google) 2011/12/02 02:14:01 Done.
+ *(content::Details<const TokenService::TokenRequestFailedDetails>(
+ details).ptr());
+ if (IsTokenServiceRelevant(token_details.service())) {
+ GoogleServiceAuthError error(
+ GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
+ UpdateAuthErrorState(error);
+ }
break;
}
case chrome::NOTIFICATION_TOKEN_AVAILABLE: {
- if (AreCredentialsAvailable()) {
+ TokenService::TokenAvailableDetails token_details =
Andrew T Wilson (Slow) 2011/12/02 00:52:35 See previous comment.
Munjal (Google) 2011/12/02 02:14:01 Done.
+ *(content::Details<const TokenService::TokenAvailableDetails>(
+ details).ptr());
+ if (IsTokenServiceRelevant(token_details.service()) &&
+ AreCredentialsAvailable(true)) {
if (backend_initialized_) {
backend_->UpdateCredentials(GetCredentials());
}
@@ -1458,11 +1490,22 @@
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 (cros_user_.empty() &&
- !signin_->GetUsername().empty() &&
- !AreCredentialsAvailable()) {
+ // This notification gets fired when TokenService loads the tokens
Andrew T Wilson (Slow) 2011/12/02 00:52:35 nit: double-space between "loads the".
Munjal (Google) 2011/12/02 02:14:01 Done.
+ // from storage. Here we only check if the chromiumsync token is
+ // available (versus both chromiumsync and oauth login tokens) to
+ // start up sync successfully for already logged in users who may
+ // only have chromiumsync token if they logged in before the code
+ // to generate oauth login token released.
+ if (AreCredentialsAvailable()) {
+ // Initialize the backend if sync token was loaded.
+ if (backend_initialized_) {
+ backend_->UpdateCredentials(GetCredentials());
+ }
+ if (!sync_prefs_.IsStartSuppressed())
+ StartUp();
+ } else if (cros_user_.empty() && !signin_->GetUsername().empty()) {
+ // If not in Chrome OS, and we have a username without tokens,
+ // the user will need to signin again, so sign out.
DisableForUser();
}
break;
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698