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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 POST_MERGE_VERIFICATION_FAILED = 5, | 142 POST_MERGE_VERIFICATION_FAILED = 5, |
143 POST_MERGE_CONNECTION_FAILED = 6, | 143 POST_MERGE_CONNECTION_FAILED = 6, |
144 POST_MERGE_COUNT = 7, | 144 POST_MERGE_COUNT = 7, |
145 }; | 145 }; |
146 | 146 |
147 // KeyedService implementation. | 147 // KeyedService implementation. |
148 void Shutdown() override; | 148 void Shutdown() override; |
149 | 149 |
150 // gaia::GaiaOAuthClient::Delegate overrides. | 150 // gaia::GaiaOAuthClient::Delegate overrides. |
151 void OnRefreshTokenResponse(const std::string& access_token, | 151 void OnRefreshTokenResponse(const std::string& access_token, |
152 int expires_in_seconds) override; | 152 int expires_in_seconds) override; |
153 void OnGetUserInfoResponse( | 153 void OnGetUserEmailResponse(const std::string& user_email) override; |
154 scoped_ptr<base::DictionaryValue> user_info) override; | |
155 void OnOAuthError() override; | 154 void OnOAuthError() override; |
156 void OnNetworkError(int response_code) override; | 155 void OnNetworkError(int response_code) override; |
157 | 156 |
158 // OAuth2LoginVerifier::Delegate overrides. | 157 // OAuth2LoginVerifier::Delegate overrides. |
159 void OnSessionMergeSuccess() override; | 158 void OnSessionMergeSuccess() override; |
160 void OnSessionMergeFailure(bool connection_error) override; | 159 void OnSessionMergeFailure(bool connection_error) override; |
161 void OnListAccountsSuccess(const std::string& data) override; | 160 void OnListAccountsSuccess(const std::string& data) override; |
162 void OnListAccountsFailure(bool connection_error) override; | 161 void OnListAccountsFailure(bool connection_error) override; |
163 | 162 |
164 // OAuth2TokenFetcher::Delegate overrides. | 163 // OAuth2TokenFetcher::Delegate overrides. |
165 void OnOAuth2TokensAvailable( | 164 void OnOAuth2TokensAvailable( |
166 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) override; | 165 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) override; |
167 void OnOAuth2TokensFetchFailed() override; | 166 void OnOAuth2TokensFetchFailed() override; |
168 | 167 |
169 // OAuth2TokenService::Observer implementation: | 168 // OAuth2TokenService::Observer implementation: |
170 void OnRefreshTokenAvailable(const std::string& account_id) override; | 169 void OnRefreshTokenAvailable(const std::string& account_id) override; |
171 | 170 |
172 // Signals delegate that authentication is completed, kicks off token fetching | 171 // Signals delegate that authentication is completed, kicks off token fetching |
173 // process. | 172 // process. |
174 void CompleteAuthentication(); | 173 void CompleteAuthentication(); |
175 | 174 |
176 // Retrieves ProfileOAuth2TokenService for |user_profile_|. | 175 // Retrieves ProfileOAuth2TokenService for |user_profile_|. |
177 ProfileOAuth2TokenService* GetTokenService(); | 176 ProfileOAuth2TokenService* GetTokenService(); |
178 | 177 |
179 // Retrieves the primary account for |user_profile_|. | 178 // Retrieves the primary account for |user_profile_|. |
180 const std::string& GetPrimaryAccountId(); | 179 const std::string& GetPrimaryAccountId(); |
181 | 180 |
182 // Records |refresh_token_| to token service. The associated account id is | 181 // Records |refresh_token_| to token service. The associated account id is |
183 // assumed to be the primary account id of the user profile. If the primary | 182 // assumed to be the primary account id of the user profile. If the primary |
184 // account id is not present, GetAccountInfoOfRefreshToken will be called to | 183 // account id is not present, GetAccountIdOfRefreshToken will be called to |
185 // retrieve the associated account info. | 184 // retrieve the associated account id. |
186 void StoreOAuth2Token(); | 185 void StoreOAuth2Token(); |
187 | 186 |
188 // Get the account info corresponding to the specified refresh token. | 187 // Get the account id corresponding to the specified refresh token. |
189 void GetAccountInfoOfRefreshToken(const std::string& refresh_token); | 188 void GetAccountIdOfRefreshToken(const std::string& refresh_token); |
190 | |
191 // Update the token service and inform listeners of a new refresh token. | |
192 void UpdateCredentials(const std::string& account_id); | |
193 | 189 |
194 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from | 190 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from |
195 // provided |auth_profile|. | 191 // provided |auth_profile|. |
196 void FetchOAuth2Tokens(); | 192 void FetchOAuth2Tokens(); |
197 | 193 |
198 // Reports when all tokens are loaded. | 194 // Reports when all tokens are loaded. |
199 void ReportOAuth2TokensLoaded(); | 195 void ReportOAuth2TokensLoaded(); |
200 | 196 |
201 // Checks if primary account sessions cookies are stale and restores them | 197 // Checks if primary account sessions cookies are stale and restores them |
202 // if needed. | 198 // if needed. |
(...skipping 24 matching lines...) Expand all Loading... |
227 | 223 |
228 // Keeps the track if we have already reported OAuth2 token being loaded | 224 // Keeps the track if we have already reported OAuth2 token being loaded |
229 // by OAuth2TokenService. | 225 // by OAuth2TokenService. |
230 Profile* user_profile_; | 226 Profile* user_profile_; |
231 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; | 227 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; |
232 SessionRestoreStrategy restore_strategy_; | 228 SessionRestoreStrategy restore_strategy_; |
233 SessionRestoreState state_; | 229 SessionRestoreState state_; |
234 | 230 |
235 scoped_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_; | 231 scoped_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_; |
236 scoped_ptr<OAuth2LoginVerifier> login_verifier_; | 232 scoped_ptr<OAuth2LoginVerifier> login_verifier_; |
237 scoped_ptr<gaia::GaiaOAuthClient> account_info_fetcher_; | 233 scoped_ptr<gaia::GaiaOAuthClient> account_id_fetcher_; |
238 | 234 |
239 // OAuth2 refresh token. | 235 // OAuth2 refresh token. |
240 std::string refresh_token_; | 236 std::string refresh_token_; |
241 | 237 |
242 // OAuthLogin scoped access token. | 238 // OAuthLogin scoped access token. |
243 std::string oauthlogin_access_token_; | 239 std::string oauthlogin_access_token_; |
244 | 240 |
245 // Authorization code for fetching OAuth2 tokens. | 241 // Authorization code for fetching OAuth2 tokens. |
246 std::string auth_code_; | 242 std::string auth_code_; |
247 | 243 |
248 // Session restore start time. | 244 // Session restore start time. |
249 base::Time session_restore_start_; | 245 base::Time session_restore_start_; |
250 | 246 |
251 // List of observers to notify when token availability changes. | 247 // List of observers to notify when token availability changes. |
252 // Makes sure list is empty on destruction. | 248 // Makes sure list is empty on destruction. |
253 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we | 249 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we |
254 // can change the line below to ObserverList<Observer, true>. | 250 // can change the line below to ObserverList<Observer, true>. |
255 ObserverList<Observer, false> observer_list_; | 251 ObserverList<Observer, false> observer_list_; |
256 | 252 |
257 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); | 253 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); |
258 }; | 254 }; |
259 | 255 |
260 } // namespace chromeos | 256 } // namespace chromeos |
261 | 257 |
262 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_ | 258 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_ |
OLD | NEW |