diff options
author | koz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 11:40:25 +0000 |
---|---|---|
committer | koz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 11:40:25 +0000 |
commit | ec15840f7bc0a031f1476fb1da0c382604990e29 (patch) | |
tree | cacb834ff665c1fe8c5afb57586c9ba8a2e8e284 | |
parent | fbb9ee0842eaf89576930fdab88ead289dfb7bcf (diff) | |
download | chromium_src-ec15840f7bc0a031f1476fb1da0c382604990e29.zip chromium_src-ec15840f7bc0a031f1476fb1da0c382604990e29.tar.gz chromium_src-ec15840f7bc0a031f1476fb1da0c382604990e29.tar.bz2 |
Proxy the PDF API to the PDF plugin.
This makes the Rotate Clockwise / Counterclockwise context menu items work.
Review URL: https://codereview.chromium.org/142413006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249366 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.cc | 2 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.h | 2 | ||||
-rw-r--r-- | content/renderer/pepper/ppp_pdf.h | 34 | ||||
-rw-r--r-- | ppapi/PRESUBMIT.py | 2 | ||||
-rw-r--r-- | ppapi/c/private/ppp_pdf.h | 34 | ||||
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 5 | ||||
-rw-r--r-- | ppapi/proxy/ppp_pdf_proxy.cc | 77 | ||||
-rw-r--r-- | ppapi/proxy/ppp_pdf_proxy.h | 40 | ||||
-rw-r--r-- | ppapi/shared_impl/api_id.h | 1 |
11 files changed, 167 insertions, 35 deletions
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 3b3c94d..b54b4d4 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -41,7 +41,6 @@ #include "content/renderer/pepper/ppb_buffer_impl.h" #include "content/renderer/pepper/ppb_graphics_3d_impl.h" #include "content/renderer/pepper/ppb_image_data_impl.h" -#include "content/renderer/pepper/ppp_pdf.h" #include "content/renderer/pepper/renderer_ppapi_host_impl.h" #include "content/renderer/pepper/url_request_info_util.h" #include "content/renderer/pepper/url_response_info_util.h" @@ -67,6 +66,7 @@ #include "ppapi/c/ppp_messaging.h" #include "ppapi/c/ppp_mouse_lock.h" #include "ppapi/c/private/ppp_instance_private.h" +#include "ppapi/c/private/ppp_pdf.h" #include "ppapi/host/ppapi_host.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/uma_private_resource.h" diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index 02861bd..62c6614 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -21,7 +21,6 @@ #include "content/public/renderer/pepper_plugin_instance.h" #include "content/public/renderer/render_frame_observer.h" #include "content/renderer/mouse_lock_dispatcher.h" -#include "content/renderer/pepper/ppp_pdf.h" #include "ppapi/c/dev/pp_cursor_type_dev.h" #include "ppapi/c/dev/ppp_find_dev.h" #include "ppapi/c/dev/ppp_printing_dev.h" @@ -41,6 +40,7 @@ #include "ppapi/c/ppp_mouse_lock.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" #include "ppapi/c/private/ppp_instance_private.h" +#include "ppapi/c/private/ppp_pdf.h" #include "ppapi/shared_impl/ppb_instance_shared.h" #include "ppapi/shared_impl/ppb_view_shared.h" #include "ppapi/shared_impl/singleton_resource_id.h" diff --git a/content/renderer/pepper/ppp_pdf.h b/content/renderer/pepper/ppp_pdf.h index 3e52ad7..7f1e257 100644 --- a/content/renderer/pepper/ppp_pdf.h +++ b/content/renderer/pepper/ppp_pdf.h @@ -2,35 +2,5 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_RENDERER_PEPPER_PPP_PDF_H_ -#define CONTENT_RENDERER_PEPPER_PPP_PDF_H_ - -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_point.h" -#include "ppapi/c/pp_var.h" - -#define PPP_PDF_INTERFACE_1 "PPP_Pdf;1" -#define PPP_PDF_INTERFACE PPP_PDF_INTERFACE_1 - -typedef enum { - // Rotates the page 90 degrees clockwise from its current orientation. - PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW, - // Rotates the page 90 degrees counterclockwise from its current orientation. - PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW -} PP_PrivatePageTransformType; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrivatePageTransformType, 4); - -struct PPP_Pdf_1 { - // Returns an absolute URL if the position is over a link. - // Deprecated: The plugin now notifies the host when the cursor is over a - // link. - PP_Var (*GetLinkAtPosition)(PP_Instance instance, - PP_Point point); - - // Requests that the plugin apply the given transform to its view. - void (*Transform)(PP_Instance instance, PP_PrivatePageTransformType type); -}; - -typedef PPP_Pdf_1 PPP_Pdf; - -#endif // CONTENT_RENDERER_PEPPER_PPP_PDF_H_ +// TODO(koz): Remove this when the PDF plugin doesn't refer to it. +#include "ppapi/c/private/ppp_pdf.h" diff --git a/ppapi/PRESUBMIT.py b/ppapi/PRESUBMIT.py index 44efb2f..4a71f49 100644 --- a/ppapi/PRESUBMIT.py +++ b/ppapi/PRESUBMIT.py @@ -202,7 +202,7 @@ def CheckChange(input_api, output_api): whitelist = ['ppb_opengles2', 'ppb_opengles2ext_dev'] # The PDF interface is hand-written. - whitelist += ['ppb_pdf'] + whitelist += ['ppb_pdf', 'ppp_pdf'] # Find all relevant .h and .idl files. for filename in files: diff --git a/ppapi/c/private/ppp_pdf.h b/ppapi/c/private/ppp_pdf.h new file mode 100644 index 0000000..144e95c --- /dev/null +++ b/ppapi/c/private/ppp_pdf.h @@ -0,0 +1,34 @@ +// 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_C_PRIVATE_PPP_PDF_H_ +#define PPAPI_C_PRIVATE_PPP_PDF_H_ + +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_point.h" +#include "ppapi/c/pp_var.h" + +#define PPP_PDF_INTERFACE_1 "PPP_Pdf;1" +#define PPP_PDF_INTERFACE PPP_PDF_INTERFACE_1 + +typedef enum { + // Rotates the page 90 degrees clockwise from its current orientation. + PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW, + // Rotates the page 90 degrees counterclockwise from its current orientation. + PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW +} PP_PrivatePageTransformType; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrivatePageTransformType, 4); + +struct PPP_Pdf_1 { + // Returns an absolute URL if the position is over a link. + PP_Var (*GetLinkAtPosition)(PP_Instance instance, + PP_Point point); + + // Requests that the plugin apply the given transform to its view. + void (*Transform)(PP_Instance instance, PP_PrivatePageTransformType type); +}; + +typedef PPP_Pdf_1 PPP_Pdf; + +#endif // PPAPI_C_PRIVATE_PPP_PDF_H_ diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index c136287..c37d64e 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -171,6 +171,8 @@ 'proxy/ppp_messaging_proxy.h', 'proxy/ppp_mouse_lock_proxy.cc', 'proxy/ppp_mouse_lock_proxy.h', + 'proxy/ppp_pdf_proxy.cc', + 'proxy/ppp_pdf_proxy.h', 'proxy/ppp_printing_proxy.cc', 'proxy/ppp_printing_proxy.h', 'proxy/ppp_text_input_proxy.cc', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 9e33c72..249f0fb 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -128,6 +128,7 @@ #include "ppapi/proxy/ppp_instance_proxy.h" #include "ppapi/proxy/ppp_messaging_proxy.h" #include "ppapi/proxy/ppp_mouse_lock_proxy.h" +#include "ppapi/proxy/ppp_pdf_proxy.h" #include "ppapi/proxy/ppp_printing_proxy.h" #include "ppapi/proxy/ppp_text_input_proxy.h" #include "ppapi/proxy/ppp_video_decoder_proxy.h" @@ -289,6 +290,8 @@ 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()); + 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_VIDEO_DECODER_DEV, &ProxyFactory<PPP_VideoDecoder_Proxy>); AddPPP(PPP_VIDEODECODER_DEV_INTERFACE, diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 92ed096..02f0a9c 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -621,6 +621,11 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPMessaging_HandleMessage, IPC_MESSAGE_ROUTED1(PpapiMsg_PPPMouseLock_MouseLockLost, PP_Instance /* instance */) +// PPP_Pdf +IPC_MESSAGE_ROUTED2(PpapiMsg_PPPPdf_Rotate, + PP_Instance /* instance */, + bool /* clockwise */) + // PPP_Printing IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPPrinting_QuerySupportedFormats, PP_Instance /* instance */, diff --git a/ppapi/proxy/ppp_pdf_proxy.cc b/ppapi/proxy/ppp_pdf_proxy.cc new file mode 100644 index 0000000..356b42f --- /dev/null +++ b/ppapi/proxy/ppp_pdf_proxy.cc @@ -0,0 +1,77 @@ +// 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_pdf_proxy.h" + +#include "ppapi/proxy/host_dispatcher.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/proxy_lock.h" + +namespace ppapi { +namespace proxy { + +namespace { + +#if !defined(OS_NACL) +PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { + // This isn't implemented in the out of process case. + return PP_MakeUndefined(); +} + +void Transform(PP_Instance instance, PP_PrivatePageTransformType type) { + bool clockwise = type == PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW; + HostDispatcher::GetForInstance(instance)->Send( + new PpapiMsg_PPPPdf_Rotate(API_ID_PPP_PDF, instance, clockwise)); +} + +const PPP_Pdf ppp_pdf_interface = { + &GetLinkAtPosition, + &Transform, +}; +#else +// The NaCl plugin doesn't need the host side interface - stub it out. +const PPP_Pdf ppp_pdf_interface = {}; +#endif + +} // namespace + +PPP_Pdf_Proxy::PPP_Pdf_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_pdf_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_pdf_ = static_cast<const PPP_Pdf*>( + dispatcher->local_get_interface()(PPP_PDF_INTERFACE)); + } +} + +PPP_Pdf_Proxy::~PPP_Pdf_Proxy() { +} + +// static +const PPP_Pdf* PPP_Pdf_Proxy::GetProxyInterface() { + return &ppp_pdf_interface; +} + +bool PPP_Pdf_Proxy::OnMessageReceived(const IPC::Message& msg) { + if (!dispatcher()->IsPlugin()) + return false; + + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PPP_Pdf_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiMsg_PPPPdf_Rotate, OnPluginMsgRotate) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void PPP_Pdf_Proxy::OnPluginMsgRotate(PP_Instance instance, bool clockwise) { + PP_PrivatePageTransformType type = clockwise ? + PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : + PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; + if (ppp_pdf_) + CallWhileUnlocked(ppp_pdf_->Transform, instance, type); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/ppp_pdf_proxy.h b/ppapi/proxy/ppp_pdf_proxy.h new file mode 100644 index 0000000..992b224 --- /dev/null +++ b/ppapi/proxy/ppp_pdf_proxy.h @@ -0,0 +1,40 @@ +// 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_PDF_PROXY_H_ +#define PPAPI_PROXY_PPP_PDF_PROXY_H_ + +#include "ppapi/c/private/ppp_pdf.h" +#include "ppapi/proxy/interface_proxy.h" + +namespace ppapi { + +namespace proxy { + +class PPP_Pdf_Proxy : public InterfaceProxy { + public: + PPP_Pdf_Proxy(Dispatcher* dispatcher); + virtual ~PPP_Pdf_Proxy(); + + static const PPP_Pdf* GetProxyInterface(); + + // InterfaceProxy implementation. + virtual bool OnMessageReceived(const IPC::Message& msg); + + private: + // Message handlers. + void OnPluginMsgRotate(PP_Instance instance, bool clockwise); + + // 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_Pdf* ppp_pdf_; + + DISALLOW_COPY_AND_ASSIGN(PPP_Pdf_Proxy); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PPP_PDF_PROXY_H_ diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h index 104a078..cf1395b 100644 --- a/ppapi/shared_impl/api_id.h +++ b/ppapi/shared_impl/api_id.h @@ -57,6 +57,7 @@ enum ApiID { API_ID_PPP_INSTANCE_PRIVATE, API_ID_PPP_MESSAGING, API_ID_PPP_MOUSE_LOCK, + API_ID_PPP_PDF, API_ID_PPP_PRINTING, API_ID_PPP_TEXT_INPUT, API_ID_PPP_VIDEO_CAPTURE_DEV, |