summaryrefslogtreecommitdiffstats
path: root/chrome/plugin
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 20:36:49 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 20:36:49 +0000
commit351355117f4cb4ee805961920a7c9d2ad0ae944c (patch)
treeeaa3fce0cb3c27c349979f3b1d396cebd94b777d /chrome/plugin
parent77e82ef4ef098225b769b64d852f5c522b22f31d (diff)
downloadchromium_src-351355117f4cb4ee805961920a7c9d2ad0ae944c.zip
chromium_src-351355117f4cb4ee805961920a7c9d2ad0ae944c.tar.gz
chromium_src-351355117f4cb4ee805961920a7c9d2ad0ae944c.tar.bz2
CPAPI (0.11) for gears drag drop.
Provide a method that allows the gears plugin to ask the browser process to verify that its renderer has permission to access the drop files. Update the copyright notices. BUG=7995 Review URL: http://codereview.chromium.org/159074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r--chrome/plugin/chrome_plugin_host.cc30
-rw-r--r--chrome/plugin/webplugin_proxy.cc8
-rw-r--r--chrome/plugin/webplugin_proxy.h5
3 files changed, 40 insertions, 3 deletions
diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc
index a81d7d3..81a128a 100644
--- a/chrome/plugin/chrome_plugin_host.cc
+++ b/chrome/plugin/chrome_plugin_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -351,6 +351,33 @@ CPError STDCALL CPB_SetDropEffect(
return CPERR_FAILURE;
}
+CPError STDCALL CPB_AllowFileDrop(
+ CPID id, CPBrowsingContext context, const char* file_drag_data) {
+ CHECK(ChromePluginLib::IsPluginThread());
+
+ WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext(context);
+ if (!webplugin || !file_drag_data)
+ return CPERR_INVALID_PARAMETER;
+
+ const int pid = webplugin->GetRendererProcessId();
+ if (!pid)
+ return CPERR_FAILURE;
+
+ static const char kDelimiter('\b');
+ std::vector<std::string> files;
+ SplitStringDontTrim(file_drag_data, kDelimiter, &files);
+
+ bool allowed = false;
+ if (!PluginThread::current()->Send(
+ new PluginProcessHostMsg_AccessFiles(pid, files, &allowed))) {
+ return CPERR_FAILURE;
+ }
+
+ if (allowed)
+ return CPERR_SUCCESS;
+ return CPERR_FAILURE;
+}
+
CPError STDCALL CPB_GetCommandLineArguments(
CPID id, CPBrowsingContext context, const char* url, char** arguments) {
CHECK(ChromePluginLib::IsPluginThread());
@@ -636,6 +663,7 @@ CPBrowserFuncs* GetCPBrowserFuncsForPlugin() {
browser_funcs.open_file_dialog = CPB_OpenFileDialog;
browser_funcs.get_drag_data = CPB_GetDragData;
browser_funcs.set_drop_effect = CPB_SetDropEffect;
+ browser_funcs.allow_file_drop = CPB_AllowFileDrop;
browser_funcs.request_funcs = &request_funcs;
browser_funcs.response_funcs = &response_funcs;
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index 1356c61..67919e8 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -247,6 +247,12 @@ WebPluginResourceClient* WebPluginProxy::GetResourceClient(int id) {
return iterator->second;
}
+int WebPluginProxy::GetRendererProcessId() {
+ if (channel_.get())
+ return channel_->peer_pid();
+ return 0;
+}
+
void WebPluginProxy::DidPaint() {
// If we have an accumulated damaged rect, then check to see if we need to
// send out another InvalidateRect message.
diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h
index 1b1468e..9454d28 100644
--- a/chrome/plugin/webplugin_proxy.h
+++ b/chrome/plugin/webplugin_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -88,6 +88,9 @@ class WebPluginProxy : public WebPlugin {
// object with that id exists.
WebPluginResourceClient* GetResourceClient(int id);
+ // Returns the process id of the renderer that contains this plugin.
+ int GetRendererProcessId();
+
// For windowless plugins, paints the given rectangle into the local buffer.
void Paint(const gfx::Rect& rect);