| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 VLOG(1) << "OAuth2 refresh token is already loaded."; | 101 VLOG(1) << "OAuth2 refresh token is already loaded."; |
| 102 VerifySessionCookies(); | 102 VerifySessionCookies(); |
| 103 } else { | 103 } else { |
| 104 VLOG(1) << "Loading OAuth2 refresh token from database."; | 104 VLOG(1) << "Loading OAuth2 refresh token from database."; |
| 105 | 105 |
| 106 // Flag user with unknown token status in case there are no saved tokens | 106 // Flag user with unknown token status in case there are no saved tokens |
| 107 // and OnRefreshTokenAvailable is not called. Flagging it here would | 107 // and OnRefreshTokenAvailable is not called. Flagging it here would |
| 108 // cause user to go through Gaia in next login to obtain a new refresh | 108 // cause user to go through Gaia in next login to obtain a new refresh |
| 109 // token. | 109 // token. |
| 110 user_manager::UserManager::Get()->SaveUserOAuthStatus( | 110 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 111 primary_account_id, user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN); | 111 user_manager::UserID::FromUserEmail(primary_account_id), user_manager::U
ser::OAUTH_TOKEN_STATUS_UNKNOWN); |
| 112 | 112 |
| 113 token_service->LoadCredentials(primary_account_id); | 113 token_service->LoadCredentials(primary_account_id); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void OAuth2LoginManager::Stop() { | 117 void OAuth2LoginManager::Stop() { |
| 118 oauth2_token_fetcher_.reset(); | 118 oauth2_token_fetcher_.reset(); |
| 119 login_verifier_.reset(); | 119 login_verifier_.reset(); |
| 120 } | 120 } |
| 121 | 121 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 141 // Do not validate tokens for supervised users, as they don't actually have | 141 // Do not validate tokens for supervised users, as they don't actually have |
| 142 // oauth2 token. | 142 // oauth2 token. |
| 143 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { | 143 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { |
| 144 VLOG(1) << "Logged in as supervised user, skip token validation."; | 144 VLOG(1) << "Logged in as supervised user, skip token validation."; |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 // Only restore session cookies for the primary account in the profile. | 147 // Only restore session cookies for the primary account in the profile. |
| 148 if (GetPrimaryAccountId() == account_id) { | 148 if (GetPrimaryAccountId() == account_id) { |
| 149 // Token is loaded. Undo the flagging before token loading. | 149 // Token is loaded. Undo the flagging before token loading. |
| 150 user_manager::UserManager::Get()->SaveUserOAuthStatus( | 150 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 151 account_id, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 151 user_manager::UserID::FromUserEmail(account_id), user_manager::User::OAU
TH2_TOKEN_STATUS_VALID); |
| 152 VerifySessionCookies(); | 152 VerifySessionCookies(); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 ProfileOAuth2TokenService* OAuth2LoginManager::GetTokenService() { | 156 ProfileOAuth2TokenService* OAuth2LoginManager::GetTokenService() { |
| 157 return ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_); | 157 return ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_); |
| 158 } | 158 } |
| 159 | 159 |
| 160 const std::string& OAuth2LoginManager::GetPrimaryAccountId() { | 160 const std::string& OAuth2LoginManager::GetPrimaryAccountId() { |
| 161 SigninManagerBase* signin_manager = | 161 SigninManagerBase* signin_manager = |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 FOR_EACH_OBSERVER(Observer, observer_list_, | 409 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 410 OnSessionRestoreStateChanged(user_profile_, state_)); | 410 OnSessionRestoreStateChanged(user_profile_, state_)); |
| 411 } | 411 } |
| 412 | 412 |
| 413 void OAuth2LoginManager::SetSessionRestoreStartForTesting( | 413 void OAuth2LoginManager::SetSessionRestoreStartForTesting( |
| 414 const base::Time& time) { | 414 const base::Time& time) { |
| 415 session_restore_start_ = time; | 415 session_restore_start_ = time; |
| 416 } | 416 } |
| 417 | 417 |
| 418 } // namespace chromeos | 418 } // namespace chromeos |
| OLD | NEW |