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

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

Issue 382983003: Pass signin_scoped_device_id to refresh token request on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/login/signin/oauth2_login_manager.h" 5 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/login/users/user_manager.h" 15 #include "chrome/browser/chromeos/login/users/user_manager.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/signin/chrome_signin_client_factory.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chromeos/chromeos_switches.h" 21 #include "chromeos/chromeos_switches.h"
21 #include "components/signin/core/browser/profile_oauth2_token_service.h" 22 #include "components/signin/core/browser/profile_oauth2_token_service.h"
23 #include "components/signin/core/browser/signin_client.h"
22 #include "components/signin/core/browser/signin_manager.h" 24 #include "components/signin/core/browser/signin_manager.h"
23 #include "google_apis/gaia/gaia_auth_util.h" 25 #include "google_apis/gaia/gaia_auth_util.h"
24 #include "google_apis/gaia/gaia_constants.h" 26 #include "google_apis/gaia/gaia_constants.h"
25 #include "google_apis/gaia/gaia_urls.h" 27 #include "google_apis/gaia/gaia_urls.h"
26 #include "net/url_request/url_request_context_getter.h" 28 #include "net/url_request/url_request_context_getter.h"
27 29
28 namespace chromeos { 30 namespace chromeos {
29 31
30 namespace { 32 namespace {
31 33
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 account_id_fetcher_.reset(); 213 account_id_fetcher_.reset();
212 LOG(ERROR) << "Account id fetch failed! response_code=" << response_code; 214 LOG(ERROR) << "Account id fetch failed! response_code=" << response_code;
213 SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_FAILED); 215 SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_FAILED);
214 } 216 }
215 217
216 void OAuth2LoginManager::FetchOAuth2Tokens() { 218 void OAuth2LoginManager::FetchOAuth2Tokens() {
217 DCHECK(auth_request_context_.get()); 219 DCHECK(auth_request_context_.get());
218 // If we have authenticated cookie jar, get OAuth1 token first, then fetch 220 // If we have authenticated cookie jar, get OAuth1 token first, then fetch
219 // SID/LSID cookies through OAuthLogin call. 221 // SID/LSID cookies through OAuthLogin call.
220 if (restore_strategy_ == RESTORE_FROM_COOKIE_JAR) { 222 if (restore_strategy_ == RESTORE_FROM_COOKIE_JAR) {
223 SigninClient* signin_client =
224 ChromeSigninClientFactory::GetForProfile(user_profile_);
225 std::string signin_scoped_device_id =
226 signin_client->GetSigninScopedDeviceId();
227
221 oauth2_token_fetcher_.reset( 228 oauth2_token_fetcher_.reset(
222 new OAuth2TokenFetcher(this, auth_request_context_.get())); 229 new OAuth2TokenFetcher(this, auth_request_context_.get()));
223 oauth2_token_fetcher_->StartExchangeFromCookies(std::string()); 230 oauth2_token_fetcher_->StartExchangeFromCookies(std::string(),
231 signin_scoped_device_id);
224 } else if (restore_strategy_ == RESTORE_FROM_AUTH_CODE) { 232 } else if (restore_strategy_ == RESTORE_FROM_AUTH_CODE) {
225 DCHECK(!auth_code_.empty()); 233 DCHECK(!auth_code_.empty());
226 oauth2_token_fetcher_.reset( 234 oauth2_token_fetcher_.reset(
227 new OAuth2TokenFetcher(this, 235 new OAuth2TokenFetcher(this,
228 g_browser_process->system_request_context())); 236 g_browser_process->system_request_context()));
229 oauth2_token_fetcher_->StartExchangeFromAuthCode(auth_code_); 237 oauth2_token_fetcher_->StartExchangeFromAuthCode(auth_code_);
230 } else { 238 } else {
231 NOTREACHED(); 239 NOTREACHED();
232 SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_FAILED); 240 SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_FAILED);
233 } 241 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 FOR_EACH_OBSERVER(Observer, observer_list_, 402 FOR_EACH_OBSERVER(Observer, observer_list_,
395 OnSessionRestoreStateChanged(user_profile_, state_)); 403 OnSessionRestoreStateChanged(user_profile_, state_));
396 } 404 }
397 405
398 void OAuth2LoginManager::SetSessionRestoreStartForTesting( 406 void OAuth2LoginManager::SetSessionRestoreStartForTesting(
399 const base::Time& time) { 407 const base::Time& time) {
400 session_restore_start_ = time; 408 session_restore_start_ = time;
401 } 409 }
402 410
403 } // namespace chromeos 411 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698