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 "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 class PepperPDFHost : public ppapi::host::ResourceHost { 38 public: 39 PepperPDFHost(content::RendererPpapiHost* host, 40 PP_Instance instance, 41 PP_Resource resource); 42 virtual ~PepperPDFHost(); 43 44 virtual int32_t OnResourceMessageReceived( 45 const IPC::Message& msg, 46 ppapi::host::HostMessageContext* context) OVERRIDE; 47 48 private: 49 int32_t OnHostMsgGetLocalizedString(ppapi::host::HostMessageContext* context, 50 PP_ResourceString string_id); 51 int32_t OnHostMsgDidStartLoading(ppapi::host::HostMessageContext* context); 52 int32_t OnHostMsgDidStopLoading(ppapi::host::HostMessageContext* context); 53 int32_t OnHostMsgSetContentRestriction( 54 ppapi::host::HostMessageContext* context, 55 int restrictions); 56 int32_t OnHostMsgUserMetricsRecordAction( 57 ppapi::host::HostMessageContext* context, 58 const std::string& action); 59 int32_t OnHostMsgHasUnsupportedFeature( 60 ppapi::host::HostMessageContext* context); 61 int32_t OnHostMsgPrint(ppapi::host::HostMessageContext* context); 62 int32_t OnHostMsgSaveAs(ppapi::host::HostMessageContext* context); 63 int32_t OnHostMsgGetResourceImage(ppapi::host::HostMessageContext* context, 64 PP_ResourceImage image_id, 65 float scale); 66 int32_t OnHostMsgSetSelectedText(ppapi::host::HostMessageContext* context, 67 const base::string16& selected_text); 68 int32_t OnHostMsgSetLinkUnderCursor(ppapi::host::HostMessageContext* context, 69 const std::string& url); 70 71 bool CreateImageData(PP_Instance instance, 72 PP_ImageDataFormat format, 73 const PP_Size& size, 74 const SkBitmap& pixels_to_write, 75 ppapi::HostResource* result, 76 PP_ImageDataDesc* out_image_data_desc, 77 IPC::PlatformFileForTransit* out_image_handle, 78 uint32_t* out_byte_count); 79 80 content::RendererPpapiHost* host_; 81 82 DISALLOW_COPY_AND_ASSIGN(PepperPDFHost); 83 }; 84 85 #endif // CHROME_RENDERER_PEPPER_PEPPER_PDF_HOST_H_ 86