OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "native_client/src/shared/ppapi_proxy/browser_ppp_selection.h" |
| 6 |
| 7 // Include file order cannot be observed because ppp_instance declares a |
| 8 // structure return type that causes an error on Windows. |
| 9 // TODO(sehr, brettw): fix the return types and include order in PPAPI. |
| 10 #include "ppapi/c/pp_instance.h" |
| 11 #include "ppapi/c/pp_rect.h" |
| 12 #include "ppapi/c/pp_resource.h" |
| 13 #include "srpcgen/ppp_rpc.h" |
| 14 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 15 #include "native_client/src/include/portability.h" |
| 16 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 17 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
| 18 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
| 19 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 20 |
| 21 namespace ppapi_proxy { |
| 22 |
| 23 namespace { |
| 24 |
| 25 struct PP_Var GetSelectedText(PP_Instance instance, PP_Bool html) { |
| 26 DebugPrintf("PPP_Selection_Dev::GetSelectedText: " |
| 27 "instance=%"NACL_PRIu32"\n", instance); |
| 28 NaClSrpcChannel* channel = GetMainSrpcChannel(instance); |
| 29 nacl_abi_size_t text_size = kMaxVarSize; |
| 30 nacl::scoped_array<char> text_bytes(new char[kMaxVarSize]); |
| 31 NaClSrpcError srpc_result = |
| 32 PppSelectionRpcClient::PPP_Selection_GetSelectedText( |
| 33 channel, |
| 34 instance, |
| 35 static_cast<int32_t>(html), |
| 36 &text_size, |
| 37 text_bytes.get()); |
| 38 |
| 39 DebugPrintf("PPP_Selection_Dev::GetSelectedText: %s\n", |
| 40 NaClSrpcErrorString(srpc_result)); |
| 41 |
| 42 PP_Var selected_text = PP_MakeUndefined(); |
| 43 if (srpc_result == NACL_SRPC_RESULT_OK) { |
| 44 (void) DeserializeTo( |
| 45 channel, text_bytes.get(), text_size, 1, &selected_text); |
| 46 } |
| 47 return selected_text; |
| 48 } |
| 49 |
| 50 } // namespace |
| 51 |
| 52 const PPP_Selection_Dev* BrowserSelection::GetInterface() { |
| 53 static const PPP_Selection_Dev selection_interface = { |
| 54 GetSelectedText |
| 55 }; |
| 56 return &selection_interface; |
| 57 } |
| 58 |
| 59 } // namespace ppapi_proxy |
| 60 |
OLD | NEW |