Chromium Code Reviews| Index: chrome/renderer/pepper/pepper_printing_renderer_host.cc |
| diff --git a/chrome/renderer/pepper/pepper_printing_renderer_host.cc b/chrome/renderer/pepper/pepper_printing_renderer_host.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..67919aca3ecf4c46cfee8011cbe4c9bcb1c77929 |
| --- /dev/null |
| +++ b/chrome/renderer/pepper/pepper_printing_renderer_host.cc |
| @@ -0,0 +1,67 @@ |
| +// 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
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/renderer/pepper/pepper_printing_renderer_host.h" |
| + |
| +#include "chrome/common/print_messages.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 "content/public/renderer/renderer_ppapi_host.h" |
| +#include "ppapi/host/dispatch_host_message.h" |
| +#include "ppapi/proxy/ppapi_messages.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" |
| +#include "third_party/WebKit/public/web/WebView.h" |
| + |
| +PepperPrintingRendererHost::PepperPrintingRendererHost( |
| + content::RendererPpapiHost* host, |
| + PP_Instance instance, |
| + PP_Resource resource) |
| + : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), |
| + host_(host) { |
| +} |
| + |
| +PepperPrintingRendererHost::~PepperPrintingRendererHost() { |
| +} |
| + |
| +int32_t PepperPrintingRendererHost::OnResourceMessageReceived( |
| + const IPC::Message& msg, |
| + ppapi::host::HostMessageContext* context) { |
| + PPAPI_BEGIN_MESSAGE_MAP(PepperPrintingRendererHost, msg) |
| + PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
| + PpapiHostMsg_PrintHost_SetPrintPresetOptionsFromDocument, |
| + OnHostMsgSetPrintPresetOptionsFromDocument) |
| + PPAPI_END_MESSAGE_MAP() |
| + return PP_ERROR_FAILED; |
| +} |
| + |
| +int32_t PepperPrintingRendererHost::OnHostMsgSetPrintPresetOptionsFromDocument( |
| + ppapi::host::HostMessageContext* context, |
| + PP_PrintPresetOptions_Dev& print_options) { |
| +#if defined(ENABLE_FULL_PRINTING) |
| + content::PepperPluginInstance* instance = |
| + host_->GetPluginInstance(pp_instance()); |
| + if (!instance) |
| + return PP_ERROR_FAILED; |
| + |
| + blink::WebElement element = instance->GetContainer()->element(); |
| + blink::WebView* view = element.document().frame()->view(); |
| + content::RenderView* render_view = content::RenderView::FromWebView(view); |
| + |
| + using printing::PrintWebViewHelper; |
| + 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
|
| + if (print_view_helper) { |
| + PrintHostMsg_SetOptionsFromDocument_Params params; |
| + params.is_scaling_disabled = print_options.is_scaling_disabled; |
| + params.copies = print_options.copies; |
| + |
| + print_view_helper->SetPrintPresetOptionsFromDocument(params); |
| + return PP_OK; |
| + } |
| +#endif |
| + return PP_ERROR_FAILED; |
| +} |