[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/renderer/pepper/host_dispatcher_wrapper.h" |
| 6 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 7 | #include "build/build_config.h" |
avi | 270d422 | 2015-09-04 22:37:19 | [diff] [blame] | 8 | #include "content/common/frame_messages.h" |
Dave Tapuska | b9fc3ef6 | 2021-01-15 17:25:10 | [diff] [blame] | 9 | #include "content/renderer/pepper/pepper_browser_connection.h" |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 10 | #include "content/renderer/pepper/pepper_hung_plugin_filter.h" |
| 11 | #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 12 | #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" |
| 13 | #include "content/renderer/pepper/plugin_module.h" |
| 14 | #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 15 | #include "content/renderer/pepper/renderer_restrict_dispatch_group.h" |
[email protected] | 6dd625e | 2013-12-20 17:03:07 | [diff] [blame] | 16 | #include "content/renderer/render_frame_impl.h" |
Frédéric Wang | 073e74a | 2020-12-16 17:43:32 | [diff] [blame] | 17 | #include "services/network/public/cpp/is_potentially_trustworthy.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 18 | #include "third_party/blink/public/web/web_document.h" |
| 19 | #include "third_party/blink/public/web/web_plugin_container.h" |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 20 | |
| 21 | namespace content { |
| 22 | |
| 23 | HostDispatcherWrapper::HostDispatcherWrapper( |
| 24 | PluginModule* module, |
| 25 | base::ProcessId peer_pid, |
| 26 | int plugin_child_id, |
| 27 | const ppapi::PpapiPermissions& perms, |
| 28 | bool is_external) |
| 29 | : module_(module), |
| 30 | peer_pid_(peer_pid), |
| 31 | plugin_child_id_(plugin_child_id), |
| 32 | permissions_(perms), |
[email protected] | ad63b5c | 2014-04-11 21:12:36 | [diff] [blame] | 33 | is_external_(is_external) {} |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 34 | |
[email protected] | ad63b5c | 2014-04-11 21:12:36 | [diff] [blame] | 35 | HostDispatcherWrapper::~HostDispatcherWrapper() {} |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 36 | |
Hajime Hoshi | 5959c54f | 2019-01-09 01:42:12 | [diff] [blame] | 37 | bool HostDispatcherWrapper::Init( |
| 38 | const IPC::ChannelHandle& channel_handle, |
| 39 | PP_GetInterface_Func local_get_interface, |
| 40 | const ppapi::Preferences& preferences, |
| 41 | scoped_refptr<PepperHungPluginFilter> filter, |
| 42 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
sammc | 414873fd | 2016-10-18 06:00:47 | [diff] [blame] | 43 | if (!channel_handle.is_mojo_channel_handle()) |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 44 | return false; |
| 45 | |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 46 | dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); |
| 47 | dispatcher_.reset(new ppapi::proxy::HostDispatcher( |
dmichael | 6b328f3d | 2014-09-29 23:49:02 | [diff] [blame] | 48 | module_->pp_module(), local_get_interface, permissions_)); |
| 49 | // The HungPluginFilter needs to know when we are blocked on a sync message |
| 50 | // to the plugin. Note the filter outlives the dispatcher, so there is no |
| 51 | // need to remove it as an observer. |
| 52 | dispatcher_->AddSyncMessageStatusObserver(filter.get()); |
| 53 | // Guarantee the hung_plugin_filter_ outlives |dispatcher_|. |
| 54 | hung_plugin_filter_ = filter; |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 55 | |
Hajime Hoshi | 5959c54f | 2019-01-09 01:42:12 | [diff] [blame] | 56 | if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), peer_pid_, |
[email protected] | 35099ad | 2013-07-26 22:06:39 | [diff] [blame] | 57 | channel_handle, |
| 58 | true, // Client. |
Hajime Hoshi | 5959c54f | 2019-01-09 01:42:12 | [
|