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"), local_state_(nullptr) {
12 DCHECK(!GetApplicationContext());
13 SetApplicationContext(this);
16 TestingApplicationContext::~TestingApplicationContext() {
17 DCHECK_EQ(this, GetApplicationContext());
18 SetApplicationContext(nullptr);
21 void TestingApplicationContext::SetLocalState(PrefService
* local_state
) {
22 DCHECK(thread_checker_
.CalledOnValidThread());
23 local_state_
= local_state
;
27 TestingApplicationContext
* TestingApplicationContext::GetGlobal() {
28 return static_cast<TestingApplicationContext
*>(GetApplicationContext());
31 PrefService
* TestingApplicationContext::GetLocalState() {
32 DCHECK(thread_checker_
.CalledOnValidThread());
36 net::URLRequestContextGetter
*
37 TestingApplicationContext::GetSystemURLRequestContext() {
38 DCHECK(thread_checker_
.CalledOnValidThread());
39 return ios::GetChromeBrowserProvider()->GetSystemURLRequestContext();
42 const std::string
& TestingApplicationContext::GetApplicationLocale() {
43 DCHECK(thread_checker_
.CalledOnValidThread());
44 DCHECK(!application_locale_
.empty());
45 return application_locale_
;