0

Remove Flash debug URLs

Start with Flash debug URLs, and remove lots of code related to
handling them.

Fixed: 1263693
Change-Id: I17f898db54589ec9ddc6450ee77c7b8f329436f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3245978
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#935993}
This commit is contained in:
Avi Drissman
2021-10-28 18:12:54 +00:00
committed by Chromium LUCI CQ
parent def507007a
commit bb0f59d26e
18 changed files with 6 additions and 166 deletions

@@ -79,7 +79,6 @@ class PluginInfoHostImplTest : public ::testing::Test {
PluginInfoHostImplTest()
: foo_plugin_path_(FILE_PATH_LITERAL("/path/to/foo")),
bar_plugin_path_(FILE_PATH_LITERAL("/path/to/bar")),
fake_flash_path_(FILE_PATH_LITERAL("/path/to/fake/flash")),
context_(0, &profile_),
host_content_settings_map_(
HostContentSettingsMapFactory::GetForProfile(&profile_)) {}
@@ -102,14 +101,6 @@ class PluginInfoHostImplTest : public ::testing::Test {
bar_plugin.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS;
PluginService::GetInstance()->RegisterInternalPlugin(bar_plugin, false);
content::WebPluginInfo fake_flash(
base::ASCIIToUTF16(content::kFlashPluginName), fake_flash_path_,
u"100.0", u"Fake Flash Description.");
mime_type.mime_type = "application/x-shockwave-flash";
fake_flash.mime_types.push_back(mime_type);
fake_flash.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS;
PluginService::GetInstance()->RegisterInternalPlugin(fake_flash, false);
PluginService::GetInstance()->SetFilter(&filter_);
#if !defined(OS_WIN)
@@ -136,7 +127,6 @@ class PluginInfoHostImplTest : public ::testing::Test {
base::FilePath foo_plugin_path_;
base::FilePath bar_plugin_path_;
base::FilePath fake_flash_path_;
FakePluginServiceFilter filter_;
private:

@@ -6,7 +6,6 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/plugin_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
@@ -35,13 +34,6 @@ void PluginUtils::GetPluginContentSetting(
ContentSetting* setting,
bool* is_default,
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();
std::unique_ptr<base::Value> value;
content_settings::SettingInfo info;

@@ -461,8 +461,6 @@ static_library("common") {
if (enable_plugins) {
sources += [
"plugin_utils.cc",
"plugin_utils.h",
"ppapi_utils.cc",
"ppapi_utils.h",
]

@@ -1,23 +0,0 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/plugin_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/webplugininfo.h"
bool ShouldUseJavaScriptSettingForPlugin(const content::WebPluginInfo& plugin) {
if (plugin.name == base::ASCIIToUTF16(content::kFlashPluginName))
return false;
// Since all the UI surfaces for Plugin content settings display "Flash",
// treat all other plugins as JavaScript. These include all of:
// - Internally registered plugins such as:
// - NaCl
// - Widevine
// - PDF
// - Custom plugins loaded from the command line
return true;
}

@@ -1,15 +0,0 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_PLUGIN_UTILS_H_
#define CHROME_COMMON_PLUGIN_UTILS_H_
namespace content {
struct WebPluginInfo;
}
// Returns true if |plugin| should use the JavaScript Content Settings.
bool ShouldUseJavaScriptSettingForPlugin(const content::WebPluginInfo& plugin);
#endif // CHROME_COMMON_PLUGIN_UTILS_H_

@@ -674,8 +674,6 @@ const char* const kChromeDebugURLs[] = {
blink::kChromeUIMemoryExhaustURL,
blink::kChromeUIMemoryPressureCriticalURL,
blink::kChromeUIMemoryPressureModerateURL,
blink::kChromeUIPpapiFlashCrashURL,
blink::kChromeUIPpapiFlashHangURL,
#if defined(OS_WIN)
blink::kChromeUIBrowserHeapCorruptionURL,
blink::kChromeUIHeapCorruptionCrashURL,

@@ -218,7 +218,6 @@
#endif // BUILDFLAG(ENABLE_PDF)
#if BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/common/plugin_utils.h"
#include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
#include "ppapi/shared_impl/ppapi_switches.h" // nogncheck crbug.com/1125897
#else
@@ -915,16 +914,6 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
render_frame, original_params);
}
} else {
// Flash is deprecated in M87 and removed in M88+. If a plugin uses flash,
// its status will be |PluginStatus::kNotFound|. If for some reason the
// status is different, we should not treat it as JavaScript plugin but
// return a deprecated message.
if (!ShouldUseJavaScriptSettingForPlugin(info)) {
return NonLoadablePluginPlaceholder::CreateFlashDeprecatedPlaceholder(
render_frame, original_params)
->plugin();
}
// TODO(bauerb): This should be in content/.
WebPluginParams params(original_params);
for (const auto& mime_type : info.mime_types) {

@@ -15,7 +15,6 @@
#include "base/files/file_path.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -50,16 +49,6 @@
namespace content {
namespace {
// This enum is used to collect Flash usage data.
enum FlashUsage {
// Number of browser processes that have started at least one PPAPI Flash
// process during their lifetime.
START_PPAPI_FLASH_AT_LEAST_ONCE = 1,
// Total number of browser processes.
TOTAL_BROWSER_PROCESSES,
FLASH_USAGE_ENUM_COUNT
};
// Callback set on the PluginList to assert that plugin loading happens on the
// correct thread.
void WillLoadPluginsCallback(base::SequenceChecker* sequence_checker) {
@@ -88,20 +77,9 @@ PluginServiceImpl* PluginServiceImpl::GetInstance() {
return base::Singleton<PluginServiceImpl>::get();
}
PluginServiceImpl::PluginServiceImpl() : filter_(nullptr) {
// Collect the total number of browser processes (which create
// PluginServiceImpl objects, to be precise). The number is used to normalize
// the number of processes which start at least one NPAPI/PPAPI Flash process.
static bool counted = false;
if (!counted) {
counted = true;
UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES,
FLASH_USAGE_ENUM_COUNT);
}
}
PluginServiceImpl::PluginServiceImpl() = default;
PluginServiceImpl::~PluginServiceImpl() {
}
PluginServiceImpl::~PluginServiceImpl() = default;
void PluginServiceImpl::Init() {
plugin_list_task_runner_ = base::ThreadPool::CreateSequencedTaskRunner(
@@ -208,15 +186,6 @@ PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess(
if (plugin_host)
return plugin_host;
// Record when PPAPI Flash process is started for the first time.
static bool counted = false;
if (!counted && info->name == kFlashPluginName) {
counted = true;
UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage",
START_PPAPI_FLASH_AT_LEAST_ONCE,
FLASH_USAGE_ENUM_COUNT);
}
// Avoid fork bomb.
if (origin_lock.has_value() && CountPpapiPluginProcessesForProfile(
plugin_path, profile_data_directory) >=

@@ -136,7 +136,7 @@ class CONTENT_EXPORT PluginServiceImpl : public PluginService {
int max_ppapi_processes_per_profile_ = kDefaultMaxPpapiProcessesPerProfile;
// Weak pointer; set during the startup on UI thread and must outlive us.
PluginServiceFilter* filter_;
PluginServiceFilter* filter_ = nullptr;
// Used to load plugins from disk.
scoped_refptr<base::SequencedTaskRunner> plugin_list_task_runner_;

@@ -55,22 +55,6 @@ const char kAsanCorruptHeapBlock[] = "/browser-corrupt-heap-block";
const char kAsanCorruptHeap[] = "/browser-corrupt-heap";
#endif
void HandlePpapiFlashDebugURL(const GURL& url) {
#if BUILDFLAG(ENABLE_PLUGINS)
bool crash = url == blink::kChromeUIPpapiFlashCrashURL;
std::vector<PpapiPluginProcessHost*> hosts;
PpapiPluginProcessHost::FindByName(base::UTF8ToUTF16(kFlashPluginName),
&hosts);
for (auto iter = hosts.begin(); iter != hosts.end(); ++iter) {
if (crash)
(*iter)->Send(new PpapiMsg_Crash());
else
(*iter)->Send(new PpapiMsg_Hang());
}
#endif
}
bool IsAsanDebugURL(const GURL& url) {
if (!(url.is_valid() && url.SchemeIs(kChromeUIScheme) &&
url.DomainIs(kAsanCrashDomain) && url.has_path())) {
@@ -212,13 +196,6 @@ bool HandleDebugURL(const GURL& url,
return true;
}
if (url == blink::kChromeUIPpapiFlashCrashURL ||
url == blink::kChromeUIPpapiFlashHangURL) {
GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(&HandlePpapiFlashDebugURL, url));
return true;
}
if (url == blink::kChromeUIMemoryPressureCriticalURL) {
base::MemoryPressureListener::NotifyMemoryPressure(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);

@@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "base/cpu.h"
#include "base/debug/alias.h"
#include "base/debug/crash_logging.h"
#include "base/files/file_util.h"
#include "base/logging.h"
@@ -19,7 +18,6 @@
#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@@ -136,8 +134,6 @@ bool PpapiThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin)
IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnCreateChannel)
IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnSetNetworkState)
IPC_MESSAGE_HANDLER(PpapiMsg_Crash, OnCrash)
IPC_MESSAGE_HANDLER(PpapiMsg_Hang, OnHang)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -355,24 +351,6 @@ void PpapiThread::OnSetNetworkState(bool online) {
ns->SetOnLine(PP_FromBool(online));
}
void PpapiThread::OnCrash() {
// Intentionally crash upon the request of the browser.
//
// Linker's ICF feature may merge this function with other functions with the
// same definition and it may confuse the crash report processing system.
static int static_variable_to_make_this_function_unique = 0;
base::debug::Alias(&static_variable_to_make_this_function_unique);
volatile int* null_pointer = nullptr;
*null_pointer = 0;
}
void PpapiThread::OnHang() {
// Intentionally hang upon the request of the browser.
for (;;)
base::PlatformThread::Sleep(base::Seconds(1));
}
bool PpapiThread::SetupChannel(base::ProcessId renderer_pid,
int renderer_child_id,
bool incognito,

@@ -95,8 +95,6 @@ class PpapiThread : public ChildThreadImpl,
int renderer_child_id,
bool incognito);
void OnSetNetworkState(bool online);
void OnCrash();
void OnHang();
// Sets up the channel to the given renderer. If |renderer_pid| is
// base::kNullProcessId, the channel is set up to the browser. On success,

@@ -18,8 +18,6 @@ const base::FilePath::CharType kPepperDataDirname[] =
const char kBrowserPluginMimeType[] = "application/browser-plugin";
const char kFlashPluginName[] = "Shockwave Flash";
const size_t kMaxURLDisplayChars = 32 * 1024;
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)

@@ -27,8 +27,6 @@ CONTENT_EXPORT extern const base::FilePath::CharType kPepperDataDirname[];
// The MIME type used for the browser plugin.
CONTENT_EXPORT extern const char kBrowserPluginMimeType[];
CONTENT_EXPORT extern const char kFlashPluginName[];
// The maximum number of characters in the URL that we're willing to accept
// in the browser process. It is set low enough to avoid damage to the browser
// but high enough that a web site can abuse location.hash for a little storage.

@@ -599,12 +599,6 @@ IPC_MESSAGE_CONTROL3(PpapiMsg_CreateChannel,
IPC_MESSAGE_CONTROL1(PpapiMsg_InitializeNaClDispatcher,
ppapi::PpapiNaClPluginArgs /* args */)
// Instructs the plugin process to crash.
IPC_MESSAGE_CONTROL0(PpapiMsg_Crash)
// Instructs the plugin process to hang.
IPC_MESSAGE_CONTROL0(PpapiMsg_Hang)
// Each plugin may be referenced by multiple renderers. We need the instance
// IDs to be unique within a plugin, despite coming from different renderers,
// and unique within a renderer, despite going to different plugins. This means

@@ -43,8 +43,6 @@ const char kChromeUIMemoryPressureModerateURL[] =
"chrome://memory-pressure-moderate/";
const char kChromeUINetworkErrorURL[] = "chrome://network-error/";
const char kChromeUINetworkErrorsListingURL[] = "chrome://network-errors/";
const char kChromeUIPpapiFlashCrashURL[] = "chrome://ppapiflashcrash/";
const char kChromeUIPpapiFlashHangURL[] = "chrome://ppapiflashhang/";
const char kChromeUIProcessInternalsURL[] = "chrome://process-internals";
#if defined(OS_ANDROID)
const char kChromeUIGpuJavaCrashURL[] = "chrome://gpu-java-crash/";

@@ -38,8 +38,6 @@ BLINK_COMMON_EXPORT extern const char kChromeUIMemoryPressureCriticalURL[];
BLINK_COMMON_EXPORT extern const char kChromeUIMemoryPressureModerateURL[];
BLINK_COMMON_EXPORT extern const char kChromeUINetworkErrorsListingURL[];
BLINK_COMMON_EXPORT extern const char kChromeUINetworkErrorURL[];
BLINK_COMMON_EXPORT extern const char kChromeUIPpapiFlashCrashURL[];
BLINK_COMMON_EXPORT extern const char kChromeUIPpapiFlashHangURL[];
BLINK_COMMON_EXPORT extern const char kChromeUIProcessInternalsURL[];
#if defined(OS_ANDROID)
BLINK_COMMON_EXPORT extern const char kChromeUIGpuJavaCrashURL[];

@@ -29,6 +29,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<histogram name="Plugin.FlashUsage" enum="FlashUsage"
expires_after="2022-04-24">
<obsolete>
Removed Oct 2021.
</obsolete>
<owner>yzshen@chromium.org</owner>
<owner>thestig@chromium.org</owner>
<summary>Collects Flash usage data.</summary>