diff options
author | msramek <msramek@chromium.org> | 2015-04-14 03:17:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-14 10:19:08 +0000 |
commit | 0a3f5498e0a200298a4393b4b06f9876610499f6 (patch) | |
tree | aa60f5daef21bbe297e663ebb25f5db1addab6dc /components/content_settings | |
parent | f72d9e86374adbf35a01550db0fbfd3fe42456f6 (diff) | |
download | chromium_src-0a3f5498e0a200298a4393b4b06f9876610499f6.zip chromium_src-0a3f5498e0a200298a4393b4b06f9876610499f6.tar.gz chromium_src-0a3f5498e0a200298a4393b4b06f9876610499f6.tar.bz2 |
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}
Diffstat (limited to 'components/content_settings')
-rw-r--r-- | components/content_settings/core/browser/content_settings_pref.cc | 33 |
1 files changed, 12 insertions, 21 deletions
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<Rule> rules_to_delete; { base::AutoLock auto_lock(lock_); - scoped_ptr<RuleIterator> 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<Rule>::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<bool> 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_, |