| Index: chrome/renderer/chrome_content_renderer_client.cc
|
| diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
|
| index 2aa64c2b23c62402b30db95333a606002ecd24f5..e62cd6684aba80648dda9c3752dd707de3dfc916 100644
|
| --- a/chrome/renderer/chrome_content_renderer_client.cc
|
| +++ b/chrome/renderer/chrome_content_renderer_client.cc
|
| @@ -51,7 +51,6 @@
|
| #include "chrome/renderer/net_benchmarking_extension.h"
|
| #include "chrome/renderer/page_load_histograms.h"
|
| #include "chrome/renderer/pepper/pepper_helper.h"
|
| -#include "chrome/renderer/pepper/ppb_pdf_impl.h"
|
| #include "chrome/renderer/playback_extension.h"
|
| #include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
|
| #include "chrome/renderer/plugins/plugin_uma.h"
|
| @@ -74,10 +73,12 @@
|
| #include "components/autofill/content/renderer/password_generation_agent.h"
|
| #include "components/dom_distiller/core/url_constants.h"
|
| #include "components/nacl/renderer/ppb_nacl_private_impl.h"
|
| +#include "components/pdf/renderer/ppb_pdf_impl.h"
|
| #include "components/plugins/renderer/mobile_youtube_plugin.h"
|
| #include "components/signin/core/common/profile_management_switches.h"
|
| #include "components/visitedlink/renderer/visitedlink_slave.h"
|
| #include "content/public/common/content_constants.h"
|
| +#include "content/public/renderer/pepper_plugin_instance.h"
|
| #include "content/public/renderer/render_frame.h"
|
| #include "content/public/renderer/render_thread.h"
|
| #include "content/public/renderer/render_view.h"
|
| @@ -257,6 +258,48 @@ void IsGuestViewApiAvailableToScriptContext(
|
|
|
| } // namespace
|
|
|
| +#if defined(ENABLE_FULL_PRINTING)
|
| +// XXX: Move into its own file.
|
| +class PDFPluginPrintDelegate : public pdf::PPB_PDF_Impl::PrintDelegate {
|
| + public:
|
| + PDFPluginPrintDelegate() {}
|
| + virtual ~PDFPluginPrintDelegate() {}
|
| +
|
| + virtual bool IsPrintingEnabled(PP_Instance instance_id) OVERRIDE {
|
| + blink::WebElement element = GetWebElement(instance_id);
|
| + printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
|
| + return helper && helper->IsPrintingEnabled();
|
| + }
|
| +
|
| + virtual void Print(PP_Instance instance_id) OVERRIDE {
|
| + blink::WebElement element = GetWebElement(instance_id);
|
| + printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
|
| + if (helper)
|
| + helper->PrintNode(element);
|
| + }
|
| +
|
| + private:
|
| + 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);
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PDFPluginPrintDelegate);
|
| +};
|
| +#endif // defined(ENABLE_FULL_PRINTING)
|
| +
|
| ChromeContentRendererClient::ChromeContentRendererClient() {
|
| g_current_client = this;
|
|
|
| @@ -416,6 +459,10 @@ void ChromeContentRendererClient::RenderThreadStarted() {
|
| if (blacklist::IsBlacklistInitialized())
|
| UMA_HISTOGRAM_BOOLEAN("Blacklist.PatchedInRenderer", true);
|
| #endif
|
| +#if defined(ENABLE_FULL_PRINTING)
|
| + pdf_print_delegate_.reset(new PDFPluginPrintDelegate());
|
| + pdf::PPB_PDF_Impl::SetPrintDelegate(pdf_print_delegate_.get());
|
| +#endif
|
| }
|
|
|
| void ChromeContentRendererClient::RenderFrameCreated(
|
| @@ -1386,7 +1433,7 @@ const void* ChromeContentRendererClient::CreatePPAPIInterface(
|
| return nacl::GetNaClPrivateInterface();
|
| #endif // DISABLE_NACL
|
| if (interface_name == PPB_PDF_INTERFACE)
|
| - return PPB_PDF_Impl::GetInterface();
|
| + return pdf::PPB_PDF_Impl::GetInterface();
|
| #endif
|
| return NULL;
|
| }
|
|
|