Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: ppapi/proxy/ppb_flash_clipboard_proxy.cc

Issue 6650029: Pepper/Flapper: Implement proxy for clipboard stuff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..4022c07abcb2e28722ccab04b7fceea2cdd9a90d
--- /dev/null
+++ b/ppapi/proxy/ppb_flash_clipboard_proxy.cc
@@ -0,0 +1,126 @@
+// Copyright (c) 2011 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.
+
+#include "ppapi/proxy/ppb_flash_clipboard_proxy.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_flash_clipboard.h"
+#include "ppapi/proxy/plugin_dispatcher.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/serialized_var.h"
+
+namespace pp {
+namespace proxy {
+
+namespace {
+
+bool IsValidClipboardType(PP_Flash_Clipboard_Type clipboard_type) {
+ return clipboard_type == PP_FLASH_CLIPBOARD_TYPE_STANDARD ||
+ clipboard_type == PP_FLASH_CLIPBOARD_TYPE_SELECTION ||
+ clipboard_type == PP_FLASH_CLIPBOARD_TYPE_DRAG;
+}
+
+PP_Var ReadPlainText(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
+ if (!dispatcher)
+ return PP_MakeUndefined();
+
+ if (!IsValidClipboardType(clipboard_type))
+ return PP_MakeUndefined();
+
+ ReceiveSerializedVarReturnValue result;
+ dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_ReadPlainText(
+ INTERFACE_ID_PPB_FLASH_CLIPBOARD, instance_id,
+ static_cast<int>(clipboard_type), &result));
+ return result.Return(dispatcher);
+}
+
+int32_t WritePlainText(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type,
+ PP_Var text) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
+ if (!dispatcher)
+ return PP_ERROR_BADARGUMENT;
+
+ if (!IsValidClipboardType(clipboard_type))
+ return PP_ERROR_BADARGUMENT;
+
+ int32_t result;
+ dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_WritePlainText(
+ INTERFACE_ID_PPB_FLASH_CLIPBOARD,
+ instance_id,
+ static_cast<int>(clipboard_type),
+ SerializedVarSendInput(dispatcher, text),
+ &result));
+ return result;
+}
+
+const PPB_Flash_Clipboard flash_clipboard_interface = {
+ &ReadPlainText,
+ &WritePlainText
+};
+
+InterfaceProxy* CreateFlashClipboardProxy(Dispatcher* dispatcher,
+ const void* target_interface) {
+ return new PPB_Flash_Clipboard_Proxy(dispatcher, target_interface);
+}
+
+} // namespace
+
+PPB_Flash_Clipboard_Proxy::PPB_Flash_Clipboard_Proxy(
+ Dispatcher* dispatcher, const void* target_interface)
+ : InterfaceProxy(dispatcher, target_interface) {
+}
+
+PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() {
+}
+
+// static
+const InterfaceProxy::Info* PPB_Flash_Clipboard_Proxy::GetInfo() {
+ static const Info info = {
+ &flash_clipboard_interface,
+ PPB_FLASH_CLIPBOARD_INTERFACE,
+ INTERFACE_ID_PPB_FLASH_CLIPBOARD,
+ false,
+ &CreateFlashClipboardProxy
+ };
+ return &info;
+}
+
+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_ReadPlainText,
+ OnMsgReadPlainText)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_WritePlainText,
+ OnMsgWritePlainText)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText(
+ PP_Instance instance_id,
+ int clipboard_type,
+ SerializedVarReturnValue result) {
+ result.Return(dispatcher(),
+ ppb_flash_clipboard_target()->ReadPlainText(
+ instance_id,
+ static_cast<PP_Flash_Clipboard_Type>(clipboard_type)));
+}
+
+void PPB_Flash_Clipboard_Proxy::OnMsgWritePlainText(
+ PP_Instance instance_id,
+ int clipboard_type,
+ SerializedVarReceiveInput text,
+ int32_t* result) {
+ *result = ppb_flash_clipboard_target()->WritePlainText(
+ instance_id,
+ static_cast<PP_Flash_Clipboard_Type>(clipboard_type),
+ text.Get(dispatcher()));
+}
+
+} // namespace proxy
+} // namespace pp
« ppapi/proxy/ppapi_messages_internal.h ('K') | « ppapi/proxy/ppb_flash_clipboard_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698