diff options
author | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 12:54:53 +0000 |
---|---|---|
committer | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 12:54:53 +0000 |
commit | 3ec70b989c3347b25ff5fc3a60df400b04ff4721 (patch) | |
tree | 016fefc54a93d1e9b57157b2e3fbdc53d62ec0c7 /chrome/browser | |
parent | 84b8ede0e3f83eb66894ca444582167e4d37aef2 (diff) | |
download | chromium_src-3ec70b989c3347b25ff5fc3a60df400b04ff4721.zip chromium_src-3ec70b989c3347b25ff5fc3a60df400b04ff4721.tar.gz chromium_src-3ec70b989c3347b25ff5fc3a60df400b04ff4721.tar.bz2 |
Remove migration code for migrating obsolete default content settings prefs.
BUG=101877
Review URL: https://chromiumcodereview.appspot.com/11299072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
5 files changed, 0 insertions, 158 deletions
diff --git a/chrome/browser/content_settings/content_settings_default_provider.cc b/chrome/browser/content_settings/content_settings_default_provider.cc index 1ef2086..2ff3945 100644 --- a/chrome/browser/content_settings/content_settings_default_provider.cc +++ b/chrome/browser/content_settings/content_settings_default_provider.cc @@ -93,16 +93,6 @@ void DefaultProvider::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings, default_content_settings, PrefService::SYNCABLE_PREF); - - // Obsolete prefs, for migrations: - prefs->RegisterIntegerPref( - prefs::kDesktopNotificationDefaultContentSetting, - kDefaultSettings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS], - PrefService::SYNCABLE_PREF); - prefs->RegisterIntegerPref( - prefs::kGeolocationDefaultContentSetting, - kDefaultSettings[CONTENT_SETTINGS_TYPE_GEOLOCATION], - PrefService::UNSYNCABLE_PREF); } DefaultProvider::DefaultProvider(PrefService* prefs, bool incognito) @@ -110,8 +100,6 @@ DefaultProvider::DefaultProvider(PrefService* prefs, bool incognito) is_incognito_(incognito), updating_preferences_(false) { DCHECK(prefs_); - MigrateObsoleteNotificationPref(); - MigrateObsoleteGeolocationPref(); // Read global defaults. ReadDefaultSettings(true); @@ -171,8 +159,6 @@ DefaultProvider::DefaultProvider(PrefService* prefs, bool incognito) PrefChangeRegistrar::NamedChangeCallback callback = base::Bind( &DefaultProvider::OnPreferenceChanged, base::Unretained(this)); pref_change_registrar_.Add(prefs::kDefaultContentSettings, callback); - pref_change_registrar_.Add( - prefs::kGeolocationDefaultContentSetting, callback); } DefaultProvider::~DefaultProvider() { @@ -203,15 +189,6 @@ bool DefaultProvider::SetWebsiteSetting( scoped_ptr<base::Value> value(in_value); { AutoReset<bool> auto_reset(&updating_preferences_, true); - // Keep the obsolete pref in sync as long as backwards compatibility is - // required. This is required to keep sync working correctly. - if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { - if (value.get()) { - prefs_->Set(prefs::kGeolocationDefaultContentSetting, *value); - } else { - prefs_->ClearPref(prefs::kGeolocationDefaultContentSetting); - } - } // |DefaultProvider| should not send any notifications when holding // |lock_|. |DictionaryPrefUpdate| destructor and @@ -286,12 +263,6 @@ void DefaultProvider::OnPreferenceChanged(const std::string& name) { if (name == prefs::kDefaultContentSettings) { ReadDefaultSettings(true); - } else if (name == prefs::kGeolocationDefaultContentSetting) { - MigrateObsoleteGeolocationPref(); - // Return and don't send a notifications. Migrating the obsolete - // geolocation pref will change the prefs::kDefaultContentSettings and - // cause the notification to be fired. - return; } else { NOTREACHED() << "Unexpected preference observed"; return; @@ -355,35 +326,4 @@ void DefaultProvider::GetSettingsFromDictionary( } } -void DefaultProvider::MigrateObsoleteNotificationPref() { - if (prefs_->HasPrefPath(prefs::kDesktopNotificationDefaultContentSetting)) { - const base::Value* value = prefs_->FindPreference( - prefs::kDesktopNotificationDefaultContentSetting)->GetValue(); - // Do not clear the old preference yet as long as we need to maintain - // backward compatibility. - SetWebsiteSetting( - ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_NOTIFICATIONS, - std::string(), - value->DeepCopy()); - prefs_->ClearPref(prefs::kDesktopNotificationDefaultContentSetting); - } -} - -void DefaultProvider::MigrateObsoleteGeolocationPref() { - if (prefs_->HasPrefPath(prefs::kGeolocationDefaultContentSetting)) { - const base::Value* value = prefs_->FindPreference( - prefs::kGeolocationDefaultContentSetting)->GetValue(); - // Do not clear the old preference yet as long as we need to maintain - // backward compatibility. - SetWebsiteSetting( - ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_GEOLOCATION, - std::string(), - value->DeepCopy()); - } -} - } // namespace content_settings diff --git a/chrome/browser/content_settings/content_settings_default_provider.h b/chrome/browser/content_settings/content_settings_default_provider.h index 7d80e95..fadca25 100644 --- a/chrome/browser/content_settings/content_settings_default_provider.h +++ b/chrome/browser/content_settings/content_settings_default_provider.h @@ -60,9 +60,6 @@ class DefaultProvider : public ObservableProvider { // true and the preference is missing, the local copy will be cleared as well. void ReadDefaultSettings(bool overwrite); - void MigrateObsoleteNotificationPref(); - void MigrateObsoleteGeolocationPref(); - // Called on prefs change. void OnPreferenceChanged(const std::string& pref_name); diff --git a/chrome/browser/content_settings/content_settings_default_provider_unittest.cc b/chrome/browser/content_settings/content_settings_default_provider_unittest.cc index ad31429..9db61172 100644 --- a/chrome/browser/content_settings/content_settings_default_provider_unittest.cc +++ b/chrome/browser/content_settings/content_settings_default_provider_unittest.cc @@ -257,56 +257,3 @@ TEST_F(DefaultProviderTest, OffTheRecord) { true)); otr_provider.ShutdownOnUIThread(); } - -TEST_F(DefaultProviderTest, MigrateDefaultGeolocationContentSettingAfterSync) { - EXPECT_EQ(CONTENT_SETTING_ASK, - GetContentSetting(&provider_, - GURL(), - GURL(), - CONTENT_SETTINGS_TYPE_GEOLOCATION, - std::string(), - false)); - - content_settings::MockObserver mock_observer; - EXPECT_CALL(mock_observer, - OnContentSettingChanged( - _, _, CONTENT_SETTINGS_TYPE_GEOLOCATION, "")); - provider_.AddObserver(&mock_observer); - - // Set obsolete preference and test if it is migrated correctly. This can - // happen when an old version of chrome syncs the obsolete default geolocation - // preference. - PrefService* prefs = profile_.GetPrefs(); - prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, - CONTENT_SETTING_ALLOW); - - EXPECT_EQ(CONTENT_SETTING_ALLOW, - GetContentSetting(&provider_, - GURL(), - GURL(), - CONTENT_SETTINGS_TYPE_GEOLOCATION, - std::string(), - false)); -} - -TEST_F(DefaultProviderTest, MigrateDefaultGeolocationContentSettingAtStartup) { - TestingProfile profile; - TestingPrefService* prefs = profile.GetTestingPrefService(); - - // Set obsolete preference and test if it is migrated correctly. - prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, - CONTENT_SETTING_ALLOW); - // Create a new |DefaultProvider| to test whether the obsolete default - // geolocation setting is correctly migrated. The migrated settings should be - // available right after creation of the provider. - content_settings::DefaultProvider provider(prefs, false); - - EXPECT_EQ(CONTENT_SETTING_ALLOW, - GetContentSetting(&provider, - GURL(), - GURL(), - CONTENT_SETTINGS_TYPE_GEOLOCATION, - std::string(), - false)); - provider.ShutdownOnUIThread(); -} diff --git a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc index 405102f..04f8011 100644 --- a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc +++ b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc @@ -59,24 +59,6 @@ TEST_F(PolicyProviderTest, DefaultGeolocationContentSetting) { false)); EXPECT_FALSE(rule_iterator->HasNext()); - prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, - CONTENT_SETTING_ALLOW); - rule_iterator.reset( - provider.GetRuleIterator( - CONTENT_SETTINGS_TYPE_GEOLOCATION, - std::string(), - false)); - EXPECT_FALSE(rule_iterator->HasNext()); - - prefs->SetManagedPref(prefs::kGeolocationDefaultContentSetting, - Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); - rule_iterator.reset( - provider.GetRuleIterator( - CONTENT_SETTINGS_TYPE_GEOLOCATION, - std::string(), - false)); - EXPECT_FALSE(rule_iterator->HasNext()); - // Change the managed value of the default geolocation setting prefs->SetManagedPref(prefs::kManagedDefaultGeolocationSetting, Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc index e8f1640..7e74ec0 100644 --- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc +++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc @@ -668,30 +668,6 @@ TEST_F(HostContentSettingsMapTest, OffTheRecord) { otr_map->ShutdownOnUIThread(); } -TEST_F(HostContentSettingsMapTest, MigrateObsoleteNotificationsPrefs) { - TestingProfile profile; - PrefService* prefs = profile.GetPrefs(); - - // Set obsolete data. - prefs->SetInteger(prefs::kDesktopNotificationDefaultContentSetting, - CONTENT_SETTING_ALLOW); - - HostContentSettingsMap* host_content_settings_map = - profile.GetHostContentSettingsMap(); - - EXPECT_EQ(CONTENT_SETTING_ALLOW, - host_content_settings_map->GetDefaultContentSetting( - CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL)); - - // Check if the pref was migrated correctly. - const DictionaryValue* default_settings_dictionary = - prefs->GetDictionary(prefs::kDefaultContentSettings); - int value; - default_settings_dictionary->GetIntegerWithoutPathExpansion( - "notifications", &value); - EXPECT_EQ(CONTENT_SETTING_ALLOW, ContentSetting(value)); -} - // For a single Unicode encoded pattern, check if it gets converted to punycode // and old pattern gets deleted. TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeOnly) { |