diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-24 17:13:38 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-24 17:13:38 +0000 |
commit | 606876c8312f1c1228a78ff3f28e65806c6b223c (patch) | |
tree | 82ea4c16106a07efc758c3f705c14277ba783c76 /webkit/plugins | |
parent | fe86d110746454b822c42742624eaa8aab740834 (diff) | |
download | chromium_src-606876c8312f1c1228a78ff3f28e65806c6b223c.zip chromium_src-606876c8312f1c1228a78ff3f28e65806c6b223c.tar.gz chromium_src-606876c8312f1c1228a78ff3f28e65806c6b223c.tar.bz2 |
Pepper/Flapper: Add IsFormatAvailable() to PPB_Flash_Clipboard.
This requires a WebKit change (see
https://bugs.webkit.org/show_bug.cgi?id=56868).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6724010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc index 630a897..c0b3273 100644 --- a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc @@ -16,6 +16,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" +#include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/var.h" @@ -42,6 +43,39 @@ WebKit::WebClipboard::Buffer ConvertClipboardType( } } +WebKit::WebClipboard::Format ConvertClipboardFormat( + PP_Flash_Clipboard_Format format) { + switch (format) { + case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: + return WebKit::WebClipboard::FormatPlainText; + case PP_FLASH_CLIPBOARD_FORMAT_HTML: + return WebKit::WebClipboard::FormatHTML; + case PP_FLASH_CLIPBOARD_FORMAT_INVALID: + default: + NOTREACHED(); + return WebKit::WebClipboard::FormatPlainText; // Gotta return something. + } +} + +PP_Bool IsFormatAvailable(PP_Instance instance_id, + PP_Flash_Clipboard_Type clipboard_type, + PP_Flash_Clipboard_Format format) { + // If you don't give us an instance, we don't give you anything. + PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + if (!instance) + return PP_FALSE; + + WebKit::WebClipboard* web_clipboard = WebKit::webKitClient()->clipboard(); + if (!web_clipboard) { + NOTREACHED(); + return PP_FALSE; + } + + return BoolToPPBool( + web_clipboard->isFormatAvailable(ConvertClipboardFormat(format), + ConvertClipboardType(clipboard_type))); +} + PP_Var ReadPlainText(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); @@ -86,6 +120,7 @@ int32_t WritePlainText(PP_Instance instance_id, } const PPB_Flash_Clipboard ppb_flash_clipboard = { + &IsFormatAvailable, &ReadPlainText, &WritePlainText, }; |