OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ | 5 #ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ |
6 #define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ | 6 #define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 namespace ppapi { | 31 namespace ppapi { |
32 namespace host { | 32 namespace host { |
33 struct HostMessageContext; | 33 struct HostMessageContext; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 namespace pdf { | 37 namespace pdf { |
38 | 38 |
39 class PepperPDFHost : public ppapi::host::ResourceHost { | 39 class PepperPDFHost : public ppapi::host::ResourceHost { |
40 public: | 40 public: |
| 41 class PrintClient { |
| 42 public: |
| 43 virtual ~PrintClient() {} |
| 44 |
| 45 // Returns whether printing is enabled for the plugin instance identified by |
| 46 // |instance_id|. |
| 47 virtual bool IsPrintingEnabled(PP_Instance instance_id) = 0; |
| 48 |
| 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; |
| 52 }; |
| 53 |
41 PepperPDFHost(content::RendererPpapiHost* host, | 54 PepperPDFHost(content::RendererPpapiHost* host, |
42 PP_Instance instance, | 55 PP_Instance instance, |
43 PP_Resource resource); | 56 PP_Resource resource); |
44 ~PepperPDFHost() override; | 57 ~PepperPDFHost() override; |
45 | 58 |
| 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 |
| 61 // issued or not. |
| 62 static bool InvokePrintingForInstance(PP_Instance instance); |
| 63 |
| 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); |
| 68 |
46 int32_t OnResourceMessageReceived( | 69 int32_t OnResourceMessageReceived( |
47 const IPC::Message& msg, | 70 const IPC::Message& msg, |
48 ppapi::host::HostMessageContext* context) override; | 71 ppapi::host::HostMessageContext* context) override; |
49 | 72 |
50 private: | 73 private: |
51 int32_t OnHostMsgGetLocalizedString(ppapi::host::HostMessageContext* context, | 74 int32_t OnHostMsgGetLocalizedString(ppapi::host::HostMessageContext* context, |
52 PP_ResourceString string_id); | 75 PP_ResourceString string_id); |
53 int32_t OnHostMsgDidStartLoading(ppapi::host::HostMessageContext* context); | 76 int32_t OnHostMsgDidStartLoading(ppapi::host::HostMessageContext* context); |
54 int32_t OnHostMsgDidStopLoading(ppapi::host::HostMessageContext* context); | 77 int32_t OnHostMsgDidStopLoading(ppapi::host::HostMessageContext* context); |
55 int32_t OnHostMsgSetContentRestriction( | 78 int32_t OnHostMsgSetContentRestriction( |
56 ppapi::host::HostMessageContext* context, | 79 ppapi::host::HostMessageContext* context, |
57 int restrictions); | 80 int restrictions); |
58 int32_t OnHostMsgUserMetricsRecordAction( | 81 int32_t OnHostMsgUserMetricsRecordAction( |
59 ppapi::host::HostMessageContext* context, | 82 ppapi::host::HostMessageContext* context, |
60 const std::string& action); | 83 const std::string& action); |
61 int32_t OnHostMsgHasUnsupportedFeature( | 84 int32_t OnHostMsgHasUnsupportedFeature( |
62 ppapi::host::HostMessageContext* context); | 85 ppapi::host::HostMessageContext* context); |
63 int32_t OnHostMsgPrint(ppapi::host::HostMessageContext* context); | 86 int32_t OnHostMsgPrint(ppapi::host::HostMessageContext* context); |
64 int32_t OnHostMsgSaveAs(ppapi::host::HostMessageContext* context); | 87 int32_t OnHostMsgSaveAs(ppapi::host::HostMessageContext* context); |
65 int32_t OnHostMsgGetResourceImage(ppapi::host::HostMessageContext* context, | |
66 PP_ResourceImage image_id, | |
67 float scale); | |
68 int32_t OnHostMsgSetSelectedText(ppapi::host::HostMessageContext* context, | 88 int32_t OnHostMsgSetSelectedText(ppapi::host::HostMessageContext* context, |
69 const base::string16& selected_text); | 89 const base::string16& selected_text); |
70 int32_t OnHostMsgSetLinkUnderCursor(ppapi::host::HostMessageContext* context, | 90 int32_t OnHostMsgSetLinkUnderCursor(ppapi::host::HostMessageContext* context, |
71 const std::string& url); | 91 const std::string& url); |
72 | 92 |
73 bool CreateImageData(PP_Instance instance, | |
74 PP_ImageDataFormat format, | |
75 const PP_Size& size, | |
76 const SkBitmap& pixels_to_write, | |
77 ppapi::HostResource* result, | |
78 PP_ImageDataDesc* out_image_data_desc, | |
79 IPC::PlatformFileForTransit* out_image_handle, | |
80 uint32_t* out_byte_count); | |
81 | |
82 content::RendererPpapiHost* host_; | 93 content::RendererPpapiHost* host_; |
83 | 94 |
84 DISALLOW_COPY_AND_ASSIGN(PepperPDFHost); | 95 DISALLOW_COPY_AND_ASSIGN(PepperPDFHost); |
85 }; | 96 }; |
86 | 97 |
87 } // namespace pdf | 98 } // namespace pdf |
88 | 99 |
89 #endif // COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ | 100 #endif // COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ |
OLD | NEW |