blob: 32d1e097059dab0eebf2e5051517d02af1922a25 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/renderer/pepper/chrome_pdf_print_client.h"
#include "chrome/renderer/printing/print_web_view_helper.h"
#include "content/public/renderer/pepper_plugin_instance.h"
#include "content/public/renderer/render_view.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
namespace {
blink::WebElement GetWebElement(PP_Instance instance_id) {
content::PepperPluginInstance* instance =
content::PepperPluginInstance::Get(instance_id);
if (!instance)
return blink::WebElement();
return instance->GetContainer()->element();
}
printing::PrintWebViewHelper* GetPrintWebViewHelper(
const blink::WebElement& element) {
if (element.isNull())
return NULL;
blink::WebView* view = element.document().frame()->view();
content::RenderView* render_view = content::RenderView::FromWebView(view);
return printing::PrintWebViewHelper::Get(render_view);
}
} // namespace
ChromePDFPrintClient::ChromePDFPrintClient() {
}
ChromePDFPrintClient::~ChromePDFPrintClient() {
}
bool ChromePDFPrintClient::IsPrintingEnabled(PP_Instance instance_id) {
blink::WebElement element = GetWebElement(instance_id);
printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
return helper && helper->IsPrintingEnabled();
}
void ChromePDFPrintClient::Print(PP_Instance instance_id) {
blink::WebElement element = GetWebElement(instance_id);
printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
if (helper)
helper->PrintNode(element);
}
|