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) { ...@@ -230,23 +230,3 @@ TEST_F(PluginInfoHostImplTest, FindEnabledPlugin) {
EXPECT_EQ(FILE_PATH_LITERAL(""), plugin.path.value()); 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) { ...@@ -19,27 +19,20 @@ TEST(ContentSettingsProviderTest, Mock) {
MockProvider mock_provider(false); MockProvider mock_provider(false);
mock_provider.SetWebsiteSetting( mock_provider.SetWebsiteSetting(
pattern, pattern, ContentSettingsType::PLUGINS, "java_plugin", pattern, pattern, ContentSettingsType::NOTIFICATIONS, std::string(),
std::make_unique<base::Value>(CONTENT_SETTING_BLOCK)); std::make_unique<base::Value>(CONTENT_SETTING_BLOCK));
EXPECT_EQ(CONTENT_SETTING_BLOCK, EXPECT_EQ(CONTENT_SETTING_BLOCK,
TestUtils::GetContentSetting(&mock_provider, url, url, TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS, ContentSettingsType::NOTIFICATIONS,
"java_plugin", false)); std::string(), false));
std::unique_ptr<base::Value> value_ptr(TestUtils::GetContentSettingValue( std::unique_ptr<base::Value> value_ptr(TestUtils::GetContentSettingValue(
&mock_provider, url, url, ContentSettingsType::PLUGINS, "java_plugin", &mock_provider, url, url, ContentSettingsType::NOTIFICATIONS,
false)); std::string(), false));
int int_value = -1; int int_value = -1;
value_ptr->GetAsInteger(&int_value); value_ptr->GetAsInteger(&int_value);
EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(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, EXPECT_EQ(CONTENT_SETTING_DEFAULT,
TestUtils::GetContentSetting(&mock_provider, url, url, TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::GEOLOCATION, ContentSettingsType::GEOLOCATION,
...@@ -50,36 +43,36 @@ TEST(ContentSettingsProviderTest, Mock) { ...@@ -50,36 +43,36 @@ TEST(ContentSettingsProviderTest, Mock) {
std::string(), false)); std::string(), false));
bool owned = mock_provider.SetWebsiteSetting( 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)); std::make_unique<base::Value>(CONTENT_SETTING_ALLOW));
EXPECT_TRUE(owned); EXPECT_TRUE(owned);
EXPECT_EQ(CONTENT_SETTING_ALLOW, EXPECT_EQ(CONTENT_SETTING_ALLOW,
TestUtils::GetContentSetting(&mock_provider, url, url, TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS, ContentSettingsType::NOTIFICATIONS,
"java_plugin", false)); std::string(), false));
mock_provider.set_read_only(true); mock_provider.set_read_only(true);
std::unique_ptr<base::Value> value(new base::Value(CONTENT_SETTING_BLOCK)); std::unique_ptr<base::Value> value(new base::Value(CONTENT_SETTING_BLOCK));
owned = mock_provider.SetWebsiteSetting(pattern, pattern, owned = mock_provider.SetWebsiteSetting(pattern, pattern,
ContentSettingsType::PLUGINS, ContentSettingsType::NOTIFICATIONS,
"java_plugin", std::move(value)); std::string(), std::move(value));
EXPECT_FALSE(owned); EXPECT_FALSE(owned);
EXPECT_EQ(CONTENT_SETTING_ALLOW, EXPECT_EQ(CONTENT_SETTING_ALLOW,
TestUtils::GetContentSetting(&mock_provider, url, url, TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS, ContentSettingsType::NOTIFICATIONS,
"java_plugin", false)); std::string(), false));
EXPECT_TRUE(mock_provider.read_only()); EXPECT_TRUE(mock_provider.read_only());
mock_provider.set_read_only(false); mock_provider.set_read_only(false);
owned = mock_provider.SetWebsiteSetting( owned = mock_provider.SetWebsiteSetting(
pattern, pattern, ContentSettingsType::PLUGINS, "java_plugin", pattern, pattern, ContentSettingsType::NOTIFICATIONS, std::string(),
std::make_unique<base::Value>(CONTENT_SETTING_BLOCK)); std::make_unique<base::Value>(CONTENT_SETTING_BLOCK));
EXPECT_TRUE(owned); EXPECT_TRUE(owned);
EXPECT_EQ(CONTENT_SETTING_BLOCK, EXPECT_EQ(CONTENT_SETTING_BLOCK,
TestUtils::GetContentSetting(&mock_provider, url, url, TestUtils::GetContentSetting(&mock_provider, url, url,
ContentSettingsType::PLUGINS, ContentSettingsType::NOTIFICATIONS,
"java_plugin", false)); std::string(), false));
} }
} // namespace content_settings } // namespace content_settings
...@@ -369,16 +369,15 @@ class HostContentSettingsMap : public content_settings::Observer, ...@@ -369,16 +369,15 @@ class HostContentSettingsMap : public content_settings::Observer,
// Collect UMA data of exceptions. // Collect UMA data of exceptions.
void RecordExceptionMetrics(); void RecordExceptionMetrics();
// Adds content settings for |content_type| and |resource_identifier|, // Adds content settings for |content_type| provided by |provider|, into
// provided by |provider|, into |settings|. If |incognito| is true, adds only // |settings|. If |incognito| is true, adds only the content settings which
// the content settings which are applicable to the incognito mode and differ // are applicable to the incognito mode and differ from the normal mode.
// from the normal mode. Otherwise, adds the content settings for the normal // Otherwise, adds the content settings for the normal mode (applying
// mode (applying inheritance rules if |is_off_the_record_|). // inheritance rules if |is_off_the_record_|).
void AddSettingsForOneType( void AddSettingsForOneType(
const content_settings::ProviderInterface* provider, const content_settings::ProviderInterface* provider,
ProviderType provider_type, ProviderType provider_type,
ContentSettingsType content_type, ContentSettingsType content_type,
const std::string& resource_identifier,
ContentSettingsForOneType* settings, ContentSettingsForOneType* settings,
bool incognito, bool incognito,
base::Optional<content_settings::SessionModel> session_model) const; base::Optional<content_settings::SessionModel> session_model) const;
...@@ -395,7 +394,6 @@ class HostContentSettingsMap : public content_settings::Observer, ...@@ -395,7 +394,6 @@ class HostContentSettingsMap : public content_settings::Observer,
const GURL& primary_url, const GURL& primary_url,
const GURL& secondary_url, const GURL& secondary_url,
ContentSettingsType content_type, ContentSettingsType content_type,
const std::string& resource_identifier,
ProviderType first_provider_to_search, ProviderType first_provider_to_search,
content_settings::SettingInfo* info) const; content_settings::SettingInfo* info) const;
...@@ -409,7 +407,6 @@ class HostContentSettingsMap : public content_settings::Observer, ...@@ -409,7 +407,6 @@ class HostContentSettingsMap : public content_settings::Observer,
const GURL& primary_url, const GURL& primary_url,
const GURL& secondary_url, const GURL& secondary_url,
ContentSettingsType content_type, ContentSettingsType content_type,
const std::string& resource_identifier,
bool include_incognito, bool include_incognito,
ContentSettingsPattern* primary_pattern, ContentSettingsPattern* primary_pattern,
ContentSettingsPattern* secondary_pattern); ContentSettingsPattern* secondary_pattern);
......
...@@ -21,7 +21,7 @@ base::Value* TestUtils::GetContentSettingValue( ...@@ -21,7 +21,7 @@ base::Value* TestUtils::GetContentSettingValue(
bool include_incognito) { bool include_incognito) {
return HostContentSettingsMap::GetContentSettingValueAndPatterns( return HostContentSettingsMap::GetContentSettingValueAndPatterns(
provider, primary_url, secondary_url, content_type, provider, primary_url, secondary_url, content_type,
resource_identifier, include_incognito, nullptr, nullptr) include_incognito, nullptr, nullptr)
.release(); .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