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

Side by Side 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 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (!cros_user_.empty()) 134 if (!cros_user_.empty())
135 auto_start_enabled_ = true; 135 auto_start_enabled_ = true;
136 } 136 }
137 137
138 ProfileSyncService::~ProfileSyncService() { 138 ProfileSyncService::~ProfileSyncService() {
139 sync_prefs_.RemoveSyncPrefObserver(this); 139 sync_prefs_.RemoveSyncPrefObserver(this);
140 Shutdown(false); 140 Shutdown(false);
141 } 141 }
142 142
143 bool ProfileSyncService::AreCredentialsAvailable() { 143 bool ProfileSyncService::AreCredentialsAvailable() {
144 return AreCredentialsAvailable(false);
145 }
146
147 bool ProfileSyncService::AreCredentialsAvailable(
148 bool check_oauth_login_token) {
144 if (IsManaged()) { 149 if (IsManaged()) {
145 return false; 150 return false;
146 } 151 }
147 152
148 // CrOS user is always logged in. Chrome uses signin_ to check logged in. 153 // CrOS user is always logged in. Chrome uses signin_ to check logged in.
149 if (!cros_user_.empty() || !signin_->GetUsername().empty()) { 154 if (cros_user_.empty() && signin_->GetUsername().empty())
150 // TODO(chron): Verify CrOS unit test behavior. 155 return false;
151 return profile()->GetTokenService() && 156
152 profile()->GetTokenService()->HasTokenForService( 157 TokenService* token_service = profile()->GetTokenService();
153 browser_sync::SyncServiceName()); 158 if (!token_service)
154 } 159 return false;
155 return false; 160
161 // TODO(chron): Verify CrOS unit test behavior.
162 if (!token_service->HasTokenForService(browser_sync::SyncServiceName()))
163 return false;
164 return !check_oauth_login_token || token_service->HasOAuthLoginToken();
156 } 165 }
157 166
158 void ProfileSyncService::Initialize() { 167 void ProfileSyncService::Initialize() {
159 InitSettings(); 168 InitSettings();
160 169
161 // We clear this here (vs Shutdown) because we want to remember that an error 170 // We clear this here (vs Shutdown) because we want to remember that an error
162 // happened on shutdown so we can display details (message, location) about it 171 // happened on shutdown so we can display details (message, location) about it
163 // in about:sync. 172 // in about:sync.
164 ClearStaleErrors(); 173 ClearStaleErrors();
165 174
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 backend_->EnableEncryptEverything(); 1443 backend_->EnableEncryptEverything();
1435 } 1444 }
1436 break; 1445 break;
1437 } 1446 }
1438 case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: { 1447 case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: {
1439 GoogleServiceAuthError error = 1448 GoogleServiceAuthError error =
1440 *(content::Details<const GoogleServiceAuthError>(details).ptr()); 1449 *(content::Details<const GoogleServiceAuthError>(details).ptr());
1441 UpdateAuthErrorState(error); 1450 UpdateAuthErrorState(error);
1442 break; 1451 break;
1443 } 1452 }
1444 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { 1453 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: {
Andrew T Wilson (Slow) 2011/12/01 22:07:01 Can you either check the token type here (and belo
Munjal (Google) 2011/12/01 22:52:58 Done.
1445 GoogleServiceAuthError error( 1454 GoogleServiceAuthError error(
1446 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 1455 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
1447 UpdateAuthErrorState(error); 1456 UpdateAuthErrorState(error);
1448 break; 1457 break;
1449 } 1458 }
1450 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { 1459 case chrome::NOTIFICATION_TOKEN_AVAILABLE: {
1451 if (AreCredentialsAvailable()) { 1460 if (AreCredentialsAvailable(true)) {
1452 if (backend_initialized_) { 1461 if (backend_initialized_) {
1453 backend_->UpdateCredentials(GetCredentials()); 1462 backend_->UpdateCredentials(GetCredentials());
1454 } 1463 }
1455 if (!sync_prefs_.IsStartSuppressed()) 1464 if (!sync_prefs_.IsStartSuppressed())
1456 StartUp(); 1465 StartUp();
1457 } 1466 }
1458 break; 1467 break;
1459 } 1468 }
1460 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { 1469 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: {
1461 // If not in Chrome OS, and we have a username without tokens, 1470 if (AreCredentialsAvailable()) {
Andrew T Wilson (Slow) 2011/12/01 22:07:01 Can you add a note here about why we are intention
Munjal (Google) 2011/12/01 22:52:58 Done. The comment is a bit long but this is an imp
1462 // the user will need to signin again, so sign out. 1471 // Initialize the backend if sync token was loaded.
1463 if (cros_user_.empty() && 1472 if (backend_initialized_) {
1464 !signin_->GetUsername().empty() && 1473 backend_->UpdateCredentials(GetCredentials());
1465 !AreCredentialsAvailable()) { 1474 }
1475 if (!sync_prefs_.IsStartSuppressed())
1476 StartUp();
1477 } else if (cros_user_.empty() && !signin_->GetUsername().empty()) {
1478 // If not in Chrome OS, and we have a username without tokens,
1479 // the user will need to signin again, so sign out.
1466 DisableForUser(); 1480 DisableForUser();
1467 } 1481 }
1468 break; 1482 break;
1469 } 1483 }
1470 default: { 1484 default: {
1471 NOTREACHED(); 1485 NOTREACHED();
1472 } 1486 }
1473 } 1487 }
1474 } 1488 }
1475 1489
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 << "Unrecoverable error."; 1571 << "Unrecoverable error.";
1558 } else { 1572 } else {
1559 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not " 1573 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not "
1560 << "initialized"; 1574 << "initialized";
1561 } 1575 }
1562 } 1576 }
1563 1577
1564 const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() { 1578 const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() {
1565 return failed_datatypes_handler_; 1579 return failed_datatypes_handler_;
1566 } 1580 }
OLDNEW
« 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