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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_
8 #include "content/public/browser/notification_observer.h"
9 #include "content/public/browser/notification_registrar.h"
10 #include "google_apis/gaia/gaia_oauth_client.h"
11 #include "google_apis/gaia/oauth2_token_service.h"
14 class GaiaAuthFetcher
;
17 // The helper class for managing the obfuscated account ID of the primary
18 // account. It fetches the ID when user first signs into Chrome or when user
19 // opens a connected Chrome profile without an obfuscated account ID, and stores
20 // the ID in the profile preference.
21 class SigninAccountIdHelper
22 : public content::NotificationObserver
,
23 public OAuth2TokenService::Observer
{
25 explicit SigninAccountIdHelper(Profile
* profile
);
26 virtual ~SigninAccountIdHelper();
28 // content::NotificationObserver
29 virtual void Observe(int type
,
30 const content::NotificationSource
& source
,
31 const content::NotificationDetails
& details
) OVERRIDE
;
33 // OAuth2TokenService::Observer:
34 virtual void OnRefreshTokenAvailable(const std::string
& email
) OVERRIDE
;
36 // Disables network requests for testing to avoid messing up with irrelevant
38 static void SetDisableForTest(bool disable_for_test
);
41 // Invoked when receiving the response for |account_id_fetcher_|.
42 void OnPrimaryAccountIdFetched(const std::string
& account_id
);
44 // Helper class for fetching the obfuscated account ID.
45 class AccountIdFetcher
;
46 scoped_ptr
<AccountIdFetcher
> id_fetcher_
;
48 static bool disable_for_test_
;
51 content::NotificationRegistrar registrar_
;
53 DISALLOW_COPY_AND_ASSIGN(SigninAccountIdHelper
);
56 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_ACCOUNT_ID_HELPER_H_