summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 23:15:00 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 23:15:00 +0000
commitfc148a7aed3f536f26c136d5c66b45b8735c069b (patch)
tree8070272863600e0a38ecfa3e7ded91fec7634c98 /ppapi/proxy
parente49221987f30d61b7b696de183a6a416f502ffbf (diff)
downloadchromium_src-fc148a7aed3f536f26c136d5c66b45b8735c069b.zip
chromium_src-fc148a7aed3f536f26c136d5c66b45b8735c069b.tar.gz
chromium_src-fc148a7aed3f536f26c136d5c66b45b8735c069b.tar.bz2
Modified the flash cipboard interface to add html clipboard support.
This changes the way the interface works. To write data, the user now passes an array of data items, one for each format they want to write to the clipboard. When reading data, they specify the format they want to read. BUG=110796 TEST=./ui_tests --gtest_filter=*PPAPITest.*Clipboard* passes Review URL: http://codereview.chromium.org/9212066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/interface_list.cc2
-rw-r--r--ppapi/proxy/ppapi_messages.h8
-rw-r--r--ppapi/proxy/ppb_flash_clipboard_proxy.cc72
-rw-r--r--ppapi/proxy/ppb_flash_clipboard_proxy.h30
4 files changed, 76 insertions, 36 deletions
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 55b97a0..9bf73c2 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -276,6 +276,8 @@ void InterfaceList::AddFlashInterfaces() {
AddProxy(API_ID_PPB_FLASH_CLIPBOARD,
&ProxyFactory<PPB_Flash_Clipboard_Proxy>);
+ AddPPB(PPB_FLASH_CLIPBOARD_INTERFACE_4_0, API_ID_PPB_FLASH_CLIPBOARD,
+ thunk::GetPPB_Flash_Clipboard_4_0_Thunk());
AddPPB(PPB_FLASH_CLIPBOARD_INTERFACE_3_0, API_ID_PPB_FLASH_CLIPBOARD,
thunk::GetPPB_Flash_Clipboard_3_0_Thunk());
AddPPB(PPB_FLASH_CLIPBOARD_INTERFACE_3_LEGACY, API_ID_PPB_FLASH_CLIPBOARD,
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index ff19419..023f11b 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -734,14 +734,16 @@ IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable,
int /* clipboard_type */,
int /* format */,
bool /* result */)
-IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlashClipboard_ReadPlainText,
+IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlashClipboard_ReadData,
PP_Instance /* instance */,
int /* clipboard_type */,
+ int /* format */,
ppapi::proxy::SerializedVar /* result */)
-IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFlashClipboard_WritePlainText,
+IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBFlashClipboard_WriteData,
PP_Instance /* instance */,
int /* clipboard_type */,
- ppapi::proxy::SerializedVar /* text */)
+ std::vector<int> /* formats */,
+ std::vector<ppapi::proxy::SerializedVar> /* data */)
// PPB_Flash_File_FileRef.
IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBFlashFile_FileRef_OpenFile,
diff --git a/ppapi/proxy/ppb_flash_clipboard_proxy.cc b/ppapi/proxy/ppb_flash_clipboard_proxy.cc
index df6cc59..b2166aa 100644
--- a/ppapi/proxy/ppb_flash_clipboard_proxy.cc
+++ b/ppapi/proxy/ppb_flash_clipboard_proxy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -62,32 +62,45 @@ 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 PP_Flash_Clipboard_Format formats[],
+ const PP_Var data_items[]) {
if (!IsValidClipboardType(clipboard_type))
return PP_ERROR_BADARGUMENT;
- dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_WritePlainText(
+ std::vector<int> formats_vector(formats, formats + data_item_count);
+
+ std::vector<SerializedVar> data_items_vector;
+ SerializedVarSendInput::ConvertVector(
+ dispatcher(),
+ data_items,
+ data_item_count,
+ &data_items_vector);
+
+ dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_WriteData(
API_ID_PPB_FLASH_CLIPBOARD,
instance,
static_cast<int>(clipboard_type),
- SerializedVarSendInput(dispatcher(), text)));
+ formats_vector,
+ data_items_vector));
// Assume success, since it allows us to avoid a sync IPC.
return PP_OK;
}
@@ -97,10 +110,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 +135,44 @@ 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) {
+ std::vector<int> formats,
+ SerializedVarVectorReceiveInput data_items) {
EnterFlashClipboardNoLock enter(instance, true);
if (enter.succeeded()) {
- int32_t result = enter.functions()->WritePlainText(
+ uint32_t data_item_count;
+ PP_Var* data_items_array = data_items.Get(dispatcher(), &data_item_count);
+ CHECK(data_item_count == formats.size());
+
+ scoped_array<PP_Flash_Clipboard_Format> formats_array(
+ new PP_Flash_Clipboard_Format[formats.size()]);
+ for (uint32_t i = 0; i < formats.size(); ++i) {
+ formats_array[i] = static_cast<PP_Flash_Clipboard_Format>(formats[i]);
+ }
+
+ int32_t result = enter.functions()->WriteData(
instance,
static_cast<PP_Flash_Clipboard_Type>(clipboard_type),
- text.Get(dispatcher()));
+ data_item_count,
+ formats_array.get(),
+ data_items_array);
DLOG_IF(WARNING, result != PP_OK)
<< "Write to clipboard failed unexpectedly.";
(void)result; // Prevent warning in release mode.
diff --git a/ppapi/proxy/ppb_flash_clipboard_proxy.h b/ppapi/proxy/ppb_flash_clipboard_proxy.h
index 08db677..e7a40bc 100644
--- a/ppapi/proxy/ppb_flash_clipboard_proxy.h
+++ b/ppapi/proxy/ppb_flash_clipboard_proxy.h
@@ -5,6 +5,8 @@
#ifndef PPAPI_PROXY_PPB_FLASH_CLIPBOARD_PROXY_H_
#define PPAPI_PROXY_PPB_FLASH_CLIPBOARD_PROXY_H_
+#include <vector>
+
#include "ppapi/c/pp_instance.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/thunk/ppb_flash_clipboard_api.h"
@@ -14,6 +16,7 @@ namespace proxy {
class SerializedVarReceiveInput;
class SerializedVarReturnValue;
+class SerializedVarVectorReceiveInput;
class PPB_Flash_Clipboard_Proxy
: public InterfaceProxy,
@@ -30,11 +33,14 @@ class PPB_Flash_Clipboard_Proxy
virtual PP_Bool IsFormatAvailable(PP_Instance instance,
PP_Flash_Clipboard_Type clipboard_type,
PP_Flash_Clipboard_Format format) OVERRIDE;
- virtual PP_Var ReadPlainText(PP_Instance instance,
- PP_Flash_Clipboard_Type clipboard_type) OVERRIDE;
- virtual int32_t WritePlainText(PP_Instance instance,
- PP_Flash_Clipboard_Type clipboard_type,
- const PP_Var& text) OVERRIDE;
+ virtual PP_Var ReadData(PP_Instance instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ PP_Flash_Clipboard_Format format) OVERRIDE;
+ virtual int32_t WriteData(PP_Instance instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ uint32_t data_item_count,
+ const PP_Flash_Clipboard_Format formats[],
+ const PP_Var data_items[]) OVERRIDE;
// InterfaceProxy implementation.
virtual bool OnMessageReceived(const IPC::Message& msg);
@@ -47,12 +53,14 @@ class PPB_Flash_Clipboard_Proxy
int clipboard_type,
int format,
bool* result);
- void OnMsgReadPlainText(PP_Instance instance,
- int clipboard_type,
- SerializedVarReturnValue result);
- void OnMsgWritePlainText(PP_Instance instance,
- int clipboard_type,
- SerializedVarReceiveInput text);
+ void OnMsgReadData(PP_Instance instance,
+ int clipboard_type,
+ int format,
+ SerializedVarReturnValue result);
+ void OnMsgWriteData(PP_Instance instance,
+ int clipboard_type,
+ std::vector<int> formats,
+ SerializedVarVectorReceiveInput data_items);
};
} // namespace proxy