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

Side by Side Diff: components/pdf/renderer/pepper_pdf_host.cc

Issue 505243003: pdf: Move PepperPDFHost into the pdf component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pdf-component
Patch Set: tot-merge Created 6 years, 3 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 | « components/pdf/renderer/pepper_pdf_host.h ('k') | components/pdf/renderer/ppb_pdf_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 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 "chrome/renderer/pepper/pepper_pdf_host.h" 5 #include "components/pdf/renderer/pepper_pdf_host.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/renderer/printing/print_web_view_helper.h"
9 #include "components/pdf/common/pdf_messages.h" 8 #include "components/pdf/common/pdf_messages.h"
9 #include "components/pdf/renderer/ppb_pdf_impl.h"
10 #include "content/app/resources/grit/content_resources.h" 10 #include "content/app/resources/grit/content_resources.h"
11 #include "content/app/strings/grit/content_strings.h" 11 #include "content/app/strings/grit/content_strings.h"
12 #include "content/public/common/referrer.h" 12 #include "content/public/common/referrer.h"
13 #include "content/public/renderer/pepper_plugin_instance.h" 13 #include "content/public/renderer/pepper_plugin_instance.h"
14 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
15 #include "content/public/renderer/render_view.h" 15 #include "content/public/renderer/render_view.h"
16 #include "content/public/renderer/renderer_ppapi_host.h" 16 #include "content/public/renderer/renderer_ppapi_host.h"
17 #include "ppapi/host/dispatch_host_message.h" 17 #include "ppapi/host/dispatch_host_message.h"
18 #include "ppapi/host/host_message_context.h" 18 #include "ppapi/host/host_message_context.h"
19 #include "ppapi/host/ppapi_host.h" 19 #include "ppapi/host/ppapi_host.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 {PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_8, IDR_PDF_PROGRESS_BAR_8}, 94 {PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_8, IDR_PDF_PROGRESS_BAR_8},
95 {PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_BACKGROUND, 95 {PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_BACKGROUND,
96 IDR_PDF_PROGRESS_BAR_BACKGROUND}, 96 IDR_PDF_PROGRESS_BAR_BACKGROUND},
97 {PP_RESOURCEIMAGE_PDF_PAGE_INDICATOR_BACKGROUND, 97 {PP_RESOURCEIMAGE_PDF_PAGE_INDICATOR_BACKGROUND,
98 IDR_PDF_PAGE_INDICATOR_BACKGROUND}, 98 IDR_PDF_PAGE_INDICATOR_BACKGROUND},
99 {PP_RESOURCEIMAGE_PDF_PAGE_DROPSHADOW, IDR_PDF_PAGE_DROPSHADOW}, 99 {PP_RESOURCEIMAGE_PDF_PAGE_DROPSHADOW, IDR_PDF_PAGE_DROPSHADOW},
100 {PP_RESOURCEIMAGE_PDF_PAN_SCROLL_ICON, IDR_PAN_SCROLL_ICON}, }; 100 {PP_RESOURCEIMAGE_PDF_PAN_SCROLL_ICON, IDR_PAN_SCROLL_ICON}, };
101 101
102 } // namespace 102 } // namespace
103 103
104 namespace pdf {
105
104 PepperPDFHost::PepperPDFHost(content::RendererPpapiHost* host, 106 PepperPDFHost::PepperPDFHost(content::RendererPpapiHost* host,
105 PP_Instance instance, 107 PP_Instance instance,
106 PP_Resource resource) 108 PP_Resource resource)
107 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), 109 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource),
108 host_(host) {} 110 host_(host) {}
109 111
110 PepperPDFHost::~PepperPDFHost() {} 112 PepperPDFHost::~PepperPDFHost() {}
111 113
112 int32_t PepperPDFHost::OnResourceMessageReceived( 114 int32_t PepperPDFHost::OnResourceMessageReceived(
113 const IPC::Message& msg, 115 const IPC::Message& msg,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 blink::WebView* view = 210 blink::WebView* view =
209 instance->GetContainer()->element().document().frame()->view(); 211 instance->GetContainer()->element().document().frame()->view();
210 content::RenderView* render_view = content::RenderView::FromWebView(view); 212 content::RenderView* render_view = content::RenderView::FromWebView(view);
211 render_view->Send( 213 render_view->Send(
212 new PDFHostMsg_PDFHasUnsupportedFeature(render_view->GetRoutingID())); 214 new PDFHostMsg_PDFHasUnsupportedFeature(render_view->GetRoutingID()));
213 return PP_OK; 215 return PP_OK;
214 } 216 }
215 217
216 int32_t PepperPDFHost::OnHostMsgPrint( 218 int32_t PepperPDFHost::OnHostMsgPrint(
217 ppapi::host::HostMessageContext* context) { 219 ppapi::host::HostMessageContext* context) {
218 #if defined(ENABLE_FULL_PRINTING) 220 return PPB_PDF_Impl::InvokePrintingForInstance(pp_instance()) ? PP_OK :
219 content::PepperPluginInstance* instance = 221 PP_ERROR_FAILED;
220 host_->GetPluginInstance(pp_instance());
221 if (!instance)
222 return PP_ERROR_FAILED;
223
224 blink::WebElement element = instance->GetContainer()->element();
225 blink::WebView* view = element.document().frame()->view();
226 content::RenderView* render_view = content::RenderView::FromWebView(view);
227
228 using printing::PrintWebViewHelper;
229 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view);
230 if (print_view_helper) {
231 print_view_helper->PrintNode(element);
232 return PP_OK;
233 }
234 #endif
235 return PP_ERROR_FAILED;
236 } 222 }
237 223
238 int32_t PepperPDFHost::OnHostMsgSaveAs( 224 int32_t PepperPDFHost::OnHostMsgSaveAs(
239 ppapi::host::HostMessageContext* context) { 225 ppapi::host::HostMessageContext* context) {
240 content::PepperPluginInstance* instance = 226 content::PepperPluginInstance* instance =
241 host_->GetPluginInstance(pp_instance()); 227 host_->GetPluginInstance(pp_instance());
242 if (!instance) 228 if (!instance)
243 return PP_ERROR_FAILED; 229 return PP_ERROR_FAILED;
244 GURL url = instance->GetPluginURL(); 230 GURL url = instance->GetPluginURL();
245 content::RenderView* render_view = instance->GetRenderView(); 231 content::RenderView* render_view = instance->GetRenderView();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 369
384 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); 370 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false);
385 pixels_to_write.copyPixelsTo( 371 pixels_to_write.copyPixelsTo(
386 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); 372 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes());
387 373
388 if (needs_unmapping) 374 if (needs_unmapping)
389 image_data->Unmap(); 375 image_data->Unmap();
390 376
391 return true; 377 return true;
392 } 378 }
379
380 } // namespace pdf
OLDNEW
« no previous file with comments | « components/pdf/renderer/pepper_pdf_host.h ('k') | components/pdf/renderer/ppb_pdf_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698