1 // Copyright 2014 The Chromium 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.
5 #include "ppapi/proxy/ppp_find_proxy.h"
7 #include "ppapi/proxy/host_dispatcher.h"
8 #include "ppapi/proxy/ppapi_messages.h"
9 #include "ppapi/shared_impl/api_id.h"
10 #include "ppapi/shared_impl/proxy_lock.h"
18 PP_Bool
StartFind(PP_Instance instance
,
20 PP_Bool case_sensitive
) {
21 DCHECK(case_sensitive
== PP_FALSE
);
22 HostDispatcher::GetForInstance(instance
)->Send(
23 new PpapiPluginMsg_PPPFind_StartFind(API_ID_PPP_FIND_PRIVATE
,
29 void SelectFindResult(PP_Instance instance
,
31 HostDispatcher::GetForInstance(instance
)->Send(
32 new PpapiPluginMsg_PPPFind_SelectFindResult(API_ID_PPP_FIND_PRIVATE
,
36 void StopFind(PP_Instance instance
) {
37 HostDispatcher::GetForInstance(instance
)->Send(
38 new PpapiPluginMsg_PPPFind_StopFind(API_ID_PPP_FIND_PRIVATE
, instance
));
41 const PPP_Find_Private ppp_find_interface
= {
47 // The NaCl plugin doesn't need the host side interface - stub it out.
48 const PPP_Find_Private ppp_find_interface
= {};
53 PPP_Find_Proxy::PPP_Find_Proxy(Dispatcher
* dispatcher
)
54 : InterfaceProxy(dispatcher
),
56 if (dispatcher
->IsPlugin()) {
57 ppp_find_
= static_cast<const PPP_Find_Private
*>(
58 dispatcher
->local_get_interface()(PPP_FIND_PRIVATE_INTERFACE
));
62 PPP_Find_Proxy::~PPP_Find_Proxy() {
66 const PPP_Find_Private
* PPP_Find_Proxy::GetProxyInterface() {
67 return &ppp_find_interface
;
70 bool PPP_Find_Proxy::OnMessageReceived(const IPC::Message
& msg
) {
71 if (!dispatcher()->IsPlugin())
75 IPC_BEGIN_MESSAGE_MAP(PPP_Find_Proxy
, msg
)
76 IPC_MESSAGE_HANDLER(PpapiPluginMsg_PPPFind_StartFind
, OnPluginMsgStartFind
)
77 IPC_MESSAGE_HANDLER(PpapiPluginMsg_PPPFind_SelectFindResult
,
78 OnPluginMsgSelectFindResult
)
79 IPC_MESSAGE_HANDLER(PpapiPluginMsg_PPPFind_StopFind
, OnPluginMsgStopFind
)
80 IPC_MESSAGE_UNHANDLED(handled
= false)
85 void PPP_Find_Proxy::OnPluginMsgStartFind(PP_Instance instance
,
86 const std::string
& text
) {
88 CallWhileUnlocked(ppp_find_
->StartFind
, instance
, text
.c_str(), PP_FALSE
);
91 void PPP_Find_Proxy::OnPluginMsgSelectFindResult(PP_Instance instance
,
94 CallWhileUnlocked(ppp_find_
->SelectFindResult
, instance
, forward
);
97 void PPP_Find_Proxy::OnPluginMsgStopFind(PP_Instance instance
) {
99 CallWhileUnlocked(ppp_find_
->StopFind
, instance
);