diff options
author | raymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-20 00:27:54 +0000 |
---|---|---|
committer | raymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-20 00:27:54 +0000 |
commit | 54ea9ff64816732a0854c0030e7a70601b81fdab (patch) | |
tree | 0fd95055eb8c713d622f5d461381f700b53c1e38 | |
parent | a15daaa6cdb86f847519fad6477437497d99a260 (diff) | |
download | chromium_src-54ea9ff64816732a0854c0030e7a70601b81fdab.zip chromium_src-54ea9ff64816732a0854c0030e7a70601b81fdab.tar.gz chromium_src-54ea9ff64816732a0854c0030e7a70601b81fdab.tar.bz2 |
This proxies PPB_Find_Dev so that it can be used out of process. It also adds a function named SetPluginToHandleFindRequests which can be called by embedded plugins which want to handle browser find. This is needed for the new out of process PDF plugin, which will be embedded in an extensions page.
BUG=303491
R=jam@chromium.org, jschuh@chromium.org, yzshen@chromium.org
Review URL: https://codereview.chromium.org/188323002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258171 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.cc | 18 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.h | 1 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 32 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 15 | ||||
-rw-r--r-- | ppapi/api/dev/ppb_find_dev.idl | 21 | ||||
-rw-r--r-- | ppapi/api/dev/ppp_find_dev.idl | 38 | ||||
-rw-r--r-- | ppapi/c/dev/ppb_find_dev.h | 21 | ||||
-rw-r--r-- | ppapi/c/dev/ppp_find_dev.h | 60 | ||||
-rw-r--r-- | ppapi/cpp/dev/find_dev.cc | 7 | ||||
-rw-r--r-- | ppapi/cpp/dev/find_dev.h | 3 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 4 | ||||
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 5 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 20 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 49 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 7 | ||||
-rw-r--r-- | ppapi/proxy/ppp_find_proxy.cc | 103 | ||||
-rw-r--r-- | ppapi/proxy/ppp_find_proxy.h | 46 | ||||
-rw-r--r-- | ppapi/shared_impl/api_id.h | 1 | ||||
-rw-r--r-- | ppapi/thunk/ppb_find_dev_thunk.cc | 11 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 1 |
21 files changed, 430 insertions, 35 deletions
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 1e8f7ab..dd3dbd91 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -631,6 +631,11 @@ PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { void PepperPluginInstanceImpl::Delete() { is_deleted_ = true; + if (render_frame_ && + render_frame_->render_view()->plugin_find_handler() == this) { + render_frame_->render_view()->set_plugin_find_handler(NULL); + } + // Keep a reference on the stack. See NOTE above. scoped_refptr<PepperPluginInstanceImpl> ref(this); // Force the MessageChannel to release its "passthrough object" which should @@ -1385,6 +1390,8 @@ void PepperPluginInstanceImpl::StopFind() { } bool PepperPluginInstanceImpl::LoadFindInterface() { + if (!module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) + return false; if (!plugin_find_interface_) { plugin_find_interface_ = static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( @@ -2382,6 +2389,17 @@ void PepperPluginInstanceImpl::DeliverSamples( content_decryptor_delegate_->DeliverSamples(audio_frames, sample_info); } +void PepperPluginInstanceImpl::SetPluginToHandleFindRequests( + PP_Instance instance) { + if (!LoadFindInterface()) + return; + bool is_main_frame = render_frame_ && + render_frame_->GetRenderView()->GetMainRenderFrame() == render_frame_; + if (!is_main_frame) + return; + render_frame_->render_view()->set_plugin_find_handler(this); +} + void PepperPluginInstanceImpl::NumberOfFindResultsChanged( PP_Instance instance, int32_t total, diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index 3dcf2d4..555685c 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -392,6 +392,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) OVERRIDE; virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; + virtual void SetPluginToHandleFindRequests(PP_Instance) OVERRIDE; virtual void NumberOfFindResultsChanged(PP_Instance instance, int32_t total, PP_Bool final_result) OVERRIDE; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 43de10e..59f1840 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -681,6 +681,7 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) focused_plugin_id_(-1), #endif #if defined(ENABLE_PLUGINS) + plugin_find_handler_(NULL), focused_pepper_plugin_(NULL), pepper_last_mouse_event_target_(NULL), #endif @@ -3348,23 +3349,34 @@ GURL RenderViewImpl::GetLoadingUrl(blink::WebFrame* frame) const { return request.url(); } -blink::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { - return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); +blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { + if (!webview()) + return NULL; + + WebFrame* main_frame = webview()->mainFrame(); + if (main_frame->document().isPluginDocument()) + return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); + +#if defined(ENABLE_PLUGINS) + if (plugin_find_handler_) + return plugin_find_handler_->container()->plugin(); +#endif + + return NULL; } void RenderViewImpl::OnFind(int request_id, const base::string16& search_text, const WebFindOptions& options) { WebFrame* main_frame = webview()->mainFrame(); - + blink::WebPlugin* plugin = GetWebPluginForFind(); // Check if the plugin still exists in the document. - if (main_frame->document().isPluginDocument() && - GetWebPluginFromPluginDocument()) { + if (plugin) { if (options.findNext) { // Just navigate back/forward. - GetWebPluginFromPluginDocument()->selectFindResult(options.forward); + plugin->selectFindResult(options.forward); } else { - if (!GetWebPluginFromPluginDocument()->startFind( + if (!plugin->startFind( search_text, options.matchCase, request_id)) { // Send "no results". SendFindReply(request_id, 0, 0, gfx::Rect(), true); @@ -3477,9 +3489,9 @@ void RenderViewImpl::OnStopFinding(StopFindAction action) { if (!view) return; - WebDocument doc = view->mainFrame()->document(); - if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { - GetWebPluginFromPluginDocument()->stopFind(); + blink::WebPlugin* plugin = GetWebPluginForFind(); + if (plugin) { + plugin->stopFind(); return; } diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index ff9ef65..3f7a5dd 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -274,6 +274,14 @@ class CONTENT_EXPORT RenderViewImpl // Plugin-related functions -------------------------------------------------- #if defined(ENABLE_PLUGINS) + // Get/set the plugin which will be used as to handle document find requests. + void set_plugin_find_handler(PepperPluginInstanceImpl* plugin) { + plugin_find_handler_ = plugin; + } + PepperPluginInstanceImpl* plugin_find_handler() { + return plugin_find_handler_; + } + PepperPluginInstanceImpl* focused_pepper_plugin() { return focused_pepper_plugin_; } @@ -1000,8 +1008,9 @@ class CONTENT_EXPORT RenderViewImpl // Returns the URL being loaded by the given frame's request. GURL GetLoadingUrl(blink::WebFrame* frame) const; - // Should only be called if this object wraps a PluginDocument. - blink::WebPlugin* GetWebPluginFromPluginDocument(); + // Called to get the WebPlugin to handle find requests in the document. + // Returns NULL if there is no such WebPlugin. + blink::WebPlugin* GetWebPluginForFind(); // Returns true if the |params| navigation is to an entry that has been // cropped due to a recent navigation the browser did not know about. @@ -1361,6 +1370,8 @@ class CONTENT_EXPORT RenderViewImpl #endif #if defined(ENABLE_PLUGINS) + PepperPluginInstanceImpl* plugin_find_handler_; + typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet; PepperPluginSet active_pepper_instances_; diff --git a/ppapi/api/dev/ppb_find_dev.idl b/ppapi/api/dev/ppb_find_dev.idl index 4f92f1c..d43e62bb 100644 --- a/ppapi/api/dev/ppb_find_dev.idl +++ b/ppapi/api/dev/ppb_find_dev.idl @@ -13,8 +13,29 @@ label Chrome { M14 = 0.3 }; +// TODO(raymes): Make PPP/PPB_Find_Dev a private interface. It's only used by +// PDF currently and it's restrictive in the way it can be used. interface PPB_Find_Dev { /** + * Sets the instance of this plugin as the mechanism that will be used to + * handle find requests in the renderer. This will only succeed if the plugin + * is embedded within the content of the top level frame. Note that this will + * result in the renderer handing over all responsibility for doing find to + * the plugin and content from the rest of the page will not be searched. + * + * + * In the case that the plugin is loaded directly as the top level document, + * this function does not need to be called. In that case the plugin is + * assumed to handle find requests. + * + * There can only be one plugin which handles find requests. If a plugin calls + * this while an existing plugin is registered, the existing plugin will be + * de-registered and will no longer receive any requests. + */ + void SetPluginToHandleFindRequests( + [in] PP_Instance instance); + + /** * Updates the number of find results for the current search term. If * there are no matches 0 should be passed in. Only when the plugin has * finished searching should it pass in the final count with final_result set diff --git a/ppapi/api/dev/ppp_find_dev.idl b/ppapi/api/dev/ppp_find_dev.idl new file mode 100644 index 0000000..d277d95 --- /dev/null +++ b/ppapi/api/dev/ppp_find_dev.idl @@ -0,0 +1,38 @@ +/* Copyright (c) 2014 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +label Chrome { + M14 = 0.3 +}; + +/** + * TODO(raymes): Make PPP/PPB_Find_Dev a private interface. + */ +interface PPP_Find_Dev { + /** + * Finds the given UTF-8 text starting at the current selection. The number of + * results will be updated asynchronously via NumberOfFindResultsChanged in + * PPB_Find. Note that multiple StartFind calls can happen before StopFind is + * called in the case of the search term changing. + * + * Return PP_FALSE if the plugin doesn't support find in page. Consequently, + * it won't call any callbacks. + */ + PP_Bool StartFind([in] PP_Instance instance, + [in] str_t text, + [in] PP_Bool case_sensitive); + + /** + * Go to the next/previous result. + */ + void SelectFindResult([in] PP_Instance instance, + [in] PP_Bool forward); + + /** + * Tells the plugin that the find operation has stopped, so it should clear + * any highlighting. + */ + void StopFind([in] PP_Instance instance); +}; diff --git a/ppapi/c/dev/ppb_find_dev.h b/ppapi/c/dev/ppb_find_dev.h index 203425d..15b8f27 100644 --- a/ppapi/c/dev/ppb_find_dev.h +++ b/ppapi/c/dev/ppb_find_dev.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From dev/ppb_find_dev.idl modified Wed Oct 5 14:06:02 2011. */ +/* From dev/ppb_find_dev.idl modified Thu Mar 13 11:05:53 2014. */ #ifndef PPAPI_C_DEV_PPB_FIND_DEV_H_ #define PPAPI_C_DEV_PPB_FIND_DEV_H_ @@ -26,8 +26,27 @@ * @addtogroup Interfaces * @{ */ +/* TODO(raymes): Make PPP/PPB_Find_Dev a private interface. It's only used by + * PDF currently and it's restrictive in the way it can be used. */ struct PPB_Find_Dev_0_3 { /** + * Sets the instance of this plugin as the mechanism that will be used to + * handle find requests in the renderer. This will only succeed if the plugin + * is embedded within the content of the top level frame. Note that this will + * result in the renderer handing over all responsibility for doing find to + * the plugin and content from the rest of the page will not be searched. + * + * + * In the case that the plugin is loaded directly as the top level document, + * this function does not need to be called. In that case the plugin is + * assumed to handle find requests. + * + * There can only be one plugin which handles find requests. If a plugin calls + * this while an existing plugin is registered, the existing plugin will be + * de-registered and will no longer receive any requests. + */ + void (*SetPluginToHandleFindRequests)(PP_Instance instance); + /** * Updates the number of find results for the current search term. If * there are no matches 0 should be passed in. Only when the plugin has * finished searching should it pass in the final count with final_result set diff --git a/ppapi/c/dev/ppp_find_dev.h b/ppapi/c/dev/ppp_find_dev.h index ecf0729..6d9a4cc 100644 --- a/ppapi/c/dev/ppp_find_dev.h +++ b/ppapi/c/dev/ppp_find_dev.h @@ -1,35 +1,61 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. +/* Copyright (c) 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + +/* From dev/ppp_find_dev.idl modified Wed Mar 19 14:02:22 2014. */ + #ifndef PPAPI_C_DEV_PPP_FIND_DEV_H_ #define PPAPI_C_DEV_PPP_FIND_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_stdint.h" + +#define PPP_FIND_DEV_INTERFACE_0_3 "PPP_Find(Dev);0.3" +#define PPP_FIND_DEV_INTERFACE PPP_FIND_DEV_INTERFACE_0_3 + +/** + * @file + */ -#define PPP_FIND_DEV_INTERFACE "PPP_Find(Dev);0.3" -struct PPP_Find_Dev { - // Finds the given UTF-8 text starting at the current selection. The number of - // results will be updated asynchronously via NumberOfFindResultsChanged in - // PPB_Find. Note that multiple StartFind calls can happen before StopFind is - // called in the case of the search term changing. - // - // Return PP_FALSE if the plugin doesn't support find in page. Consequently, - // it won't call any callbacks. +/** + * @addtogroup Interfaces + * @{ + */ +/** + * TODO(raymes): Make PPP/PPB_Find_Dev a private interface. + */ +struct PPP_Find_Dev_0_3 { + /** + * Finds the given UTF-8 text starting at the current selection. The number of + * results will be updated asynchronously via NumberOfFindResultsChanged in + * PPB_Find. Note that multiple StartFind calls can happen before StopFind is + * called in the case of the search term changing. + * + * Return PP_FALSE if the plugin doesn't support find in page. Consequently, + * it won't call any callbacks. + */ PP_Bool (*StartFind)(PP_Instance instance, const char* text, PP_Bool case_sensitive); - - // Go to the next/previous result. - void (*SelectFindResult)(PP_Instance instance, - PP_Bool forward); - - // Tells the plugin that the find operation has stopped, so it should clear - // any highlighting. + /** + * Go to the next/previous result. + */ + void (*SelectFindResult)(PP_Instance instance, PP_Bool forward); + /** + * Tells the plugin that the find operation has stopped, so it should clear + * any highlighting. + */ void (*StopFind)(PP_Instance instance); }; +typedef struct PPP_Find_Dev_0_3 PPP_Find_Dev; +/** + * @} + */ + #endif /* PPAPI_C_DEV_PPP_FIND_DEV_H_ */ diff --git a/ppapi/cpp/dev/find_dev.cc b/ppapi/cpp/dev/find_dev.cc index e9640bc..1004b49 100644 --- a/ppapi/cpp/dev/find_dev.cc +++ b/ppapi/cpp/dev/find_dev.cc @@ -60,6 +60,13 @@ Find_Dev::~Find_Dev() { kPPPFindInterface, this); } +void Find_Dev::SetPluginToHandleFindRequests() { + if (has_interface<PPB_Find_Dev>()) { + get_interface<PPB_Find_Dev>()->SetPluginToHandleFindRequests( + associated_instance_.pp_instance()); + } +} + void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) { if (has_interface<PPB_Find_Dev>()) { get_interface<PPB_Find_Dev>()->NumberOfFindResultsChanged( diff --git a/ppapi/cpp/dev/find_dev.h b/ppapi/cpp/dev/find_dev.h index 89c2d5a..a3170eb 100644 --- a/ppapi/cpp/dev/find_dev.h +++ b/ppapi/cpp/dev/find_dev.h @@ -49,7 +49,8 @@ class Find_Dev { virtual void SelectFindResult(bool forward) = 0; virtual void StopFind() = 0; - // PPB_Find_Def functions for you to call to report find results. + // PPB_Find_Dev functions for you to call to report find results. + void SetPluginToHandleFindRequests(); void NumberOfFindResultsChanged(int32_t total, bool final_result); void SelectedFindResultChanged(int32_t index); diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 0728453..9cee893 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -2402,6 +2402,8 @@ static void Pnacl_M14_PPB_VideoDecoder_Dev_Destroy(PP_Resource video_decoder) { /* Not generating wrapper methods for PPB_Zoom_Dev_0_2 */ +/* Not generating wrapper methods for PPP_Find_Dev_0_3 */ + /* Not generating wrapper methods for PPP_NetworkState_Dev_0_1 */ /* Not generating wrapper methods for PPP_Printing_Dev_0_6 */ @@ -4853,6 +4855,8 @@ static const struct PPB_VideoDecoder_Dev_0_16 Pnacl_Wrappers_PPB_VideoDecoder_De /* Not generating wrapper interface for PPB_Zoom_Dev_0_2 */ +/* Not generating wrapper interface for PPP_Find_Dev_0_3 */ + /* Not generating wrapper interface for PPP_NetworkState_Dev_0_1 */ /* Not generating wrapper interface for PPP_Printing_Dev_0_6 */ diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index d6fc604..49e2232 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -158,6 +158,8 @@ 'proxy/ppp_class_proxy.h', 'proxy/ppp_content_decryptor_private_proxy.cc', 'proxy/ppp_content_decryptor_private_proxy.h', + 'proxy/ppp_find_proxy.cc', + 'proxy/ppp_find_proxy.h', 'proxy/ppp_graphics_3d_proxy.cc', 'proxy/ppp_graphics_3d_proxy.h', 'proxy/ppp_input_event_proxy.cc', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 8b00e66..3a6d988 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -125,6 +125,7 @@ #include "ppapi/proxy/ppb_x509_certificate_private_proxy.h" #include "ppapi/proxy/ppp_class_proxy.h" #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h" +#include "ppapi/proxy/ppp_find_proxy.h" #include "ppapi/proxy/ppp_graphics_3d_proxy.h" #include "ppapi/proxy/ppp_input_event_proxy.h" #include "ppapi/proxy/ppp_instance_private_proxy.h" @@ -299,9 +300,11 @@ InterfaceList::InterfaceList() { AddPPP(PPP_PRINTING_DEV_INTERFACE, PPP_Printing_Proxy::GetProxyInterface()); AddProxy(API_ID_PPP_TEXT_INPUT, &ProxyFactory<PPP_TextInput_Proxy>); AddPPP(PPP_TEXTINPUT_DEV_INTERFACE, PPP_TextInput_Proxy::GetProxyInterface()); +#if !defined(OS_NACL) AddProxy(API_ID_PPP_PDF, &ProxyFactory<PPP_Pdf_Proxy>); AddPPP(PPP_PDF_INTERFACE, PPP_Pdf_Proxy::GetProxyInterface()); -#if !defined(OS_NACL) + AddProxy(API_ID_PPP_FIND_DEV, &ProxyFactory<PPP_Find_Proxy>); + AddPPP(PPP_FIND_DEV_INTERFACE, PPP_Find_Proxy::GetProxyInterface()); AddProxy(API_ID_PPP_VIDEO_DECODER_DEV, &ProxyFactory<PPP_VideoDecoder_Proxy>); AddPPP(PPP_VIDEODECODER_DEV_INTERFACE, PPP_VideoDecoder_Proxy::GetProxyInterface()); diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index bf5048e..ead5680 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -633,6 +633,26 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPPdf_Rotate, PP_Instance /* instance */, bool /* clockwise */) +// Find +IPC_MESSAGE_ROUTED2(PpapiPluginMsg_PPPFind_StartFind, + PP_Instance /* instance */, + std::string /* text */) +IPC_MESSAGE_ROUTED2(PpapiPluginMsg_PPPFind_SelectFindResult, + PP_Instance /* instance */, + PP_Bool /* forward */) +IPC_MESSAGE_ROUTED1(PpapiPluginMsg_PPPFind_StopFind, + PP_Instance /* instance */) + +IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBInstance_SetPluginToHandleFindRequests, + PP_Instance /* instance */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged, + PP_Instance /* instance */, + int32_t /* total */, + PP_Bool /* final_result */) +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SelectFindResultChanged, + PP_Instance /* instance */, + int32_t /* index */) + // PPP_Printing IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPPrinting_QuerySupportedFormats, PP_Instance /* instance */, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 885b5e4..3dda61b 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -127,6 +127,12 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgExecuteScript) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDefaultCharSet, OnHostMsgGetDefaultCharSet) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetPluginToHandleFindRequests, + OnHostMsgSetPluginToHandleFindRequests); + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged, + OnHostMsgNumberOfFindResultsChanged) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SelectFindResultChanged, + OnHostMsgSelectFindResultChanged) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, OnHostMsgPostMessage) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, @@ -311,15 +317,22 @@ PP_Var PPB_Instance_Proxy::GetDefaultCharSet(PP_Instance instance) { return result.Return(dispatcher); } +void PPB_Instance_Proxy::SetPluginToHandleFindRequests(PP_Instance instance) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetPluginToHandleFindRequests( + API_ID_PPB_INSTANCE, instance)); +} + void PPB_Instance_Proxy::NumberOfFindResultsChanged(PP_Instance instance, int32_t total, PP_Bool final_result) { - NOTIMPLEMENTED(); // Not proxied yet. + dispatcher()->Send(new PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged( + API_ID_PPB_INSTANCE, instance, total, final_result)); } void PPB_Instance_Proxy::SelectedFindResultChanged(PP_Instance instance, int32_t index) { - NOTIMPLEMENTED(); // Not proxied yet. + dispatcher()->Send(new PpapiHostMsg_PPBInstance_SelectFindResultChanged( + API_ID_PPB_INSTANCE, instance, index)); } PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { @@ -899,6 +912,38 @@ void PPB_Instance_Proxy::OnHostMsgGetDefaultCharSet( result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); } +void PPB_Instance_Proxy::OnHostMsgSetPluginToHandleFindRequests( + PP_Instance instance) { + if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) + return; + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) + enter.functions()->SetPluginToHandleFindRequests(instance); +} + +void PPB_Instance_Proxy::OnHostMsgNumberOfFindResultsChanged( + PP_Instance instance, + int32_t total, + PP_Bool final_result) { + if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) + return; + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) { + enter.functions()->NumberOfFindResultsChanged( + instance, total, final_result); + } +} + +void PPB_Instance_Proxy::OnHostMsgSelectFindResultChanged( + PP_Instance instance, + int32_t index) { + if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) + return; + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) + enter.functions()->SelectedFindResultChanged(instance, index); +} + void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance, PP_Bool fullscreen, PP_Bool* result) { diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index c8aa49d..2304ae6 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -58,6 +58,7 @@ class PPB_Instance_Proxy : public InterfaceProxy, virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) OVERRIDE; virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; + virtual void SetPluginToHandleFindRequests(PP_Instance instance) OVERRIDE; virtual void NumberOfFindResultsChanged(PP_Instance instance, int32_t total, PP_Bool final_result) OVERRIDE; @@ -172,6 +173,12 @@ class PPB_Instance_Proxy : public InterfaceProxy, uint32_t *result); void OnHostMsgGetDefaultCharSet(PP_Instance instance, SerializedVarReturnValue result); + void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance); + void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance, + int32_t total, + PP_Bool final_result); + void OnHostMsgSelectFindResultChanged(PP_Instance instance, + int32_t index); void OnHostMsgSetFullscreen(PP_Instance instance, PP_Bool fullscreen, PP_Bool* result); diff --git a/ppapi/proxy/ppp_find_proxy.cc b/ppapi/proxy/ppp_find_proxy.cc new file mode 100644 index 0000000..0547e61 --- /dev/null +++ b/ppapi/proxy/ppp_find_proxy.cc @@ -0,0 +1,103 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/proxy/ppp_find_proxy.h" + +#include "ppapi/proxy/host_dispatcher.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/api_id.h" +#include "ppapi/shared_impl/proxy_lock.h" + +namespace ppapi { +namespace proxy { + +namespace { + +#if !defined(OS_NACL) +PP_Bool StartFind(PP_Instance instance, + const char* text, + PP_Bool case_sensitive) { + DCHECK(case_sensitive == PP_FALSE); + HostDispatcher::GetForInstance(instance)->Send( + new PpapiPluginMsg_PPPFind_StartFind(API_ID_PPP_FIND_DEV, + instance, + text)); + return PP_TRUE; +} + +void SelectFindResult(PP_Instance instance, + PP_Bool forward) { + HostDispatcher::GetForInstance(instance)->Send( + new PpapiPluginMsg_PPPFind_SelectFindResult(API_ID_PPP_FIND_DEV, + instance, forward)); +} + +void StopFind(PP_Instance instance) { + HostDispatcher::GetForInstance(instance)->Send( + new PpapiPluginMsg_PPPFind_StopFind(API_ID_PPP_FIND_DEV, instance)); +} + +const PPP_Find_Dev ppp_find_interface = { + &StartFind, + &SelectFindResult, + &StopFind +}; +#else +// The NaCl plugin doesn't need the host side interface - stub it out. +const PPP_Find_Dev ppp_find_interface = {}; +#endif + +} // namespace + +PPP_Find_Proxy::PPP_Find_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_find_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_find_ = static_cast<const PPP_Find_Dev*>( + dispatcher->local_get_interface()(PPP_FIND_DEV_INTERFACE)); + } +} + +PPP_Find_Proxy::~PPP_Find_Proxy() { +} + +// static +const PPP_Find_Dev* PPP_Find_Proxy::GetProxyInterface() { + return &ppp_find_interface; +} + +bool PPP_Find_Proxy::OnMessageReceived(const IPC::Message& msg) { + if (!dispatcher()->IsPlugin()) + return false; + + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PPP_Find_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiPluginMsg_PPPFind_StartFind, OnPluginMsgStartFind) + IPC_MESSAGE_HANDLER(PpapiPluginMsg_PPPFind_SelectFindResult, + OnPluginMsgSelectFindResult) + IPC_MESSAGE_HANDLER(PpapiPluginMsg_PPPFind_StopFind, OnPluginMsgStopFind) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void PPP_Find_Proxy::OnPluginMsgStartFind(PP_Instance instance, + const std::string& text) { + if (ppp_find_) + CallWhileUnlocked(ppp_find_->StartFind, instance, text.c_str(), PP_FALSE); +} + +void PPP_Find_Proxy::OnPluginMsgSelectFindResult(PP_Instance instance, + PP_Bool forward) { + if (ppp_find_) + CallWhileUnlocked(ppp_find_->SelectFindResult, instance, forward); +} + +void PPP_Find_Proxy::OnPluginMsgStopFind(PP_Instance instance) { + if (ppp_find_) + CallWhileUnlocked(ppp_find_->StopFind, instance); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/ppp_find_proxy.h b/ppapi/proxy/ppp_find_proxy.h new file mode 100644 index 0000000..fa0961e --- /dev/null +++ b/ppapi/proxy/ppp_find_proxy.h @@ -0,0 +1,46 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_PPP_FIND_PROXY_H_ +#define PPAPI_PROXY_PPP_FIND_PROXY_H_ + +#include <string> + +#include "ppapi/c/dev/ppp_find_dev.h" +#include "ppapi/proxy/interface_proxy.h" + +namespace ppapi { + +namespace proxy { + +class PPP_Find_Proxy : public InterfaceProxy { + public: + explicit PPP_Find_Proxy(Dispatcher* dispatcher); + virtual ~PPP_Find_Proxy(); + + static const PPP_Find_Dev* GetProxyInterface(); + + // InterfaceProxy implementation. + virtual bool OnMessageReceived(const IPC::Message& msg); + + private: + // Message handlers. + void OnPluginMsgStartFind(PP_Instance instance, + const std::string& text); + void OnPluginMsgSelectFindResult(PP_Instance instance, + PP_Bool forward); + void OnPluginMsgStopFind(PP_Instance instance); + + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_Find_Dev* ppp_find_; + + DISALLOW_COPY_AND_ASSIGN(PPP_Find_Proxy); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PPP_FIND_PROXY_H_ diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h index dd19bb7..2f18a85 100644 --- a/ppapi/shared_impl/api_id.h +++ b/ppapi/shared_impl/api_id.h @@ -50,6 +50,7 @@ enum ApiID { // TODO(tomfinegan): Remove this after we refactor things to load the PPP // interface struct from the PPB interface. API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, + API_ID_PPP_FIND_DEV, API_ID_PPP_GRAPHICS_3D, API_ID_PPP_INPUT_EVENT, API_ID_PPP_INSTANCE, diff --git a/ppapi/thunk/ppb_find_dev_thunk.cc b/ppapi/thunk/ppb_find_dev_thunk.cc index 05698cb..91224f9 100644 --- a/ppapi/thunk/ppb_find_dev_thunk.cc +++ b/ppapi/thunk/ppb_find_dev_thunk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From dev/ppb_find_dev.idl modified Tue Aug 20 08:13:36 2013. +// From dev/ppb_find_dev.idl modified Thu Mar 13 11:05:53 2014. #include "ppapi/c/dev/ppb_find_dev.h" #include "ppapi/c/pp_errors.h" @@ -15,6 +15,14 @@ namespace thunk { namespace { +void SetPluginToHandleFindRequests(PP_Instance instance) { + VLOG(4) << "PPB_Find_Dev::SetPluginToHandleFindRequests()"; + EnterInstance enter(instance); + if (enter.failed()) + return; + enter.functions()->SetPluginToHandleFindRequests(instance); +} + void NumberOfFindResultsChanged(PP_Instance instance, int32_t total, PP_Bool final_result) { @@ -34,6 +42,7 @@ void SelectedFindResultChanged(PP_Instance instance, int32_t index) { } const PPB_Find_Dev_0_3 g_ppb_find_dev_thunk_0_3 = { + &SetPluginToHandleFindRequests, &NumberOfFindResultsChanged, &SelectedFindResultChanged }; diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 0136839..377b3a8 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -78,6 +78,7 @@ class PPB_Instance_API { PP_Var value) = 0; // Find. + virtual void SetPluginToHandleFindRequests(PP_Instance instance) = 0; virtual void NumberOfFindResultsChanged(PP_Instance instance, int32_t total, PP_Bool final_result) = 0; |