Commit 8643e471 authored by Illia Klimov's avatar Illia Klimov Committed by Chromium LUCI CQ

Remove ContentSettingsType::PLUGINS from PluginUtils.

Flash is deprecated since M87 and almost entirely removed in M88+.
This CL removes ContentSettingsType::PLUGINS from PluginUtils and
returns CONTENT_SETTING_BLOCK for any Flash-related request.

Bug: 1149393
Change-Id: I7649e568e634556a698edc066efba70b53a1f291
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582219
Commit-Queue: Illia Klimov <elklm@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835875}
parent 847ffbc3
...@@ -253,7 +253,6 @@ void PluginInfoHostImpl::Context::DecidePluginStatus( ...@@ -253,7 +253,6 @@ void PluginInfoHostImpl::Context::DecidePluginStatus(
&is_managed); &is_managed);
DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
DCHECK(plugin_setting != CONTENT_SETTING_ASK);
if (*status == chrome::mojom::PluginStatus::kFlashHiddenPreferHtml) { if (*status == chrome::mojom::PluginStatus::kFlashHiddenPreferHtml) {
if (plugin_setting == CONTENT_SETTING_BLOCK) { if (plugin_setting == CONTENT_SETTING_BLOCK) {
...@@ -295,7 +294,7 @@ void PluginInfoHostImpl::Context::DecidePluginStatus( ...@@ -295,7 +294,7 @@ void PluginInfoHostImpl::Context::DecidePluginStatus(
} }
#endif // BUILDFLAG(ENABLE_EXTENSIONS) #endif // BUILDFLAG(ENABLE_EXTENSIONS)
if (plugin_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT || if (plugin_setting == CONTENT_SETTING_ASK ||
(plugin_setting == CONTENT_SETTING_ALLOW && (plugin_setting == CONTENT_SETTING_ALLOW &&
!run_all_flash_in_allow_mode_.GetValue())) { !run_all_flash_in_allow_mode_.GetValue())) {
*status = chrome::mojom::PluginStatus::kPlayImportantContent; *status = chrome::mojom::PluginStatus::kPlayImportantContent;
......
...@@ -142,30 +142,6 @@ class PluginInfoHostImplTest : public ::testing::Test { ...@@ -142,30 +142,6 @@ class PluginInfoHostImplTest : public ::testing::Test {
return host_content_settings_map_; return host_content_settings_map_;
} }
void VerifyPluginContentSetting(const GURL& url,
const std::string& plugin,
ContentSetting expected_setting,
bool expected_is_default,
bool expected_is_managed) {
ContentSetting setting = expected_setting == CONTENT_SETTING_DEFAULT
? CONTENT_SETTING_BLOCK
: CONTENT_SETTING_DEFAULT;
bool is_default = !expected_is_default;
bool is_managed = !expected_is_managed;
// Pass in a fake Flash plugin info.
content::WebPluginInfo plugin_info(
base::ASCIIToUTF16("Shockwave Flash"), base::FilePath(),
base::ASCIIToUTF16("1"), base::ASCIIToUTF16("Fake Flash"));
PluginUtils::GetPluginContentSetting(
host_content_settings_map_, plugin_info, url::Origin::Create(url), url,
plugin, &setting, &is_default, &is_managed);
EXPECT_EQ(expected_setting, setting);
EXPECT_EQ(expected_is_default, is_default);
EXPECT_EQ(expected_is_managed, is_managed);
}
base::FilePath foo_plugin_path_; base::FilePath foo_plugin_path_;
base::FilePath bar_plugin_path_; base::FilePath bar_plugin_path_;
base::FilePath fake_flash_path_; base::FilePath fake_flash_path_;
......
...@@ -25,50 +25,30 @@ ...@@ -25,50 +25,30 @@
#include "extensions/common/manifest_handlers/mime_types_handler.h" #include "extensions/common/manifest_handlers/mime_types_handler.h"
#endif #endif
namespace { // static
void PluginUtils::GetPluginContentSetting(
const char kFlashPluginID[] = "adobe-flash-player";
void GetPluginContentSettingInternal(
const HostContentSettingsMap* host_content_settings_map, const HostContentSettingsMap* host_content_settings_map,
bool use_javascript_setting, const content::WebPluginInfo& plugin,
const url::Origin& main_frame_origin, const url::Origin& main_frame_origin,
const GURL& plugin_url, const GURL& plugin_url,
const std::string& resource, const std::string& resource,
ContentSetting* setting, ContentSetting* setting,
bool* is_default, bool* is_default,
bool* is_managed) { bool* is_managed) {
// Not JS means Flash. Flash is deprecated.
if (!ShouldUseJavaScriptSettingForPlugin(plugin)) {
*is_default = true;
*setting = CONTENT_SETTING_BLOCK;
return;
}
GURL main_frame_url = main_frame_origin.GetURL(); GURL main_frame_url = main_frame_origin.GetURL();
std::unique_ptr<base::Value> value; std::unique_ptr<base::Value> value;
content_settings::SettingInfo info; content_settings::SettingInfo info;
bool uses_plugin_specific_setting = false; bool uses_plugin_specific_setting = false;
if (use_javascript_setting) { value = host_content_settings_map->GetWebsiteSetting(
value = host_content_settings_map->GetWebsiteSetting( main_frame_url, main_frame_url, ContentSettingsType::JAVASCRIPT, &info);
main_frame_url, main_frame_url, ContentSettingsType::JAVASCRIPT, &info);
} else {
content_settings::SettingInfo specific_info;
std::unique_ptr<base::Value> specific_setting =
host_content_settings_map->GetWebsiteSetting(
main_frame_url, plugin_url, ContentSettingsType::PLUGINS,
&specific_info);
content_settings::SettingInfo general_info;
std::unique_ptr<base::Value> general_setting =
host_content_settings_map->GetWebsiteSetting(
main_frame_url, plugin_url, ContentSettingsType::PLUGINS,
&general_info);
// If there is a plugin-specific setting, we use it, unless the general
// setting was set by policy, in which case it takes precedence.
uses_plugin_specific_setting =
specific_setting &&
general_info.source != content_settings::SETTING_SOURCE_POLICY;
if (uses_plugin_specific_setting) {
value = std::move(specific_setting);
info = specific_info;
} else {
value = std::move(general_setting);
info = general_info;
}
}
*setting = content_settings::ValueToContentSetting(value.get()); *setting = content_settings::ValueToContentSetting(value.get());
bool uses_default_content_setting = bool uses_default_content_setting =
...@@ -80,59 +60,6 @@ void GetPluginContentSettingInternal( ...@@ -80,59 +60,6 @@ void GetPluginContentSettingInternal(
*is_default = uses_default_content_setting; *is_default = uses_default_content_setting;
if (is_managed) if (is_managed)
*is_managed = info.source == content_settings::SETTING_SOURCE_POLICY; *is_managed = info.source == content_settings::SETTING_SOURCE_POLICY;
// Special behavior for non-JavaScript treated plugins (Flash):
if (!use_javascript_setting) {
// ALLOW-by-default is obsolete and should be treated as DETECT.
if (*setting == CONTENT_SETTING_ALLOW && uses_default_content_setting)
*setting = CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
// Unless the setting is explicitly ALLOW, return BLOCK for any scheme that
// is not HTTP, HTTPS, FILE, or chrome-extension.
if (*setting != CONTENT_SETTING_ALLOW &&
!main_frame_url.SchemeIsHTTPOrHTTPS() &&
!main_frame_url.SchemeIsFile() &&
!main_frame_url.SchemeIs(extensions::kExtensionScheme)) {
*setting = CONTENT_SETTING_BLOCK;
}
}
// For Plugins, ASK is obsolete. Show as DETECT_IMPORTANT_CONTENT to reflect
// actual behavior.
if (*setting == ContentSetting::CONTENT_SETTING_ASK)
*setting = ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
}
} // namespace
// static
void PluginUtils::GetPluginContentSetting(
const HostContentSettingsMap* host_content_settings_map,
const content::WebPluginInfo& plugin,
const url::Origin& main_frame_origin,
const GURL& plugin_url,
const std::string& resource,
ContentSetting* setting,
bool* uses_default_content_setting,
bool* is_managed) {
GetPluginContentSettingInternal(
host_content_settings_map, ShouldUseJavaScriptSettingForPlugin(plugin),
main_frame_origin, plugin_url, resource, setting,
uses_default_content_setting, is_managed);
}
// static
ContentSetting PluginUtils::GetFlashPluginContentSetting(
const HostContentSettingsMap* host_content_settings_map,
const url::Origin& main_frame_origin,
const GURL& plugin_url,
bool* is_managed) {
ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
GetPluginContentSettingInternal(host_content_settings_map,
false /* use_javascript_setting */,
main_frame_origin, plugin_url, kFlashPluginID,
&plugin_setting, nullptr, is_managed);
return plugin_setting;
} }
// static // static
......
...@@ -37,14 +37,6 @@ class PluginUtils { ...@@ -37,14 +37,6 @@ class PluginUtils {
bool* is_default, bool* is_default,
bool* is_managed); bool* is_managed);
// Returns the content setting for Flash. This is the same as
// |GetPluginContentSetting| but flash-specific.
static ContentSetting GetFlashPluginContentSetting(
const HostContentSettingsMap* host_content_settings_map,
const url::Origin& main_frame_origin,
const GURL& plugin_url,
bool* is_managed);
// If there's an extension that is allowed to handle |mime_type|, returns its // If there's an extension that is allowed to handle |mime_type|, returns its
// ID. Otherwise returns an empty string. // ID. Otherwise returns an empty string.
static std::string GetExtensionIdForMimeType( static std::string GetExtensionIdForMimeType(
......
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