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/extensions/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_pref_store.h" | 10 #include "chrome/browser/extensions/extension_pref_store.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 | 220 |
221 std::string JoinPrefs(std::string parent, const char* child) { | 221 std::string JoinPrefs(std::string parent, const char* child) { |
222 return parent + "." + child; | 222 return parent + "." + child; |
223 } | 223 } |
224 | 224 |
225 } // namespace | 225 } // namespace |
226 | 226 |
227 ExtensionPrefs::ExtensionPrefs( | 227 ExtensionPrefs::ExtensionPrefs( |
228 PrefService* prefs, | 228 PrefService* prefs, |
229 const FilePath& root_dir, | 229 const FilePath& root_dir, |
230 ExtensionPrefValueMap* extension_pref_value_map) | 230 ExtensionPrefValueMap* extension_pref_value_map, |
231 bool extensions_disabled) | |
231 : prefs_(prefs), | 232 : prefs_(prefs), |
232 install_directory_(root_dir), | 233 install_directory_(root_dir), |
233 extension_pref_value_map_(extension_pref_value_map), | 234 extension_pref_value_map_(extension_pref_value_map), |
234 content_settings_store_(new ExtensionContentSettingsStore()) { | 235 content_settings_store_(new ExtensionContentSettingsStore()) { |
235 MakePathsRelative(); | 236 MakePathsRelative(); |
236 | 237 |
237 InitPrefStore(); | 238 InitPrefStore(extensions_disabled); |
asargent_no_longer_on_chrome
2011/09/29 18:06:59
It is sort of against the style guide to be doing
battre
2011/09/29 20:37:47
I would still want to call InitPrefStore(false) to
| |
238 | 239 |
239 content_settings_store_->AddObserver(this); | 240 content_settings_store_->AddObserver(this); |
240 } | 241 } |
241 | 242 |
242 ExtensionPrefs::~ExtensionPrefs() { | 243 ExtensionPrefs::~ExtensionPrefs() { |
243 } | 244 } |
244 | 245 |
245 // static | 246 // static |
246 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings"; | 247 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings"; |
247 | 248 |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref); | 1513 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref); |
1513 if (!source_dict->GetDictionary(key, &preferences)) { | 1514 if (!source_dict->GetDictionary(key, &preferences)) { |
1514 // And then create a dictionary if it did not exist before. | 1515 // And then create a dictionary if it did not exist before. |
1515 DictionaryPrefUpdate update(prefs_, kExtensionsPref); | 1516 DictionaryPrefUpdate update(prefs_, kExtensionsPref); |
1516 preferences = new DictionaryValue; | 1517 preferences = new DictionaryValue; |
1517 update->Set(key, preferences); | 1518 update->Set(key, preferences); |
1518 } | 1519 } |
1519 return preferences; | 1520 return preferences; |
1520 } | 1521 } |
1521 | 1522 |
1522 void ExtensionPrefs::InitPrefStore() { | 1523 void ExtensionPrefs::InitPrefStore(bool extensions_disabled) { |
1524 if (extensions_disabled) { | |
1525 extension_pref_value_map_->NotifyInitializationCompleted(); | |
1526 return; | |
1527 } | |
1528 | |
1523 // When this is called, the PrefService is initialized and provides access | 1529 // When this is called, the PrefService is initialized and provides access |
1524 // to the user preferences stored in a JSON file. | 1530 // to the user preferences stored in a JSON file. |
1525 ExtensionIdSet extension_ids; | 1531 ExtensionIdSet extension_ids; |
1526 GetExtensions(&extension_ids); | 1532 GetExtensions(&extension_ids); |
1527 // Create empty preferences dictionary for each extension (these dictionaries | 1533 // Create empty preferences dictionary for each extension (these dictionaries |
1528 // are pruned when persisting the preferences to disk). | 1534 // are pruned when persisting the preferences to disk). |
1529 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); | 1535 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); |
1530 ext_id != extension_ids.end(); ++ext_id) { | 1536 ext_id != extension_ids.end(); ++ext_id) { |
1531 ScopedExtensionPrefUpdate update(prefs_, *ext_id); | 1537 ScopedExtensionPrefUpdate update(prefs_, *ext_id); |
1532 // This creates an empty dictionary if none is stored. | 1538 // This creates an empty dictionary if none is stored. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1702 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1708 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
1703 PrefService::UNSYNCABLE_PREF); | 1709 PrefService::UNSYNCABLE_PREF); |
1704 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1710 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
1705 PrefService::UNSYNCABLE_PREF); | 1711 PrefService::UNSYNCABLE_PREF); |
1706 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1712 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
1707 PrefService::UNSYNCABLE_PREF); | 1713 PrefService::UNSYNCABLE_PREF); |
1708 prefs->RegisterStringPref(kWebStoreLogin, | 1714 prefs->RegisterStringPref(kWebStoreLogin, |
1709 std::string() /* default_value */, | 1715 std::string() /* default_value */, |
1710 PrefService::UNSYNCABLE_PREF); | 1716 PrefService::UNSYNCABLE_PREF); |
1711 } | 1717 } |
OLD | NEW |