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

Side by Side Diff: chrome/renderer/pepper/chrome_pdf_print_delegate.cc

Issue 477263003: pdf: Create a separate component for using the pdf pepper plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 | Annotate | Revision Log
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 "chrome/renderer/pepper/chrome_pdf_print_delegate.h"
6
7 #include "chrome/renderer/printing/print_web_view_helper.h"
8 #include "content/public/renderer/pepper_plugin_instance.h"
9 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/public/web/WebDocument.h"
11 #include "third_party/WebKit/public/web/WebElement.h"
12 #include "third_party/WebKit/public/web/WebLocalFrame.h"
13 #include "third_party/WebKit/public/web/WebPluginContainer.h"
14
15 namespace {
16
17 blink::WebElement GetWebElement(PP_Instance instance_id) {
18 content::PepperPluginInstance* instance =
19 content::PepperPluginInstance::Get(instance_id);
20 if (!instance)
21 return blink::WebElement();
22 return instance->GetContainer()->element();
23 }
24
25 printing::PrintWebViewHelper* GetPrintWebViewHelper(
26 const blink::WebElement& element) {
27 if (element.isNull())
28 return NULL;
29 blink::WebView* view = element.document().frame()->view();
30 content::RenderView* render_view = content::RenderView::FromWebView(view);
31 return printing::PrintWebViewHelper::Get(render_view);
32 }
33
34 } // namespace
35
36 ChromePDFPrintDelegate::ChromePDFPrintDelegate() {}
37 ChromePDFPrintDelegate::~ChromePDFPrintDelegate() {}
38
39 bool ChromePDFPrintDelegate::IsPrintingEnabled(PP_Instance instance_id) {
40 blink::WebElement element = GetWebElement(instance_id);
41 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
42 return helper && helper->IsPrintingEnabled();
43 }
44
45 void ChromePDFPrintDelegate::Print(PP_Instance instance_id) {
46 blink::WebElement element = GetWebElement(instance_id);
47 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
48 if (helper)
49 helper->PrintNode(element);
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698