test_signin_client.cc revision e5d81f57cb97b3b6b7fccc9c5610d21eb81db09d
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. 4 5#include "base/logging.h" 6#include "components/signin/core/browser/test_signin_client.h" 7#include "components/signin/core/browser/webdata/token_service_table.h" 8#include "components/webdata/common/web_data_service_base.h" 9#include "components/webdata/common/web_database_service.h" 10#include "testing/gtest/include/gtest/gtest.h" 11 12TestSigninClient::TestSigninClient() 13 : request_context_(new net::TestURLRequestContextGetter( 14 base::MessageLoopProxy::current())) { 15 LoadDatabase(); 16} 17 18TestSigninClient::~TestSigninClient() {} 19 20PrefService* TestSigninClient::GetPrefs() { return NULL; } 21 22scoped_refptr<TokenWebData> TestSigninClient::GetDatabase() { 23 return database_; 24} 25 26bool TestSigninClient::CanRevokeCredentials() { return true; } 27 28net::URLRequestContextGetter* TestSigninClient::GetURLRequestContext() { 29 return request_context_; 30} 31 32std::string TestSigninClient::GetProductVersion() { return ""; } 33 34void TestSigninClient::LoadDatabase() { 35 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 36 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); 37 scoped_refptr<WebDatabaseService> web_database = 38 new WebDatabaseService(path, 39 base::MessageLoopProxy::current(), 40 base::MessageLoopProxy::current()); 41 web_database->AddTable(scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); 42 web_database->LoadDatabase(); 43 database_ = new TokenWebData(web_database, 44 base::MessageLoopProxy::current(), 45 base::MessageLoopProxy::current(), 46 WebDataServiceBase::ProfileErrorCallback()); 47 database_->Init(); 48} 49 50bool TestSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() { 51 return true; 52} 53 54void TestSigninClient::SetCookieChangedCallback( 55 const CookieChangedCallback& callback) {} 56