OLD | NEW |
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/web_view_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/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
| 16 #include "components/prefs/in_memory_pref_store.h" |
16 #include "components/prefs/json_pref_store.h" | 17 #include "components/prefs/json_pref_store.h" |
17 #include "components/prefs/pref_filter.h" | 18 #include "components/prefs/pref_filter.h" |
18 #include "components/prefs/pref_service_factory.h" | 19 #include "components/prefs/pref_service_factory.h" |
19 #include "components/translate/core/browser/translate_pref_names.h" | 20 #include "components/translate/core/browser/translate_pref_names.h" |
20 #include "components/translate/core/browser/translate_prefs.h" | 21 #include "components/translate/core/browser/translate_prefs.h" |
21 #include "ios/web/public/web_thread.h" | 22 #include "ios/web/public/web_thread.h" |
22 #include "ios/web_view/internal/pref_names.h" | 23 #include "ios/web_view/internal/pref_names.h" |
23 #include "ios/web_view/internal/web_view_url_request_context_getter.h" | 24 #include "ios/web_view/internal/web_view_url_request_context_getter.h" |
24 #include "ui/base/l10n/l10n_util_mac.h" | 25 #include "ui/base/l10n/l10n_util_mac.h" |
25 | 26 |
(...skipping 23 matching lines...) Expand all Loading... |
49 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE)); | 50 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE)); |
50 | 51 |
51 // Initialize prefs. | 52 // Initialize prefs. |
52 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry = | 53 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry = |
53 new user_prefs::PrefRegistrySyncable; | 54 new user_prefs::PrefRegistrySyncable; |
54 RegisterPrefs(pref_registry.get()); | 55 RegisterPrefs(pref_registry.get()); |
55 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = | 56 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = |
56 JsonPrefStore::GetTaskRunnerForFile(path_, | 57 JsonPrefStore::GetTaskRunnerForFile(path_, |
57 web::WebThread::GetBlockingPool()); | 58 web::WebThread::GetBlockingPool()); |
58 | 59 |
59 scoped_refptr<PersistentPrefStore> user_pref_store = new JsonPrefStore( | 60 scoped_refptr<PersistentPrefStore> user_pref_store; |
60 path_.Append(kPreferencesFilename), sequenced_task_runner, nullptr); | 61 if (off_the_record) { |
| 62 user_pref_store = new InMemoryPrefStore(); |
| 63 } else { |
| 64 user_pref_store = new JsonPrefStore(path_.Append(kPreferencesFilename), |
| 65 sequenced_task_runner, nullptr); |
| 66 } |
61 | 67 |
62 PrefServiceFactory factory; | 68 PrefServiceFactory factory; |
63 factory.set_user_prefs(user_pref_store); | 69 factory.set_user_prefs(user_pref_store); |
64 prefs_ = factory.Create(pref_registry.get()); | 70 prefs_ = factory.Create(pref_registry.get()); |
65 | 71 |
66 base::ThreadRestrictions::SetIOAllowed(wasIOAllowed); | 72 base::ThreadRestrictions::SetIOAllowed(wasIOAllowed); |
67 } | 73 } |
68 | 74 |
69 WebViewBrowserState::~WebViewBrowserState() = default; | 75 WebViewBrowserState::~WebViewBrowserState() = default; |
70 | 76 |
(...skipping 25 matching lines...) Expand all Loading... |
96 // TODO(crbug.com/679895): Find a good value for the kAcceptLanguages pref. | 102 // TODO(crbug.com/679895): Find a good value for the kAcceptLanguages pref. |
97 // TODO(crbug.com/679895): Pass this value to the network stack somehow, for | 103 // TODO(crbug.com/679895): Pass this value to the network stack somehow, for |
98 // the HTTP header. | 104 // the HTTP header. |
99 pref_registry->RegisterStringPref(prefs::kAcceptLanguages, | 105 pref_registry->RegisterStringPref(prefs::kAcceptLanguages, |
100 l10n_util::GetLocaleOverride()); | 106 l10n_util::GetLocaleOverride()); |
101 pref_registry->RegisterBooleanPref(prefs::kEnableTranslate, true); | 107 pref_registry->RegisterBooleanPref(prefs::kEnableTranslate, true); |
102 translate::TranslatePrefs::RegisterProfilePrefs(pref_registry); | 108 translate::TranslatePrefs::RegisterProfilePrefs(pref_registry); |
103 } | 109 } |
104 | 110 |
105 } // namespace ios_web_view | 111 } // namespace ios_web_view |
OLD | NEW |