OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_ |
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_ |
7 | 7 |
8 #include "chrome/browser/signin/signin_manager.h" | 8 #include "chrome/browser/signin/signin_manager.h" |
9 #include "google_apis/gaia/gaia_oauth_client.h" | 9 #include "google_apis/gaia/gaia_oauth_client.h" |
10 #include "google_apis/gaia/oauth2_token_service.h" | 10 #include "google_apis/gaia/oauth2_token_service.h" |
11 | 11 |
12 class CookieSettings; | 12 class CookieSettings; |
13 class GaiaAuthFetcher; | 13 class GaiaAuthFetcher; |
14 class Profile; | 14 class ProfileOAuth2TokenService; |
| 15 class SigninClient; |
15 | 16 |
16 // The helper class for managing the obfuscated GAIA ID of the primary | 17 // The helper class for managing the obfuscated GAIA ID of the primary |
17 // account. It fetches the ID when user first signs into Chrome or when user | 18 // account. It fetches the ID when user first signs into Chrome or when user |
18 // opens a connected Chrome profile without an obfuscated GAIA ID, and stores | 19 // opens a connected Chrome profile without an obfuscated GAIA ID, and stores |
19 // the ID in the profile preference. | 20 // the ID in the profile preference. |
20 class SigninAccountIdHelper : public SigninManagerBase::Observer, | 21 class SigninAccountIdHelper : public SigninManagerBase::Observer, |
21 public OAuth2TokenService::Observer { | 22 public OAuth2TokenService::Observer { |
22 public: | 23 public: |
23 SigninAccountIdHelper(Profile* profile, SigninManagerBase* signin_manager); | 24 SigninAccountIdHelper(SigninClient* client, |
| 25 ProfileOAuth2TokenService* token_service, |
| 26 SigninManagerBase* signin_manager); |
24 virtual ~SigninAccountIdHelper(); | 27 virtual ~SigninAccountIdHelper(); |
25 | 28 |
26 // SigninManagerBase::Observer: | 29 // SigninManagerBase::Observer: |
27 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; | 30 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; |
28 | 31 |
29 // OAuth2TokenService::Observer: | 32 // OAuth2TokenService::Observer: |
30 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; | 33 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; |
31 | 34 |
32 // Disables network requests for testing to avoid messing up with irrelevant | 35 // Disables network requests for testing to avoid messing up with irrelevant |
33 // tests. | 36 // tests. |
34 static void SetDisableForTest(bool disable_for_test); | 37 static void SetDisableForTest(bool disable_for_test); |
35 | 38 |
36 private: | 39 private: |
37 // Invoked when receiving the response for |account_id_fetcher_|. | 40 // Invoked when receiving the response for |account_id_fetcher_|. |
38 void OnPrimaryAccountIdFetched(const std::string& gaia_id); | 41 void OnPrimaryAccountIdFetched(const std::string& gaia_id); |
39 | 42 |
40 // Helper class for fetching the obfuscated account ID. | 43 // Helper class for fetching the obfuscated account ID. |
41 class GaiaIdFetcher; | 44 class GaiaIdFetcher; |
42 scoped_ptr<GaiaIdFetcher> id_fetcher_; | 45 scoped_ptr<GaiaIdFetcher> id_fetcher_; |
43 | 46 |
44 static bool disable_for_test_; | 47 static bool disable_for_test_; |
45 | 48 |
46 Profile* profile_; | 49 SigninClient* client_; |
| 50 ProfileOAuth2TokenService* token_service_; |
47 SigninManagerBase* signin_manager_; | 51 SigninManagerBase* signin_manager_; |
48 | 52 |
49 DISALLOW_COPY_AND_ASSIGN(SigninAccountIdHelper); | 53 DISALLOW_COPY_AND_ASSIGN(SigninAccountIdHelper); |
50 }; | 54 }; |
51 | 55 |
52 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_ | 56 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_ |
OLD | NEW |