0
Files
android_webview
apps
ash
base
blink
build
build_overrides
cc
chrome
chrome_cleaner
chrome_elf
chromecast
chromeos
cloud_print
components
content
app
browser
accessibility
android
appcache
background_fetch
background_sync
blob_storage
bluetooth
broadcast_channel
browser_plugin
browsing_data
cache_storage
cocoa
compositor
dedicated_worker
device_sensors
devtools
dom_storage
download
fileapi
frame_host
generic_sensor
geolocation
gpu
hyphenation
image_capture
indexed_db
installedapp
keyboard_lock
loader
locks
manifest
media
memory
net
notifications
origin_manifest
payments
permissions
presentation
push_messaging
renderer_host
resources
screen_orientation
service_manager
service_worker
shape_detection
shared_worker
speech
ssl
streams
tracing
wake_lock
web_contents
web_package
webauth
webrtc
websockets
webui
zygote_host
BUILD.gn
DEPS
OWNERS
PRESUBMIT.py
after_startup_task_utils.cc
after_startup_task_utils.h
bad_message.cc
bad_message.h
battery_monitor_browsertest.cc
bookmarklet_browsertest.cc
browser_associated_interface_unittest.cc
browser_child_process_host_impl.cc
browser_child_process_host_impl.h
browser_context.cc
browser_ipc_logging.cc
browser_main.cc
browser_main.h
browser_main_loop.cc
browser_main_loop.h
browser_main_loop_unittest.cc
browser_main_runner.cc
browser_process_sub_thread.cc
browser_process_sub_thread.h
browser_shutdown_profile_dumper.cc
browser_shutdown_profile_dumper.h
browser_side_navigation_browsertest.cc
browser_thread_impl.cc
browser_thread_impl.h
browser_thread_unittest.cc
browser_url_handler_impl.cc
browser_url_handler_impl.h
browser_url_handler_impl_unittest.cc
browsing_instance.cc
browsing_instance.h
byte_stream.cc
byte_stream.h
byte_stream_unittest.cc
child_process_launcher.cc
child_process_launcher.h
child_process_launcher_browsertest.cc
child_process_launcher_helper.cc
child_process_launcher_helper.h
child_process_launcher_helper_android.cc
child_process_launcher_helper_fuchsia.cc
child_process_launcher_helper_linux.cc
child_process_launcher_helper_mac.cc
child_process_launcher_helper_posix.cc
child_process_launcher_helper_posix.h
child_process_launcher_helper_win.cc
child_process_security_policy_browsertest.cc
child_process_security_policy_impl.cc
child_process_security_policy_impl.h
child_process_security_policy_unittest.cc
context_factory.cc
cross_site_transfer_browsertest.cc
database_browsertest.cc
discardable_shared_memory_manager.cc
do_not_track_browsertest.cc
field_trial_recorder.cc
field_trial_recorder.h
file_url_loader_factory.cc
file_url_loader_factory.h
find_request_manager.cc
find_request_manager.h
find_request_manager_browsertest.cc
font_list_async.cc
generic_sensor_browsertest.cc
histogram_controller.cc
histogram_controller.h
histogram_internals_request_job.cc
histogram_internals_request_job.h
histogram_internals_url_loader.cc
histogram_internals_url_loader.h
histogram_subscriber.h
histogram_synchronizer.cc
histogram_synchronizer.h
host_zoom_level_context.cc
host_zoom_level_context.h
host_zoom_map_impl.cc
host_zoom_map_impl.h
host_zoom_map_impl_browsertest.cc
host_zoom_map_impl_unittest.cc
host_zoom_map_observer.cc
host_zoom_map_observer.h
interface_provider_filtering.cc
interface_provider_filtering.h
isolated_origin_browsertest.cc
isolated_origin_util.cc
isolated_origin_util.h
leveldb_wrapper_impl.cc
leveldb_wrapper_impl.h
leveldb_wrapper_impl_unittest.cc
linux_ipc_browsertest.cc
loader_delegate_impl.cc
loader_delegate_impl.h
mach_broker_mac.h
mach_broker_mac.mm
mach_broker_mac_unittest.cc
message_port_provider.cc
message_port_provider_browsertest.cc
mime_registry_impl.cc
mime_registry_impl.h
mojo_sandbox_browsertest.cc
net_info_browsertest.cc
network_service_browsertest.cc
network_service_client.cc
network_service_client.h
network_service_instance.cc
network_service_restart_browsertest.cc
notification_service_impl.cc
notification_service_impl.h
notification_service_impl_unittest.cc
oop_browsertest.cc
pepper_flash_settings_helper_impl.cc
pepper_flash_settings_helper_impl.h
plugin_content_origin_whitelist.cc
plugin_content_origin_whitelist.h
plugin_data_remover_impl.cc
plugin_data_remover_impl.h
plugin_private_storage_helper.cc
plugin_private_storage_helper.h
plugin_service_impl.cc
plugin_service_impl.h
plugin_service_impl_browsertest.cc
plugin_service_impl_unittest.cc
pointer_lock_browsertest.cc
pointer_lock_browsertest.h
pointer_lock_browsertest_mac.mm
posix_file_descriptor_info_impl.cc
posix_file_descriptor_info_impl.h
posix_file_descriptor_info_impl_unittest.cc
power_monitor_browsertest.cc
ppapi_plugin_process_host.cc
ppapi_plugin_process_host.h
quota_dispatcher_host.cc
quota_dispatcher_host.h
renderer_interface_binders.cc
renderer_interface_binders.h
resolve_proxy_msg_helper.cc
resolve_proxy_msg_helper.h
resolve_proxy_msg_helper_unittest.cc
resource_context_impl.cc
resource_context_impl.h
resource_loading_browsertest.cc
sandbox_host_linux.cc
sandbox_host_linux.h
sandbox_ipc_linux.cc
sandbox_ipc_linux.h
sandbox_parameters_mac.h
sandbox_parameters_mac.mm
scoped_active_url.cc
scoped_active_url.h
security_exploit_browsertest.cc
session_history_browsertest.cc
shareable_file_reference_unittest.cc
site_instance_impl.cc
site_instance_impl.h
site_instance_impl_unittest.cc
site_isolation_policy.cc
site_isolation_policy.h
site_isolation_policy_unittest.cc
site_per_process_browsertest.cc
site_per_process_browsertest.h
site_per_process_hit_test_browsertest.cc
site_per_process_mac_browsertest.mm
snapshot_browsertest.cc
ssl_private_key_impl.cc
ssl_private_key_impl.h
startup_task_runner.cc
startup_task_runner.h
startup_task_runner_unittest.cc
storage_partition_impl.cc
storage_partition_impl.h
storage_partition_impl_browsertest.cc
storage_partition_impl_map.cc
storage_partition_impl_map.h
storage_partition_impl_map_unittest.cc
storage_partition_impl_unittest.cc
theme_helper_mac.h
theme_helper_mac.mm
top_document_isolation_browsertest.cc
url_loader_factory_getter.cc
url_loader_factory_getter.h
utility_process_host_impl.cc
utility_process_host_impl.h
utility_process_host_impl_browsertest.cc
vibration_browsertest.cc
web_contents_binding_set_browsertest.cc
webkit_browsertest.cc
zoom_browsertest.cc
child
common
gpu
ppapi_plugin
public
renderer
shell
test
utility
zygote
BUILD.gn
DEPS
OWNERS
README.md
content_resources.grd
courgette
crypto
dbus
device
docs
extensions
gin
google_apis
google_update
gpu
headless
infra
ios
ipc
jingle
mash
media
mojo
native_client_sdk
net
notification_helper
pdf
ppapi
printing
remoting
rlz
sandbox
services
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
.clang-format
.eslintrc.js
.git-blame-ignore-revs
.gitattributes
.gitignore
.gn
.vpython
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
DEPS
ENG_REVIEW_OWNERS
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings
src/content/browser/plugin_service_impl.h
Tom Sepez f84d722890 Add mechanism to count PDF PPAPI processes in browser tests
Call it as appropriate in pdf_extension_test.cc

Split off from https://chromium-review.googlesource.com/c/chromium/src/+/922727
so as to get a baseline before making further changes.

Bug: 809614
Change-Id: I85e947230fd4f87547dac169e2271c2510c41b29
Reviewed-on: https://chromium-review.googlesource.com/953712
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541866}
2018-03-08 19:34:50 +00:00

183 lines
6.9 KiB
C++

// Copyright (c) 2012 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.
// This class responds to requests from renderers for the list of plugins, and
// also a proxy object for plugin instances.
#ifndef CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_
#define CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_
#include "ppapi/features/features.h"
#if !BUILDFLAG(ENABLE_PLUGINS)
#error "Plugins should be enabled"
#endif
#include <map>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
#include "base/optional.h"
#include "base/sequence_checker.h"
#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event_watcher.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/browser/ppapi_plugin_process_host.h"
#include "content/common/content_export.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/common/pepper_plugin_info.h"
#include "ipc/ipc_channel_handle.h"
#include "url/gurl.h"
#include "url/origin.h"
#if defined(OS_WIN)
#include "base/win/registry.h"
#endif
#if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID)
#include "base/files/file_path_watcher.h"
#endif
namespace content {
class BrowserContext;
class PluginServiceFilter;
class ResourceContext;
struct PepperPluginInfo;
class CONTENT_EXPORT PluginServiceImpl : public PluginService {
public:
// Returns the PluginServiceImpl singleton.
static PluginServiceImpl* GetInstance();
// PluginService implementation:
void Init() override;
bool GetPluginInfoArray(const GURL& url,
const std::string& mime_type,
bool allow_wildcard,
std::vector<WebPluginInfo>* info,
std::vector<std::string>* actual_mime_types) override;
bool GetPluginInfo(int render_process_id,
int render_frame_id,
ResourceContext* context,
const GURL& url,
const url::Origin& main_frame_origin,
const std::string& mime_type,
bool allow_wildcard,
bool* is_stale,
WebPluginInfo* info,
std::string* actual_mime_type) override;
bool GetPluginInfoByPath(const base::FilePath& plugin_path,
WebPluginInfo* info) override;
base::string16 GetPluginDisplayNameByPath(
const base::FilePath& path) override;
void GetPlugins(GetPluginsCallback callback) override;
PepperPluginInfo* GetRegisteredPpapiPluginInfo(
const base::FilePath& plugin_path) override;
void SetFilter(PluginServiceFilter* filter) override;
PluginServiceFilter* GetFilter() override;
bool IsPluginUnstable(const base::FilePath& plugin_path) override;
void RefreshPlugins() override;
void RegisterInternalPlugin(const WebPluginInfo& info,
bool add_at_beginning) override;
void UnregisterInternalPlugin(const base::FilePath& path) override;
void GetInternalPlugins(std::vector<WebPluginInfo>* plugins) override;
bool PpapiDevChannelSupported(BrowserContext* browser_context,
const GURL& document_url) override;
int CountPpapiPluginProcessesForProfile(
const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory) override;
// Returns the plugin process host corresponding to the plugin process that
// has been started by this service. This will start a process to host the
// 'plugin_path' if needed. If the process fails to start, the return value
// is NULL. Must be called on the IO thread.
PpapiPluginProcessHost* FindOrStartPpapiPluginProcess(
int render_process_id,
const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock);
PpapiPluginProcessHost* FindOrStartPpapiBrokerProcess(
int render_process_id, const base::FilePath& plugin_path);
// Opens a channel to a plugin process for the given mime type, starting
// a new plugin process if necessary. This must be called on the IO thread
// or else a deadlock can occur.
void OpenChannelToPpapiPlugin(int render_process_id,
const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock,
PpapiPluginProcessHost::PluginClient* client);
void OpenChannelToPpapiBroker(int render_process_id,
int render_frame_id,
const base::FilePath& path,
PpapiPluginProcessHost::BrokerClient* client);
// Used to monitor plugin stability.
void RegisterPluginCrash(const base::FilePath& plugin_path);
// For testing without creating many, many processes.
void SetMaxPpapiProcessesPerProfileForTesting(int number) {
max_ppapi_processes_per_profile_ = number;
}
private:
friend struct base::DefaultSingletonTraits<PluginServiceImpl>;
// Pulled out of the air, seems reasonable.
static constexpr int kDefaultMaxPpapiProcessesPerProfile = 15;
// Helper for recording URLs to UKM.
static void RecordBrokerUsage(int render_process_id, int render_frame_id);
// Creates the PluginServiceImpl object, but doesn't actually build the plugin
// list yet. It's generated lazily.
PluginServiceImpl();
~PluginServiceImpl() override;
#if defined(OS_WIN)
void OnKeyChanged(base::win::RegKey* key);
#endif
// Returns the plugin process host corresponding to the plugin process that
// has been started by this service. Returns NULL if no process has been
// started.
PpapiPluginProcessHost* FindPpapiPluginProcess(
const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock);
PpapiPluginProcessHost* FindPpapiBrokerProcess(
const base::FilePath& broker_path);
void RegisterPepperPlugins();
// Loads the plugins synchronously in a thread pool.
std::vector<WebPluginInfo> GetPluginsInternal();
std::vector<PepperPluginInfo> ppapi_plugins_;
int max_ppapi_processes_per_profile_ = kDefaultMaxPpapiProcessesPerProfile;
// Weak pointer; outlives us.
PluginServiceFilter* filter_;
// Used to load plugins from disk.
scoped_refptr<base::SequencedTaskRunner> plugin_list_task_runner_;
// Used to verify that loading plugins from disk is done sequentially.
base::SequenceChecker plugin_list_sequence_checker_;
// Used to detect if a given plugin is crashing over and over.
std::map<base::FilePath, std::vector<base::Time> > crash_times_;
DISALLOW_COPY_AND_ASSIGN(PluginServiceImpl);
};
} // namespace content
#endif // CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_