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

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

Issue 2376453003: Remove old, unused per-plugin data from user prefs
Patch Set: Remove old, unused per-plugin data from user prefs Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
diff --git a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
index f6cacd2e4e31dfaece9f4c2b88d7c361b72a69d1..1044f6922447c1ece7aed240892d0af56f856da5 100644
--- a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
+++ b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
@@ -293,37 +293,63 @@ TEST_F(PrefProviderTest, Patterns) {
}
#if defined(ENABLE_PLUGINS)
-TEST_F(PrefProviderTest, ResourceIdentifier) {
+// Old per-plugin pref settings should be deleted when reading settings.
+TEST_F(PrefProviderTest, DeprecateResourceIdentifierPrefs) {
TestingProfile testing_profile;
- PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(),
- false);
+ PrefService* prefs = testing_profile.GetPrefs();
- GURL host("http://example.com/");
- ContentSettingsPattern pattern =
- ContentSettingsPattern::FromString("[*.]example.com");
- std::string resource1("someplugin");
- std::string resource2("otherplugin");
+ std::string pref_name =
+ content_settings::WebsiteSettingsRegistry::GetInstance()
+ ->Get(CONTENT_SETTINGS_TYPE_PLUGINS)
+ ->pref_name();
- EXPECT_EQ(CONTENT_SETTING_DEFAULT,
- TestUtils::GetContentSetting(&pref_content_settings_provider, host,
- host, CONTENT_SETTINGS_TYPE_PLUGINS,
- resource1, false));
- pref_content_settings_provider.SetWebsiteSetting(
- pattern,
- pattern,
- CONTENT_SETTINGS_TYPE_PLUGINS,
- resource1,
- new base::FundamentalValue(CONTENT_SETTING_BLOCK));
- EXPECT_EQ(CONTENT_SETTING_BLOCK,
- TestUtils::GetContentSetting(&pref_content_settings_provider, host,
- host, CONTENT_SETTINGS_TYPE_PLUGINS,
- resource1, false));
- EXPECT_EQ(CONTENT_SETTING_DEFAULT,
- TestUtils::GetContentSetting(&pref_content_settings_provider, host,
- host, CONTENT_SETTINGS_TYPE_PLUGINS,
- resource2, false));
+ // Set an old per-plugin setting.
+ {
+ DictionaryPrefUpdate update(prefs, pref_name);
+ base::DictionaryValue* all_settings_dictionary = update.Get();
+
+ base::DictionaryValue* per_resource_dictionary = new base::DictionaryValue;
+ per_resource_dictionary->SetIntegerWithoutPathExpansion(
+ "plugin_name", CONTENT_SETTING_ALLOW);
+ base::DictionaryValue* settings_dictionary = new base::DictionaryValue;
+ settings_dictionary->SetWithoutPathExpansion("per_resource",
+ per_resource_dictionary);
+
+ base::DictionaryValue* settings_dictionary2 =
+ settings_dictionary->DeepCopy();
+ settings_dictionary2->SetIntegerWithoutPathExpansion("setting",
+ CONTENT_SETTING_ALLOW);
+
+ // This only has a per-plugin setting.
+ all_settings_dictionary->SetWithoutPathExpansion("[*.]test.com,*",
+ settings_dictionary);
+
+ // This has a per-plugin setting and a per-site setting.
+ all_settings_dictionary->SetWithoutPathExpansion("[*.]test2.com,*",
+ settings_dictionary2);
+ }
- pref_content_settings_provider.ShutdownOnUIThread();
+ // Create the pref-provider.
+ PrefProvider pref_content_settings_provider(prefs, false);
+
+ const base::DictionaryValue* all_settings_dictionary =
+ prefs->GetDictionary(pref_name);
+
+ // The pref that only had the per-plugin setting should be gone.
+ const base::DictionaryValue* result;
+ EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
+ "[*.]test.com,*", &result));
+
+ // The pref that had the per-site setting should still be there, but the
+ // per-plugin part should be gone.
+ EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
+ "[*.]test2.com,*", &result));
+ int setting_result;
+ EXPECT_TRUE(
+ result->GetIntegerWithoutPathExpansion("setting", &setting_result));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW, setting_result);
+ EXPECT_FALSE(
+ result->GetDictionaryWithoutPathExpansion("per_resource", nullptr));
}
#endif

Powered by Google App Engine
This is Rietveld 408576698