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

Unified Diff: chrome/browser/chromeos/login/oauth2_login_manager.cc

Issue 12052040: Added step that saves OAuth2 tokens fetched through policy into TokenService. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/login/oauth2_login_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/oauth2_login_manager.cc
diff --git a/chrome/browser/chromeos/login/oauth2_login_manager.cc b/chrome/browser/chromeos/login/oauth2_login_manager.cc
index 314708c3c5e70b6866850d7a8bd6299e29d356dd..b8e28091a5794c81b4f947962997a9f37e2ff24e 100644
--- a/chrome/browser/chromeos/login/oauth2_login_manager.cc
+++ b/chrome/browser/chromeos/login/oauth2_login_manager.cc
@@ -36,6 +36,7 @@ void OAuth2LoginManager::RestoreSession(
user_profile_ = user_profile;
auth_request_context_ = auth_request_context;
state_ = OAuthLoginManager::SESSION_RESTORE_IN_PROGRESS;
+ restore_from_auth_cookies_ = restore_from_auth_cookies;
// TODO(zelidrag): Remove eventually the next line in some future milestone.
RemoveLegacyTokens();
@@ -45,10 +46,11 @@ void OAuth2LoginManager::RestoreSession(
if (oauth2_policy_fetcher_.get() &&
oauth2_policy_fetcher_->has_oauth2_tokens()) {
VLOG(1) << "Resuming profile creation after fetching policy token";
- refresh_token_ = oauth2_policy_fetcher_->oauth2_tokens().refresh_token;
- restore_from_auth_cookies = false;
+ // We already have tokens, no need to get them from the cookie jar again.
+ restore_from_auth_cookies_ = false;
+ StoreOAuth2Tokens(oauth2_policy_fetcher_->oauth2_tokens());
}
- restore_from_auth_cookies_ = restore_from_auth_cookies;
+
ContinueSessionRestore();
}
@@ -58,11 +60,6 @@ void OAuth2LoginManager::ContinueSessionRestore() {
return;
}
- // Did we already fetch the refresh token (either policy or db)?
- if (!refresh_token_.empty()) {
- // TODO(zelidrag): Figure out where to stick that refresh_token_ into.
- // We probalby need bit more than that.
- }
LoadAndVerifyOAuth2Tokens();
}
@@ -107,6 +104,13 @@ void OAuth2LoginManager::RemoveLegacyTokens() {
prefs->UnregisterPreference(prefs::kOAuth1Secret);
}
+void OAuth2LoginManager::StoreOAuth2Tokens(
+ const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
+ TokenService* token_service =
+ TokenServiceFactory::GetForProfile(user_profile_);
+ token_service->UpdateCredentialsWithOAuth2(oauth2_tokens);
+}
+
void OAuth2LoginManager::LoadAndVerifyOAuth2Tokens() {
// If we have no cookies, try to load saved OAuth2 token from TokenService.
TokenService* token_service = SetupTokenService();
@@ -126,8 +130,7 @@ void OAuth2LoginManager::FetchOAuth2Tokens() {
void OAuth2LoginManager::OnOAuth2TokensAvailable(
const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
LOG(INFO) << "OAuth2 tokens fetched";
- TokenService* token_service = SetupTokenService();
- token_service->UpdateCredentialsWithOAuth2(oauth2_tokens);
+ StoreOAuth2Tokens(oauth2_tokens);
}
void OAuth2LoginManager::OnOAuth2TokensFetchFailed() {
« no previous file with comments | « chrome/browser/chromeos/login/oauth2_login_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698