OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/proxy/ppb_flash_clipboard_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_clipboard_proxy.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/private/ppb_flash_clipboard.h" | 8 #include "ppapi/c/private/ppb_flash_clipboard.h" |
9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 PP_Flash_Clipboard_Format format) { | 32 PP_Flash_Clipboard_Format format) { |
33 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); | 33 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
34 if (!dispatcher) | 34 if (!dispatcher) |
35 return PP_FALSE; | 35 return PP_FALSE; |
36 | 36 |
37 if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format)) | 37 if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format)) |
38 return PP_FALSE; | 38 return PP_FALSE; |
39 | 39 |
40 bool result = false; | 40 bool result = false; |
41 dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable( | 41 dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable( |
42 INTERFACE_ID_PPB_FLASH_CLIPBOARD, | 42 API_ID_PPB_FLASH_CLIPBOARD, |
43 instance_id, | 43 instance_id, |
44 static_cast<int>(clipboard_type), | 44 static_cast<int>(clipboard_type), |
45 static_cast<int>(format), | 45 static_cast<int>(format), |
46 &result)); | 46 &result)); |
47 return PP_FromBool(result); | 47 return PP_FromBool(result); |
48 } | 48 } |
49 | 49 |
50 PP_Var ReadPlainText(PP_Instance instance_id, | 50 PP_Var ReadPlainText(PP_Instance instance_id, |
51 PP_Flash_Clipboard_Type clipboard_type) { | 51 PP_Flash_Clipboard_Type clipboard_type) { |
52 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); | 52 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
53 if (!dispatcher) | 53 if (!dispatcher) |
54 return PP_MakeUndefined(); | 54 return PP_MakeUndefined(); |
55 | 55 |
56 if (!IsValidClipboardType(clipboard_type)) | 56 if (!IsValidClipboardType(clipboard_type)) |
57 return PP_MakeUndefined(); | 57 return PP_MakeUndefined(); |
58 | 58 |
59 ReceiveSerializedVarReturnValue result; | 59 ReceiveSerializedVarReturnValue result; |
60 dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_ReadPlainText( | 60 dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_ReadPlainText( |
61 INTERFACE_ID_PPB_FLASH_CLIPBOARD, instance_id, | 61 API_ID_PPB_FLASH_CLIPBOARD, instance_id, |
62 static_cast<int>(clipboard_type), &result)); | 62 static_cast<int>(clipboard_type), &result)); |
63 return result.Return(dispatcher); | 63 return result.Return(dispatcher); |
64 } | 64 } |
65 | 65 |
66 int32_t WritePlainText(PP_Instance instance_id, | 66 int32_t WritePlainText(PP_Instance instance_id, |
67 PP_Flash_Clipboard_Type clipboard_type, | 67 PP_Flash_Clipboard_Type clipboard_type, |
68 PP_Var text) { | 68 PP_Var text) { |
69 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); | 69 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
70 if (!dispatcher) | 70 if (!dispatcher) |
71 return PP_ERROR_BADARGUMENT; | 71 return PP_ERROR_BADARGUMENT; |
72 | 72 |
73 if (!IsValidClipboardType(clipboard_type)) | 73 if (!IsValidClipboardType(clipboard_type)) |
74 return PP_ERROR_BADARGUMENT; | 74 return PP_ERROR_BADARGUMENT; |
75 | 75 |
76 dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_WritePlainText( | 76 dispatcher->Send(new PpapiHostMsg_PPBFlashClipboard_WritePlainText( |
77 INTERFACE_ID_PPB_FLASH_CLIPBOARD, | 77 API_ID_PPB_FLASH_CLIPBOARD, |
78 instance_id, | 78 instance_id, |
79 static_cast<int>(clipboard_type), | 79 static_cast<int>(clipboard_type), |
80 SerializedVarSendInput(dispatcher, text))); | 80 SerializedVarSendInput(dispatcher, text))); |
81 // Assume success, since it allows us to avoid a sync IPC. | 81 // Assume success, since it allows us to avoid a sync IPC. |
82 return PP_OK; | 82 return PP_OK; |
83 } | 83 } |
84 | 84 |
85 const PPB_Flash_Clipboard flash_clipboard_interface = { | 85 const PPB_Flash_Clipboard flash_clipboard_interface = { |
86 &IsFormatAvailable, | 86 &IsFormatAvailable, |
87 &ReadPlainText, | 87 &ReadPlainText, |
(...skipping 16 matching lines...) Expand all Loading... |
104 } | 104 } |
105 | 105 |
106 PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() { | 106 PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() { |
107 } | 107 } |
108 | 108 |
109 // static | 109 // static |
110 const InterfaceProxy::Info* PPB_Flash_Clipboard_Proxy::GetInfo() { | 110 const InterfaceProxy::Info* PPB_Flash_Clipboard_Proxy::GetInfo() { |
111 static const Info info = { | 111 static const Info info = { |
112 &flash_clipboard_interface, | 112 &flash_clipboard_interface, |
113 PPB_FLASH_CLIPBOARD_INTERFACE, | 113 PPB_FLASH_CLIPBOARD_INTERFACE, |
114 INTERFACE_ID_PPB_FLASH_CLIPBOARD, | 114 API_ID_PPB_FLASH_CLIPBOARD, |
115 false, | 115 false, |
116 &CreateFlashClipboardProxy | 116 &CreateFlashClipboardProxy |
117 }; | 117 }; |
118 return &info; | 118 return &info; |
119 } | 119 } |
120 | 120 |
121 bool PPB_Flash_Clipboard_Proxy::OnMessageReceived(const IPC::Message& msg) { | 121 bool PPB_Flash_Clipboard_Proxy::OnMessageReceived(const IPC::Message& msg) { |
122 bool handled = true; | 122 bool handled = true; |
123 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Clipboard_Proxy, msg) | 123 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Clipboard_Proxy, msg) |
124 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable, | 124 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 SerializedVarReceiveInput text) { | 159 SerializedVarReceiveInput text) { |
160 int32_t result = ppb_flash_clipboard_impl_->WritePlainText( | 160 int32_t result = ppb_flash_clipboard_impl_->WritePlainText( |
161 instance_id, | 161 instance_id, |
162 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | 162 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), |
163 text.Get(dispatcher())); | 163 text.Get(dispatcher())); |
164 LOG_IF(WARNING, result != PP_OK) << "Write to clipboard failed unexpectedly."; | 164 LOG_IF(WARNING, result != PP_OK) << "Write to clipboard failed unexpectedly."; |
165 } | 165 } |
166 | 166 |
167 } // namespace proxy | 167 } // namespace proxy |
168 } // namespace ppapi | 168 } // namespace ppapi |
OLD | NEW |