1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// 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.
#include "content/renderer/pepper/host_dispatcher_wrapper.h"
#include "content/common/view_messages.h"
#include "content/renderer/pepper/pepper_hung_plugin_filter.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
#include "content/renderer/pepper/renderer_restrict_dispatch_group.h"
#include "content/renderer/render_view_impl.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
namespace content {
HostDispatcherWrapper::HostDispatcherWrapper(
PluginModule* module,
base::ProcessId peer_pid,
int plugin_child_id,
const ppapi::PpapiPermissions& perms,
bool is_external)
: module_(module),
peer_pid_(peer_pid),
plugin_child_id_(plugin_child_id),
permissions_(perms),
is_external_(is_external) {
}
HostDispatcherWrapper::~HostDispatcherWrapper() {
}
bool HostDispatcherWrapper::Init(const IPC::ChannelHandle& channel_handle,
PP_GetInterface_Func local_get_interface,
const ppapi::Preferences& preferences,
PepperHungPluginFilter* filter) {
if (channel_handle.name.empty())
return false;
#if defined(OS_POSIX)
DCHECK_NE(-1, channel_handle.socket.fd);
if (channel_handle.socket.fd == -1)
return false;
#endif
dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
dispatcher_.reset(new ppapi::proxy::HostDispatcher(
module_->pp_module(), local_get_interface, filter, permissions_));
if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(),
peer_pid_,
channel_handle,
true, // Client.
preferences)) {
dispatcher_.reset();
dispatcher_delegate_.reset();
return false;
}
dispatcher_->channel()->SetRestrictDispatchChannelGroup(
kRendererRestrictDispatchGroup_Pepper);
return true;
}
const void* HostDispatcherWrapper::GetProxiedInterface(const char* name) {
return dispatcher_->GetProxiedInterface(name);
}
void HostDispatcherWrapper::AddInstance(PP_Instance instance) {
ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get());
RendererPpapiHostImpl* host =
RendererPpapiHostImpl::GetForPPInstance(instance);
// TODO(brettw) remove this null check when the old-style pepper-based
// browser tag is removed from this file. Getting this notification should
// always give us an instance we can find in the map otherwise, but that
// isn't true for browser tag support.
if (host) {
RenderView* render_view = host->GetRenderViewForInstance(instance);
PepperPluginInstance* plugin_instance = host->GetPluginInstance(instance);
render_view->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance(
plugin_child_id_,
instance,
PepperRendererInstanceData(
0, // The render process id will be supplied in the browser.
render_view->GetRoutingID(),
plugin_instance->GetContainer()->element().document().url(),
plugin_instance->GetPluginURL()),
is_external_));
}
}
void HostDispatcherWrapper::RemoveInstance(PP_Instance instance) {
ppapi::proxy::HostDispatcher::RemoveForInstance(instance);
RendererPpapiHostImpl* host =
RendererPpapiHostImpl::GetForPPInstance(instance);
// TODO(brettw) remove null check as described in AddInstance.
if (host) {
RenderView* render_view = host->GetRenderViewForInstance(instance);
render_view->Send(new ViewHostMsg_DidDeleteOutOfProcessPepperInstance(
plugin_child_id_,
instance,
is_external_));
}
}
} // namespace content
|