1 // Copyright (c) 2013 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 CHROME_RENDERER_PEPPER_PEPPER_PDF_HOST_H_ 6 #define CHROME_RENDERER_PEPPER_PEPPER_PDF_HOST_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "base/compiler_specific.h" 12 #include "ipc/ipc_platform_file.h" 13 #include "ppapi/c/ppb_image_data.h" 14 #include "ppapi/c/private/ppb_pdf.h" 15 #include "ppapi/host/resource_host.h" 16 #include "ppapi/proxy/serialized_structs.h" 17 18 struct PP_ImageDataDesc; 19 struct PP_Size; 20 class SkBitmap; 21 22 namespace content { 23 class RendererPpapiHost; 24 } 25 26 namespace ppapi { 27 class HostResource; 28 } 29 30 namespace ppapi { 31 namespace host { 32 struct HostMessageContext; 33 } 34 } 35 36 namespace chrome { 37 38 class PepperPDFHost : public ppapi::host::ResourceHost { 39 public: 40 PepperPDFHost(content::RendererPpapiHost* host, 41 PP_Instance instance, 42 PP_Resource resource); 43 virtual ~PepperPDFHost(); 44 45 virtual int32_t OnResourceMessageReceived( 46 const IPC::Message& msg, 47 ppapi::host::HostMessageContext* context) OVERRIDE; 48 49 private: 50 int32_t OnHostMsgGetLocalizedString(ppapi::host::HostMessageContext* context, 51 PP_ResourceString string_id); 52 int32_t OnHostMsgDidStartLoading(ppapi::host::HostMessageContext* context); 53 int32_t OnHostMsgDidStopLoading(ppapi::host::HostMessageContext* context); 54 int32_t OnHostMsgSetContentRestriction( 55 ppapi::host::HostMessageContext* context, 56 int restrictions); 57 int32_t OnHostMsgUserMetricsRecordAction( 58 ppapi::host::HostMessageContext* context, 59 const std::string& action); 60 int32_t OnHostMsgHasUnsupportedFeature( 61 ppapi::host::HostMessageContext* context); 62 int32_t OnHostMsgPrint(ppapi::host::HostMessageContext* context); 63 int32_t OnHostMsgSaveAs(ppapi::host::HostMessageContext* context); 64 int32_t OnHostMsgGetResourceImage(ppapi::host::HostMessageContext* context, 65 PP_ResourceImage image_id, 66 float scale); 67 68 bool CreateImageData(PP_Instance instance, 69 PP_ImageDataFormat format, 70 const PP_Size& size, 71 const SkBitmap& pixels_to_write, 72 ppapi::HostResource* result, 73 PP_ImageDataDesc* out_image_data_desc, 74 IPC::PlatformFileForTransit* out_image_handle, 75 uint32_t* out_byte_count); 76 77 content::RendererPpapiHost* host_; 78 79 DISALLOW_COPY_AND_ASSIGN(PepperPDFHost); 80 }; 81 82 } // namespace chrome 83 84 #endif // CHROME_RENDERER_PEPPER_PEPPER_PDF_HOST_H_ 85