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 /ppapi/proxy/ppb_flash_clipboard_proxy.cc | |
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 'ppapi/proxy/ppb_flash_clipboard_proxy.cc')
-rw-r--r-- | ppapi/proxy/ppb_flash_clipboard_proxy.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ppapi/proxy/ppb_flash_clipboard_proxy.cc b/ppapi/proxy/ppb_flash_clipboard_proxy.cc index a849071..efe1df3 100644 --- a/ppapi/proxy/ppb_flash_clipboard_proxy.cc +++ b/ppapi/proxy/ppb_flash_clipboard_proxy.cc @@ -21,6 +21,32 @@ bool IsValidClipboardType(PP_Flash_Clipboard_Type clipboard_type) { clipboard_type == PP_FLASH_CLIPBOARD_TYPE_DRAG; } +bool IsValidClipboardFormat(PP_Flash_Clipboard_Format format) { + // Purposely excludes |PP_FLASH_CLIPBOARD_FORMAT_INVALID|. + return format == PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT || + format == PP_FLASH_CLIPBOARD_FORMAT_HTML; +} + +PP_Bool IsFormatAvailable(PP_Instance instance_id, + PP_Flash_Clipboard_Type clipboard_type, + PP_Flash_Clipboard_Format format) { + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); + if (!dispatcher) + return PP_FALSE; + + if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format)) + return PP_FALSE; + + bool result = false; + dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable( + INTERFACE_ID_PPB_FLASH_CLIPBOARD, + instance_id, + static_cast<int>(clipboard_type), + static_cast<int>(format), + &result)); + return BoolToPPBool(result); +} + PP_Var ReadPlainText(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); @@ -57,6 +83,7 @@ int32_t WritePlainText(PP_Instance instance_id, } const PPB_Flash_Clipboard flash_clipboard_interface = { + &IsFormatAvailable, &ReadPlainText, &WritePlainText }; @@ -91,6 +118,8 @@ const InterfaceProxy::Info* PPB_Flash_Clipboard_Proxy::GetInfo() { bool PPB_Flash_Clipboard_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Clipboard_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable, + OnMsgIsFormatAvailable) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_ReadPlainText, OnMsgReadPlainText) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_WritePlainText, @@ -100,6 +129,17 @@ bool PPB_Flash_Clipboard_Proxy::OnMessageReceived(const IPC::Message& msg) { return handled; } +void PPB_Flash_Clipboard_Proxy::OnMsgIsFormatAvailable( + PP_Instance instance_id, + int clipboard_type, + int format, + bool* result) { + *result = PPBoolToBool(ppb_flash_clipboard_target()->IsFormatAvailable( + instance_id, + static_cast<PP_Flash_Clipboard_Type>(clipboard_type), + static_cast<PP_Flash_Clipboard_Format>(format))); +} + void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText( PP_Instance instance_id, int clipboard_type, |