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 #include "athena/main/athena_renderer_pdf_helper.h" | 5 #include "athena/main/athena_renderer_pdf_helper.h" |
6 | 6 |
7 #include "components/pdf/renderer/pepper_pdf_host.h" | 7 #include "components/pdf/renderer/pepper_pdf_host.h" |
8 #include "content/public/renderer/renderer_ppapi_host.h" | 8 #include "content/public/renderer/renderer_ppapi_host.h" |
9 #include "ppapi/host/host_factory.h" | 9 #include "ppapi/host/host_factory.h" |
10 #include "ppapi/host/ppapi_host.h" | 10 #include "ppapi/host/ppapi_host.h" |
11 #include "ppapi/host/resource_host.h" | 11 #include "ppapi/host/resource_host.h" |
12 #include "ppapi/proxy/ppapi_messages.h" | 12 #include "ppapi/proxy/ppapi_messages.h" |
13 | 13 |
14 namespace athena { | 14 namespace athena { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 class PDFRendererHostFactory : public ppapi::host::HostFactory { | 18 class PDFRendererHostFactory : public ppapi::host::HostFactory { |
19 public: | 19 public: |
20 explicit PDFRendererHostFactory(content::RendererPpapiHost* host) | 20 explicit PDFRendererHostFactory(content::RendererPpapiHost* host) |
21 : host_(host) {} | 21 : host_(host) {} |
22 virtual ~PDFRendererHostFactory() {} | 22 virtual ~PDFRendererHostFactory() {} |
23 | 23 |
24 private: | 24 private: |
25 // ppapi::host::HostFactory: | 25 // ppapi::host::HostFactory: |
26 virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost( | 26 virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost( |
27 ppapi::host::PpapiHost* host, | 27 ppapi::host::PpapiHost* host, |
28 const ppapi::proxy::ResourceMessageCallParams& params, | 28 const ppapi::proxy::ResourceMessageCallParams& params, |
29 PP_Instance instance, | 29 PP_Instance instance, |
30 const IPC::Message& message) OVERRIDE { | 30 const IPC::Message& message) override { |
31 DCHECK_EQ(host_->GetPpapiHost(), host); | 31 DCHECK_EQ(host_->GetPpapiHost(), host); |
32 // Make sure the plugin is giving us a valid instance for this resource. | 32 // Make sure the plugin is giving us a valid instance for this resource. |
33 if (!host_->IsValidInstance(instance)) | 33 if (!host_->IsValidInstance(instance)) |
34 return scoped_ptr<ppapi::host::ResourceHost>(); | 34 return scoped_ptr<ppapi::host::ResourceHost>(); |
35 | 35 |
36 if (host_->GetPpapiHost()->permissions().HasPermission( | 36 if (host_->GetPpapiHost()->permissions().HasPermission( |
37 ppapi::PERMISSION_PRIVATE)) { | 37 ppapi::PERMISSION_PRIVATE)) { |
38 switch (message.type()) { | 38 switch (message.type()) { |
39 case PpapiHostMsg_PDF_Create::ID: | 39 case PpapiHostMsg_PDF_Create::ID: |
40 return scoped_ptr<ppapi::host::ResourceHost>( | 40 return scoped_ptr<ppapi::host::ResourceHost>( |
(...skipping 23 matching lines...) Expand all Loading... |
64 | 64 |
65 AthenaRendererPDFHelper::~AthenaRendererPDFHelper() {} | 65 AthenaRendererPDFHelper::~AthenaRendererPDFHelper() {} |
66 | 66 |
67 void AthenaRendererPDFHelper::DidCreatePepperPlugin( | 67 void AthenaRendererPDFHelper::DidCreatePepperPlugin( |
68 content::RendererPpapiHost* host) { | 68 content::RendererPpapiHost* host) { |
69 host->GetPpapiHost()->AddHostFactoryFilter( | 69 host->GetPpapiHost()->AddHostFactoryFilter( |
70 scoped_ptr<ppapi::host::HostFactory>(new PDFRendererHostFactory(host))); | 70 scoped_ptr<ppapi::host::HostFactory>(new PDFRendererHostFactory(host))); |
71 } | 71 } |
72 | 72 |
73 } // namespace athena | 73 } // namespace athena |
OLD | NEW |