OLD | NEW |
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/signin/token_handle_util.h" | 15 #include "chrome/browser/chromeos/login/signin/token_handle_util.h" |
| 16 #include "chrome/browser/chromeos/login/startup_utils.h" |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/signin/account_tracker_service_factory.h" | 19 #include "chrome/browser/signin/account_tracker_service_factory.h" |
19 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 20 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
21 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
24 #include "components/signin/core/browser/account_tracker_service.h" | 25 #include "components/signin/core/browser/account_tracker_service.h" |
25 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 26 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_FAILED); | 262 SetSessionRestoreState(OAuth2LoginManager::SESSION_RESTORE_FAILED); |
262 } | 263 } |
263 } | 264 } |
264 | 265 |
265 void OAuth2LoginManager::OnOAuth2TokensAvailable( | 266 void OAuth2LoginManager::OnOAuth2TokensAvailable( |
266 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { | 267 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { |
267 VLOG(1) << "OAuth2 tokens fetched"; | 268 VLOG(1) << "OAuth2 tokens fetched"; |
268 DCHECK(refresh_token_.empty()); | 269 DCHECK(refresh_token_.empty()); |
269 refresh_token_.assign(oauth2_tokens.refresh_token); | 270 refresh_token_.assign(oauth2_tokens.refresh_token); |
270 oauthlogin_access_token_ = oauth2_tokens.access_token; | 271 oauthlogin_access_token_ = oauth2_tokens.access_token; |
271 | 272 if (StartupUtils::IsWebviewSigninEnabled()) { |
272 auto user = chromeos::ProfileHelper::Get()->GetUserByProfile(user_profile_); | 273 auto user = chromeos::ProfileHelper::Get()->GetUserByProfile(user_profile_); |
273 DCHECK(user); | 274 DCHECK(user); |
274 if (user) { | 275 if (user) { |
275 token_handle_util_.reset( | 276 token_handle_util_.reset( |
276 new TokenHandleUtil(user_manager::UserManager::Get())); | 277 new TokenHandleUtil(user_manager::UserManager::Get())); |
277 token_handle_util_->GetTokenHandle( | 278 token_handle_util_->GetTokenHandle( |
278 user->GetUserID(), oauthlogin_access_token_, | 279 user->GetUserID(), oauthlogin_access_token_, |
279 base::Bind(&OAuth2LoginManager::OnTokenHandleComplete, | 280 base::Bind(&OAuth2LoginManager::OnTokenHandleComplete, |
280 weak_factory_.GetWeakPtr())); | 281 weak_factory_.GetWeakPtr())); |
| 282 } |
281 } | 283 } |
282 StoreOAuth2Token(); | 284 StoreOAuth2Token(); |
283 } | 285 } |
284 | 286 |
285 void OAuth2LoginManager::OnOAuth2TokensFetchFailed() { | 287 void OAuth2LoginManager::OnOAuth2TokensFetchFailed() { |
286 LOG(ERROR) << "OAuth2 tokens fetch failed!"; | 288 LOG(ERROR) << "OAuth2 tokens fetch failed!"; |
287 RecordSessionRestoreOutcome(SESSION_RESTORE_TOKEN_FETCH_FAILED, | 289 RecordSessionRestoreOutcome(SESSION_RESTORE_TOKEN_FETCH_FAILED, |
288 SESSION_RESTORE_FAILED); | 290 SESSION_RESTORE_FAILED); |
289 } | 291 } |
290 | 292 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 base::MessageLoop::current()->DeleteSoon(FROM_HERE, | 443 base::MessageLoop::current()->DeleteSoon(FROM_HERE, |
442 token_handle_util_.release()); | 444 token_handle_util_.release()); |
443 } | 445 } |
444 | 446 |
445 void OAuth2LoginManager::SetSessionRestoreStartForTesting( | 447 void OAuth2LoginManager::SetSessionRestoreStartForTesting( |
446 const base::Time& time) { | 448 const base::Time& time) { |
447 session_restore_start_ = time; | 449 session_restore_start_ = time; |
448 } | 450 } |
449 | 451 |
450 } // namespace chromeos | 452 } // namespace chromeos |
OLD | NEW |