Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: ios/web_view/internal/web_view_browser_state.mm

Issue 2715043002: Replace prefix of ios/web_view C++ classes. (Closed)
Patch Set: Respond to comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ios/web_view/internal/criwv_browser_state.h" 5 #include "ios/web_view/internal/web_view_browser_state.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "components/pref_registry/pref_registry_syncable.h" 14 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "components/prefs/json_pref_store.h" 15 #include "components/prefs/json_pref_store.h"
16 #include "components/prefs/pref_filter.h" 16 #include "components/prefs/pref_filter.h"
17 #include "components/prefs/pref_service_factory.h" 17 #include "components/prefs/pref_service_factory.h"
18 #include "components/translate/core/browser/translate_prefs.h" 18 #include "components/translate/core/browser/translate_prefs.h"
19 #include "components/translate/core/common/translate_pref_names.h" 19 #include "components/translate/core/common/translate_pref_names.h"
20 #include "ios/web/public/web_thread.h" 20 #include "ios/web/public/web_thread.h"
21 #include "ios/web_view/internal/criwv_url_request_context_getter.h"
22 #include "ios/web_view/internal/pref_names.h" 21 #include "ios/web_view/internal/pref_names.h"
22 #include "ios/web_view/internal/web_view_url_request_context_getter.h"
23 #include "ui/base/l10n/l10n_util_mac.h" 23 #include "ui/base/l10n/l10n_util_mac.h"
24 24
25 #if !defined(__has_feature) || !__has_feature(objc_arc) 25 #if !defined(__has_feature) || !__has_feature(objc_arc)
26 #error "This file requires ARC support." 26 #error "This file requires ARC support."
27 #endif 27 #endif
28 28
29 namespace { 29 namespace {
30 const char kPreferencesFilename[] = FILE_PATH_LITERAL("Preferences"); 30 const char kPreferencesFilename[] = FILE_PATH_LITERAL("Preferences");
31 } 31 }
32 32
33 namespace ios_web_view { 33 namespace ios_web_view {
34 34
35 CRIWVBrowserState::CRIWVBrowserState(bool off_the_record) 35 WebViewBrowserState::WebViewBrowserState(bool off_the_record)
36 : web::BrowserState(), off_the_record_(off_the_record) { 36 : web::BrowserState(), off_the_record_(off_the_record) {
37 CHECK(PathService::Get(base::DIR_APP_DATA, &path_)); 37 CHECK(PathService::Get(base::DIR_APP_DATA, &path_));
38 38
39 request_context_getter_ = new CRIWVURLRequestContextGetter( 39 request_context_getter_ = new WebViewURLRequestContextGetter(
40 GetStatePath(), 40 GetStatePath(),
41 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), 41 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO),
42 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE), 42 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE),
43 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE)); 43 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE));
44 44
45 // Initialize prefs. 45 // Initialize prefs.
46 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry = 46 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry =
47 new user_prefs::PrefRegistrySyncable; 47 new user_prefs::PrefRegistrySyncable;
48 RegisterPrefs(pref_registry.get()); 48 RegisterPrefs(pref_registry.get());
49 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = 49 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner =
50 JsonPrefStore::GetTaskRunnerForFile(path_, 50 JsonPrefStore::GetTaskRunnerForFile(path_,
51 web::WebThread::GetBlockingPool()); 51 web::WebThread::GetBlockingPool());
52 52
53 scoped_refptr<PersistentPrefStore> user_pref_store = new JsonPrefStore( 53 scoped_refptr<PersistentPrefStore> user_pref_store = new JsonPrefStore(
54 path_.Append(kPreferencesFilename), sequenced_task_runner, nullptr); 54 path_.Append(kPreferencesFilename), sequenced_task_runner, nullptr);
55 55
56 PrefServiceFactory factory; 56 PrefServiceFactory factory;
57 factory.set_user_prefs(user_pref_store); 57 factory.set_user_prefs(user_pref_store);
58 prefs_ = factory.Create(pref_registry.get()); 58 prefs_ = factory.Create(pref_registry.get());
59 } 59 }
60 60
61 CRIWVBrowserState::~CRIWVBrowserState() {} 61 WebViewBrowserState::~WebViewBrowserState() = default;
62 62
63 PrefService* CRIWVBrowserState::GetPrefs() { 63 PrefService* WebViewBrowserState::GetPrefs() {
64 DCHECK(prefs_); 64 DCHECK(prefs_);
65 return prefs_.get(); 65 return prefs_.get();
66 } 66 }
67 67
68 // static 68 // static
69 CRIWVBrowserState* CRIWVBrowserState::FromBrowserState( 69 WebViewBrowserState* WebViewBrowserState::FromBrowserState(
70 web::BrowserState* browser_state) { 70 web::BrowserState* browser_state) {
71 return static_cast<CRIWVBrowserState*>(browser_state); 71 return static_cast<WebViewBrowserState*>(browser_state);
72 } 72 }
73 73
74 bool CRIWVBrowserState::IsOffTheRecord() const { 74 bool WebViewBrowserState::IsOffTheRecord() const {
75 return off_the_record_; 75 return off_the_record_;
76 } 76 }
77 77
78 base::FilePath CRIWVBrowserState::GetStatePath() const { 78 base::FilePath WebViewBrowserState::GetStatePath() const {
79 return path_; 79 return path_;
80 } 80 }
81 81
82 net::URLRequestContextGetter* CRIWVBrowserState::GetRequestContext() { 82 net::URLRequestContextGetter* WebViewBrowserState::GetRequestContext() {
83 return request_context_getter_.get(); 83 return request_context_getter_.get();
84 } 84 }
85 85
86 void CRIWVBrowserState::RegisterPrefs( 86 void WebViewBrowserState::RegisterPrefs(
87 user_prefs::PrefRegistrySyncable* pref_registry) { 87 user_prefs::PrefRegistrySyncable* pref_registry) {
88 // TODO(crbug.com/679895): Find a good value for the kAcceptLanguages pref. 88 // TODO(crbug.com/679895): Find a good value for the kAcceptLanguages pref.
89 // TODO(crbug.com/679895): Pass this value to the network stack somehow, for 89 // TODO(crbug.com/679895): Pass this value to the network stack somehow, for
90 // the HTTP header. 90 // the HTTP header.
91 pref_registry->RegisterStringPref(prefs::kAcceptLanguages, 91 pref_registry->RegisterStringPref(prefs::kAcceptLanguages,
92 l10n_util::GetLocaleOverride()); 92 l10n_util::GetLocaleOverride());
93 pref_registry->RegisterBooleanPref(prefs::kEnableTranslate, true); 93 pref_registry->RegisterBooleanPref(prefs::kEnableTranslate, true);
94 translate::TranslatePrefs::RegisterProfilePrefs(pref_registry); 94 translate::TranslatePrefs::RegisterProfilePrefs(pref_registry);
95 } 95 }
96 96
97 } // namespace ios_web_view 97 } // namespace ios_web_view
OLDNEW
« no previous file with comments | « ios/web_view/internal/web_view_browser_state.h ('k') | ios/web_view/internal/web_view_network_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698