Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / signin / core / browser / test_signin_client.h
bloba35980463f023a043f7891a4ef2434a81e60dd6f
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 COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/files/scoped_temp_dir.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/signin/core/browser/signin_client.h"
14 #include "net/url_request/url_request_test_util.h"
16 #if defined(OS_IOS)
17 #include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h"
18 #endif
20 class PrefService;
22 // An implementation of SigninClient for use in unittests. Instantiates test
23 // versions of the various objects that SigninClient is required to provide as
24 // part of its interface.
25 class TestSigninClient : public SigninClient {
26 public:
27 TestSigninClient();
28 TestSigninClient(PrefService* pref_service);
29 ~TestSigninClient() override;
31 // SigninClient implementation that is specialized for unit tests.
33 // Returns NULL.
34 // NOTE: This should be changed to return a properly-initalized PrefService
35 // once there is a unit test that requires it.
36 PrefService* GetPrefs() override;
38 // Returns a pointer to a loaded database.
39 scoped_refptr<TokenWebData> GetDatabase() override;
41 // Returns true.
42 bool CanRevokeCredentials() override;
44 // Returns empty string.
45 std::string GetSigninScopedDeviceId() override;
47 // Does nothing.
48 void OnSignedOut() override;
50 // Returns the empty string.
51 std::string GetProductVersion() override;
53 // Returns a TestURLRequestContextGetter or an manually provided
54 // URLRequestContextGetter.
55 net::URLRequestContextGetter* GetURLRequestContext() override;
57 // For testing purposes, can override the TestURLRequestContextGetter created
58 // in the default constructor.
59 void SetURLRequestContext(net::URLRequestContextGetter* request_context);
61 #if defined(OS_IOS)
62 virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() override;
63 #endif
65 // Returns true.
66 bool ShouldMergeSigninCredentialsIntoCookieJar() override;
68 // Registers |callback| and returns the subscription.
69 // Note that |callback| will never be called.
70 scoped_ptr<SigninClient::CookieChangedSubscription> AddCookieChangedCallback(
71 const GURL& url,
72 const std::string& name,
73 const net::CookieStore::CookieChangedCallback& callback) override;
75 #if defined(OS_IOS)
76 ios::FakeProfileOAuth2TokenServiceIOSProvider* GetIOSProviderAsFake();
77 #endif
79 // SigninClient overrides:
80 void SetSigninProcess(int host_id) override;
81 void ClearSigninProcess() override;
82 bool IsSigninProcess(int host_id) const override;
83 bool HasSigninProcess() const override;
84 bool IsFirstRun() const override;
85 base::Time GetInstallDate() override;
87 private:
88 // Loads the token database.
89 void LoadDatabase();
91 base::ScopedTempDir temp_dir_;
92 scoped_refptr<net::URLRequestContextGetter> request_context_;
93 scoped_refptr<TokenWebData> database_;
94 int signin_host_id_;
95 PrefService* pref_service_;
97 #if defined(OS_IOS)
98 scoped_ptr<ios::FakeProfileOAuth2TokenServiceIOSProvider> iosProvider_;
99 #endif
101 DISALLOW_COPY_AND_ASSIGN(TestSigninClient);
104 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_