Commit 7d7577c2 authored by Illia Klimov's avatar Illia Klimov Committed by Commit Bot

Remove resource identifier from HostContentSettingsMap private methods.

As part of the Flash/Plugins deprecation, the resource identifier
becomes obsolete. This CL removes resource_identifier from the
HostContentSettingsMap private methods only.

The rest methods API will be cleaned separately.

Bug: 1134547
Change-Id: Id74420f86abcd91b034af1eb040f09d1d95d456f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517587Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Illia Klimov <elklm@google.com>
Auto-Submit: Illia Klimov <elklm@google.com>
Cr-Commit-Position: refs/heads/master@{#824078}
parent 6412f40b
......@@ -230,23 +230,3 @@ TEST_F(PluginInfoHostImplTest, FindEnabledPlugin) {
EXPECT_EQ(FILE_PATH_LITERAL(""), plugin.path.value());
}
}
TEST_F(PluginInfoHostImplTest, PluginsOnlyAllowedInAllowlistedSchemes) {
host_content_settings_map()->SetDefaultContentSetting(
ContentSettingsType::PLUGINS, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
VerifyPluginContentSetting(GURL("http://example.com"), "foo",
CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, true,
false);
VerifyPluginContentSetting(GURL("https://example.com"), "foo",
CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, true,
false);
VerifyPluginContentSetting(GURL("file://foobar/"), "foo",
CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, true,
false);
VerifyPluginContentSetting(GURL("chrome-extension://extension-id"), "foo",
CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, true,
false);
VerifyPluginContentSetting(GURL("unknown-scheme://foobar"), "foo",
CONTENT_SETTING_BLOCK, true, false);
}
......@@ -19,27 +19,20 @@ TEST(ContentSettingsProviderTest, Mock) {
MockProvider mock_provider(false);
mock_provider.SetWebsiteSetting(
pattern, pattern, ContentSettingsType::PLUGINS, "java_plugin",
pattern, pattern, ContentSettingsType::NOTIFICATIONS, std::string(),
std::make_unique<base::Value>(CONTENT_SETTING_BLOCK));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS,
"java_plugin", false));
ContentSettingsType::NOTIFICATIONS,
std::string(), false));
std::unique_ptr<base::Value> value_ptr(TestUtils::GetContentSettingValue(
&mock_provider, url, url, ContentSettingsType::PLUGINS, "java_plugin",
false));
&mock_provider, url, url, ContentSettingsType::NOTIFICATIONS,
std::string(), false));
int int_value = -1;
value_ptr->GetAsInteger(&int_value);
EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value));
EXPECT_EQ(CONTENT_SETTING_DEFAULT,
TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS,
"flash_plugin", false));
EXPECT_EQ(nullptr, TestUtils::GetContentSettingValue(
&mock_provider, url, url, ContentSettingsType::PLUGINS,
"flash_plugin", false));
EXPECT_EQ(CONTENT_SETTING_DEFAULT,
TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::GEOLOCATION,
......@@ -50,36 +43,36 @@ TEST(ContentSettingsProviderTest, Mock) {
std::string(), false));
bool owned = mock_provider.SetWebsiteSetting(
pattern, pattern, ContentSettingsType::PLUGINS, "java_plugin",
pattern, pattern, ContentSettingsType::NOTIFICATIONS, std::string(),
std::make_unique<base::Value>(CONTENT_SETTING_ALLOW));
EXPECT_TRUE(owned);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS,
"java_plugin", false));
ContentSettingsType::NOTIFICATIONS,
std::string(), false));
mock_provider.set_read_only(true);
std::unique_ptr<base::Value> value(new base::Value(CONTENT_SETTING_BLOCK));
owned = mock_provider.SetWebsiteSetting(pattern, pattern,
ContentSettingsType::PLUGINS,
"java_plugin", std::move(value));
ContentSettingsType::NOTIFICATIONS,
std::string(), std::move(value));
EXPECT_FALSE(owned);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS,
"java_plugin", false));
ContentSettingsType::NOTIFICATIONS,
std::string(), false));
EXPECT_TRUE(mock_provider.read_only());
mock_provider.set_read_only(false);
owned = mock_provider.SetWebsiteSetting(
pattern, pattern, ContentSettingsType::PLUGINS, "java_plugin",
pattern, pattern, ContentSettingsType::NOTIFICATIONS, std::string(),
std::make_unique<base::Value>(CONTENT_SETTING_BLOCK));
EXPECT_TRUE(owned);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS,
"java_plugin", false));
ContentSettingsType::NOTIFICATIONS,
std::string(), false));
}
} // namespace content_settings
......@@ -369,16 +369,15 @@ class HostContentSettingsMap : public content_settings::Observer,
// Collect UMA data of exceptions.
void RecordExceptionMetrics();
// Adds content settings for |content_type| and |resource_identifier|,
// provided by |provider|, into |settings|. If |incognito| is true, adds only
// the content settings which are applicable to the incognito mode and differ
// from the normal mode. Otherwise, adds the content settings for the normal
// mode (applying inheritance rules if |is_off_the_record_|).
// Adds content settings for |content_type| provided by |provider|, into
// |settings|. If |incognito| is true, adds only the content settings which
// are applicable to the incognito mode and differ from the normal mode.
// Otherwise, adds the content settings for the normal mode (applying
// inheritance rules if |is_off_the_record_|).
void AddSettingsForOneType(
const content_settings::ProviderInterface* provider,
ProviderType provider_type,
ContentSettingsType content_type,
const std::string& resource_identifier,
ContentSettingsForOneType* settings,
bool incognito,
base::Optional<content_settings::SessionModel> session_model) const;
......@@ -395,7 +394,6 @@ class HostContentSettingsMap : public content_settings::Observer,
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier,
ProviderType first_provider_to_search,
content_settings::SettingInfo* info) const;
......@@ -409,7 +407,6 @@ class HostContentSettingsMap : public content_settings::Observer,
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier,
bool include_incognito,
ContentSettingsPattern* primary_pattern,
ContentSettingsPattern* secondary_pattern);
......
......@@ -21,7 +21,7 @@ base::Value* TestUtils::GetContentSettingValue(
bool include_incognito) {
return HostContentSettingsMap::GetContentSettingValueAndPatterns(
provider, primary_url, secondary_url, content_type,
resource_identifier, include_incognito, nullptr, nullptr)
include_incognito, nullptr, nullptr)
.release();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment