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

Side by Side Diff: chrome/browser/extensions/extension_prefs.cc

Issue 8060017: Ensure that --disable-extensions disables extension prefs from being enacted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split ExtensionPrefs constructor into constructor and Init function Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 : prefs_(prefs), 231 : prefs_(prefs),
232 install_directory_(root_dir), 232 install_directory_(root_dir),
233 extension_pref_value_map_(extension_pref_value_map), 233 extension_pref_value_map_(extension_pref_value_map),
234 content_settings_store_(new ExtensionContentSettingsStore()) { 234 content_settings_store_(new ExtensionContentSettingsStore()) {
235 MakePathsRelative();
236
237 InitPrefStore();
238
239 content_settings_store_->AddObserver(this);
240 } 235 }
241 236
242 ExtensionPrefs::~ExtensionPrefs() { 237 ExtensionPrefs::~ExtensionPrefs() {
243 } 238 }
244 239
240 void ExtensionPrefs::Init(bool extensions_disabled) {
241 MakePathsRelative();
242
243 InitPrefStore(extensions_disabled);
244
245 content_settings_store_->AddObserver(this);
246 }
247
245 // static 248 // static
246 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings"; 249 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings";
247 250
248 static FilePath::StringType MakePathRelative(const FilePath& parent, 251 static FilePath::StringType MakePathRelative(const FilePath& parent,
249 const FilePath& child) { 252 const FilePath& child) {
250 if (!parent.IsParent(child)) 253 if (!parent.IsParent(child))
251 return child.value(); 254 return child.value();
252 255
253 FilePath::StringType retval = child.value().substr( 256 FilePath::StringType retval = child.value().substr(
254 parent.value().length()); 257 parent.value().length());
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref); 1515 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref);
1513 if (!source_dict->GetDictionary(key, &preferences)) { 1516 if (!source_dict->GetDictionary(key, &preferences)) {
1514 // And then create a dictionary if it did not exist before. 1517 // And then create a dictionary if it did not exist before.
1515 DictionaryPrefUpdate update(prefs_, kExtensionsPref); 1518 DictionaryPrefUpdate update(prefs_, kExtensionsPref);
1516 preferences = new DictionaryValue; 1519 preferences = new DictionaryValue;
1517 update->Set(key, preferences); 1520 update->Set(key, preferences);
1518 } 1521 }
1519 return preferences; 1522 return preferences;
1520 } 1523 }
1521 1524
1522 void ExtensionPrefs::InitPrefStore() { 1525 void ExtensionPrefs::InitPrefStore(bool extensions_disabled) {
1526 if (extensions_disabled) {
1527 extension_pref_value_map_->NotifyInitializationCompleted();
1528 return;
1529 }
1530
1523 // When this is called, the PrefService is initialized and provides access 1531 // When this is called, the PrefService is initialized and provides access
1524 // to the user preferences stored in a JSON file. 1532 // to the user preferences stored in a JSON file.
1525 ExtensionIdSet extension_ids; 1533 ExtensionIdSet extension_ids;
1526 GetExtensions(&extension_ids); 1534 GetExtensions(&extension_ids);
1527 // Create empty preferences dictionary for each extension (these dictionaries 1535 // Create empty preferences dictionary for each extension (these dictionaries
1528 // are pruned when persisting the preferences to disk). 1536 // are pruned when persisting the preferences to disk).
1529 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); 1537 for (ExtensionIdSet::iterator ext_id = extension_ids.begin();
1530 ext_id != extension_ids.end(); ++ext_id) { 1538 ext_id != extension_ids.end(); ++ext_id) {
1531 ScopedExtensionPrefUpdate update(prefs_, *ext_id); 1539 ScopedExtensionPrefUpdate update(prefs_, *ext_id);
1532 // This creates an empty dictionary if none is stored. 1540 // This creates an empty dictionary if none is stored.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, 1710 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
1703 PrefService::UNSYNCABLE_PREF); 1711 PrefService::UNSYNCABLE_PREF);
1704 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 1712 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
1705 PrefService::UNSYNCABLE_PREF); 1713 PrefService::UNSYNCABLE_PREF);
1706 prefs->RegisterListPref(prefs::kExtensionInstallForceList, 1714 prefs->RegisterListPref(prefs::kExtensionInstallForceList,
1707 PrefService::UNSYNCABLE_PREF); 1715 PrefService::UNSYNCABLE_PREF);
1708 prefs->RegisterStringPref(kWebStoreLogin, 1716 prefs->RegisterStringPref(kWebStoreLogin,
1709 std::string() /* default_value */, 1717 std::string() /* default_value */,
1710 PrefService::UNSYNCABLE_PREF); 1718 PrefService::UNSYNCABLE_PREF);
1711 } 1719 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698