summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 23:07:51 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 23:07:51 +0000
commit4dc69e7976ea44a8570feed29c2a233f23a9d074 (patch)
treeb962c98a66cfa284bd3d6453b1c66cf2338475c9
parent3f8c5dfb8851026b8072a8da5779eca0a8e71116 (diff)
downloadchromium_src-4dc69e7976ea44a8570feed29c2a233f23a9d074.zip
chromium_src-4dc69e7976ea44a8570feed29c2a233f23a9d074.tar.gz
chromium_src-4dc69e7976ea44a8570feed29c2a233f23a9d074.tar.bz2
Committing change from Gene Gutnik <gene@chromium.org>. Original change at http://codereview.chromium.org/667011.
Add function to Pepper API to copy text from plugin to clipboard. This functionality is necessary for good user experience, since plugin may have a custom copy button, menu, shortcut for copy functionality. This is a simple text copy interface first, and later we might need more complex format (HTML maybe) as well as cut/paste functionality. BUG=none TEST=Call CopyClipboard from plugin. Try to paste in the text editor. Verify that paste inserts the same characters. Review URL: http://codereview.chromium.org/669187 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40791 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--third_party/npapi/bindings/npapi_extensions.h7
-rw-r--r--webkit/glue/plugins/npapi_extension_thunk.cc9
2 files changed, 16 insertions, 0 deletions
diff --git a/third_party/npapi/bindings/npapi_extensions.h b/third_party/npapi/bindings/npapi_extensions.h
index 011628e..2e18a6a 100644
--- a/third_party/npapi/bindings/npapi_extensions.h
+++ b/third_party/npapi/bindings/npapi_extensions.h
@@ -116,10 +116,17 @@ typedef NPDevice* (*NPAcquireDevicePtr)(
NPP instance,
NPDeviceID device);
+/* Copy UTF-8 string into clipboard */
+typedef void (*NPCopyTextToClipboardPtr)(
+ NPP instance,
+ const char* content);
+
/* Pepper extensions */
struct NPExtensions {
/* Device interface acquisition */
NPAcquireDevicePtr acquireDevice;
+ /* Clipboard functionality */
+ NPCopyTextToClipboardPtr copyTextToClipboard;
};
/* Events -------------------------------------------------------------------*/
diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc
index 61054c7..ab5b852 100644
--- a/webkit/glue/plugins/npapi_extension_thunk.cc
+++ b/webkit/glue/plugins/npapi_extension_thunk.cc
@@ -5,8 +5,11 @@
#include "webkit/glue/plugins/npapi_extension_thunk.h"
#include "base/logging.h"
+#include "base/utf_string_conversions.h"
#include "third_party/npapi/bindings/npapi_extensions.h"
#include "webkit/glue/plugins/plugin_instance.h"
+#include "webkit/glue/scoped_clipboard_writer_glue.h"
+#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webplugin.h"
#include "webkit/glue/webplugin_delegate.h"
@@ -374,11 +377,17 @@ static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) {
}
}
+static void CopyTextToClipboard(NPP id, const char* content) {
+ ScopedClipboardWriterGlue scw(webkit_glue::ClipboardGetClipboard());
+ scw.WriteText(UTF8ToUTF16(content));
+}
+
namespace NPAPI {
NPError GetPepperExtensionsFunctions(void* value) {
static const NPExtensions kExtensions = {
&AcquireDevice,
+ &CopyTextToClipboard,
};
// Return a pointer to the canonical function table.