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
;
34 TestingApplicationContext
* TestingApplicationContext::GetGlobal() {
35 return static_cast<TestingApplicationContext
*>(GetApplicationContext());
38 PrefService
* TestingApplicationContext::GetLocalState() {
39 DCHECK(thread_checker_
.CalledOnValidThread());
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() {
64 rappor::RapporService
* TestingApplicationContext::GetRapporService() {