| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, |
| 88 &WritePlainText | 88 &WritePlainText |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 InterfaceProxy* CreateFlashClipboardProxy(Dispatcher* dispatcher, | 91 InterfaceProxy* CreateFlashClipboardProxy(Dispatcher* dispatcher) { |
| 92 const void* target_interface) { | 92 return new PPB_Flash_Clipboard_Proxy(dispatcher); |
| 93 return new PPB_Flash_Clipboard_Proxy(dispatcher, target_interface); | |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace | 95 } // namespace |
| 97 | 96 |
| 98 PPB_Flash_Clipboard_Proxy::PPB_Flash_Clipboard_Proxy( | 97 PPB_Flash_Clipboard_Proxy::PPB_Flash_Clipboard_Proxy(Dispatcher* dispatcher) |
| 99 Dispatcher* dispatcher, const void* target_interface) | 98 : InterfaceProxy(dispatcher), |
| 100 : InterfaceProxy(dispatcher, target_interface) { | 99 ppb_flash_clipboard_impl_(NULL) { |
| 100 if (!dispatcher->IsPlugin()) { |
| 101 ppb_flash_clipboard_impl_ = static_cast<const PPB_Flash_Clipboard*>( |
| 102 dispatcher->local_get_interface()(PPB_FLASH_CLIPBOARD_INTERFACE)); |
| 103 } |
| 101 } | 104 } |
| 102 | 105 |
| 103 PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() { | 106 PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() { |
| 104 } | 107 } |
| 105 | 108 |
| 106 // static | 109 // static |
| 107 const InterfaceProxy::Info* PPB_Flash_Clipboard_Proxy::GetInfo() { | 110 const InterfaceProxy::Info* PPB_Flash_Clipboard_Proxy::GetInfo() { |
| 108 static const Info info = { | 111 static const Info info = { |
| 109 &flash_clipboard_interface, | 112 &flash_clipboard_interface, |
| 110 PPB_FLASH_CLIPBOARD_INTERFACE, | 113 PPB_FLASH_CLIPBOARD_INTERFACE, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 127 IPC_MESSAGE_UNHANDLED(handled = false) | 130 IPC_MESSAGE_UNHANDLED(handled = false) |
| 128 IPC_END_MESSAGE_MAP() | 131 IPC_END_MESSAGE_MAP() |
| 129 return handled; | 132 return handled; |
| 130 } | 133 } |
| 131 | 134 |
| 132 void PPB_Flash_Clipboard_Proxy::OnMsgIsFormatAvailable( | 135 void PPB_Flash_Clipboard_Proxy::OnMsgIsFormatAvailable( |
| 133 PP_Instance instance_id, | 136 PP_Instance instance_id, |
| 134 int clipboard_type, | 137 int clipboard_type, |
| 135 int format, | 138 int format, |
| 136 bool* result) { | 139 bool* result) { |
| 137 *result = PP_ToBool(ppb_flash_clipboard_target()->IsFormatAvailable( | 140 *result = PP_ToBool(ppb_flash_clipboard_impl_->IsFormatAvailable( |
| 138 instance_id, | 141 instance_id, |
| 139 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | 142 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), |
| 140 static_cast<PP_Flash_Clipboard_Format>(format))); | 143 static_cast<PP_Flash_Clipboard_Format>(format))); |
| 141 } | 144 } |
| 142 | 145 |
| 143 void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText( | 146 void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText( |
| 144 PP_Instance instance_id, | 147 PP_Instance instance_id, |
| 145 int clipboard_type, | 148 int clipboard_type, |
| 146 SerializedVarReturnValue result) { | 149 SerializedVarReturnValue result) { |
| 147 result.Return(dispatcher(), | 150 result.Return(dispatcher(), |
| 148 ppb_flash_clipboard_target()->ReadPlainText( | 151 ppb_flash_clipboard_impl_->ReadPlainText( |
| 149 instance_id, | 152 instance_id, |
| 150 static_cast<PP_Flash_Clipboard_Type>(clipboard_type))); | 153 static_cast<PP_Flash_Clipboard_Type>(clipboard_type))); |
| 151 } | 154 } |
| 152 | 155 |
| 153 void PPB_Flash_Clipboard_Proxy::OnMsgWritePlainText( | 156 void PPB_Flash_Clipboard_Proxy::OnMsgWritePlainText( |
| 154 PP_Instance instance_id, | 157 PP_Instance instance_id, |
| 155 int clipboard_type, | 158 int clipboard_type, |
| 156 SerializedVarReceiveInput text) { | 159 SerializedVarReceiveInput text) { |
| 157 int32_t result = ppb_flash_clipboard_target()->WritePlainText( | 160 int32_t result = ppb_flash_clipboard_impl_->WritePlainText( |
| 158 instance_id, | 161 instance_id, |
| 159 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | 162 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), |
| 160 text.Get(dispatcher())); | 163 text.Get(dispatcher())); |
| 161 LOG_IF(WARNING, result != PP_OK) << "Write to clipboard failed unexpectedly."; | 164 LOG_IF(WARNING, result != PP_OK) << "Write to clipboard failed unexpectedly."; |
| 162 } | 165 } |
| 163 | 166 |
| 164 } // namespace proxy | 167 } // namespace proxy |
| 165 } // namespace ppapi | 168 } // namespace ppapi |
| OLD | NEW |