Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/chromeos/login/signin/oauth2_login_manager.h

Issue 2921653004: cros: Remove get user info code from OAuth2LoginManager (Closed)
Patch Set: revise to just clean-up Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/chromeos/login/signin/oauth2_login_verifier.h" 14 #include "chrome/browser/chromeos/login/signin/oauth2_login_verifier.h"
15 #include "chrome/browser/chromeos/login/signin/oauth2_token_fetcher.h" 15 #include "chrome/browser/chromeos/login/signin/oauth2_token_fetcher.h"
16 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
17 #include "google_apis/gaia/gaia_oauth_client.h"
18 #include "google_apis/gaia/oauth2_token_service.h" 17 #include "google_apis/gaia/oauth2_token_service.h"
19 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
20 19
21 class GoogleServiceAuthError; 20 class GoogleServiceAuthError;
22 class Profile; 21 class Profile;
23 class ProfileOAuth2TokenService; 22 class ProfileOAuth2TokenService;
24 23
25 namespace chromeos { 24 namespace chromeos {
26 25
27 // This class is responsible for restoring authenticated web sessions out of 26 // This class is responsible for restoring authenticated web sessions out of
28 // OAuth2 refresh tokens or pre-authenticated cookie jar. 27 // OAuth2 refresh tokens or pre-authenticated cookie jar.
29 class OAuth2LoginManager : public KeyedService, 28 class OAuth2LoginManager : public KeyedService,
30 public gaia::GaiaOAuthClient::Delegate,
31 public OAuth2LoginVerifier::Delegate, 29 public OAuth2LoginVerifier::Delegate,
32 public OAuth2TokenFetcher::Delegate, 30 public OAuth2TokenFetcher::Delegate,
33 public OAuth2TokenService::Observer { 31 public OAuth2TokenService::Observer {
34 public: 32 public:
35 // Session restore states. 33 // Session restore states.
36 enum SessionRestoreState { 34 enum SessionRestoreState {
37 // Session restore is not started. 35 // Session restore is not started.
38 SESSION_RESTORE_NOT_STARTED = 0, 36 SESSION_RESTORE_NOT_STARTED = 0,
39 // Session restore is being prepared. 37 // Session restore is being prepared.
40 SESSION_RESTORE_PREPARING = 1, 38 SESSION_RESTORE_PREPARING = 1,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 POST_MERGE_MISSING_PRIMARY_ACCOUNT = 3, 137 POST_MERGE_MISSING_PRIMARY_ACCOUNT = 3,
140 POST_MERGE_PRIMARY_NOT_FIRST_ACCOUNT = 4, 138 POST_MERGE_PRIMARY_NOT_FIRST_ACCOUNT = 4,
141 POST_MERGE_VERIFICATION_FAILED = 5, 139 POST_MERGE_VERIFICATION_FAILED = 5,
142 POST_MERGE_CONNECTION_FAILED = 6, 140 POST_MERGE_CONNECTION_FAILED = 6,
143 POST_MERGE_COUNT = 7, 141 POST_MERGE_COUNT = 7,
144 }; 142 };
145 143
146 // KeyedService implementation. 144 // KeyedService implementation.
147 void Shutdown() override; 145 void Shutdown() override;
148 146
149 // gaia::GaiaOAuthClient::Delegate overrides.
150 void OnRefreshTokenResponse(const std::string& access_token,
151 int expires_in_seconds) override;
152 void OnGetUserInfoResponse(
153 std::unique_ptr<base::DictionaryValue> user_info) override;
154 void OnOAuthError() override;
155 void OnNetworkError(int response_code) override;
156
157 // OAuth2LoginVerifier::Delegate overrides. 147 // OAuth2LoginVerifier::Delegate overrides.
158 void OnSessionMergeSuccess() override; 148 void OnSessionMergeSuccess() override;
159 void OnSessionMergeFailure(bool connection_error) override; 149 void OnSessionMergeFailure(bool connection_error) override;
160 void OnListAccountsSuccess( 150 void OnListAccountsSuccess(
161 const std::vector<gaia::ListedAccount>& accounts) override; 151 const std::vector<gaia::ListedAccount>& accounts) override;
162 void OnListAccountsFailure(bool connection_error) override; 152 void OnListAccountsFailure(bool connection_error) override;
163 153
164 // OAuth2TokenFetcher::Delegate overrides. 154 // OAuth2TokenFetcher::Delegate overrides.
165 void OnOAuth2TokensAvailable( 155 void OnOAuth2TokensAvailable(
166 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) override; 156 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) override;
167 void OnOAuth2TokensFetchFailed() override; 157 void OnOAuth2TokensFetchFailed() override;
168 158
169 // OAuth2TokenService::Observer implementation: 159 // OAuth2TokenService::Observer implementation:
170 void OnRefreshTokenAvailable(const std::string& user_email) override; 160 void OnRefreshTokenAvailable(const std::string& user_email) override;
171 161
172 // Signals delegate that authentication is completed, kicks off token fetching 162 // Signals delegate that authentication is completed, kicks off token fetching
173 // process. 163 // process.
174 void CompleteAuthentication(); 164 void CompleteAuthentication();
175 165
176 // Retrieves ProfileOAuth2TokenService for |user_profile_|. 166 // Retrieves ProfileOAuth2TokenService for |user_profile_|.
177 ProfileOAuth2TokenService* GetTokenService(); 167 ProfileOAuth2TokenService* GetTokenService();
178 168
179 // Retrieves the primary account for |user_profile_|. 169 // Retrieves the primary account for |user_profile_|.
180 const std::string& GetPrimaryAccountId(); 170 std::string GetPrimaryAccountId();
181 171
182 // Records |refresh_token_| to token service. The associated account id is 172 // 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 173 // 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 174 // account id is not present, GetAccountInfoOfRefreshToken will be called to
185 // retrieve the associated account info. 175 // retrieve the associated account info.
186 void StoreOAuth2Token(); 176 void StoreOAuth2Token();
187 177
188 // Get the account info corresponding to the specified refresh token.
189 void GetAccountInfoOfRefreshToken(const std::string& refresh_token);
190
191 // Update the token service and inform listeners of a new refresh token. 178 // Update the token service and inform listeners of a new refresh token.
192 void UpdateCredentials(const std::string& account_id); 179 void UpdateCredentials(const std::string& account_id);
193 180
194 // Notify that the refresh tokens are loaded and ready to use. 181 // Notify that the refresh tokens are loaded and ready to use.
195 void FireRefreshTokensLoaded(); 182 void FireRefreshTokensLoaded();
196 183
197 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from 184 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from
198 // provided |auth_profile|. 185 // provided |auth_profile|.
199 void FetchOAuth2Tokens(); 186 void FetchOAuth2Tokens();
200 187
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 Profile* user_profile_; 220 Profile* user_profile_;
234 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; 221 scoped_refptr<net::URLRequestContextGetter> auth_request_context_;
235 SessionRestoreStrategy restore_strategy_; 222 SessionRestoreStrategy restore_strategy_;
236 SessionRestoreState state_; 223 SessionRestoreState state_;
237 224
238 // Whether there is pending TokenService::LoadCredentials call. 225 // Whether there is pending TokenService::LoadCredentials call.
239 bool pending_token_service_load_ = false; 226 bool pending_token_service_load_ = false;
240 227
241 std::unique_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_; 228 std::unique_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_;
242 std::unique_ptr<OAuth2LoginVerifier> login_verifier_; 229 std::unique_ptr<OAuth2LoginVerifier> login_verifier_;
243 std::unique_ptr<gaia::GaiaOAuthClient> account_info_fetcher_;
244 230
245 // OAuth2 refresh token. 231 // OAuth2 refresh token.
246 std::string refresh_token_; 232 std::string refresh_token_;
247 233
248 // OAuthLogin scoped access token. 234 // OAuthLogin scoped access token.
249 std::string oauthlogin_access_token_; 235 std::string oauthlogin_access_token_;
250 236
251 // Session restore start time. 237 // Session restore start time.
252 base::Time session_restore_start_; 238 base::Time session_restore_start_;
253 239
254 // List of observers to notify when token availability changes. 240 // List of observers to notify when token availability changes.
255 // Makes sure list is empty on destruction. 241 // Makes sure list is empty on destruction.
256 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we 242 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we
257 // can change the line below to base::ObserverList<Observer, true>. 243 // can change the line below to base::ObserverList<Observer, true>.
258 base::ObserverList<Observer, false> observer_list_; 244 base::ObserverList<Observer, false> observer_list_;
259 245
260 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); 246 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager);
261 }; 247 };
262 248
263 } // namespace chromeos 249 } // namespace chromeos
264 250
265 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_ 251 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698