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 #include "components/signin/core/browser/test_signin_client.h"
7 #include "base/logging.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "components/signin/core/browser/webdata/token_service_table.h"
10 #include "components/webdata/common/web_data_service_base.h"
11 #include "components/webdata/common/web_database_service.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 TestSigninClient::TestSigninClient(PrefService
* pref_service
)
15 : pref_service_(pref_service
), are_signin_cookies_allowed_(true) {}
17 TestSigninClient::~TestSigninClient() {}
19 void TestSigninClient::DoFinalInit() {}
21 PrefService
* TestSigninClient::GetPrefs() {
25 scoped_refptr
<TokenWebData
> TestSigninClient::GetDatabase() {
29 bool TestSigninClient::CanRevokeCredentials() { return true; }
31 std::string
TestSigninClient::GetSigninScopedDeviceId() {
35 void TestSigninClient::OnSignedOut() {}
37 void TestSigninClient::PostSignedIn(const std::string
& account_id
,
38 const std::string
& username
,
39 const std::string
& password
) {
40 signed_in_password_
= password
;
43 net::URLRequestContextGetter
* TestSigninClient::GetURLRequestContext() {
44 return request_context_
.get();
47 void TestSigninClient::SetURLRequestContext(
48 net::URLRequestContextGetter
* request_context
) {
49 request_context_
= request_context
;
52 std::string
TestSigninClient::GetProductVersion() { return ""; }
54 void TestSigninClient::LoadTokenDatabase() {
55 ASSERT_TRUE(temp_dir_
.CreateUniqueTempDir());
56 base::FilePath path
= temp_dir_
.path().AppendASCII("TestWebDB");
57 scoped_refptr
<WebDatabaseService
> web_database
=
58 new WebDatabaseService(path
, base::ThreadTaskRunnerHandle::Get(),
59 base::ThreadTaskRunnerHandle::Get());
60 web_database
->AddTable(scoped_ptr
<WebDatabaseTable
>(new TokenServiceTable()));
61 web_database
->LoadDatabase();
63 new TokenWebData(web_database
, base::ThreadTaskRunnerHandle::Get(),
64 base::ThreadTaskRunnerHandle::Get(),
65 WebDataServiceBase::ProfileErrorCallback());
69 bool TestSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() {
73 scoped_ptr
<SigninClient::CookieChangedSubscription
>
74 TestSigninClient::AddCookieChangedCallback(
76 const std::string
& name
,
77 const net::CookieStore::CookieChangedCallback
& callback
) {
78 return scoped_ptr
<SigninClient::CookieChangedSubscription
>(
79 new SigninClient::CookieChangedSubscription
);
82 bool TestSigninClient::UpdateAccountInfo(
83 AccountTrackerService::AccountInfo
* out_account_info
) {
87 bool TestSigninClient::IsFirstRun() const {
91 base::Time
TestSigninClient::GetInstallDate() {
92 return base::Time::Now();
95 bool TestSigninClient::AreSigninCookiesAllowed() {
96 return are_signin_cookies_allowed_
;
99 void TestSigninClient::AddContentSettingsObserver(
100 content_settings::Observer
* observer
) {
103 void TestSigninClient::RemoveContentSettingsObserver(
104 content_settings::Observer
* observer
) {
107 void TestSigninClient::DelayNetworkCall(const base::Closure
& callback
) {
111 GaiaAuthFetcher
* TestSigninClient::CreateGaiaAuthFetcher(
112 GaiaAuthConsumer
* consumer
,
113 const std::string
& source
,
114 net::URLRequestContextGetter
* getter
) {
115 return new GaiaAuthFetcher(consumer
, source
, getter
);