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 #ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
6 #define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/strings/string16.h"
13 #include "ipc/ipc_platform_file.h"
14 #include "ppapi/c/ppb_image_data.h"
15 #include "ppapi/c/private/ppb_pdf.h"
16 #include "ppapi/host/resource_host.h"
17 #include "ppapi/proxy/serialized_structs.h"
19 struct PP_ImageDataDesc
;
24 class RendererPpapiHost
;
33 struct HostMessageContext
;
39 class PepperPDFHost
: public ppapi::host::ResourceHost
{
43 virtual ~PrintClient() {}
45 // Returns whether printing is enabled for the plugin instance identified by
47 virtual bool IsPrintingEnabled(PP_Instance instance_id
) = 0;
49 // Invokes the "Print" command for the plugin instance identified by
50 // |instance_id|. Returns whether the "Print" command was issued or not.
51 virtual bool Print(PP_Instance instance_id
) = 0;
54 PepperPDFHost(content::RendererPpapiHost
* host
,
56 PP_Resource resource
);
57 ~PepperPDFHost() override
;
59 // Invokes the "Print" command for the given instance as if the user right
60 // clicked on it and selected "Print". Returns if the "Print" command was
62 static bool InvokePrintingForInstance(PP_Instance instance
);
64 // The caller retains the ownership of |print_client|. The client is
65 // allowed to be set only once, and when set, the client must outlive the
66 // PPB_PDF_Impl instance.
67 static void SetPrintClient(PrintClient
* print_client
);
69 int32_t OnResourceMessageReceived(
70 const IPC::Message
& msg
,
71 ppapi::host::HostMessageContext
* context
) override
;
74 int32_t OnHostMsgGetLocalizedString(ppapi::host::HostMessageContext
* context
,
75 PP_ResourceString string_id
);
76 int32_t OnHostMsgDidStartLoading(ppapi::host::HostMessageContext
* context
);
77 int32_t OnHostMsgDidStopLoading(ppapi::host::HostMessageContext
* context
);
78 int32_t OnHostMsgSetContentRestriction(
79 ppapi::host::HostMessageContext
* context
,
81 int32_t OnHostMsgUserMetricsRecordAction(
82 ppapi::host::HostMessageContext
* context
,
83 const std::string
& action
);
84 int32_t OnHostMsgHasUnsupportedFeature(
85 ppapi::host::HostMessageContext
* context
);
86 int32_t OnHostMsgPrint(ppapi::host::HostMessageContext
* context
);
87 int32_t OnHostMsgSaveAs(ppapi::host::HostMessageContext
* context
);
88 int32_t OnHostMsgSetSelectedText(ppapi::host::HostMessageContext
* context
,
89 const base::string16
& selected_text
);
90 int32_t OnHostMsgSetLinkUnderCursor(ppapi::host::HostMessageContext
* context
,
91 const std::string
& url
);
93 content::RendererPpapiHost
* host_
;
95 DISALLOW_COPY_AND_ASSIGN(PepperPDFHost
);
100 #endif // COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_