| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "native_client/src/shared/ppapi_proxy/browser_ppp_find.h" | 5 #include "native_client/src/shared/ppapi_proxy/browser_ppp_find.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 // Include file order cannot be observed because ppp_instance declares a | 9 // Include file order cannot be observed because ppp_instance declares a |
| 10 // structure return type that causes an error on Windows. | 10 // structure return type that causes an error on Windows. |
| 11 // TODO(sehr, brettw): fix the return types and include order in PPAPI. | 11 // TODO(sehr, brettw): fix the return types and include order in PPAPI. |
| 12 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
| 13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
| 14 #include "srpcgen/ppp_rpc.h" | 14 #include "srpcgen/ppp_rpc.h" |
| 15 #include "native_client/src/include/portability.h" | 15 #include "native_client/src/include/portability.h" |
| 16 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 16 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 17 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" | 17 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
| 18 #include "native_client/src/shared/ppapi_proxy/utility.h" | 18 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 19 | 19 |
| 20 namespace ppapi_proxy { | 20 namespace ppapi_proxy { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 PP_Bool StartFind(PP_Instance instance, | 24 PP_Bool StartFind(PP_Instance instance, |
| 25 const char* text, | 25 const char* text, |
| 26 PP_Bool case_sensitive) { | 26 PP_Bool case_sensitive) { |
| 27 DebugPrintf("PPP_Find::StartFind: instance=%"NACL_PRIu32"\n", instance); | 27 DebugPrintf("PPP_Find::StartFind: instance=%"NACL_PRId32"\n", instance); |
| 28 | 28 |
| 29 int32_t supports_find = 0; | 29 int32_t supports_find = 0; |
| 30 nacl_abi_size_t text_bytes = static_cast<nacl_abi_size_t>(strlen(text)) + 1; | 30 nacl_abi_size_t text_bytes = static_cast<nacl_abi_size_t>(strlen(text)) + 1; |
| 31 NaClSrpcError srpc_result = PppFindRpcClient::PPP_Find_StartFind( | 31 NaClSrpcError srpc_result = PppFindRpcClient::PPP_Find_StartFind( |
| 32 GetMainSrpcChannel(instance), | 32 GetMainSrpcChannel(instance), |
| 33 instance, | 33 instance, |
| 34 text_bytes, const_cast<char*>(text), | 34 text_bytes, const_cast<char*>(text), |
| 35 static_cast<int32_t>(case_sensitive), | 35 static_cast<int32_t>(case_sensitive), |
| 36 &supports_find); | 36 &supports_find); |
| 37 | 37 |
| 38 DebugPrintf("PPP_Find::StartFind: %s\n", NaClSrpcErrorString(srpc_result)); | 38 DebugPrintf("PPP_Find::StartFind: %s\n", NaClSrpcErrorString(srpc_result)); |
| 39 return supports_find ? PP_TRUE : PP_FALSE; | 39 return PP_FromBool(supports_find); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void SelectFindResult(PP_Instance instance, | 42 void SelectFindResult(PP_Instance instance, |
| 43 PP_Bool forward) { | 43 PP_Bool forward) { |
| 44 DebugPrintf("PPP_Find::SelectFindResult: " | 44 DebugPrintf("PPP_Find::SelectFindResult: " |
| 45 "instance=%"NACL_PRIu32"\n", instance); | 45 "instance=%"NACL_PRId32"\n", instance); |
| 46 | 46 |
| 47 NaClSrpcError srpc_result = PppFindRpcClient::PPP_Find_SelectFindResult( | 47 NaClSrpcError srpc_result = PppFindRpcClient::PPP_Find_SelectFindResult( |
| 48 GetMainSrpcChannel(instance), | 48 GetMainSrpcChannel(instance), |
| 49 instance, | 49 instance, |
| 50 static_cast<int32_t>(forward)); | 50 static_cast<int32_t>(forward)); |
| 51 | 51 |
| 52 DebugPrintf("PPP_Find::SelectFindResult: %s\n", | 52 DebugPrintf("PPP_Find::SelectFindResult: %s\n", |
| 53 NaClSrpcErrorString(srpc_result)); | 53 NaClSrpcErrorString(srpc_result)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void StopFind(PP_Instance instance) { | 56 void StopFind(PP_Instance instance) { |
| 57 DebugPrintf("PPP_Find::StopFind: instance=%"NACL_PRIu32"\n", instance); | 57 DebugPrintf("PPP_Find::StopFind: instance=%"NACL_PRId32"\n", instance); |
| 58 | 58 |
| 59 NaClSrpcError srpc_result = PppFindRpcClient::PPP_Find_StopFind( | 59 NaClSrpcError srpc_result = PppFindRpcClient::PPP_Find_StopFind( |
| 60 GetMainSrpcChannel(instance), | 60 GetMainSrpcChannel(instance), |
| 61 instance); | 61 instance); |
| 62 | 62 |
| 63 DebugPrintf("PPP_Find::StopFind: %s\n", NaClSrpcErrorString(srpc_result)); | 63 DebugPrintf("PPP_Find::StopFind: %s\n", NaClSrpcErrorString(srpc_result)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 const PPP_Find_Dev* BrowserFind::GetInterface() { | 68 const PPP_Find_Dev* BrowserFind::GetInterface() { |
| 69 static const PPP_Find_Dev find_interface = { | 69 static const PPP_Find_Dev find_interface = { |
| 70 StartFind, | 70 StartFind, |
| 71 SelectFindResult, | 71 SelectFindResult, |
| 72 StopFind | 72 StopFind |
| 73 }; | 73 }; |
| 74 return &find_interface; | 74 return &find_interface; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace ppapi_proxy | 77 } // namespace ppapi_proxy |
| 78 | |
| OLD | NEW |