| 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 26 matching lines...) Expand all Loading... |
| 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 INTERFACE_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 BoolToPPBool(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(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 IPC_MESSAGE_UNHANDLED(handled = false) | 127 IPC_MESSAGE_UNHANDLED(handled = false) |
| 128 IPC_END_MESSAGE_MAP() | 128 IPC_END_MESSAGE_MAP() |
| 129 return handled; | 129 return handled; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void PPB_Flash_Clipboard_Proxy::OnMsgIsFormatAvailable( | 132 void PPB_Flash_Clipboard_Proxy::OnMsgIsFormatAvailable( |
| 133 PP_Instance instance_id, | 133 PP_Instance instance_id, |
| 134 int clipboard_type, | 134 int clipboard_type, |
| 135 int format, | 135 int format, |
| 136 bool* result) { | 136 bool* result) { |
| 137 *result = PPBoolToBool(ppb_flash_clipboard_target()->IsFormatAvailable( | 137 *result = PP_ToBool(ppb_flash_clipboard_target()->IsFormatAvailable( |
| 138 instance_id, | 138 instance_id, |
| 139 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | 139 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), |
| 140 static_cast<PP_Flash_Clipboard_Format>(format))); | 140 static_cast<PP_Flash_Clipboard_Format>(format))); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText( | 143 void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText( |
| 144 PP_Instance instance_id, | 144 PP_Instance instance_id, |
| 145 int clipboard_type, | 145 int clipboard_type, |
| 146 SerializedVarReturnValue result) { | 146 SerializedVarReturnValue result) { |
| 147 result.Return(dispatcher(), | 147 result.Return(dispatcher(), |
| 148 ppb_flash_clipboard_target()->ReadPlainText( | 148 ppb_flash_clipboard_target()->ReadPlainText( |
| 149 instance_id, | 149 instance_id, |
| 150 static_cast<PP_Flash_Clipboard_Type>(clipboard_type))); | 150 static_cast<PP_Flash_Clipboard_Type>(clipboard_type))); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void PPB_Flash_Clipboard_Proxy::OnMsgWritePlainText( | 153 void PPB_Flash_Clipboard_Proxy::OnMsgWritePlainText( |
| 154 PP_Instance instance_id, | 154 PP_Instance instance_id, |
| 155 int clipboard_type, | 155 int clipboard_type, |
| 156 SerializedVarReceiveInput text) { | 156 SerializedVarReceiveInput text) { |
| 157 int32_t result = ppb_flash_clipboard_target()->WritePlainText( | 157 int32_t result = ppb_flash_clipboard_target()->WritePlainText( |
| 158 instance_id, | 158 instance_id, |
| 159 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | 159 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), |
| 160 text.Get(dispatcher())); | 160 text.Get(dispatcher())); |
| 161 LOG_IF(WARNING, result != PP_OK) << "Write to clipboard failed unexpectedly."; | 161 LOG_IF(WARNING, result != PP_OK) << "Write to clipboard failed unexpectedly."; |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace proxy | 164 } // namespace proxy |
| 165 } // namespace pp | 165 } // namespace pp |
| OLD | NEW |