diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 23:00:09 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 23:00:09 +0000 |
commit | cc21fb5b4e675a86c8862b934aa8e100643e75e4 (patch) | |
tree | f5055650bc147382260bc397f417560c6090812e /chrome/plugin/webplugin_proxy.cc | |
parent | 5abb7f799f538318c702f0f26372b38464ab888a (diff) | |
download | chromium_src-cc21fb5b4e675a86c8862b934aa8e100643e75e4.zip chromium_src-cc21fb5b4e675a86c8862b934aa8e100643e75e4.tar.gz chromium_src-cc21fb5b4e675a86c8862b934aa8e100643e75e4.tar.bz2 |
CPAPI gears drag drop and renderer IPC.
CPAPI (0.10) functions for gears drag drop; one to extract thedrag type/data given an NPObject *event, one to override thedrop effect (drag cursor).
Gears drag drop API receives a browser event as an NPObject* sothe event is untrusted. Provide IPC calls to the renderer sogears can pass the event to renderer/V8 for checking, prior todrag type/data extraction, or the setting of the drop effect.
Original patch by Noel Gordon via:
http://codereview.chromium.org/99240
BUG=7995
TEST=none
Review URL: http://codereview.chromium.org/112056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/webplugin_proxy.cc')
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 0075e79..2a84267 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -305,6 +305,58 @@ void WebPluginProxy::HandleURLRequest(const char *method, Send(new PluginHostMsg_URLRequest(route_id_, params)); } +bool WebPluginProxy::GetDragData(struct NPObject* event, bool add_data, + int32* identity, int32* event_id, + std::string* type, std::string* data) { + DCHECK(event); + NPObjectProxy* proxy = NPObjectProxy::GetProxy(event); + if (!proxy) // NPObject* event should have/be a renderer proxy. + return false; + + NPVariant_Param event_param; + event_param.type = NPVARIANT_PARAM_OBJECT_POINTER; + event_param.npobject_pointer = proxy->npobject_ptr(); + if (!event_param.npobject_pointer) + return false; + + std::vector<NPVariant_Param> values; + bool success = false; + Send(new PluginHostMsg_GetDragData(route_id_, event_param, add_data, + &values, &success)); + if (!success) + return false; + + DCHECK(values.size() == 4); + DCHECK(values[0].type == NPVARIANT_PARAM_INT); + *identity = static_cast<int32>(values[0].int_value); + DCHECK(values[1].type == NPVARIANT_PARAM_INT); + *event_id = static_cast<int32>(values[1].int_value); + DCHECK(values[2].type == NPVARIANT_PARAM_STRING); + type->swap(values[2].string_value); + if (add_data && (values[3].type == NPVARIANT_PARAM_STRING)) + data->swap(values[3].string_value); + + return true; +} + +bool WebPluginProxy::SetDropEffect(struct NPObject* event, int effect) { + DCHECK(event); + NPObjectProxy* proxy = NPObjectProxy::GetProxy(event); + if (!proxy) // NPObject* event should have/be a renderer proxy. + return false; + + NPVariant_Param event_param; + event_param.type = NPVARIANT_PARAM_OBJECT_POINTER; + event_param.npobject_pointer = proxy->npobject_ptr(); + if (!event_param.npobject_pointer) + return false; + + bool success = false; + Send(new PluginHostMsg_SetDropEffect(route_id_, event_param, effect, + &success)); + return success; +} + void WebPluginProxy::Paint(const gfx::Rect& rect) { #if defined(OS_WIN) if (!windowless_hdc_) |