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

Side by Side Diff: chrome/browser/chromeos/login/signin/oauth2_token_initializer.cc

Issue 1097663003: Fetch OAuth2 tokens prior to profile creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: OAuth2TokenInitializer for non-SAML only Created 5 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/signin/oauth2_token_initializer.h"
6
7 #include "chrome/browser/browser_process.h"
8
9 namespace chromeos {
10
11 OAuth2TokenInitializer::OAuth2TokenInitializer() {
12 }
13
14 OAuth2TokenInitializer::~OAuth2TokenInitializer() {
15 }
16
17 void OAuth2TokenInitializer::Start(const UserContext& user_context,
18 const FetchOAuth2TokensCallback& callback) {
19 DCHECK(!user_context.GetAuthCode().empty());
20 callback_ = callback;
21 user_context_ = user_context;
22 oauth2_token_fetcher_.reset(new OAuth2TokenFetcher(
23 this, g_browser_process->system_request_context()));
24 oauth2_token_fetcher_->StartExchangeFromAuthCode(user_context.GetAuthCode());
25 }
26
27 void OAuth2TokenInitializer::OnOAuth2TokensAvailable(
28 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
29 VLOG(1) << "OAuth2 tokens fetched";
30 user_context_.SetAuthCode(std::string());
31 user_context_.SetRefreshToken(oauth2_tokens.refresh_token);
32 user_context_.SetAccessToken(oauth2_tokens.access_token);
33 callback_.Run(true, user_context_);
34 }
35
36 void OAuth2TokenInitializer::OnOAuth2TokensFetchFailed() {
37 LOG(WARNING) << "OAuth2TokenInitializer - OAuth2 token fetch failed";
38 callback_.Run(false, user_context_);
39 }
40
41 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/signin/oauth2_token_initializer.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698