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

Unified Diff: chrome/browser/signin/token_service.cc

Issue 11991002: Merge 176800 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/signin/token_service.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/token_service.cc
===================================================================
--- chrome/browser/signin/token_service.cc (revision 177312)
+++ chrome/browser/signin/token_service.cc (working copy)
@@ -103,6 +103,15 @@
token_map_[service] = auth_token;
FireTokenAvailableNotification(service, auth_token);
SaveAuthTokenToDB(service, auth_token);
+
+#if defined(OS_CHROMEOS)
+ // We don't ever want to fetch OAuth2 tokens from LSO service token in case
+ // when ChromeOS is in forced OAuth2 use mode. OAuth2 token should only
+ // arrive into token service exclusively through UpdateCredentialsWithOAuth2.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceOAuth1))
+ return;
+#endif
+
// If we got ClientLogin token for "lso" service, and we don't already have
// OAuth2 tokens, start fetching OAuth2 login scoped token pair.
if (service == GaiaConstants::kLSOService && !HasOAuthLoginToken()) {
@@ -147,10 +156,8 @@
}
void TokenService::UpdateCredentialsWithOAuth2(
- const GaiaAuthConsumer::ClientOAuthResult& credentials) {
- // Will be implemented once the ClientOAuth signin is complete. Not called
- // yet by any code.
- NOTREACHED();
+ const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
+ SaveOAuth2Credentials(oauth2_tokens);
}
void TokenService::LoadTokensFromDB() {
@@ -232,6 +239,10 @@
return HasTokenForService(GaiaConstants::kGaiaOAuth2LoginRefreshToken);
}
+bool TokenService::HasOAuthLoginAccessToken() const {
+ return HasTokenForService(GaiaConstants::kGaiaOAuth2LoginAccessToken);
+}
+
const std::string& TokenService::GetOAuth2LoginRefreshToken() const {
return GetTokenForService(GaiaConstants::kGaiaOAuth2LoginRefreshToken);
}
@@ -312,13 +323,16 @@
void TokenService::OnClientOAuthSuccess(const ClientOAuthResult& result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
VLOG(1) << "Got OAuth2 login token pair";
+ SaveOAuth2Credentials(result);
+}
+
+void TokenService::SaveOAuth2Credentials(const ClientOAuthResult& result) {
token_map_[GaiaConstants::kGaiaOAuth2LoginRefreshToken] =
result.refresh_token;
token_map_[GaiaConstants::kGaiaOAuth2LoginAccessToken] = result.access_token;
+ // Save refresh token only since access token is transient anyway.
SaveAuthTokenToDB(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
result.refresh_token);
- SaveAuthTokenToDB(GaiaConstants::kGaiaOAuth2LoginAccessToken,
- result.access_token);
// We don't save expiration information for now.
FireTokenAvailableNotification(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
« no previous file with comments | « chrome/browser/signin/token_service.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698