OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
Vitaly Buka (NO REVIEWS)
2014/09/03 21:36:24
Copyright (c) 2014 -> Copyright 2014
please update
| |
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/pepper_printing_renderer_host.h" | |
6 | |
7 #include "chrome/common/print_messages.h" | |
8 #include "chrome/renderer/printing/print_web_view_helper.h" | |
9 #include "content/public/renderer/pepper_plugin_instance.h" | |
10 #include "content/public/renderer/render_view.h" | |
11 #include "content/public/renderer/renderer_ppapi_host.h" | |
12 #include "ppapi/host/dispatch_host_message.h" | |
13 #include "ppapi/proxy/ppapi_messages.h" | |
14 #include "third_party/WebKit/public/web/WebDocument.h" | |
15 #include "third_party/WebKit/public/web/WebElement.h" | |
16 #include "third_party/WebKit/public/web/WebLocalFrame.h" | |
17 #include "third_party/WebKit/public/web/WebPluginContainer.h" | |
18 #include "third_party/WebKit/public/web/WebView.h" | |
19 | |
20 PepperPrintingRendererHost::PepperPrintingRendererHost( | |
21 content::RendererPpapiHost* host, | |
22 PP_Instance instance, | |
23 PP_Resource resource) | |
24 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), | |
25 host_(host) { | |
26 } | |
27 | |
28 PepperPrintingRendererHost::~PepperPrintingRendererHost() { | |
29 } | |
30 | |
31 int32_t PepperPrintingRendererHost::OnResourceMessageReceived( | |
32 const IPC::Message& msg, | |
33 ppapi::host::HostMessageContext* context) { | |
34 PPAPI_BEGIN_MESSAGE_MAP(PepperPrintingRendererHost, msg) | |
35 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | |
36 PpapiHostMsg_PrintHost_SetPrintPresetOptionsFromDocument, | |
37 OnHostMsgSetPrintPresetOptionsFromDocument) | |
38 PPAPI_END_MESSAGE_MAP() | |
39 return PP_ERROR_FAILED; | |
40 } | |
41 | |
42 int32_t PepperPrintingRendererHost::OnHostMsgSetPrintPresetOptionsFromDocument( | |
43 ppapi::host::HostMessageContext* context, | |
44 PP_PrintPresetOptions_Dev& print_options) { | |
45 #if defined(ENABLE_FULL_PRINTING) | |
46 content::PepperPluginInstance* instance = | |
47 host_->GetPluginInstance(pp_instance()); | |
48 if (!instance) | |
49 return PP_ERROR_FAILED; | |
50 | |
51 blink::WebElement element = instance->GetContainer()->element(); | |
52 blink::WebView* view = element.document().frame()->view(); | |
53 content::RenderView* render_view = content::RenderView::FromWebView(view); | |
54 | |
55 using printing::PrintWebViewHelper; | |
56 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); | |
Vitaly Buka (NO REVIEWS)
2014/09/03 21:36:24
why not to send message to browser directly, witho
Nikhil
2014/09/04 11:42:53
Yea, we can send from here without going to helper
raymes
2014/09/05 00:06:41
Also - another thing to keep in mind is that we co
| |
57 if (print_view_helper) { | |
58 PrintHostMsg_SetOptionsFromDocument_Params params; | |
59 params.is_scaling_disabled = print_options.is_scaling_disabled; | |
60 params.copies = print_options.copies; | |
61 | |
62 print_view_helper->SetPrintPresetOptionsFromDocument(params); | |
63 return PP_OK; | |
64 } | |
65 #endif | |
66 return PP_ERROR_FAILED; | |
67 } | |
OLD | NEW |