| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/oauth2_login_manager.h" | 5 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 TokenService* OAuth2LoginManager::SetupTokenService() { | 101 TokenService* OAuth2LoginManager::SetupTokenService() { |
| 102 TokenService* token_service = | 102 TokenService* token_service = |
| 103 TokenServiceFactory::GetForProfile(user_profile_); | 103 TokenServiceFactory::GetForProfile(user_profile_); |
| 104 return token_service; | 104 return token_service; |
| 105 } | 105 } |
| 106 | 106 |
| 107 void OAuth2LoginManager::StoreOAuth2Tokens( | 107 void OAuth2LoginManager::StoreOAuth2Tokens( |
| 108 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { | 108 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { |
| 109 TokenService* token_service = SetupTokenService(); | 109 TokenService* token_service = SetupTokenService(); |
| 110 token_service->UpdateCredentialsWithOAuth2(oauth2_tokens); | 110 token_service->UpdateCredentialsWithOAuth2(oauth2_tokens); |
| 111 |
| 112 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 113 OnNewRefreshTokenAvaiable(user_profile_)); |
| 111 } | 114 } |
| 112 | 115 |
| 113 void OAuth2LoginManager::LoadAndVerifyOAuth2Tokens() { | 116 void OAuth2LoginManager::LoadAndVerifyOAuth2Tokens() { |
| 114 // If we have no cookies, try to load saved OAuth2 token from TokenService. | 117 // If we have no cookies, try to load saved OAuth2 token from TokenService. |
| 115 TokenService* token_service = SetupTokenService(); | 118 TokenService* token_service = SetupTokenService(); |
| 116 token_service->Initialize(GaiaConstants::kChromeSource, user_profile_); | 119 token_service->Initialize(GaiaConstants::kChromeSource, user_profile_); |
| 117 token_service->LoadTokensFromDB(); | 120 token_service->LoadTokensFromDB(); |
| 118 } | 121 } |
| 119 | 122 |
| 120 void OAuth2LoginManager::FetchOAuth2Tokens() { | 123 void OAuth2LoginManager::FetchOAuth2Tokens() { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 FOR_EACH_OBSERVER(Observer, observer_list_, | 230 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 228 OnSessionRestoreStateChanged(user_profile_, state_)); | 231 OnSessionRestoreStateChanged(user_profile_, state_)); |
| 229 } | 232 } |
| 230 | 233 |
| 231 void OAuth2LoginManager::SetSessionRestoreStartForTesting( | 234 void OAuth2LoginManager::SetSessionRestoreStartForTesting( |
| 232 const base::Time& time) { | 235 const base::Time& time) { |
| 233 session_restore_start_ = time; | 236 session_restore_start_ = time; |
| 234 } | 237 } |
| 235 | 238 |
| 236 } // namespace chromeos | 239 } // namespace chromeos |
| OLD | NEW |