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

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

Issue 2508923003: Make printing work better with OOPIF. (try 2) (Closed)
Patch Set: Fix android_webview Created 4 years, 1 month 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
OLDNEW
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 "chrome/renderer/pepper/chrome_pdf_print_client.h" 5 #include "chrome/renderer/pepper/chrome_pdf_print_client.h"
6 6
7 #include "components/printing/renderer/print_web_view_helper.h" 7 #include "components/printing/renderer/print_web_view_helper.h"
8 #include "content/public/renderer/pepper_plugin_instance.h" 8 #include "content/public/renderer/pepper_plugin_instance.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_frame.h"
10 #include "third_party/WebKit/public/web/WebDocument.h" 10 #include "third_party/WebKit/public/web/WebDocument.h"
11 #include "third_party/WebKit/public/web/WebElement.h" 11 #include "third_party/WebKit/public/web/WebElement.h"
12 #include "third_party/WebKit/public/web/WebLocalFrame.h" 12 #include "third_party/WebKit/public/web/WebLocalFrame.h"
13 #include "third_party/WebKit/public/web/WebPluginContainer.h" 13 #include "third_party/WebKit/public/web/WebPluginContainer.h"
14 14
15 namespace { 15 namespace {
16 16
17 blink::WebElement GetWebElement(PP_Instance instance_id) { 17 blink::WebElement GetWebElement(PP_Instance instance_id) {
18 content::PepperPluginInstance* instance = 18 content::PepperPluginInstance* instance =
19 content::PepperPluginInstance::Get(instance_id); 19 content::PepperPluginInstance::Get(instance_id);
20 if (!instance) 20 if (!instance)
21 return blink::WebElement(); 21 return blink::WebElement();
22 return instance->GetContainer()->element(); 22 return instance->GetContainer()->element();
23 } 23 }
24 24
25 printing::PrintWebViewHelper* GetPrintWebViewHelper( 25 printing::PrintWebViewHelper* GetPrintWebViewHelper(
26 const blink::WebElement& element) { 26 const blink::WebElement& element) {
27 if (element.isNull()) 27 if (element.isNull())
28 return nullptr; 28 return nullptr;
29 blink::WebView* view = element.document().frame()->view(); 29 auto* render_frame =
30 content::RenderView* render_view = content::RenderView::FromWebView(view); 30 content::RenderFrame::FromWebFrame(element.document().frame());
31 return printing::PrintWebViewHelper::Get(render_view); 31 return printing::PrintWebViewHelper::Get(render_frame);
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 ChromePDFPrintClient::ChromePDFPrintClient() {} 36 ChromePDFPrintClient::ChromePDFPrintClient() {}
37
37 ChromePDFPrintClient::~ChromePDFPrintClient() {} 38 ChromePDFPrintClient::~ChromePDFPrintClient() {}
38 39
39 bool ChromePDFPrintClient::IsPrintingEnabled(PP_Instance instance_id) { 40 bool ChromePDFPrintClient::IsPrintingEnabled(PP_Instance instance_id) {
40 blink::WebElement element = GetWebElement(instance_id); 41 blink::WebElement element = GetWebElement(instance_id);
41 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); 42 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
42 return helper && helper->IsPrintingEnabled(); 43 return helper && helper->IsPrintingEnabled();
43 } 44 }
44 45
45 bool ChromePDFPrintClient::Print(PP_Instance instance_id) { 46 bool ChromePDFPrintClient::Print(PP_Instance instance_id) {
46 blink::WebElement element = GetWebElement(instance_id); 47 blink::WebElement element = GetWebElement(instance_id);
47 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); 48 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
48 if (!helper) 49 if (!helper)
49 return false; 50 return false;
50 helper->PrintNode(element); 51 helper->PrintNode(element);
51 return true; 52 return true;
52 } 53 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_frame_observer.cc ('k') | chrome/renderer/printing/chrome_print_web_view_helper_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698