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

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: ... 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/command_line.h"
7 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
8 #include "base/string_util.h" 9 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_pref_store.h" 11 #include "chrome/browser/extensions/extension_pref_store.h"
11 #include "chrome/browser/prefs/pref_notifier.h" 12 #include "chrome/browser/prefs/pref_notifier.h"
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" 13 #include "chrome/browser/prefs/scoped_user_pref_update.h"
13 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
15 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/url_pattern.h" 18 #include "chrome/common/extensions/url_pattern.h"
17 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
18 #include "content/common/notification_service.h" 20 #include "content/common/notification_service.h"
19 21
20 using base::Time; 22 using base::Time;
21 23
22 namespace { 24 namespace {
23 25
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 ExtensionPrefs::ExtensionPrefs( 229 ExtensionPrefs::ExtensionPrefs(
228 PrefService* prefs, 230 PrefService* prefs,
229 const FilePath& root_dir, 231 const FilePath& root_dir,
230 ExtensionPrefValueMap* extension_pref_value_map) 232 ExtensionPrefValueMap* extension_pref_value_map)
231 : prefs_(prefs), 233 : prefs_(prefs),
232 install_directory_(root_dir), 234 install_directory_(root_dir),
233 extension_pref_value_map_(extension_pref_value_map), 235 extension_pref_value_map_(extension_pref_value_map),
234 content_settings_store_(new ExtensionContentSettingsStore()) { 236 content_settings_store_(new ExtensionContentSettingsStore()) {
235 MakePathsRelative(); 237 MakePathsRelative();
236 238
237 InitPrefStore(); 239 bool extensions_disabled =
240 (prefs->FindPreference(prefs::kDisableExtensions) &&
241 prefs->GetBoolean(prefs::kDisableExtensions)) ||
242 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions);
Mattias Nissler (ping if slow) 2011/09/28 09:24:51 I must say I personally don't like depending on st
243 InitPrefStore(!extensions_disabled);
238 244
239 content_settings_store_->AddObserver(this); 245 content_settings_store_->AddObserver(this);
240 } 246 }
241 247
242 ExtensionPrefs::~ExtensionPrefs() { 248 ExtensionPrefs::~ExtensionPrefs() {
243 } 249 }
244 250
245 // static 251 // static
246 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings"; 252 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings";
247 253
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref); 1518 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref);
1513 if (!source_dict->GetDictionary(key, &preferences)) { 1519 if (!source_dict->GetDictionary(key, &preferences)) {
1514 // And then create a dictionary if it did not exist before. 1520 // And then create a dictionary if it did not exist before.
1515 DictionaryPrefUpdate update(prefs_, kExtensionsPref); 1521 DictionaryPrefUpdate update(prefs_, kExtensionsPref);
1516 preferences = new DictionaryValue; 1522 preferences = new DictionaryValue;
1517 update->Set(key, preferences); 1523 update->Set(key, preferences);
1518 } 1524 }
1519 return preferences; 1525 return preferences;
1520 } 1526 }
1521 1527
1522 void ExtensionPrefs::InitPrefStore() { 1528 void ExtensionPrefs::InitPrefStore(bool extensions_enabled) {
1529 if (!extensions_enabled) {
1530 extension_pref_value_map_->NotifyInitializationCompleted();
1531 return;
1532 }
1533
1523 // When this is called, the PrefService is initialized and provides access 1534 // When this is called, the PrefService is initialized and provides access
1524 // to the user preferences stored in a JSON file. 1535 // to the user preferences stored in a JSON file.
1525 ExtensionIdSet extension_ids; 1536 ExtensionIdSet extension_ids;
1526 GetExtensions(&extension_ids); 1537 GetExtensions(&extension_ids);
1527 // Create empty preferences dictionary for each extension (these dictionaries 1538 // Create empty preferences dictionary for each extension (these dictionaries
1528 // are pruned when persisting the preferences to disk). 1539 // are pruned when persisting the preferences to disk).
1529 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); 1540 for (ExtensionIdSet::iterator ext_id = extension_ids.begin();
1530 ext_id != extension_ids.end(); ++ext_id) { 1541 ext_id != extension_ids.end(); ++ext_id) {
1531 ScopedExtensionPrefUpdate update(prefs_, *ext_id); 1542 ScopedExtensionPrefUpdate update(prefs_, *ext_id);
1532 // This creates an empty dictionary if none is stored. 1543 // 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, 1713 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
1703 PrefService::UNSYNCABLE_PREF); 1714 PrefService::UNSYNCABLE_PREF);
1704 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 1715 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
1705 PrefService::UNSYNCABLE_PREF); 1716 PrefService::UNSYNCABLE_PREF);
1706 prefs->RegisterListPref(prefs::kExtensionInstallForceList, 1717 prefs->RegisterListPref(prefs::kExtensionInstallForceList,
1707 PrefService::UNSYNCABLE_PREF); 1718 PrefService::UNSYNCABLE_PREF);
1708 prefs->RegisterStringPref(kWebStoreLogin, 1719 prefs->RegisterStringPref(kWebStoreLogin,
1709 std::string() /* default_value */, 1720 std::string() /* default_value */,
1710 PrefService::UNSYNCABLE_PREF); 1721 PrefService::UNSYNCABLE_PREF);
1711 } 1722 }
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