Stack sampling profiler: add fire-and-forget interface
[chromium-blink-merge.git] / components / signin / core / browser / test_signin_client.h
blob255a3c3103039d115a95e6ff92066cde08c09f41
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 class PrefService;
18 // An implementation of SigninClient for use in unittests. Instantiates test
19 // versions of the various objects that SigninClient is required to provide as
20 // part of its interface.
21 class TestSigninClient : public SigninClient {
22 public:
23 TestSigninClient(PrefService* pref_service);
24 ~TestSigninClient() override;
26 // SigninClient implementation that is specialized for unit tests.
28 void DoFinalInit() override;
30 // Returns NULL.
31 // NOTE: This should be changed to return a properly-initalized PrefService
32 // once there is a unit test that requires it.
33 PrefService* GetPrefs() override;
35 // Returns a pointer to a loaded database.
36 scoped_refptr<TokenWebData> GetDatabase() override;
38 // Returns true.
39 bool CanRevokeCredentials() override;
41 // Returns empty string.
42 std::string GetSigninScopedDeviceId() override;
44 // Does nothing.
45 void OnSignedOut() override;
47 // Trace that this was called.
48 void PostSignedIn(const std::string& account_id,
49 const std::string& username,
50 const std::string& password) override;
52 std::string get_signed_in_password() { return signed_in_password_; }
54 // Returns the empty string.
55 std::string GetProductVersion() override;
57 // Returns a TestURLRequestContextGetter or an manually provided
58 // URLRequestContextGetter.
59 net::URLRequestContextGetter* GetURLRequestContext() override;
61 // For testing purposes, can override the TestURLRequestContextGetter created
62 // in the default constructor.
63 void SetURLRequestContext(net::URLRequestContextGetter* request_context);
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 bool UpdateAccountInfo(
76 AccountTrackerService::AccountInfo* out_account_info) override;
78 void set_are_signin_cookies_allowed(bool value) {
79 are_signin_cookies_allowed_ = value;
82 // SigninClient overrides:
83 bool IsFirstRun() const override;
84 base::Time GetInstallDate() override;
85 bool AreSigninCookiesAllowed() override;
86 void AddContentSettingsObserver(
87 content_settings::Observer* observer) override;
88 void RemoveContentSettingsObserver(
89 content_settings::Observer* observer) override;
90 void DelayNetworkCall(const base::Closure& callback) override;
91 GaiaAuthFetcher* CreateGaiaAuthFetcher(
92 GaiaAuthConsumer* consumer,
93 const std::string& source,
94 net::URLRequestContextGetter* getter) override;
96 // Loads the token database.
97 void LoadTokenDatabase();
99 private:
100 base::ScopedTempDir temp_dir_;
101 scoped_refptr<net::URLRequestContextGetter> request_context_;
102 scoped_refptr<TokenWebData> database_;
103 PrefService* pref_service_;
104 bool are_signin_cookies_allowed_;
106 // Pointer to be filled by PostSignedIn.
107 std::string signed_in_password_;
109 DISALLOW_COPY_AND_ASSIGN(TestSigninClient);
112 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_