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 /ppapi/proxy/ppp_pdf_proxy.cc | |
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
Diffstat (limited to 'ppapi/proxy/ppp_pdf_proxy.cc')
-rw-r--r-- | ppapi/proxy/ppp_pdf_proxy.cc | 77 |
1 files changed, 77 insertions, 0 deletions
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 |