From 0a3f5498e0a200298a4393b4b06f9876610499f6 Mon Sep 17 00:00:00 2001 From: msramek Date: Tue, 14 Apr 2015 03:17:36 -0700 Subject: Make ClearAllContentSettingsRules() clear resource IDs as well. This means that if a resource identifier rule (e.g. plugin allowed on a site) is delete in an old instance of Chrome, the deletion will not propagate to a new version. This change also affects ProfileResetter, which calls this function to delete all content settings rules; it did not delete rules with resource identifier before. Since the OriginIdentifierValueMap now only contains one content type per instance, we can delete all rules (regardless of resource identifier) by simply calling clear(), which greatly improves the deletion speed as well. BUG=475951 Review URL: https://codereview.chromium.org/1079133003 Cr-Commit-Position: refs/heads/master@{#325022} --- .../core/browser/content_settings_pref.cc | 33 ++++++++-------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'components/content_settings') diff --git a/components/content_settings/core/browser/content_settings_pref.cc b/components/content_settings/core/browser/content_settings_pref.cc index 4c48da3..1035732 100644 --- a/components/content_settings/core/browser/content_settings_pref.cc +++ b/components/content_settings/core/browser/content_settings_pref.cc @@ -161,33 +161,24 @@ void ContentSettingsPref::ClearAllContentSettingsRules() { if (!is_incognito_) map_to_modify = &value_map_; - std::vector rules_to_delete; { base::AutoLock auto_lock(lock_); - scoped_ptr rule_iterator( - map_to_modify->GetRuleIterator(content_type_, - ResourceIdentifier(), - NULL)); - // Copy the rules; we cannot call |UpdatePref| while holding |lock_|. - while (rule_iterator->HasNext()) - rules_to_delete.push_back(rule_iterator->Next()); - - map_to_modify->DeleteValues(content_type_, ResourceIdentifier()); + map_to_modify->clear(); } - for (std::vector::const_iterator it = rules_to_delete.begin(); - it != rules_to_delete.end(); ++it) { - UpdatePref(it->primary_pattern, - it->secondary_pattern, - ResourceIdentifier(), - NULL); - if (IsContentSettingsTypeSyncable(content_type_)) { - UpdateOldPref(it->primary_pattern, - it->secondary_pattern, - ResourceIdentifier(), - NULL); + if (!is_incognito_) { + // Clear the new preference. + { + base::AutoReset auto_reset(&updating_preferences_, true); + DictionaryPrefUpdate update(prefs_, pref_name_); + base::DictionaryValue* pattern_pairs_settings = update.Get(); + pattern_pairs_settings->Clear(); } + + if (IsContentSettingsTypeSyncable(content_type_)) + ClearOldPreference(); } + notify_callback_.Run(ContentSettingsPattern(), ContentSettingsPattern(), content_type_, -- cgit v1.1