summaryrefslogtreecommitdiffstats
path: root/content/plugin
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-02 19:06:56 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-02 19:06:56 +0000
commitc48de1a9346a8a674c52e61bf97b2387a37084c3 (patch)
treeddc597b4383b914bd27cc110bd440be8b9465c5b /content/plugin
parent30664b3286a3e4a5f898fac1fd58bcaa861b32ed (diff)
downloadchromium_src-c48de1a9346a8a674c52e61bf97b2387a37084c3.zip
chromium_src-c48de1a9346a8a674c52e61bf97b2387a37084c3.tar.gz
chromium_src-c48de1a9346a8a674c52e61bf97b2387a37084c3.tar.bz2
Use the RenderView's routing_id, instead of HWND, as the unique identifier used in plugin code as a key for the page-wide event used to enable nested message loops.
Review URL: https://codereview.chromium.org/11367056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/plugin')
-rw-r--r--content/plugin/plugin_channel.cc51
-rw-r--r--content/plugin/plugin_channel.h3
-rw-r--r--content/plugin/webplugin_delegate_stub.cc7
-rw-r--r--content/plugin/webplugin_proxy.cc6
-rw-r--r--content/plugin/webplugin_proxy.h3
5 files changed, 30 insertions, 40 deletions
diff --git a/content/plugin/plugin_channel.cc b/content/plugin/plugin_channel.cc
index 7bf0858..36dd194 100644
--- a/content/plugin/plugin_channel.cc
+++ b/content/plugin/plugin_channel.cc
@@ -44,33 +44,32 @@ class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter {
public:
MessageFilter() : channel_(NULL) { }
- base::WaitableEvent* GetModalDialogEvent(
- gfx::NativeViewId containing_window) {
+ base::WaitableEvent* GetModalDialogEvent(int render_view_id) {
base::AutoLock auto_lock(modal_dialog_event_map_lock_);
- if (!modal_dialog_event_map_.count(containing_window)) {
+ if (!modal_dialog_event_map_.count(render_view_id)) {
NOTREACHED();
return NULL;
}
- return modal_dialog_event_map_[containing_window].event;
+ return modal_dialog_event_map_[render_view_id].event;
}
// Decrement the ref count associated with the modal dialog event for the
// given tab.
- void ReleaseModalDialogEvent(gfx::NativeViewId containing_window) {
+ void ReleaseModalDialogEvent(int render_view_id) {
base::AutoLock auto_lock(modal_dialog_event_map_lock_);
- if (!modal_dialog_event_map_.count(containing_window)) {
+ if (!modal_dialog_event_map_.count(render_view_id)) {
NOTREACHED();
return;
}
- if (--(modal_dialog_event_map_[containing_window].refcount))
+ if (--(modal_dialog_event_map_[render_view_id].refcount))
return;
// Delete the event when the stack unwinds as it could be in use now.
MessageLoop::current()->DeleteSoon(
- FROM_HERE, modal_dialog_event_map_[containing_window].event);
- modal_dialog_event_map_.erase(containing_window);
+ FROM_HERE, modal_dialog_event_map_[render_view_id].event);
+ modal_dialog_event_map_.erase(render_view_id);
}
bool Send(IPC::Message* message) {
@@ -93,8 +92,6 @@ class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter {
message.type() == PluginMsg_ResetModalDialogEvent::ID;
}
-
-
protected:
virtual ~MessageFilter() {
// Clean up in case of renderer crash.
@@ -107,34 +104,34 @@ class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter {
private:
void OnInit(const PluginMsg_Init_Params& params, IPC::Message* reply_msg) {
base::AutoLock auto_lock(modal_dialog_event_map_lock_);
- if (modal_dialog_event_map_.count(params.containing_window)) {
- modal_dialog_event_map_[params.containing_window].refcount++;
+ if (modal_dialog_event_map_.count(params.host_render_view_routing_id)) {
+ modal_dialog_event_map_[params.host_render_view_routing_id].refcount++;
return;
}
WaitableEventWrapper wrapper;
wrapper.event = new base::WaitableEvent(true, false);
wrapper.refcount = 1;
- modal_dialog_event_map_[params.containing_window] = wrapper;
+ modal_dialog_event_map_[params.host_render_view_routing_id] = wrapper;
}
- void OnSignalModalDialogEvent(gfx::NativeViewId containing_window) {
+ void OnSignalModalDialogEvent(int render_view_id) {
base::AutoLock auto_lock(modal_dialog_event_map_lock_);
- if (modal_dialog_event_map_.count(containing_window))
- modal_dialog_event_map_[containing_window].event->Signal();
+ if (modal_dialog_event_map_.count(render_view_id))
+ modal_dialog_event_map_[render_view_id].event->Signal();
}
- void OnResetModalDialogEvent(gfx::NativeViewId containing_window) {
+ void OnResetModalDialogEvent(int render_view_id) {
base::AutoLock auto_lock(modal_dialog_event_map_lock_);
- if (modal_dialog_event_map_.count(containing_window))
- modal_dialog_event_map_[containing_window].event->Reset();
+ if (modal_dialog_event_map_.count(render_view_id))
+ modal_dialog_event_map_[render_view_id].event->Reset();
}
struct WaitableEventWrapper {
base::WaitableEvent* event;
int refcount; // There could be multiple plugin instances per tab.
};
- typedef std::map<gfx::NativeViewId, WaitableEventWrapper> ModalDialogEventMap;
+ typedef std::map<int, WaitableEventWrapper> ModalDialogEventMap;
ModalDialogEventMap modal_dialog_event_map_;
base::Lock modal_dialog_event_map_lock_;
@@ -196,9 +193,8 @@ int PluginChannel::GenerateRouteID() {
return ++last_id;
}
-base::WaitableEvent* PluginChannel::GetModalDialogEvent(
- gfx::NativeViewId containing_window) {
- return filter_->GetModalDialogEvent(containing_window);
+base::WaitableEvent* PluginChannel::GetModalDialogEvent(int render_view_id) {
+ return filter_->GetModalDialogEvent(render_view_id);
}
PluginChannel::~PluginChannel() {
@@ -273,8 +269,8 @@ void PluginChannel::OnDestroyInstance(int instance_id,
for (size_t i = 0; i < plugin_stubs_.size(); ++i) {
if (plugin_stubs_[i]->instance_id() == instance_id) {
scoped_refptr<MessageFilter> filter(filter_);
- gfx::NativeViewId window =
- plugin_stubs_[i]->webplugin()->containing_window();
+ int render_view_id =
+ plugin_stubs_[i]->webplugin()->host_render_view_routing_id();
plugin_stubs_.erase(plugin_stubs_.begin() + i);
Send(reply_msg);
RemoveRoute(instance_id);
@@ -283,7 +279,8 @@ void PluginChannel::OnDestroyInstance(int instance_id,
// stack unwinds since the plugin can be destroyed later if it's in use
// right now.
MessageLoop::current()->PostNonNestableTask(FROM_HERE, base::Bind(
- &MessageFilter::ReleaseModalDialogEvent, filter.get(), window));
+ &MessageFilter::ReleaseModalDialogEvent, filter.get(),
+ render_view_id));
return;
}
}
diff --git a/content/plugin/plugin_channel.h b/content/plugin/plugin_channel.h
index e923a33..c717bd6 100644
--- a/content/plugin/plugin_channel.h
+++ b/content/plugin/plugin_channel.h
@@ -43,8 +43,7 @@ class PluginChannel : public NPChannelBase {
// Returns the event that's set when a call to the renderer causes a modal
// dialog to come up.
- virtual base::WaitableEvent* GetModalDialogEvent(
- gfx::NativeViewId containing_window) OVERRIDE;
+ virtual base::WaitableEvent* GetModalDialogEvent(int render_view_id) OVERRIDE;
bool in_send() { return in_send_ != 0; }
diff --git a/content/plugin/webplugin_delegate_stub.cc b/content/plugin/webplugin_delegate_stub.cc
index e6baa22..4ffb71c 100644
--- a/content/plugin/webplugin_delegate_stub.cc
+++ b/content/plugin/webplugin_delegate_stub.cc
@@ -164,8 +164,7 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params,
command_line.GetSwitchValuePath(switches::kPluginPath);
webplugin_ = new WebPluginProxy(
- channel_, instance_id_, page_url_, params.containing_window,
- params.host_render_view_routing_id);
+ channel_, instance_id_, page_url_, params.host_render_view_routing_id);
delegate_ = webkit::npapi::WebPluginDelegateImpl::Create(path, mime_type_);
if (delegate_) {
webplugin_->set_delegate(delegate_);
@@ -280,8 +279,8 @@ void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id) {
// delegate. It will delete itself sooner if the proxy tells it that it has
// been released, or if the channel to the proxy is closed.
NPObjectStub* scriptable_stub = new NPObjectStub(
- object, channel_.get(), *route_id, webplugin_->containing_window(),
- page_url_);
+ object, channel_.get(), *route_id,
+ webplugin_->host_render_view_routing_id(), page_url_);
plugin_scriptable_object_ = scriptable_stub->AsWeakPtr();
// Release ref added by GetPluginScriptableObject (our stub holds its own).
diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc
index a403dc0..12c1541 100644
--- a/content/plugin/webplugin_proxy.cc
+++ b/content/plugin/webplugin_proxy.cc
@@ -59,7 +59,6 @@ WebPluginProxy::WebPluginProxy(
PluginChannel* channel,
int route_id,
const GURL& page_url,
- gfx::NativeViewId containing_window,
int host_render_view_routing_id)
: channel_(channel),
route_id_(route_id),
@@ -67,7 +66,6 @@ WebPluginProxy::WebPluginProxy(
plugin_element_(NULL),
delegate_(NULL),
waiting_for_paint_(false),
- containing_window_(containing_window),
page_url_(page_url),
transparent_(false),
windowless_buffer_index_(0),
@@ -221,7 +219,7 @@ NPObject* WebPluginProxy::GetWindowScriptNPObject() {
return NULL;
window_npobject_ = NPObjectProxy::Create(
- channel_, npobject_route_id, containing_window_, page_url_);
+ channel_, npobject_route_id, host_render_view_routing_id_, page_url_);
return window_npobject_;
}
@@ -238,7 +236,7 @@ NPObject* WebPluginProxy::GetPluginElement() {
return NULL;
plugin_element_ = NPObjectProxy::Create(
- channel_, npobject_route_id, containing_window_, page_url_);
+ channel_, npobject_route_id, host_render_view_routing_id_, page_url_);
return plugin_element_;
}
diff --git a/content/plugin/webplugin_proxy.h b/content/plugin/webplugin_proxy.h
index 686c7c4..81bdf86 100644
--- a/content/plugin/webplugin_proxy.h
+++ b/content/plugin/webplugin_proxy.h
@@ -53,7 +53,6 @@ class WebPluginProxy : public webkit::npapi::WebPlugin {
WebPluginProxy(PluginChannel* channel,
int route_id,
const GURL& page_url,
- gfx::NativeViewId containing_window,
int host_render_view_routing_id);
virtual ~WebPluginProxy();
@@ -131,7 +130,6 @@ class WebPluginProxy : public webkit::npapi::WebPlugin {
virtual bool IsOffTheRecord() OVERRIDE;
virtual void ResourceClientDeleted(
webkit::npapi::WebPluginResourceClient* resource_client) OVERRIDE;
- gfx::NativeViewId containing_window() { return containing_window_; }
#if defined(OS_MACOSX)
virtual void FocusChanged(bool focused) OVERRIDE;
@@ -273,7 +271,6 @@ class WebPluginProxy : public webkit::npapi::WebPlugin {
webkit::npapi::WebPluginDelegateImpl* delegate_;
gfx::Rect damaged_rect_;
bool waiting_for_paint_;
- gfx::NativeViewId containing_window_;
// The url of the main frame hosting the plugin.
GURL page_url_;