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

Unified Diff: chrome/browser/content_settings/content_settings_pref_provider.cc

Issue 8676017: Remove corrupted values from obsolete geolocation preference. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/content_settings/content_settings_pref_provider.cc
diff --git a/chrome/browser/content_settings/content_settings_pref_provider.cc b/chrome/browser/content_settings/content_settings_pref_provider.cc
index d1d17a316c98e57affcaeb935db87ad3ad2715dd..93f5aed1d011ca0c3c19d46079ebcb7f89c62b70 100644
--- a/chrome/browser/content_settings/content_settings_pref_provider.cc
+++ b/chrome/browser/content_settings/content_settings_pref_provider.cc
@@ -592,6 +592,13 @@ void PrefProvider::UpdateObsoleteGeolocationPref(
if (!prefs_)
return;
+ // Ignore settings with wildcard patterns as they are not supported by the
+ // obsolete preference.
+ if (primary_pattern == ContentSettingsPattern::Wildcard() ||
+ secondary_pattern == ContentSettingsPattern::Wildcard()) {
+ return;
+ }
+
const GURL requesting_origin(primary_pattern.ToString());
const GURL embedding_origin(secondary_pattern.ToString());
DCHECK(requesting_origin.is_valid() && embedding_origin.is_valid());
@@ -926,6 +933,8 @@ void PrefProvider::MigrateObsoleteGeolocationPref() {
const DictionaryValue* geolocation_settings =
prefs_->GetDictionary(prefs::kGeolocationContentSettings);
+
+ std::vector<std::pair<std::string, std::string> > corrupted_keys;
for (DictionaryValue::key_iterator i =
geolocation_settings->begin_keys();
i != geolocation_settings->end_keys();
@@ -945,7 +954,11 @@ void PrefProvider::MigrateObsoleteGeolocationPref() {
++j) {
const std::string& secondary_key(*j);
GURL secondary_url(secondary_key);
- DCHECK(secondary_url.is_valid());
+ // Save corrupted keys to remove them later.
+ if (!secondary_url.is_valid()) {
+ corrupted_keys.push_back(std::make_pair(primary_key, secondary_key));
+ continue;
+ }
base::Value* value = NULL;
found = requesting_origin_settings->GetWithoutPathExpansion(
@@ -966,6 +979,22 @@ void PrefProvider::MigrateObsoleteGeolocationPref() {
pattern_pairs_settings);
}
}
+
+ // Remove corrupted keys.
+ DictionaryPrefUpdate update_geo_settings(
+ prefs_, prefs::kGeolocationContentSettings);
+ base::DictionaryValue* geo_dict = update_geo_settings.Get();
+ std::vector<std::pair<std::string, std::string> >::iterator key_pair;
+ for (key_pair = corrupted_keys.begin();
+ key_pair != corrupted_keys.end();
+ ++key_pair) {
+ base::DictionaryValue* dict;
+ bool found = geo_dict->GetDictionaryWithoutPathExpansion(
+ key_pair->first, &dict);
+ DCHECK(found);
+ DCHECK(dict->HasKey(key_pair->second));
+ dict->RemoveWithoutPathExpansion(key_pair->second, NULL);
+ }
}
void PrefProvider::MigrateObsoleteNotificationsPrefs() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698