| 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" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 this); | 191 this); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void OAuth2LoginManager::UpdateCredentials(const std::string& account_id) { | 194 void OAuth2LoginManager::UpdateCredentials(const std::string& account_id) { |
| 195 DCHECK(!account_id.empty()); | 195 DCHECK(!account_id.empty()); |
| 196 DCHECK(!refresh_token_.empty()); | 196 DCHECK(!refresh_token_.empty()); |
| 197 // |account_id| is assumed to be already canonicalized if it's an email. | 197 // |account_id| is assumed to be already canonicalized if it's an email. |
| 198 GetTokenService()->UpdateCredentials(account_id, refresh_token_); | 198 GetTokenService()->UpdateCredentials(account_id, refresh_token_); |
| 199 FireRefreshTokensLoaded(); | 199 FireRefreshTokensLoaded(); |
| 200 | 200 |
| 201 FOR_EACH_OBSERVER(Observer, observer_list_, | 201 for (auto& observer : observer_list_) |
| 202 OnNewRefreshTokenAvaiable(user_profile_)); | 202 observer.OnNewRefreshTokenAvaiable(user_profile_); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void OAuth2LoginManager::FireRefreshTokensLoaded() { | 205 void OAuth2LoginManager::FireRefreshTokensLoaded() { |
| 206 // TODO(570218): Figure out the right way to plumb this. | 206 // TODO(570218): Figure out the right way to plumb this. |
| 207 GetTokenService()->LoadCredentials(std::string()); | 207 GetTokenService()->LoadCredentials(std::string()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void OAuth2LoginManager::OnRefreshTokenResponse( | 210 void OAuth2LoginManager::OnRefreshTokenResponse( |
| 211 const std::string& access_token, | 211 const std::string& access_token, |
| 212 int expires_in_seconds) { | 212 int expires_in_seconds) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 409 |
| 410 state_ = state; | 410 state_ = state; |
| 411 if (state == OAuth2LoginManager::SESSION_RESTORE_FAILED) { | 411 if (state == OAuth2LoginManager::SESSION_RESTORE_FAILED) { |
| 412 UMA_HISTOGRAM_TIMES("OAuth2Login.SessionRestoreTimeToFailure", | 412 UMA_HISTOGRAM_TIMES("OAuth2Login.SessionRestoreTimeToFailure", |
| 413 base::Time::Now() - session_restore_start_); | 413 base::Time::Now() - session_restore_start_); |
| 414 } else if (state == OAuth2LoginManager::SESSION_RESTORE_DONE) { | 414 } else if (state == OAuth2LoginManager::SESSION_RESTORE_DONE) { |
| 415 UMA_HISTOGRAM_TIMES("OAuth2Login.SessionRestoreTimeToSuccess", | 415 UMA_HISTOGRAM_TIMES("OAuth2Login.SessionRestoreTimeToSuccess", |
| 416 base::Time::Now() - session_restore_start_); | 416 base::Time::Now() - session_restore_start_); |
| 417 } | 417 } |
| 418 | 418 |
| 419 FOR_EACH_OBSERVER(Observer, observer_list_, | 419 for (auto& observer : observer_list_) |
| 420 OnSessionRestoreStateChanged(user_profile_, state_)); | 420 observer.OnSessionRestoreStateChanged(user_profile_, state_); |
| 421 } | 421 } |
| 422 | 422 |
| 423 void OAuth2LoginManager::SetSessionRestoreStartForTesting( | 423 void OAuth2LoginManager::SetSessionRestoreStartForTesting( |
| 424 const base::Time& time) { | 424 const base::Time& time) { |
| 425 session_restore_start_ = time; | 425 session_restore_start_ = time; |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace chromeos | 428 } // namespace chromeos |
| OLD | NEW |