Added content browser test that checks gum callbacks are fired after an
[chromium-blink-merge.git] / ppapi / proxy / ppp_pdf_proxy.cc
blob356b42f0ebdddd253889f2108a966bb5d57a2c62
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_pdf_proxy.h"
7 #include "ppapi/proxy/host_dispatcher.h"
8 #include "ppapi/proxy/ppapi_messages.h"
9 #include "ppapi/shared_impl/proxy_lock.h"
11 namespace ppapi {
12 namespace proxy {
14 namespace {
16 #if !defined(OS_NACL)
17 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) {
18 // This isn't implemented in the out of process case.
19 return PP_MakeUndefined();
22 void Transform(PP_Instance instance, PP_PrivatePageTransformType type) {
23 bool clockwise = type == PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW;
24 HostDispatcher::GetForInstance(instance)->Send(
25 new PpapiMsg_PPPPdf_Rotate(API_ID_PPP_PDF, instance, clockwise));
28 const PPP_Pdf ppp_pdf_interface = {
29 &GetLinkAtPosition,
30 &Transform,
32 #else
33 // The NaCl plugin doesn't need the host side interface - stub it out.
34 const PPP_Pdf ppp_pdf_interface = {};
35 #endif
37 } // namespace
39 PPP_Pdf_Proxy::PPP_Pdf_Proxy(Dispatcher* dispatcher)
40 : InterfaceProxy(dispatcher),
41 ppp_pdf_(NULL) {
42 if (dispatcher->IsPlugin()) {
43 ppp_pdf_ = static_cast<const PPP_Pdf*>(
44 dispatcher->local_get_interface()(PPP_PDF_INTERFACE));
48 PPP_Pdf_Proxy::~PPP_Pdf_Proxy() {
51 // static
52 const PPP_Pdf* PPP_Pdf_Proxy::GetProxyInterface() {
53 return &ppp_pdf_interface;
56 bool PPP_Pdf_Proxy::OnMessageReceived(const IPC::Message& msg) {
57 if (!dispatcher()->IsPlugin())
58 return false;
60 bool handled = true;
61 IPC_BEGIN_MESSAGE_MAP(PPP_Pdf_Proxy, msg)
62 IPC_MESSAGE_HANDLER(PpapiMsg_PPPPdf_Rotate, OnPluginMsgRotate)
63 IPC_MESSAGE_UNHANDLED(handled = false)
64 IPC_END_MESSAGE_MAP()
65 return handled;
68 void PPP_Pdf_Proxy::OnPluginMsgRotate(PP_Instance instance, bool clockwise) {
69 PP_PrivatePageTransformType type = clockwise ?
70 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW :
71 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW;
72 if (ppp_pdf_)
73 CallWhileUnlocked(ppp_pdf_->Transform, instance, type);
76 } // namespace proxy
77 } // namespace ppapi