summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 01:45:33 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 01:45:33 +0000
commit3391ebb097b95feb8587b1ae43ee1cc47e601f79 (patch)
treee2a0c9cef329b7801548f81232cc8e488158dfb5
parent4e7b8920056148dc43d0af4f45b6498890ea2979 (diff)
downloadchromium_src-3391ebb097b95feb8587b1ae43ee1cc47e601f79.zip
chromium_src-3391ebb097b95feb8587b1ae43ee1cc47e601f79.tar.gz
chromium_src-3391ebb097b95feb8587b1ae43ee1cc47e601f79.tar.bz2
Add GetSequenceNumber function to PPB_Flash_Clipboard
This provides access to a sequence number which identifies the clipboard state. BUG=333094 Review URL: https://codereview.chromium.org/136183002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247383 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc19
-rw-r--r--chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h2
-rw-r--r--ppapi/api/private/ppb_flash_clipboard.idl14
-rw-r--r--ppapi/c/private/ppb_flash_clipboard.h34
-rw-r--r--ppapi/cpp/private/flash_clipboard.cc62
-rw-r--r--ppapi/cpp/private/flash_clipboard.h6
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c45
-rw-r--r--ppapi/proxy/flash_clipboard_resource.cc12
-rw-r--r--ppapi/proxy/flash_clipboard_resource.h4
-rw-r--r--ppapi/proxy/ppapi_messages.h4
-rw-r--r--ppapi/tests/test_flash_clipboard.cc66
-rw-r--r--ppapi/tests/test_flash_clipboard.h2
-rw-r--r--ppapi/thunk/interfaces_ppb_private_flash.h2
-rw-r--r--ppapi/thunk/ppb_flash_clipboard_api.h4
-rw-r--r--ppapi/thunk/ppb_flash_clipboard_thunk.cc22
15 files changed, 288 insertions, 10 deletions
diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc
index 57f99b4..a2b70d7 100644
--- a/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc
+++ b/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc
@@ -137,6 +137,9 @@ int32_t PepperFlashClipboardMessageFilter::OnResourceMessageReceived(
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_FlashClipboard_WriteData,
OnMsgWriteData);
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+ PpapiHostMsg_FlashClipboard_GetSequenceNumber,
+ OnMsgGetSequenceNumber);
IPC_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -359,4 +362,20 @@ int32_t PepperFlashClipboardMessageFilter::OnMsgWriteData(
return res;
}
+int32_t PepperFlashClipboardMessageFilter::OnMsgGetSequenceNumber(
+ ppapi::host::HostMessageContext* host_context,
+ uint32_t clipboard_type) {
+ if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_FAILED;
+ }
+
+ ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
+ ui::ClipboardType type = ConvertClipboardType(clipboard_type);
+ int64_t sequence_number = clipboard->GetSequenceNumber(type);
+ host_context->reply_msg =
+ PpapiPluginMsg_FlashClipboard_GetSequenceNumberReply(sequence_number);
+ return PP_OK;
+}
+
} // namespace chrome
diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h b/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h
index 2b23b5f..e5de23b 100644
--- a/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h
+++ b/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h
@@ -61,6 +61,8 @@ class PepperFlashClipboardMessageFilter
uint32_t clipboard_type,
const std::vector<uint32_t>& formats,
const std::vector<std::string>& data);
+ int32_t OnMsgGetSequenceNumber(ppapi::host::HostMessageContext* host_context,
+ uint32_t clipboard_type);
int32_t WriteClipboardDataItem(uint32_t format,
const std::string& data,
diff --git a/ppapi/api/private/ppb_flash_clipboard.idl b/ppapi/api/private/ppb_flash_clipboard.idl
index 5a97318..d2fef48 100644
--- a/ppapi/api/private/ppb_flash_clipboard.idl
+++ b/ppapi/api/private/ppb_flash_clipboard.idl
@@ -10,7 +10,8 @@
label Chrome {
M19 = 4.0,
- M24 = 5.0
+ M24 = 5.0,
+ M34 = 5.1
};
/**
@@ -142,4 +143,15 @@ interface PPB_Flash_Clipboard {
[in] uint32_t data_item_count,
[in, size_is(data_item_count)] uint32_t[] formats,
[in, size_is(data_item_count)] PP_Var[] data_items);
+
+ /**
+ * Gets a sequence number which uniquely identifies clipboard state. This can
+ * be used to version the data on the clipboard and determine whether it has
+ * changed. The sequence number will be placed in |sequence_number| and
+ * PP_TRUE returned if the sequence number was retrieved successfully.
+ */
+ [version=5.1]
+ PP_Bool GetSequenceNumber([in] PP_Instance instance_id,
+ [in] PP_Flash_Clipboard_Type clipboard_type,
+ [out] uint64_t sequence_number);
};
diff --git a/ppapi/c/private/ppb_flash_clipboard.h b/ppapi/c/private/ppb_flash_clipboard.h
index d59957a..1ff8614 100644
--- a/ppapi/c/private/ppb_flash_clipboard.h
+++ b/ppapi/c/private/ppb_flash_clipboard.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From private/ppb_flash_clipboard.idl modified Thu Mar 28 10:23:59 2013. */
+/* From private/ppb_flash_clipboard.idl modified Thu Jan 23 10:16:39 2014. */
#ifndef PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_
#define PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_
@@ -16,7 +16,8 @@
#define PPB_FLASH_CLIPBOARD_INTERFACE_4_0 "PPB_Flash_Clipboard;4.0"
#define PPB_FLASH_CLIPBOARD_INTERFACE_5_0 "PPB_Flash_Clipboard;5.0"
-#define PPB_FLASH_CLIPBOARD_INTERFACE PPB_FLASH_CLIPBOARD_INTERFACE_5_0
+#define PPB_FLASH_CLIPBOARD_INTERFACE_5_1 "PPB_Flash_Clipboard;5.1"
+#define PPB_FLASH_CLIPBOARD_INTERFACE PPB_FLASH_CLIPBOARD_INTERFACE_5_1
/**
* @file
@@ -77,7 +78,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Flash_Clipboard_Format, 4);
* used by Pepper Flash to access the clipboard.
*
*/
-struct PPB_Flash_Clipboard_5_0 {
+struct PPB_Flash_Clipboard_5_1 {
/**
* Registers a custom clipboard format. The format is identified by a
* string. An id identifying the format will be returned if the format is
@@ -129,9 +130,18 @@ struct PPB_Flash_Clipboard_5_0 {
uint32_t data_item_count,
const uint32_t formats[],
const struct PP_Var data_items[]);
+ /**
+ * Gets a sequence number which uniquely identifies clipboard state. This can
+ * be used to version the data on the clipboard and determine whether it has
+ * changed. The sequence number will be placed in |sequence_number| and
+ * PP_TRUE returned if the sequence number was retrieved successfully.
+ */
+ PP_Bool (*GetSequenceNumber)(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint64_t* sequence_number);
};
-typedef struct PPB_Flash_Clipboard_5_0 PPB_Flash_Clipboard;
+typedef struct PPB_Flash_Clipboard_5_1 PPB_Flash_Clipboard;
struct PPB_Flash_Clipboard_4_0 {
PP_Bool (*IsFormatAvailable)(PP_Instance instance_id,
@@ -146,6 +156,22 @@ struct PPB_Flash_Clipboard_4_0 {
const PP_Flash_Clipboard_Format formats[],
const struct PP_Var data_items[]);
};
+
+struct PPB_Flash_Clipboard_5_0 {
+ uint32_t (*RegisterCustomFormat)(PP_Instance instance_id,
+ const char* format_name);
+ PP_Bool (*IsFormatAvailable)(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint32_t format);
+ struct PP_Var (*ReadData)(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint32_t format);
+ int32_t (*WriteData)(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint32_t data_item_count,
+ const uint32_t formats[],
+ const struct PP_Var data_items[]);
+};
/**
* @}
*/
diff --git a/ppapi/cpp/private/flash_clipboard.cc b/ppapi/cpp/private/flash_clipboard.cc
index c63f747..77e68ba 100644
--- a/ppapi/cpp/private/flash_clipboard.cc
+++ b/ppapi/cpp/private/flash_clipboard.cc
@@ -24,13 +24,18 @@ template <> const char* interface_name<PPB_Flash_Clipboard_5_0>() {
return PPB_FLASH_CLIPBOARD_INTERFACE_5_0;
}
+template <> const char* interface_name<PPB_Flash_Clipboard_5_1>() {
+ return PPB_FLASH_CLIPBOARD_INTERFACE_5_1;
+}
+
} // namespace
namespace flash {
// static
bool Clipboard::IsAvailable() {
- return has_interface<PPB_Flash_Clipboard_5_0>() ||
+ return has_interface<PPB_Flash_Clipboard_5_1>() ||
+ has_interface<PPB_Flash_Clipboard_5_0>() ||
has_interface<PPB_Flash_Clipboard_4_0>() ;
}
@@ -38,7 +43,10 @@ bool Clipboard::IsAvailable() {
uint32_t Clipboard::RegisterCustomFormat(const InstanceHandle& instance,
const std::string& format_name) {
uint32_t rv = PP_FLASH_CLIPBOARD_FORMAT_INVALID;
- if (has_interface<PPB_Flash_Clipboard_5_0>()) {
+ if (has_interface<PPB_Flash_Clipboard_5_1>()) {
+ rv = get_interface<PPB_Flash_Clipboard_5_1>()->RegisterCustomFormat(
+ instance.pp_instance(), format_name.c_str());
+ } else if (has_interface<PPB_Flash_Clipboard_5_0>()) {
rv = get_interface<PPB_Flash_Clipboard_5_0>()->RegisterCustomFormat(
instance.pp_instance(), format_name.c_str());
}
@@ -50,7 +58,10 @@ bool Clipboard::IsFormatAvailable(const InstanceHandle& instance,
PP_Flash_Clipboard_Type clipboard_type,
uint32_t format) {
bool rv = false;
- if (has_interface<PPB_Flash_Clipboard_5_0>()) {
+ if (has_interface<PPB_Flash_Clipboard_5_1>()) {
+ rv = PP_ToBool(get_interface<PPB_Flash_Clipboard_5_1>()->IsFormatAvailable(
+ instance.pp_instance(), clipboard_type, format));
+ } else if (has_interface<PPB_Flash_Clipboard_5_0>()) {
rv = PP_ToBool(get_interface<PPB_Flash_Clipboard_5_0>()->IsFormatAvailable(
instance.pp_instance(), clipboard_type, format));
} else if (has_interface<PPB_Flash_Clipboard_4_0>()) {
@@ -68,7 +79,14 @@ bool Clipboard::ReadData(
uint32_t format,
Var* out) {
bool rv = false;
- if (has_interface<PPB_Flash_Clipboard_5_0>()) {
+ if (has_interface<PPB_Flash_Clipboard_5_1>()) {
+ PP_Var result = get_interface<PPB_Flash_Clipboard_5_1>()->ReadData(
+ instance.pp_instance(),
+ clipboard_type,
+ format);
+ *out = Var(PASS_REF, result);
+ rv = true;
+ } else if (has_interface<PPB_Flash_Clipboard_5_0>()) {
PP_Var result = get_interface<PPB_Flash_Clipboard_5_0>()->ReadData(
instance.pp_instance(),
clipboard_type,
@@ -96,7 +114,29 @@ bool Clipboard::WriteData(
return false;
bool rv = false;
- if (has_interface<PPB_Flash_Clipboard_5_0>()) {
+ if (has_interface<PPB_Flash_Clipboard_5_1>()) {
+ // Convert vector of pp::Var into a vector of PP_Var.
+ std::vector<PP_Var> data_items_vector;
+ for (uint32_t i = 0; i < data_items.size(); ++i)
+ data_items_vector.push_back(data_items[i].pp_var());
+
+ // Ensure that we don't dereference the memory in empty vectors. We still
+ // want to call WriteData because it has the effect of clearing the
+ // clipboard.
+ const uint32_t* formats_ptr(NULL);
+ const PP_Var* data_items_ptr(NULL);
+ if (data_items.size() > 0) {
+ formats_ptr = &formats[0];
+ data_items_ptr = &data_items_vector[0];
+ }
+
+ rv = (get_interface<PPB_Flash_Clipboard_5_1>()->WriteData(
+ instance.pp_instance(),
+ clipboard_type,
+ data_items.size(),
+ formats_ptr,
+ data_items_ptr) == PP_OK);
+ } else if (has_interface<PPB_Flash_Clipboard_5_0>()) {
// Convert vector of pp::Var into a vector of PP_Var.
std::vector<PP_Var> data_items_vector;
for (uint32_t i = 0; i < data_items.size(); ++i)
@@ -148,5 +188,17 @@ bool Clipboard::WriteData(
return rv;
}
+// static
+bool Clipboard::GetSequenceNumber(const InstanceHandle& instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint64_t* sequence_number) {
+ if (has_interface<PPB_Flash_Clipboard_5_1>()) {
+ return PP_ToBool(
+ get_interface<PPB_Flash_Clipboard_5_1>()->GetSequenceNumber(
+ instance.pp_instance(), clipboard_type, sequence_number));
+ }
+ return false;
+}
+
} // namespace flash
} // namespace pp
diff --git a/ppapi/cpp/private/flash_clipboard.h b/ppapi/cpp/private/flash_clipboard.h
index aab06ef..0df6028 100644
--- a/ppapi/cpp/private/flash_clipboard.h
+++ b/ppapi/cpp/private/flash_clipboard.h
@@ -45,6 +45,12 @@ class Clipboard {
PP_Flash_Clipboard_Type clipboard_type,
const std::vector<uint32_t>& formats,
const std::vector<Var>& data_items);
+
+ // Outputs a sequence number that uniquely identifies the clipboard state in
+ // |sequence_number| and returns true if successful.
+ static bool GetSequenceNumber(const InstanceHandle& instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint64_t* sequence_number);
};
} // namespace flash
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 16567e4..9e7a8b6 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -208,6 +208,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_12_6;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_13_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_Clipboard_4_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_0;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DeviceID_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DRM_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DRM_1_1;
@@ -2900,6 +2901,35 @@ static int32_t Pnacl_M24_PPB_Flash_Clipboard_WriteData(PP_Instance instance_id,
/* End wrapper methods for PPB_Flash_Clipboard_5_0 */
+/* Begin wrapper methods for PPB_Flash_Clipboard_5_1 */
+
+static uint32_t Pnacl_M34_PPB_Flash_Clipboard_RegisterCustomFormat(PP_Instance instance_id, const char* format_name) {
+ const struct PPB_Flash_Clipboard_5_1 *iface = Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1.real_iface;
+ return iface->RegisterCustomFormat(instance_id, format_name);
+}
+
+static PP_Bool Pnacl_M34_PPB_Flash_Clipboard_IsFormatAvailable(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format) {
+ const struct PPB_Flash_Clipboard_5_1 *iface = Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1.real_iface;
+ return iface->IsFormatAvailable(instance_id, clipboard_type, format);
+}
+
+static void Pnacl_M34_PPB_Flash_Clipboard_ReadData(struct PP_Var* _struct_result, PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format) {
+ const struct PPB_Flash_Clipboard_5_1 *iface = Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1.real_iface;
+ *_struct_result = iface->ReadData(instance_id, clipboard_type, format);
+}
+
+static int32_t Pnacl_M34_PPB_Flash_Clipboard_WriteData(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]) {
+ const struct PPB_Flash_Clipboard_5_1 *iface = Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1.real_iface;
+ return iface->WriteData(instance_id, clipboard_type, data_item_count, formats, data_items);
+}
+
+static PP_Bool Pnacl_M34_PPB_Flash_Clipboard_GetSequenceNumber(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint64_t* sequence_number) {
+ const struct PPB_Flash_Clipboard_5_1 *iface = Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1.real_iface;
+ return iface->GetSequenceNumber(instance_id, clipboard_type, sequence_number);
+}
+
+/* End wrapper methods for PPB_Flash_Clipboard_5_1 */
+
/* Begin wrapper methods for PPB_Flash_DeviceID_1_0 */
static PP_Resource Pnacl_M21_PPB_Flash_DeviceID_Create(PP_Instance instance) {
@@ -4914,6 +4944,14 @@ static struct PPB_Flash_Clipboard_5_0 Pnacl_Wrappers_PPB_Flash_Clipboard_5_0 = {
.WriteData = (int32_t (*)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]))&Pnacl_M24_PPB_Flash_Clipboard_WriteData
};
+static struct PPB_Flash_Clipboard_5_1 Pnacl_Wrappers_PPB_Flash_Clipboard_5_1 = {
+ .RegisterCustomFormat = (uint32_t (*)(PP_Instance instance_id, const char* format_name))&Pnacl_M34_PPB_Flash_Clipboard_RegisterCustomFormat,
+ .IsFormatAvailable = (PP_Bool (*)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format))&Pnacl_M34_PPB_Flash_Clipboard_IsFormatAvailable,
+ .ReadData = (struct PP_Var (*)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format))&Pnacl_M34_PPB_Flash_Clipboard_ReadData,
+ .WriteData = (int32_t (*)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]))&Pnacl_M34_PPB_Flash_Clipboard_WriteData,
+ .GetSequenceNumber = (PP_Bool (*)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint64_t* sequence_number))&Pnacl_M34_PPB_Flash_Clipboard_GetSequenceNumber
+};
+
static struct PPB_Flash_DeviceID_1_0 Pnacl_Wrappers_PPB_Flash_DeviceID_1_0 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M21_PPB_Flash_DeviceID_Create,
.GetDeviceID = (int32_t (*)(PP_Resource device_id, struct PP_Var* id, struct PP_CompletionCallback callback))&Pnacl_M21_PPB_Flash_DeviceID_GetDeviceID
@@ -5662,6 +5700,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_0 = {
.real_iface = NULL
};
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1 = {
+ .iface_macro = PPB_FLASH_CLIPBOARD_INTERFACE_5_1,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Flash_Clipboard_5_1,
+ .real_iface = NULL
+};
+
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DeviceID_1_0 = {
.iface_macro = PPB_FLASH_DEVICEID_INTERFACE_1_0,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Flash_DeviceID_1_0,
@@ -5923,6 +5967,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_Flash_13_0,
&Pnacl_WrapperInfo_PPB_Flash_Clipboard_4_0,
&Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_0,
+ &Pnacl_WrapperInfo_PPB_Flash_Clipboard_5_1,
&Pnacl_WrapperInfo_PPB_Flash_DeviceID_1_0,
&Pnacl_WrapperInfo_PPB_Flash_DRM_1_0,
&Pnacl_WrapperInfo_PPB_Flash_DRM_1_1,
diff --git a/ppapi/proxy/flash_clipboard_resource.cc b/ppapi/proxy/flash_clipboard_resource.cc
index 5f06402..2b665bf 100644
--- a/ppapi/proxy/flash_clipboard_resource.cc
+++ b/ppapi/proxy/flash_clipboard_resource.cc
@@ -152,5 +152,17 @@ int32_t FlashClipboardResource::WriteData(
return PP_OK;
}
+PP_Bool FlashClipboardResource::GetSequenceNumber(
+ PP_Instance instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint64_t* sequence_number) {
+ int32_t result =
+ SyncCall<PpapiPluginMsg_FlashClipboard_GetSequenceNumberReply>(
+ BROWSER,
+ PpapiHostMsg_FlashClipboard_GetSequenceNumber(clipboard_type),
+ sequence_number);
+ return PP_FromBool(result == PP_OK);
+}
+
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/flash_clipboard_resource.h b/ppapi/proxy/flash_clipboard_resource.h
index fdb7e79..3c12f55 100644
--- a/ppapi/proxy/flash_clipboard_resource.h
+++ b/ppapi/proxy/flash_clipboard_resource.h
@@ -37,6 +37,10 @@ class FlashClipboardResource
uint32_t data_item_count,
const uint32_t formats[],
const PP_Var data_items[]) OVERRIDE;
+ virtual PP_Bool GetSequenceNumber(
+ PP_Instance instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint64_t* sequence_number) OVERRIDE;
private:
FlashClipboardFormatRegistry clipboard_formats_;
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 76fa380..ab28cf8 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -1909,6 +1909,10 @@ IPC_MESSAGE_CONTROL3(PpapiHostMsg_FlashClipboard_WriteData,
uint32_t /* clipboard_type */,
std::vector<uint32_t> /* formats */,
std::vector<std::string> /* data */)
+IPC_MESSAGE_CONTROL1(PpapiHostMsg_FlashClipboard_GetSequenceNumber,
+ uint32_t /* clipboard_type */)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FlashClipboard_GetSequenceNumberReply,
+ uint64_t /* sequence_number */)
// Flash file.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashFile_Create)
diff --git a/ppapi/tests/test_flash_clipboard.cc b/ppapi/tests/test_flash_clipboard.cc
index c328269..505399d 100644
--- a/ppapi/tests/test_flash_clipboard.cc
+++ b/ppapi/tests/test_flash_clipboard.cc
@@ -39,6 +39,7 @@ void TestFlashClipboard::RunTests(const std::string& filter) {
RUN_TEST(Clear, filter);
RUN_TEST(InvalidFormat, filter);
RUN_TEST(RegisterCustomFormat, filter);
+ RUN_TEST(GetSequenceNumber, filter);
}
bool TestFlashClipboard::ReadStringVar(uint32_t format, std::string* result) {
@@ -113,6 +114,19 @@ bool TestFlashClipboard::ReadHTMLMatches(const std::string& expected) {
return false;
}
+uint64_t TestFlashClipboard::GetSequenceNumber(uint64_t last_sequence_number) {
+ uint64_t next_sequence_number = last_sequence_number;
+ for (int i = 0; i < kMaxIntervals; ++i) {
+ pp::flash::Clipboard::GetSequenceNumber(
+ instance_, PP_FLASH_CLIPBOARD_TYPE_STANDARD, &next_sequence_number);
+ if (next_sequence_number != last_sequence_number)
+ return next_sequence_number;
+
+ PlatformSleep(kIntervalMs);
+ }
+ return next_sequence_number;
+}
+
std::string TestFlashClipboard::TestReadWritePlainText() {
std::string input = "Hello world plain text!";
ASSERT_TRUE(WriteStringVar(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT, input));
@@ -282,3 +296,55 @@ std::string TestFlashClipboard::TestRegisterCustomFormat() {
PASS();
}
+
+std::string TestFlashClipboard::TestGetSequenceNumber() {
+ uint64_t sequence_number_before = 0;
+ uint64_t sequence_number_after = 0;
+ ASSERT_TRUE(pp::flash::Clipboard::GetSequenceNumber(
+ instance_, PP_FLASH_CLIPBOARD_TYPE_STANDARD, &sequence_number_before));
+
+ // Test the sequence number changes after writing html.
+ ASSERT_TRUE(WriteStringVar(PP_FLASH_CLIPBOARD_FORMAT_HTML, "<html>"));
+ sequence_number_after = GetSequenceNumber(sequence_number_before);
+ ASSERT_NE(sequence_number_before, sequence_number_after);
+ sequence_number_before = sequence_number_after;
+
+ // Test the sequence number changes after writing some custom data.
+ std::string custom_data = "custom_data";
+ pp::VarArrayBuffer array_buffer(custom_data.size());
+ char* bytes = static_cast<char*>(array_buffer.Map());
+ std::copy(custom_data.begin(), custom_data.end(), bytes);
+ uint32_t format_id =
+ pp::flash::Clipboard::RegisterCustomFormat(instance_, "my-format");
+ std::vector<uint32_t> formats_vector(1, format_id);
+ std::vector<pp::Var> data_vector(1, array_buffer);
+ ASSERT_TRUE(pp::flash::Clipboard::WriteData(instance_,
+ PP_FLASH_CLIPBOARD_TYPE_STANDARD,
+ formats_vector,
+ data_vector));
+ sequence_number_after = GetSequenceNumber(sequence_number_before);
+ ASSERT_NE(sequence_number_before, sequence_number_after);
+ sequence_number_before = sequence_number_after;
+
+ // Read the data and make sure the sequence number doesn't change.
+ pp::Var custom_data_result;
+ ASSERT_TRUE(pp::flash::Clipboard::ReadData(
+ instance_,
+ PP_FLASH_CLIPBOARD_TYPE_STANDARD,
+ format_id,
+ &custom_data_result));
+ ASSERT_TRUE(pp::flash::Clipboard::GetSequenceNumber(
+ instance_, PP_FLASH_CLIPBOARD_TYPE_STANDARD, &sequence_number_after));
+ ASSERT_EQ(sequence_number_before, sequence_number_after);
+ sequence_number_before = sequence_number_after;
+
+ // Clear the clipboard and check the sequence number changes.
+ pp::flash::Clipboard::WriteData(instance_,
+ PP_FLASH_CLIPBOARD_TYPE_STANDARD,
+ std::vector<uint32_t>(),
+ std::vector<pp::Var>());
+ sequence_number_after = GetSequenceNumber(sequence_number_before);
+ ASSERT_NE(sequence_number_before, sequence_number_after);
+
+ PASS();
+}
diff --git a/ppapi/tests/test_flash_clipboard.h b/ppapi/tests/test_flash_clipboard.h
index 3b11d5b..824386c 100644
--- a/ppapi/tests/test_flash_clipboard.h
+++ b/ppapi/tests/test_flash_clipboard.h
@@ -25,6 +25,7 @@ class TestFlashClipboard : public TestCase {
bool IsFormatAvailableMatches(uint32_t format, bool expected);
bool ReadPlainTextMatches(const std::string& expected);
bool ReadHTMLMatches(const std::string& expected);
+ uint64_t GetSequenceNumber(uint64_t last_sequence_number);
// Tests.
std::string TestReadWritePlainText();
@@ -35,6 +36,7 @@ class TestFlashClipboard : public TestCase {
std::string TestClear();
std::string TestInvalidFormat();
std::string TestRegisterCustomFormat();
+ std::string TestGetSequenceNumber();
};
#endif // PAPPI_TESTS_TEST_FLASH_FULLSCREEN_H_
diff --git a/ppapi/thunk/interfaces_ppb_private_flash.h b/ppapi/thunk/interfaces_ppb_private_flash.h
index 32d33ff..a3915c2 100644
--- a/ppapi/thunk/interfaces_ppb_private_flash.h
+++ b/ppapi/thunk/interfaces_ppb_private_flash.h
@@ -25,6 +25,8 @@ PROXIED_IFACE(PPB_FLASH_CLIPBOARD_INTERFACE_4_0,
PPB_Flash_Clipboard_4_0)
PROXIED_IFACE(PPB_FLASH_CLIPBOARD_INTERFACE_5_0,
PPB_Flash_Clipboard_5_0)
+PROXIED_IFACE(PPB_FLASH_CLIPBOARD_INTERFACE_5_1,
+ PPB_Flash_Clipboard_5_1)
PROXIED_IFACE(PPB_FLASH_DRM_INTERFACE_1_0,
PPB_Flash_DRM_1_0)
diff --git a/ppapi/thunk/ppb_flash_clipboard_api.h b/ppapi/thunk/ppb_flash_clipboard_api.h
index 4be9aee..6d39bbe 100644
--- a/ppapi/thunk/ppb_flash_clipboard_api.h
+++ b/ppapi/thunk/ppb_flash_clipboard_api.h
@@ -29,6 +29,10 @@ class PPB_Flash_Clipboard_API {
uint32_t data_item_count,
const uint32_t formats[],
const PP_Var data_items[]) = 0;
+ virtual PP_Bool GetSequenceNumber(
+ PP_Instance instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint64_t* sequence_number) = 0;
static const SingletonResourceID kSingletonResourceID =
FLASH_CLIPBOARD_SINGLETON_ID;
diff --git a/ppapi/thunk/ppb_flash_clipboard_thunk.cc b/ppapi/thunk/ppb_flash_clipboard_thunk.cc
index 359d78f..95e4ba5 100644
--- a/ppapi/thunk/ppb_flash_clipboard_thunk.cc
+++ b/ppapi/thunk/ppb_flash_clipboard_thunk.cc
@@ -77,6 +77,16 @@ int32_t WriteData_4_0(PP_Instance instance,
new_formats.get(), data_items);
}
+PP_Bool GetSequenceNumber(PP_Instance instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint64_t* sequence_number) {
+ EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->GetSequenceNumber(instance, clipboard_type,
+ sequence_number);
+}
+
const PPB_Flash_Clipboard_4_0 g_ppb_flash_clipboard_thunk_4_0 = {
&IsFormatAvailable_4_0,
&ReadData_4_0,
@@ -90,6 +100,14 @@ const PPB_Flash_Clipboard_5_0 g_ppb_flash_clipboard_thunk_5_0 = {
&WriteData
};
+const PPB_Flash_Clipboard_5_1 g_ppb_flash_clipboard_thunk_5_1 = {
+ &RegisterCustomFormat,
+ &IsFormatAvailable,
+ &ReadData,
+ &WriteData,
+ &GetSequenceNumber
+};
+
} // namespace
const PPB_Flash_Clipboard_4_0* GetPPB_Flash_Clipboard_4_0_Thunk() {
@@ -100,5 +118,9 @@ const PPB_Flash_Clipboard_5_0* GetPPB_Flash_Clipboard_5_0_Thunk() {
return &g_ppb_flash_clipboard_thunk_5_0;
}
+const PPB_Flash_Clipboard_5_1* GetPPB_Flash_Clipboard_5_1_Thunk() {
+ return &g_ppb_flash_clipboard_thunk_5_1;
+}
+
} // namespace thunk
} // namespace ppapi