Support SizeClassIdiom on iOS7.
[chromium-blink-merge.git] / chrome / browser / signin / chrome_signin_client.h
blob247d099f6ae0518347a2d730b94c8e4895276883
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_
6 #define CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "components/signin/core/browser/signin_client.h"
11 #include "components/signin/core/browser/signin_error_controller.h"
12 #include "google_apis/gaia/gaia_oauth_client.h"
13 #include "google_apis/gaia/oauth2_token_service.h"
15 #if !defined(OS_CHROMEOS)
16 #include "net/base/network_change_notifier.h"
17 #endif
19 namespace content_settings {
20 class CookieSettings;
23 class Profile;
25 class ChromeSigninClient
26 : public SigninClient,
27 #if !defined(OS_CHROMEOS)
28 public net::NetworkChangeNotifier::NetworkChangeObserver,
29 #endif
30 public SigninErrorController::Observer,
31 public gaia::GaiaOAuthClient::Delegate,
32 public OAuth2TokenService::Consumer {
33 public:
34 explicit ChromeSigninClient(
35 Profile* profile, SigninErrorController* signin_error_controller);
36 ~ChromeSigninClient() override;
37 void Shutdown() override;
38 void DoFinalInit() override;
40 // Utility method.
41 static bool ProfileAllowsSigninCookies(Profile* profile);
43 // SigninClient implementation.
44 PrefService* GetPrefs() override;
45 scoped_refptr<TokenWebData> GetDatabase() override;
46 bool CanRevokeCredentials() override;
47 std::string GetSigninScopedDeviceId() override;
48 void OnSignedOut() override;
49 net::URLRequestContextGetter* GetURLRequestContext() override;
50 bool ShouldMergeSigninCredentialsIntoCookieJar() override;
51 bool IsFirstRun() const override;
52 base::Time GetInstallDate() override;
53 bool AreSigninCookiesAllowed() override;
54 void AddContentSettingsObserver(
55 content_settings::Observer* observer) override;
56 void RemoveContentSettingsObserver(
57 content_settings::Observer* observer) override;
58 void DelayNetworkCall(const base::Closure& callback) override;
59 GaiaAuthFetcher* CreateGaiaAuthFetcher(
60 GaiaAuthConsumer* consumer,
61 const std::string& source,
62 net::URLRequestContextGetter* getter) override;
64 // Returns a string describing the chrome version environment. Version format:
65 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel">
66 // If version information is unavailable, returns "invalid."
67 std::string GetProductVersion() override;
68 scoped_ptr<CookieChangedSubscription> AddCookieChangedCallback(
69 const GURL& url,
70 const std::string& name,
71 const net::CookieStore::CookieChangedCallback& callback) override;
72 void OnSignedIn(const std::string& account_id,
73 const std::string& gaia_id,
74 const std::string& username,
75 const std::string& password) override;
76 void PostSignedIn(const std::string& account_id,
77 const std::string& username,
78 const std::string& password) override;
79 bool UpdateAccountInfo(
80 AccountTrackerService::AccountInfo* out_account_info) override;
82 // SigninErrorController::Observer implementation.
83 void OnErrorChanged() override;
85 // gaia::GaiaOAuthClient::Delegate implementation.
86 void OnGetTokenInfoResponse(
87 scoped_ptr<base::DictionaryValue> token_info) override;
88 void OnOAuthError() override;
89 void OnNetworkError(int response_code) override;
91 // OAuth2TokenService::Consumer implementation
92 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
93 const std::string& access_token,
94 const base::Time& expiration_time) override;
95 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
96 const GoogleServiceAuthError& error) override;
98 #if !defined(OS_CHROMEOS)
99 // net::NetworkChangeController::NetworkChangeObserver implementation.
100 void OnNetworkChanged(net::NetworkChangeNotifier::ConnectionType type)
101 override;
102 #endif
104 private:
105 void MaybeFetchSigninTokenHandle();
107 Profile* profile_;
109 SigninErrorController* signin_error_controller_;
110 #if !defined(OS_CHROMEOS)
111 std::list<base::Closure> delayed_callbacks_;
112 #endif
114 scoped_ptr<gaia::GaiaOAuthClient> oauth_client_;
115 scoped_ptr<OAuth2TokenService::Request> oauth_request_;
117 DISALLOW_COPY_AND_ASSIGN(ChromeSigninClient);
120 #endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_