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. 4 5 #ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ 6 #define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ 7 8 #include <string> 9 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" 18 19 struct PP_ImageDataDesc; 20 struct PP_Size; 21 class SkBitmap; 22 23 namespace content { 24 class RendererPpapiHost; 25 } 26 27 namespace ppapi { 28 class HostResource; 29 } 30 31 namespace ppapi { 32 namespace host { 33 struct HostMessageContext; 34 } 35 } 36 37 namespace pdf { 38 39 class PepperPDFHost : public ppapi::host::ResourceHost { 40 public: 41 PepperPDFHost(content::RendererPpapiHost* host, 42 PP_Instance instance, 43 PP_Resource resource); 44 virtual ~PepperPDFHost(); 45 46 virtual int32_t OnResourceMessageReceived( 47 const IPC::Message& msg, 48 ppapi::host::HostMessageContext* context) OVERRIDE; 49 50 private: 51 int32_t OnHostMsgGetLocalizedString(ppapi::host::HostMessageContext* context, 52 PP_ResourceString string_id); 53 int32_t OnHostMsgDidStartLoading(ppapi::host::HostMessageContext* context); 54 int32_t OnHostMsgDidStopLoading(ppapi::host::HostMessageContext* context); 55 int32_t OnHostMsgSetContentRestriction( 56 ppapi::host::HostMessageContext* context, 57 int restrictions); 58 int32_t OnHostMsgUserMetricsRecordAction( 59 ppapi::host::HostMessageContext* context, 60 const std::string& action); 61 int32_t OnHostMsgHasUnsupportedFeature( 62 ppapi::host::HostMessageContext* context); 63 int32_t OnHostMsgPrint(ppapi::host::HostMessageContext* context); 64 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, 69 const base::string16& selected_text); 70 int32_t OnHostMsgSetLinkUnderCursor(ppapi::host::HostMessageContext* context, 71 const std::string& url); 72 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_; 83 84 DISALLOW_COPY_AND_ASSIGN(PepperPDFHost); 85 }; 86 87 } // namespace pdf 88 89 #endif // COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ 90