| Index: ppapi/proxy/ppb_flash_clipboard_proxy.cc
|
| diff --git a/ppapi/proxy/ppb_flash_clipboard_proxy.cc b/ppapi/proxy/ppb_flash_clipboard_proxy.cc
|
| index df6cc59946bce0775b9360c94a93e88854280a95..13158eb0b99cd3d0f516d9bc1bf4c6f8dfd6827a 100644
|
| --- a/ppapi/proxy/ppb_flash_clipboard_proxy.cc
|
| +++ b/ppapi/proxy/ppb_flash_clipboard_proxy.cc
|
| @@ -62,32 +62,53 @@ PP_Bool PPB_Flash_Clipboard_Proxy::IsFormatAvailable(
|
| &result));
|
| return PP_FromBool(result);
|
| }
|
| -
|
| -PP_Var PPB_Flash_Clipboard_Proxy::ReadPlainText(
|
| +PP_Var PPB_Flash_Clipboard_Proxy::ReadData(
|
| PP_Instance instance,
|
| - PP_Flash_Clipboard_Type clipboard_type) {
|
| - if (!IsValidClipboardType(clipboard_type))
|
| + PP_Flash_Clipboard_Type clipboard_type,
|
| + PP_Flash_Clipboard_Format format) {
|
| + if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format))
|
| return PP_MakeUndefined();
|
|
|
| ReceiveSerializedVarReturnValue result;
|
| - dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_ReadPlainText(
|
| + dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_ReadData(
|
| API_ID_PPB_FLASH_CLIPBOARD, instance,
|
| - static_cast<int>(clipboard_type), &result));
|
| + static_cast<int>(clipboard_type), static_cast<int>(format), &result));
|
| return result.Return(dispatcher());
|
| }
|
|
|
| -int32_t PPB_Flash_Clipboard_Proxy::WritePlainText(
|
| +
|
| +int32_t PPB_Flash_Clipboard_Proxy::WriteData(
|
| PP_Instance instance,
|
| PP_Flash_Clipboard_Type clipboard_type,
|
| - const PP_Var& text) {
|
| + uint32_t data_item_count,
|
| + const struct
|
| + PP_Flash_Clipboard_Data_Item data_items[]) {
|
| if (!IsValidClipboardType(clipboard_type))
|
| return PP_ERROR_BADARGUMENT;
|
|
|
| - dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_WritePlainText(
|
| + // Convert the array of PP_Flash_Clipboard_Data_Item into two parallel
|
| + // arrays of format and corresponding data.
|
| + PP_Var formats[data_item_count];
|
| + PP_Var data[data_item_count];
|
| +
|
| + for (uint32_t i = 0; i < data_item_count; ++i) {
|
| + formats[i] = PP_MakeInt32(data_items[i].format);
|
| + data[i] = data_items[i].data;
|
| + }
|
| +
|
| + std::vector<SerializedVar> formats_converted;
|
| + std::vector<SerializedVar> data_converted;
|
| + SerializedVarSendInput::ConvertVector(dispatcher(), formats, data_item_count,
|
| + &formats_converted);
|
| + SerializedVarSendInput::ConvertVector(dispatcher(), data, data_item_count,
|
| + &data_converted);
|
| +
|
| + dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_WriteData(
|
| API_ID_PPB_FLASH_CLIPBOARD,
|
| instance,
|
| static_cast<int>(clipboard_type),
|
| - SerializedVarSendInput(dispatcher(), text)));
|
| + formats_converted,
|
| + data_converted));
|
| // Assume success, since it allows us to avoid a sync IPC.
|
| return PP_OK;
|
| }
|
| @@ -97,10 +118,10 @@ bool PPB_Flash_Clipboard_Proxy::OnMessageReceived(const IPC::Message& msg) {
|
| 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,
|
| - OnMsgWritePlainText)
|
| + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_ReadData,
|
| + OnMsgReadData)
|
| + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_WriteData,
|
| + OnMsgWriteData)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -122,29 +143,49 @@ void PPB_Flash_Clipboard_Proxy::OnMsgIsFormatAvailable(
|
| }
|
| }
|
|
|
| -void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText(
|
| +void PPB_Flash_Clipboard_Proxy::OnMsgReadData(
|
| PP_Instance instance,
|
| int clipboard_type,
|
| + int format,
|
| SerializedVarReturnValue result) {
|
| EnterFlashClipboardNoLock enter(instance, true);
|
| if (enter.succeeded()) {
|
| result.Return(dispatcher(),
|
| - enter.functions()->ReadPlainText(
|
| + enter.functions()->ReadData(
|
| instance,
|
| - static_cast<PP_Flash_Clipboard_Type>(clipboard_type)));
|
| + static_cast<PP_Flash_Clipboard_Type>(clipboard_type),
|
| + static_cast<PP_Flash_Clipboard_Format>(format)));
|
| }
|
| }
|
|
|
| -void PPB_Flash_Clipboard_Proxy::OnMsgWritePlainText(
|
| +void PPB_Flash_Clipboard_Proxy::OnMsgWriteData(
|
| PP_Instance instance,
|
| int clipboard_type,
|
| - SerializedVarReceiveInput text) {
|
| + SerializedVarVectorReceiveInput formats_vector,
|
| + SerializedVarVectorReceiveInput data_vector) {
|
| EnterFlashClipboardNoLock enter(instance, true);
|
| if (enter.succeeded()) {
|
| - int32_t result = enter.functions()->WritePlainText(
|
| + // Convert parallel arrays of PP_Var into an array of
|
| + // PP_Flash_Clipboard_Data_Item structs.
|
| + uint32_t formats_size;
|
| + uint32_t data_size;
|
| + PP_Var* formats = formats_vector.Get(dispatcher(), &formats_size);
|
| + PP_Var* data = data_vector.Get(dispatcher(), &data_size);
|
| + CHECK(formats_size == data_size);
|
| +
|
| + PP_Flash_Clipboard_Data_Item data_items[formats_size];
|
| +
|
| + for (uint32_t i = 0; i < formats_size; ++i) {
|
| + data_items[i].format =
|
| + static_cast<PP_Flash_Clipboard_Format>(formats[i].value.as_int);
|
| + data_items[i].data = data[i];
|
| + }
|
| +
|
| + int32_t result = enter.functions()->WriteData(
|
| instance,
|
| static_cast<PP_Flash_Clipboard_Type>(clipboard_type),
|
| - text.Get(dispatcher()));
|
| + data_size,
|
| + data_items);
|
| DLOG_IF(WARNING, result != PP_OK)
|
| << "Write to clipboard failed unexpectedly.";
|
| (void)result; // Prevent warning in release mode.
|
|
|