Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ios / chrome / test / testing_application_context.cc
blob3717731846132f862aebe06b8bf225e19991d6d4
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 "ios/chrome/test/testing_application_context.h"
7 #include "base/logging.h"
8 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
10 TestingApplicationContext::TestingApplicationContext()
11 : application_locale_("en"),
12 local_state_(nullptr),
13 chrome_browser_state_manager_(nullptr) {
14 DCHECK(!GetApplicationContext());
15 SetApplicationContext(this);
18 TestingApplicationContext::~TestingApplicationContext() {
19 DCHECK_EQ(this, GetApplicationContext());
20 SetApplicationContext(nullptr);
23 void TestingApplicationContext::SetLocalState(PrefService* local_state) {
24 DCHECK(thread_checker_.CalledOnValidThread());
25 local_state_ = local_state;
28 void TestingApplicationContext::SetChromeBrowserStateManager(
29 ios::ChromeBrowserStateManager* manager) {
30 chrome_browser_state_manager_ = manager;
33 // static
34 TestingApplicationContext* TestingApplicationContext::GetGlobal() {
35 return static_cast<TestingApplicationContext*>(GetApplicationContext());
38 PrefService* TestingApplicationContext::GetLocalState() {
39 DCHECK(thread_checker_.CalledOnValidThread());
40 return local_state_;
43 net::URLRequestContextGetter*
44 TestingApplicationContext::GetSystemURLRequestContext() {
45 DCHECK(thread_checker_.CalledOnValidThread());
46 return ios::GetChromeBrowserProvider()->GetSystemURLRequestContext();
49 const std::string& TestingApplicationContext::GetApplicationLocale() {
50 DCHECK(thread_checker_.CalledOnValidThread());
51 DCHECK(!application_locale_.empty());
52 return application_locale_;
55 ios::ChromeBrowserStateManager*
56 TestingApplicationContext::GetChromeBrowserStateManager() {
57 return chrome_browser_state_manager_;
60 metrics::MetricsService* TestingApplicationContext::GetMetricsService() {
61 return nullptr;
64 rappor::RapporService* TestingApplicationContext::GetRapporService() {
65 return nullptr;