cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ios / chrome / browser / signin / signin_client_impl.h
blob28919139f92eaf786bb63ac161cded45b8e35fca
1 // Copyright 2015 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 IOS_CHROME_BROWSER_SIGNIN_SIGNIN_CLIENT_IMPL_H_
6 #define IOS_CHROME_BROWSER_SIGNIN_SIGNIN_CLIENT_IMPL_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/signin/core/browser/signin_client.h"
13 #include "components/signin/core/browser/signin_error_controller.h"
14 #include "google_apis/gaia/gaia_oauth_client.h"
15 #include "google_apis/gaia/oauth2_token_service.h"
16 #include "net/base/network_change_notifier.h"
18 namespace content_settings {
19 class CookieSettings;
22 namespace ios {
23 class ChromeBrowserState;
26 class SigninClientImpl
27 : public SigninClient,
28 public net::NetworkChangeNotifier::NetworkChangeObserver,
29 public SigninErrorController::Observer,
30 public gaia::GaiaOAuthClient::Delegate,
31 public OAuth2TokenService::Consumer {
32 public:
33 SigninClientImpl(ios::ChromeBrowserState* browser_state,
34 SigninErrorController* signin_error_controller);
35 ~SigninClientImpl() override;
37 // Utility method.
38 static bool AllowsSigninCookies(ios::ChromeBrowserState* browser_state);
40 // If |for_ephemeral| is true, special kind of device ID for ephemeral users
41 // is generated.
42 static std::string GenerateSigninScopedDeviceID(bool for_ephemeral);
44 // SigninClient implementation.
45 void DoFinalInit() override;
46 PrefService* GetPrefs() override;
47 scoped_refptr<TokenWebData> GetDatabase() override;
48 bool CanRevokeCredentials() override;
49 std::string GetSigninScopedDeviceId() override;
50 void OnSignedOut() override;
51 net::URLRequestContextGetter* GetURLRequestContext() override;
52 bool ShouldMergeSigninCredentialsIntoCookieJar() override;
53 bool IsFirstRun() const override;
54 base::Time GetInstallDate() override;
55 bool AreSigninCookiesAllowed() override;
56 void AddContentSettingsObserver(
57 content_settings::Observer* observer) override;
58 void RemoveContentSettingsObserver(
59 content_settings::Observer* observer) override;
60 void DelayNetworkCall(const base::Closure& callback) override;
61 GaiaAuthFetcher* CreateGaiaAuthFetcher(
62 GaiaAuthConsumer* consumer,
63 const std::string& source,
64 net::URLRequestContextGetter* getter) override;
66 // KeyedService implementation.
67 void Shutdown() override;
69 // Returns a string describing the chrome version environment. Version format:
70 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel">
71 // If version information is unavailable, returns "invalid."
72 std::string GetProductVersion() override;
73 scoped_ptr<CookieChangedSubscription> AddCookieChangedCallback(
74 const GURL& url,
75 const std::string& name,
76 const net::CookieStore::CookieChangedCallback& callback) override;
77 void OnSignedIn(const std::string& account_id,
78 const std::string& gaia_id,
79 const std::string& username,
80 const std::string& password) override;
81 bool UpdateAccountInfo(AccountInfo* out_account_info) override;
83 // SigninErrorController::Observer implementation.
84 void OnErrorChanged() override;
86 // gaia::GaiaOAuthClient::Delegate implementation.
87 void OnGetTokenInfoResponse(
88 scoped_ptr<base::DictionaryValue> token_info) override;
89 void OnOAuthError() override;
90 void OnNetworkError(int response_code) override;
92 // OAuth2TokenService::Consumer implementation
93 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
94 const std::string& access_token,
95 const base::Time& expiration_time) override;
96 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
97 const GoogleServiceAuthError& error) override;
99 // net::NetworkChangeController::NetworkChangeObserver implementation.
100 void OnNetworkChanged(
101 net::NetworkChangeNotifier::ConnectionType type) override;
103 private:
104 ios::ChromeBrowserState* browser_state_;
106 SigninErrorController* signin_error_controller_;
107 std::list<base::Closure> delayed_callbacks_;
109 scoped_ptr<gaia::GaiaOAuthClient> oauth_client_;
110 scoped_ptr<OAuth2TokenService::Request> oauth_request_;
112 DISALLOW_COPY_AND_ASSIGN(SigninClientImpl);
115 #endif // IOS_CHROME_BROWSER_SIGNIN_SIGNIN_CLIENT_IMPL_H_