Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2140)

Side by Side Diff: athena/main/athena_renderer_pdf_helper.cc

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « athena/main/athena_renderer_pdf_helper.h ('k') | athena/main/athena_views_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "athena/main/athena_renderer_pdf_helper.h"
6
7 #include "components/pdf/renderer/pepper_pdf_host.h"
8 #include "content/public/renderer/renderer_ppapi_host.h"
9 #include "ppapi/host/host_factory.h"
10 #include "ppapi/host/ppapi_host.h"
11 #include "ppapi/host/resource_host.h"
12 #include "ppapi/proxy/ppapi_messages.h"
13
14 namespace athena {
15
16 namespace {
17
18 class PDFRendererHostFactory : public ppapi::host::HostFactory {
19 public:
20 explicit PDFRendererHostFactory(content::RendererPpapiHost* host)
21 : host_(host) {}
22 ~PDFRendererHostFactory() override {}
23
24 private:
25 // ppapi::host::HostFactory:
26 virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
27 ppapi::host::PpapiHost* host,
28 PP_Resource resource,
29 PP_Instance instance,
30 const IPC::Message& message) override {
31 DCHECK_EQ(host_->GetPpapiHost(), host);
32 // Make sure the plugin is giving us a valid instance for this resource.
33 if (!host_->IsValidInstance(instance))
34 return scoped_ptr<ppapi::host::ResourceHost>();
35
36 if (host_->GetPpapiHost()->permissions().HasPermission(
37 ppapi::PERMISSION_PRIVATE)) {
38 switch (message.type()) {
39 case PpapiHostMsg_PDF_Create::ID:
40 return scoped_ptr<ppapi::host::ResourceHost>(
41 new pdf::PepperPDFHost(host_, instance, resource));
42
43 case PpapiHostMsg_FlashFontFile_Create::ID:
44 return scoped_ptr<ppapi::host::ResourceHost>(
45 new ppapi::host::ResourceHost(host_->GetPpapiHost(), instance,
46 resource));
47 }
48 }
49
50 return scoped_ptr<ppapi::host::ResourceHost>();
51 }
52
53 // Not owned by this object.
54 content::RendererPpapiHost* host_;
55
56 DISALLOW_COPY_AND_ASSIGN(PDFRendererHostFactory);
57 };
58
59 } // namespace
60
61 AthenaRendererPDFHelper::AthenaRendererPDFHelper(content::RenderFrame* frame)
62 : content::RenderFrameObserver(frame) {}
63
64 AthenaRendererPDFHelper::~AthenaRendererPDFHelper() {}
65
66 void AthenaRendererPDFHelper::DidCreatePepperPlugin(
67 content::RendererPpapiHost* host) {
68 host->GetPpapiHost()->AddHostFactoryFilter(
69 scoped_ptr<ppapi::host::HostFactory>(new PDFRendererHostFactory(host)));
70 }
71
72 } // namespace athena
OLDNEW
« no previous file with comments | « athena/main/athena_renderer_pdf_helper.h ('k') | athena/main/athena_views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698