summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/private/ppb_flash_clipboard.h16
-rw-r--r--ppapi/proxy/ppapi_messages.h5
-rw-r--r--ppapi/proxy/ppb_flash_clipboard_proxy.cc40
-rw-r--r--ppapi/proxy/ppb_flash_clipboard_proxy.h4
4 files changed, 63 insertions, 2 deletions
diff --git a/ppapi/c/private/ppb_flash_clipboard.h b/ppapi/c/private/ppb_flash_clipboard.h
index c16ae36..e95e19c 100644
--- a/ppapi/c/private/ppb_flash_clipboard.h
+++ b/ppapi/c/private/ppb_flash_clipboard.h
@@ -5,10 +5,11 @@
#ifndef PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_
#define PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_
+#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_var.h"
-#define PPB_FLASH_CLIPBOARD_INTERFACE "PPB_Flash_Clipboard;2"
+#define PPB_FLASH_CLIPBOARD_INTERFACE "PPB_Flash_Clipboard;3"
typedef enum {
PP_FLASH_CLIPBOARD_TYPE_STANDARD = 0,
@@ -16,7 +17,18 @@ typedef enum {
PP_FLASH_CLIPBOARD_TYPE_DRAG = 2
} PP_Flash_Clipboard_Type;
+typedef enum {
+ PP_FLASH_CLIPBOARD_FORMAT_INVALID = 0,
+ PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT = 1,
+ PP_FLASH_CLIPBOARD_FORMAT_HTML = 2
+} PP_Flash_Clipboard_Format;
+
struct PPB_Flash_Clipboard {
+ // Returns true if the given format is available from the given clipboard.
+ PP_Bool (*IsFormatAvailable)(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type,
+ PP_Flash_Clipboard_Format format);
+
// Reads plain text data from the clipboard.
struct PP_Var (*ReadPlainText)(PP_Instance instance_id,
PP_Flash_Clipboard_Type clipboard_type);
@@ -27,7 +39,7 @@ struct PPB_Flash_Clipboard {
PP_Flash_Clipboard_Type clipboard_type,
struct PP_Var text);
- // TODO(vtl): More formats, a |IsFormatAvailable()|, ....
+ // TODO(vtl): More formats (e.g., HTML)....
};
#endif // PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 3681d1e..6f5aae8 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -391,6 +391,11 @@ IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBFlash_QuitMessageLoop,
PP_Instance /* instance */)
// PPB_Flash_Clipboard.
+IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable,
+ PP_Instance /* instance */,
+ int /* clipboard_type */,
+ int /* format */,
+ bool /* result */)
IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlashClipboard_ReadPlainText,
PP_Instance /* instance */,
int /* clipboard_type */,
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,
diff --git a/ppapi/proxy/ppb_flash_clipboard_proxy.h b/ppapi/proxy/ppb_flash_clipboard_proxy.h
index 2d68183..6d9604f 100644
--- a/ppapi/proxy/ppb_flash_clipboard_proxy.h
+++ b/ppapi/proxy/ppb_flash_clipboard_proxy.h
@@ -33,6 +33,10 @@ class PPB_Flash_Clipboard_Proxy : public InterfaceProxy {
private:
// Message handlers.
+ void OnMsgIsFormatAvailable(PP_Instance instance_id,
+ int clipboard_type,
+ int format,
+ bool* result);
void OnMsgReadPlainText(PP_Instance instance_id,
int clipboard_type,
SerializedVarReturnValue result);