diff options
author | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-30 17:21:08 +0000 |
---|---|---|
committer | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-30 17:21:08 +0000 |
commit | fb0115f6c9c8c8a9486acfd7d62efbefd28af060 (patch) | |
tree | f71981234018bf8ed89561600023b53b923407b7 | |
parent | 5c7b379e0c9f1cfd2e771643786bffbf49c9c1bc (diff) | |
download | chromium_src-fb0115f6c9c8c8a9486acfd7d62efbefd28af060.zip chromium_src-fb0115f6c9c8c8a9486acfd7d62efbefd28af060.tar.gz chromium_src-fb0115f6c9c8c8a9486acfd7d62efbefd28af060.tar.bz2 |
Add a PPB_Find_Private function to set the tickmarks on the page.
This adds a PPB_Find_Private function to set the tickmarks on the page.
BUG=303491
TBR=viettrungluu@chromium.org
Review URL: https://codereview.chromium.org/195893044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260443 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.cc | 19 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.h | 3 | ||||
-rw-r--r-- | mojo/examples/pepper_container_app/plugin_instance.cc | 6 | ||||
-rw-r--r-- | mojo/examples/pepper_container_app/plugin_instance.h | 3 | ||||
-rw-r--r-- | ppapi/api/private/ppb_find_private.idl | 9 | ||||
-rw-r--r-- | ppapi/c/private/ppb_find_private.h | 12 | ||||
-rw-r--r-- | ppapi/cpp/private/find_private.cc | 13 | ||||
-rw-r--r-- | ppapi/cpp/private/find_private.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 25 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 5 | ||||
-rw-r--r-- | ppapi/thunk/ppb_find_private_thunk.cc | 15 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 3 |
13 files changed, 116 insertions, 3 deletions
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 1577431..e5eab7e 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -92,6 +92,7 @@ #include "skia/ext/platform_device.h" #include "third_party/WebKit/public/platform/WebCursorInfo.h" #include "third_party/WebKit/public/platform/WebGamepads.h" +#include "third_party/WebKit/public/platform/WebRect.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebURL.h" #include "third_party/WebKit/public/platform/WebURLError.h" @@ -2420,6 +2421,24 @@ void PepperPluginInstanceImpl::SelectedFindResultChanged(PP_Instance instance, } } +void PepperPluginInstanceImpl::SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) { + if (!render_frame_ || !render_frame_->GetWebFrame()) + return; + + blink::WebVector<blink::WebRect> tickmarks_converted( + static_cast<size_t>(count)); + for (uint32 i = 0; i < count; ++i) { + tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x, + tickmarks[i].point.y, + tickmarks[i].size.width, + tickmarks[i].size.height);; + } + blink::WebFrame* frame = render_frame_->GetWebFrame(); + frame->setTickmarks(tickmarks_converted); +} + PP_Bool PepperPluginInstanceImpl::IsFullscreen(PP_Instance instance) { return PP_FromBool(view_data_.is_fullscreen); } diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index cdf478a..8bddfb1 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -398,6 +398,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl PP_Bool final_result) OVERRIDE; virtual void SelectedFindResultChanged(PP_Instance instance, int32_t index) OVERRIDE; + virtual void SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) OVERRIDE; virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) OVERRIDE; diff --git a/mojo/examples/pepper_container_app/plugin_instance.cc b/mojo/examples/pepper_container_app/plugin_instance.cc index 2403927..cb39240 100644 --- a/mojo/examples/pepper_container_app/plugin_instance.cc +++ b/mojo/examples/pepper_container_app/plugin_instance.cc @@ -172,6 +172,12 @@ void PluginInstance::SelectedFindResultChanged(PP_Instance instance, NOTIMPLEMENTED(); } +void PluginInstance::SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) { + NOTIMPLEMENTED(); +} + PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) { NOTIMPLEMENTED(); return PP_FALSE; diff --git a/mojo/examples/pepper_container_app/plugin_instance.h b/mojo/examples/pepper_container_app/plugin_instance.h index 61f25fb..56bd73f 100644 --- a/mojo/examples/pepper_container_app/plugin_instance.h +++ b/mojo/examples/pepper_container_app/plugin_instance.h @@ -66,6 +66,9 @@ class PluginInstance : public ppapi::thunk::PPB_Instance_API { PP_Bool final_result) OVERRIDE; virtual void SelectedFindResultChanged(PP_Instance instance, int32_t index) OVERRIDE; + virtual void SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) OVERRIDE; virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) OVERRIDE; diff --git a/ppapi/api/private/ppb_find_private.idl b/ppapi/api/private/ppb_find_private.idl index 6ab272d..e6f7cfa 100644 --- a/ppapi/api/private/ppb_find_private.idl +++ b/ppapi/api/private/ppb_find_private.idl @@ -53,5 +53,14 @@ interface PPB_Find_Private { void SelectedFindResultChanged( [in] PP_Instance instance, [in] int32_t index); + + /** + * Updates the tickmarks on the scrollbar for the find request. |tickmarks| + * contains |count| PP_Rects indicating the tickmark ranges. + */ + void SetTickmarks( + [in] PP_Instance instance, + [in, size_as=count] PP_Rect[] tickmarks, + [in] uint32_t count); }; diff --git a/ppapi/c/private/ppb_find_private.h b/ppapi/c/private/ppb_find_private.h index 3aaaabd..09ebab0 100644 --- a/ppapi/c/private/ppb_find_private.h +++ b/ppapi/c/private/ppb_find_private.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/ppb_find_private.idl modified Thu Mar 13 11:56:31 2014. */ +/* From private/ppb_find_private.idl modified Wed Mar 19 13:42:13 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_FIND_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_FIND_PRIVATE_H_ @@ -11,6 +11,9 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_point.h" +#include "ppapi/c/pp_rect.h" +#include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_FIND_PRIVATE_INTERFACE_0_3 "PPB_Find_Private;0.3" @@ -60,6 +63,13 @@ struct PPB_Find_Private_0_3 { * Updates the index of the currently selected search item. */ void (*SelectedFindResultChanged)(PP_Instance instance, int32_t index); + /** + * Updates the tickmarks on the scrollbar for the find request. |tickmarks| + * contains |count| PP_Rects indicating the tickmark ranges. + */ + void (*SetTickmarks)(PP_Instance instance, + const struct PP_Rect tickmarks[], + uint32_t count); }; typedef struct PPB_Find_Private_0_3 PPB_Find_Private; diff --git a/ppapi/cpp/private/find_private.cc b/ppapi/cpp/private/find_private.cc index bd592a4..440bc74 100644 --- a/ppapi/cpp/private/find_private.cc +++ b/ppapi/cpp/private/find_private.cc @@ -8,6 +8,7 @@ #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/rect.h" namespace pp { @@ -83,4 +84,16 @@ void Find_Private::SelectedFindResultChanged(int32_t index) { } } +void Find_Private::SetTickmarks(const std::vector<pp::Rect>& tickmarks) { + if (has_interface<PPB_Find_Private>()) { + if (tickmarks.empty()) + return; + std::vector<PP_Rect> tickmarks_converted(tickmarks.begin(), + tickmarks.end()); + get_interface<PPB_Find_Private>()->SetTickmarks( + associated_instance_.pp_instance(), &tickmarks_converted[0], + static_cast<uint32_t>(tickmarks.size())); + } +} + } // namespace pp diff --git a/ppapi/cpp/private/find_private.h b/ppapi/cpp/private/find_private.h index 80ecb98..268033b 100644 --- a/ppapi/cpp/private/find_private.h +++ b/ppapi/cpp/private/find_private.h @@ -6,6 +6,7 @@ #define PPAPI_CPP_PRIVATE_FIND_PRIVATE_H_ #include <string> +#include <vector> #include "ppapi/c/private/ppp_find_private.h" #include "ppapi/cpp/instance_handle.h" @@ -13,6 +14,7 @@ namespace pp { class Instance; +class Rect; // This class allows you to associate the PPP_Find and PPB_Find C-based // interfaces with an object. It associates itself with the given instance, and @@ -53,6 +55,7 @@ class Find_Private { void SetPluginToHandleFindRequests(); void NumberOfFindResultsChanged(int32_t total, bool final_result); void SelectedFindResultChanged(int32_t index); + void SetTickmarks(const std::vector<pp::Rect>& tickmarks); private: InstanceHandle associated_instance_; diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index d4b84414..4366773 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -653,6 +653,9 @@ IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged, IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SelectFindResultChanged, PP_Instance /* instance */, int32_t /* index */) +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SetTickmarks, + PP_Instance /* instance */, + std::vector<PP_Rect> /* tickmarks */) // PPP_Printing IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPPrinting_QuerySupportedFormats, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 3dda61b..257d0d2 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -133,6 +133,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgNumberOfFindResultsChanged) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SelectFindResultChanged, OnHostMsgSelectFindResultChanged) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTickmarks, + OnHostMsgSetTickmarks) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, OnHostMsgPostMessage) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, @@ -335,6 +337,14 @@ void PPB_Instance_Proxy::SelectedFindResultChanged(PP_Instance instance, API_ID_PPB_INSTANCE, instance, index)); } +void PPB_Instance_Proxy::SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTickmarks( + API_ID_PPB_INSTANCE, instance, + std::vector<PP_Rect>(tickmarks, tickmarks + count))); +} + PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> GetInstanceData(instance); @@ -944,6 +954,21 @@ void PPB_Instance_Proxy::OnHostMsgSelectFindResultChanged( enter.functions()->SelectedFindResultChanged(instance, index); } +void PPB_Instance_Proxy::OnHostMsgSetTickmarks( + PP_Instance instance, + const std::vector<PP_Rect>& tickmarks) { + if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) + return; + if (tickmarks.empty()) + return; + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) { + enter.functions()->SetTickmarks(instance, + &tickmarks[0], + static_cast<uint32_t>(tickmarks.size())); + } +} + 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 2304ae6..40bb3f1 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -64,6 +64,9 @@ class PPB_Instance_Proxy : public InterfaceProxy, PP_Bool final_result) OVERRIDE; virtual void SelectedFindResultChanged(PP_Instance instance, int32_t index) OVERRIDE; + virtual void SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) OVERRIDE; virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) OVERRIDE; @@ -179,6 +182,8 @@ class PPB_Instance_Proxy : public InterfaceProxy, PP_Bool final_result); void OnHostMsgSelectFindResultChanged(PP_Instance instance, int32_t index); + void OnHostMsgSetTickmarks(PP_Instance instance, + const std::vector<PP_Rect>& tickmarks); void OnHostMsgSetFullscreen(PP_Instance instance, PP_Bool fullscreen, PP_Bool* result); diff --git a/ppapi/thunk/ppb_find_private_thunk.cc b/ppapi/thunk/ppb_find_private_thunk.cc index f530b62..ffa50af 100644 --- a/ppapi/thunk/ppb_find_private_thunk.cc +++ b/ppapi/thunk/ppb_find_private_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 private/ppb_find_private.idl modified Thu Mar 13 11:56:31 2014. +// From private/ppb_find_private.idl modified Wed Mar 19 13:42:13 2014. #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_find_private.h" @@ -41,10 +41,21 @@ void SelectedFindResultChanged(PP_Instance instance, int32_t index) { enter.functions()->SelectedFindResultChanged(instance, index); } +void SetTickmarks(PP_Instance instance, + const struct PP_Rect tickmarks[], + uint32_t count) { + VLOG(4) << "PPB_Find_Private::SetTickmarks()"; + EnterInstance enter(instance); + if (enter.failed()) + return; + enter.functions()->SetTickmarks(instance, tickmarks, count); +} + const PPB_Find_Private_0_3 g_ppb_find_private_thunk_0_3 = { &SetPluginToHandleFindRequests, &NumberOfFindResultsChanged, - &SelectedFindResultChanged + &SelectedFindResultChanged, + &SetTickmarks }; } // namespace diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 377b3a8..23bf18c 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -84,6 +84,9 @@ class PPB_Instance_API { PP_Bool final_result) = 0; virtual void SelectedFindResultChanged(PP_Instance instance, int32_t index) = 0; + virtual void SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) = 0; // Fullscreen. virtual PP_Bool IsFullscreen(PP_Instance instance) = 0; |