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