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

Side by Side Diff: chrome/browser/signin/signin_tracker.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 7 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/signin/signin_tracker_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/signin/signin_tracker.h" 5 #include "chrome/browser/signin/signin_tracker.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/signin/signin_manager.h" 8 #include "chrome/browser/signin/signin_manager.h"
9 #include "chrome/browser/signin/signin_manager_factory.h" 9 #include "chrome/browser/signin/signin_manager_factory.h"
10 #include "chrome/browser/signin/token_service.h" 10 #include "chrome/browser/signin/token_service.h"
11 #include "chrome/browser/signin/token_service_factory.h" 11 #include "chrome/browser/signin/token_service_factory.h"
12 #include "chrome/browser/sync/profile_sync_service.h" 12 #include "chrome/browser/sync/profile_sync_service.h"
13 #include "chrome/browser/sync/profile_sync_service_factory.h" 13 #include "chrome/browser/sync/profile_sync_service_factory.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
17 #include "google_apis/gaia/gaia_constants.h" 17 #include "google_apis/gaia/gaia_constants.h"
18 18
19 static const char* kSignedInServices[] = { 19 static const char* kSignedInServices[] = {
20 GaiaConstants::kSyncService, 20 GaiaConstants::kSyncService,
Andrew T Wilson (Slow) 2013/06/07 13:04:42 BTW, should we stop fetching the kSyncService toke
21 GaiaConstants::kGaiaOAuth2LoginRefreshToken 21 GaiaConstants::kGaiaOAuth2LoginRefreshToken
22 }; 22 };
23 static const int kNumSignedInServices = 23 static const int kNumSignedInServices =
24 arraysize(kSignedInServices); 24 arraysize(kSignedInServices);
25 25
26 // Helper to check if the given token service is relevant for sync. 26 // Helper to check if the given token service is relevant for sync.
27 SigninTracker::SigninTracker(Profile* profile, Observer* observer) 27 SigninTracker::SigninTracker(Profile* profile, Observer* observer)
28 : state_(WAITING_FOR_GAIA_VALIDATION), 28 : state_(WAITING_FOR_GAIA_VALIDATION),
29 profile_(profile), 29 profile_(profile),
30 observer_(observer), 30 observer_(observer),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return false; 168 return false;
169 // Don't care about the sync state if sync is disabled by policy. 169 // Don't care about the sync state if sync is disabled by policy.
170 if (!profile->IsSyncAccessible()) 170 if (!profile->IsSyncAccessible())
171 return true; 171 return true;
172 ProfileSyncService* service = 172 ProfileSyncService* service =
173 ProfileSyncServiceFactory::GetForProfile(profile); 173 ProfileSyncServiceFactory::GetForProfile(profile);
174 // Check the sync service state - we ignore CONNECTION_FAILED errors here 174 // Check the sync service state - we ignore CONNECTION_FAILED errors here
175 // because they are transient and do not signify a failure of the signin 175 // because they are transient and do not signify a failure of the signin
176 // process. 176 // process.
177 return (service->IsSyncEnabledAndLoggedIn() && 177 return (service->IsSyncEnabledAndLoggedIn() &&
178 service->IsSyncTokenAvailable() && 178 service->IsOAuthRefreshTokenAvailable() &&
179 (service->GetAuthError().state() == GoogleServiceAuthError::NONE || 179 (service->GetAuthError().state() == GoogleServiceAuthError::NONE ||
180 service->GetAuthError().state() == 180 service->GetAuthError().state() ==
181 GoogleServiceAuthError::CONNECTION_FAILED) && 181 GoogleServiceAuthError::CONNECTION_FAILED) &&
182 !service->HasUnrecoverableError()); 182 !service->HasUnrecoverableError());
183 } 183 }
184 184
185 // static 185 // static
186 SigninTracker::LoginState SigninTracker::GetSigninState( 186 SigninTracker::LoginState SigninTracker::GetSigninState(
187 Profile* profile, 187 Profile* profile,
188 GoogleServiceAuthError* error) { 188 GoogleServiceAuthError* error) {
(...skipping 28 matching lines...) Expand all
217 if (error) 217 if (error)
218 *error = signin->signin_global_error()->GetLastAuthError(); 218 *error = signin->signin_global_error()->GetLastAuthError();
219 return WAITING_FOR_GAIA_VALIDATION; 219 return WAITING_FOR_GAIA_VALIDATION;
220 } 220 }
221 221
222 if (!service || service->sync_initialized()) 222 if (!service || service->sync_initialized())
223 return SIGNIN_COMPLETE; 223 return SIGNIN_COMPLETE;
224 224
225 return SERVICES_INITIALIZING; 225 return SERVICES_INITIALIZING;
226 } 226 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/signin/signin_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698