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 b122262248ba5aedc70ad68f28dec4eee65a0b39..87f63e6e482f698eb77da2cc2625ad144e284022 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" |
@@ -75,10 +74,12 @@ |
#include "components/dom_distiller/core/url_constants.h" |
#include "components/nacl/renderer/ppb_nacl_private_impl.h" |
#include "components/password_manager/content/renderer/credential_manager_client.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" |
@@ -258,6 +259,48 @@ void IsGuestViewApiAvailableToScriptContext( |
} // namespace |
+#if defined(ENABLE_FULL_PRINTING) |
+// XXX: Move into its own file. |
raymes
2014/08/25 03:11:49
I guess you might as well move this into its own f
sadrul
2014/08/26 17:09:54
Done.
|
+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; |
@@ -421,6 +464,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( |
@@ -1394,7 +1441,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; |
} |