diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-13 19:22:56 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-13 19:22:56 +0000 |
commit | 0167204bc9a6f6873af4b92c8f0969d5ae465088 (patch) | |
tree | 95e5e2d475da2c25152ebe31689fc8e1f74acf16 /chrome/renderer | |
parent | 89518924aa928807e7d5daf4d59fdb969cd19494 (diff) | |
download | chromium_src-0167204bc9a6f6873af4b92c8f0969d5ae465088.zip chromium_src-0167204bc9a6f6873af4b92c8f0969d5ae465088.tar.gz chromium_src-0167204bc9a6f6873af4b92c8f0969d5ae465088.tar.bz2 |
CPAPI gears drag drop and renderer IPC....
CPAPI (0.10) functions for gears drag drop; one to extract the
drag type/data given an NPObject *event, one to override the
drop effect (drag cursor).
Gears drag drop API receives a browser event as an NPObject* so
the event is untrusted. Provide IPC calls to the renderer so
gears can pass the event to renderer/V8 for checking, prior to
drag type/data extraction, or the setting of the drop effect.
V8 event checking is a TODO(noel), http://mondrian/10947778 for
the CPAPI (0.10) change submitted to gears.
BUG=7995
Original patch by Noel Gordon via:
http://codereview.chromium.org/99240
Review URL: http://codereview.chromium.org/115280
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 59 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.h | 6 |
2 files changed, 63 insertions, 2 deletions
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 4e05f1d..a9cb138 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -23,6 +23,7 @@ #include "chrome/common/render_messages.h" #include "chrome/plugin/npobject_proxy.h" #include "chrome/plugin/npobject_stub.h" +#include "chrome/plugin/npobject_util.h" #include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_view.h" #include "googleurl/src/gurl.h" @@ -339,6 +340,8 @@ void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) IPC_MESSAGE_HANDLER(PluginHostMsg_ShowModalHTMLDialog, OnShowModalHTMLDialog) + IPC_MESSAGE_HANDLER(PluginHostMsg_GetDragData, OnGetDragData); + IPC_MESSAGE_HANDLER(PluginHostMsg_SetDropEffect, OnSetDropEffect); IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, OnMissingPluginStatus) IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) @@ -726,6 +729,58 @@ void WebPluginDelegateProxy::OnShowModalHTMLDialog( json_retval); } +void WebPluginDelegateProxy::OnGetDragData(const NPVariant_Param& object, + bool add_data, + std::vector<NPVariant_Param>* values, + bool* success) { + DCHECK(values && success); + *success = false; + + WebView* webview = NULL; + if (render_view_) + webview = render_view_->webview(); + if (!webview) + return; + + NPVariant results[4]; + NPObject* event = reinterpret_cast<NPObject*>(object.npobject_pointer); + const int32 drag_id = webview->GetDragIdentity(); + if (!drag_id || !webkit_glue::GetDragData(event, add_data, &results[1])) + return; + + INT32_TO_NPVARIANT(drag_id, results[0]); + values->push_back(NPVariant_Param()); + CreateNPVariantParam(results[0], NULL, &values->back(), false, NULL); + values->push_back(NPVariant_Param()); + CreateNPVariantParam(results[1], NULL, &values->back(), false, NULL); + values->push_back(NPVariant_Param()); + CreateNPVariantParam(results[2], NULL, &values->back(), false, NULL); + values->push_back(NPVariant_Param()); + CreateNPVariantParam(results[3], NULL, &values->back(), add_data, NULL); + + *success = true; +} + +void WebPluginDelegateProxy::OnSetDropEffect(const NPVariant_Param& object, + int effect, + bool* success) { + DCHECK(success); + *success = false; + + WebView* webview = NULL; + if (render_view_) + webview = render_view_->webview(); + if (!webview) + return; + + NPObject* event = reinterpret_cast<NPObject*>(object.npobject_pointer); + const int32 drag_id = webview->GetDragIdentity(); + if (!drag_id || !webkit_glue::IsDragEvent(event)) + return; + + *success = webview->SetDropEffect(effect != 0); +} + void WebPluginDelegateProxy::OnMissingPluginStatus(int status) { if (render_view_) render_view_->OnMissingPluginStatus(this, status); @@ -825,8 +880,8 @@ void WebPluginDelegateProxy::OnCancelDocumentLoad() { } void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( - const std::string& url, const std::string& range_info, - intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { + const std::string& url, const std::string& range_info, + intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), existing_stream, notify_needed, notify_data); diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 99bd1e1..6baa42a 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -6,6 +6,7 @@ #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ #include <string> +#include <vector> #include "base/gfx/rect.h" #include "base/gfx/native_widget_types.h" @@ -19,6 +20,7 @@ class GURL; struct NPObject; class NPObjectStub; +struct NPVariant_Param; struct PluginHostMsg_URLRequest_Params; class RenderView; class SkBitmap; @@ -125,6 +127,10 @@ class WebPluginDelegateProxy : public WebPluginDelegate, void OnShowModalHTMLDialog(const GURL& url, int width, int height, const std::string& json_arguments, std::string* json_retval); + void OnGetDragData(const NPVariant_Param& event, bool add_data, + std::vector<NPVariant_Param>* values, bool* success); + void OnSetDropEffect(const NPVariant_Param& event, int effect, + bool* success); void OnMissingPluginStatus(int status); void OnGetCPBrowsingContext(uint32* context); void OnCancelDocumentLoad(); |