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