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

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

Issue 11649055: OAuth2 sign-in flow for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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) 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/token_service.h" 5 #include "chrome/browser/signin/token_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 fetchers_[i].reset(); 155 fetchers_[i].reset();
156 } 156 }
157 157
158 // Notify AboutSigninInternals that a new lsid and sid are available. 158 // Notify AboutSigninInternals that a new lsid and sid are available.
159 FOR_DIAGNOSTICS_OBSERVERS(NotifySigninValueChanged( 159 FOR_DIAGNOSTICS_OBSERVERS(NotifySigninValueChanged(
160 signin_internals_util::SID, credentials.sid)); 160 signin_internals_util::SID, credentials.sid));
161 FOR_DIAGNOSTICS_OBSERVERS(NotifySigninValueChanged(LSID, credentials.lsid)); 161 FOR_DIAGNOSTICS_OBSERVERS(NotifySigninValueChanged(LSID, credentials.lsid));
162 } 162 }
163 163
164 void TokenService::UpdateCredentialsWithOAuth2( 164 void TokenService::UpdateCredentialsWithOAuth2(
165 const GaiaAuthConsumer::ClientOAuthResult& credentials) { 165 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
166 // Will be implemented once the ClientOAuth signin is complete. Not called 166 SaveOAuth2Credentials(oauth2_tokens);
167 // yet by any code.
168 NOTREACHED();
169 } 167 }
170 168
171 void TokenService::LoadTokensFromDB() { 169 void TokenService::LoadTokensFromDB() {
172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
173 if (web_data_service_.get()) 171 if (web_data_service_.get())
174 token_loading_query_ = web_data_service_->GetAllTokens(this); 172 token_loading_query_ = web_data_service_->GetAllTokens(this);
175 } 173 }
176 174
177 void TokenService::SaveAuthTokenToDB(const std::string& service, 175 void TokenService::SaveAuthTokenToDB(const std::string& service,
178 const std::string& auth_token) { 176 const std::string& auth_token) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 LOG(WARNING) << "Auth token issuing failed for service:" << service 334 LOG(WARNING) << "Auth token issuing failed for service:" << service
337 << ", error: " << error.ToString(); 335 << ", error: " << error.ToString();
338 FOR_DIAGNOSTICS_OBSERVERS( 336 FOR_DIAGNOSTICS_OBSERVERS(
339 NotifyTokenReceivedFailure(service, error.ToString())); 337 NotifyTokenReceivedFailure(service, error.ToString()));
340 FireTokenRequestFailedNotification(service, error); 338 FireTokenRequestFailedNotification(service, error);
341 } 339 }
342 340
343 void TokenService::OnClientOAuthSuccess(const ClientOAuthResult& result) { 341 void TokenService::OnClientOAuthSuccess(const ClientOAuthResult& result) {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 342 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345 VLOG(1) << "Got OAuth2 login token pair"; 343 VLOG(1) << "Got OAuth2 login token pair";
344 SaveOAuth2Credentials(result);
345 }
346
347 void TokenService::SaveOAuth2Credentials(const ClientOAuthResult& result) {
346 token_map_[GaiaConstants::kGaiaOAuth2LoginRefreshToken] = 348 token_map_[GaiaConstants::kGaiaOAuth2LoginRefreshToken] =
347 result.refresh_token; 349 result.refresh_token;
348 token_map_[GaiaConstants::kGaiaOAuth2LoginAccessToken] = result.access_token; 350 token_map_[GaiaConstants::kGaiaOAuth2LoginAccessToken] = result.access_token;
349 SaveAuthTokenToDB(GaiaConstants::kGaiaOAuth2LoginRefreshToken, 351 SaveAuthTokenToDB(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
350 result.refresh_token); 352 result.refresh_token);
351 SaveAuthTokenToDB(GaiaConstants::kGaiaOAuth2LoginAccessToken, 353 SaveAuthTokenToDB(GaiaConstants::kGaiaOAuth2LoginAccessToken,
352 result.access_token); 354 result.access_token);
353 // We don't save expiration information for now. 355 // We don't save expiration information for now.
354 356
355 FOR_DIAGNOSTICS_OBSERVERS( 357 FOR_DIAGNOSTICS_OBSERVERS(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 473
472 void TokenService::AddSigninDiagnosticsObserver( 474 void TokenService::AddSigninDiagnosticsObserver(
473 SigninDiagnosticsObserver* observer) { 475 SigninDiagnosticsObserver* observer) {
474 signin_diagnostics_observers_.AddObserver(observer); 476 signin_diagnostics_observers_.AddObserver(observer);
475 } 477 }
476 478
477 void TokenService::RemoveSigninDiagnosticsObserver( 479 void TokenService::RemoveSigninDiagnosticsObserver(
478 SigninDiagnosticsObserver* observer) { 480 SigninDiagnosticsObserver* observer) {
479 signin_diagnostics_observers_.RemoveObserver(observer); 481 signin_diagnostics_observers_.RemoveObserver(observer);
480 } 482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698