OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/value_conversions.h" | 20 #include "base/value_conversions.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/extensions/extension_pref_store.h" | 23 #include "chrome/browser/extensions/extension_pref_store.h" |
24 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 24 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
25 #include "chrome/browser/prefs/command_line_pref_store.h" | 25 #include "chrome/browser/prefs/command_line_pref_store.h" |
26 #include "chrome/browser/prefs/default_pref_store.h" | 26 #include "chrome/browser/prefs/default_pref_store.h" |
27 #include "chrome/browser/prefs/incognito_user_pref_store.h" | 27 #include "chrome/browser/prefs/overlay_user_pref_store.h" |
28 #include "chrome/browser/prefs/per_tab_user_pref_store.h" | |
29 #include "chrome/browser/prefs/pref_model_associator.h" | 28 #include "chrome/browser/prefs/pref_model_associator.h" |
30 #include "chrome/browser/prefs/pref_notifier_impl.h" | 29 #include "chrome/browser/prefs/pref_notifier_impl.h" |
31 #include "chrome/browser/prefs/pref_value_store.h" | 30 #include "chrome/browser/prefs/pref_value_store.h" |
| 31 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
32 #include "chrome/browser/ui/profile_error_dialog.h" | 32 #include "chrome/browser/ui/profile_error_dialog.h" |
33 #include "chrome/common/json_pref_store.h" | 33 #include "chrome/common/json_pref_store.h" |
| 34 #include "chrome/common/pref_names.h" |
34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
35 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
36 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
38 | 39 |
39 using content::BrowserThread; | 40 using content::BrowserThread; |
40 | 41 |
41 namespace { | 42 namespace { |
42 | 43 |
43 // A helper function for RegisterLocalized*Pref that creates a Value* based on | 44 // A helper function for RegisterLocalized*Pref that creates a Value* based on |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 pref_notifier), | 174 pref_notifier), |
174 user, | 175 user, |
175 default_pref_store, | 176 default_pref_store, |
176 pref_sync_associator, | 177 pref_sync_associator, |
177 async); | 178 async); |
178 } | 179 } |
179 | 180 |
180 PrefService* PrefService::CreateIncognitoPrefService( | 181 PrefService* PrefService::CreateIncognitoPrefService( |
181 PrefStore* incognito_extension_prefs) { | 182 PrefStore* incognito_extension_prefs) { |
182 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); | 183 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); |
183 PersistentPrefStore* incognito_pref_store = | 184 OverlayUserPrefStore* incognito_pref_store = |
184 new IncognitoUserPrefStore(user_pref_store_.get()); | 185 new OverlayUserPrefStore(user_pref_store_.get()); |
| 186 PrefsTabHelper::InitIncognitoUserPrefStore(incognito_pref_store); |
185 return new PrefService( | 187 return new PrefService( |
186 pref_notifier, | 188 pref_notifier, |
187 pref_value_store_->CloneAndSpecialize( | 189 pref_value_store_->CloneAndSpecialize( |
188 NULL, // managed_platform_prefs | 190 NULL, // managed_platform_prefs |
189 NULL, // managed_cloud_prefs | 191 NULL, // managed_cloud_prefs |
190 incognito_extension_prefs, | 192 incognito_extension_prefs, |
191 NULL, // command_line_prefs | 193 NULL, // command_line_prefs |
192 incognito_pref_store, | 194 incognito_pref_store, |
193 NULL, // recommended_platform_prefs | 195 NULL, // recommended_platform_prefs |
194 NULL, // recommended_cloud_prefs | 196 NULL, // recommended_cloud_prefs |
195 default_store_.get(), | 197 default_store_.get(), |
196 NULL, // pref_sync_associator | 198 NULL, // pref_sync_associator |
197 pref_notifier), | 199 pref_notifier), |
198 incognito_pref_store, | 200 incognito_pref_store, |
199 default_store_.get(), | 201 default_store_.get(), |
200 NULL, | 202 NULL, |
201 false); | 203 false); |
202 } | 204 } |
203 | 205 |
204 PrefService* PrefService::CreatePrefServiceWithPerTabPrefStore() { | 206 PrefService* PrefService::CreatePrefServiceWithPerTabPrefStore() { |
205 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); | 207 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); |
206 PersistentPrefStore* per_tab_pref_store = | 208 OverlayUserPrefStore* per_tab_pref_store = |
207 new PerTabUserPrefStore(user_pref_store_.get()); | 209 new OverlayUserPrefStore(user_pref_store_.get()); |
| 210 PrefsTabHelper::InitPerTabUserPrefStore(per_tab_pref_store); |
208 DefaultPrefStore* default_store = new DefaultPrefStore(); | 211 DefaultPrefStore* default_store = new DefaultPrefStore(); |
209 return new PrefService( | 212 return new PrefService( |
210 pref_notifier, | 213 pref_notifier, |
211 pref_value_store_->CloneAndSpecialize( | 214 pref_value_store_->CloneAndSpecialize( |
212 NULL, // managed_platform_prefs | 215 NULL, // managed_platform_prefs |
213 NULL, // managed_cloud_prefs | 216 NULL, // managed_cloud_prefs |
214 NULL, // extension_prefs | 217 NULL, // extension_prefs |
215 NULL, // command_line_prefs | 218 NULL, // command_line_prefs |
216 per_tab_pref_store, | 219 per_tab_pref_store, |
217 NULL, // recommended_platform_prefs | 220 NULL, // recommended_platform_prefs |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 943 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |
941 } | 944 } |
942 | 945 |
943 bool PrefService::Preference::IsUserModifiable() const { | 946 bool PrefService::Preference::IsUserModifiable() const { |
944 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 947 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |
945 } | 948 } |
946 | 949 |
947 bool PrefService::Preference::IsExtensionModifiable() const { | 950 bool PrefService::Preference::IsExtensionModifiable() const { |
948 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 951 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |
949 } | 952 } |
OLD | NEW |