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