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/browser/application_context_impl.h"
7 #include "base/logging.h"
8 #include "components/translate/core/browser/translate_download_manager.h"
9 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
11 ApplicationContextImpl::ApplicationContextImpl() {
12 DCHECK(!GetApplicationContext());
13 SetApplicationContext(this);
16 ApplicationContextImpl::~ApplicationContextImpl() {
17 DCHECK_EQ(this, GetApplicationContext());
18 SetApplicationContext(nullptr);
21 PrefService
* ApplicationContextImpl::GetLocalState() {
22 DCHECK(thread_checker_
.CalledOnValidThread());
23 return ios::GetChromeBrowserProvider()->GetLocalState();
26 net::URLRequestContextGetter
*
27 ApplicationContextImpl::GetSystemURLRequestContext() {
28 DCHECK(thread_checker_
.CalledOnValidThread());
29 return ios::GetChromeBrowserProvider()->GetSystemURLRequestContext();
32 const std::string
& ApplicationContextImpl::GetApplicationLocale() {
33 DCHECK(thread_checker_
.CalledOnValidThread());
34 DCHECK(!application_locale_
.empty());
35 return application_locale_
;
38 void ApplicationContextImpl::SetApplicationLocale(const std::string
& locale
) {
39 DCHECK(thread_checker_
.CalledOnValidThread());
40 application_locale_
= locale
;
41 translate::TranslateDownloadManager::GetInstance()->set_application_locale(
45 ios::ChromeBrowserStateManager
*
46 ApplicationContextImpl::GetChromeBrowserStateManager() {
47 return ios::GetChromeBrowserProvider()->GetChromeBrowserStateManager();
50 metrics::MetricsService
* ApplicationContextImpl::GetMetricsService() {
51 return ios::GetChromeBrowserProvider()->GetMetricsService();
54 rappor::RapporService
* ApplicationContextImpl::GetRapporService() {
55 return ios::GetChromeBrowserProvider()->GetRapporService();