Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: components/pdf/renderer/ppb_pdf_impl.cc

Issue 477263003: pdf: Create a separate component for using the pdf pepper plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/pdf/renderer/ppb_pdf_impl.h ('k') | ipc/ipc_message_start.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/pdf/renderer/ppb_pdf_impl.cc
diff --git a/chrome/renderer/pepper/ppb_pdf_impl.cc b/components/pdf/renderer/ppb_pdf_impl.cc
similarity index 89%
rename from chrome/renderer/pepper/ppb_pdf_impl.cc
rename to components/pdf/renderer/ppb_pdf_impl.cc
index 16317adf2e728d154e580f2e3bfacaf11ca4c252..f6300f8ba624e9acafb95c52bc84e9cf4b5f3cc1 100644
--- a/chrome/renderer/pepper/ppb_pdf_impl.cc
+++ b/components/pdf/renderer/ppb_pdf_impl.cc
@@ -1,16 +1,15 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// 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/ppb_pdf_impl.h"
+#include "components/pdf/renderer/ppb_pdf_impl.h"
#include "base/files/scoped_file.h"
#include "base/metrics/histogram.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
-#include "chrome/common/render_messages.h"
-#include "chrome/renderer/printing/print_web_view_helper.h"
+#include "components/pdf/common/pdf_messages.h"
#include "content/app/strings/grit/content_strings.h"
jam 2014/08/22 00:44:59 why is this include there?
#include "content/public/common/child_process_sandbox_support_linux.h"
#include "content/public/common/referrer.h"
@@ -35,8 +34,11 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+namespace pdf {
namespace {
+PPB_PDF_Impl::PrintDelegate* print_delegate = NULL;
+
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
class PrivateFontFile : public ppapi::Resource {
public:
@@ -119,37 +121,6 @@ static const ResourceImageInfo kResourceImageMap[] = {
{PP_RESOURCEIMAGE_PDF_PAGE_DROPSHADOW, IDR_PDF_PAGE_DROPSHADOW},
{PP_RESOURCEIMAGE_PDF_PAN_SCROLL_ICON, IDR_PAN_SCROLL_ICON}, };
-#if defined(ENABLE_FULL_PRINTING)
-
-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);
-}
-
-bool IsPrintingEnabled(PP_Instance instance_id) {
- blink::WebElement element = GetWebElement(instance_id);
- printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
- return helper && helper->IsPrintingEnabled();
-}
-
-#else // ENABLE_FULL_PRINTING
-
-bool IsPrintingEnabled(PP_Instance instance_id) { return false; }
-
-#endif // ENABLE_FULL_PRINTING
-
PP_Var GetLocalizedString(PP_Instance instance_id,
PP_ResourceString string_id) {
content::PepperPluginInstance* instance =
@@ -301,7 +272,7 @@ void SetContentRestriction(PP_Instance instance_id, int restrictions) {
if (!instance)
return;
instance->GetRenderView()->Send(
- new ChromeViewHostMsg_PDFUpdateContentRestrictions(
+ new PDFHostMsg_PDFUpdateContentRestrictions(
instance->GetRenderView()->GetRoutingID(), restrictions));
}
@@ -329,7 +300,7 @@ void HasUnsupportedFeature(PP_Instance instance_id) {
blink::WebView* view =
instance->GetContainer()->element().document().frame()->view();
content::RenderView* render_view = content::RenderView::FromWebView(view);
- render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature(
+ render_view->Send(new PDFHostMsg_PDFHasUnsupportedFeature(
render_view->GetRoutingID()));
}
@@ -345,7 +316,7 @@ void SaveAs(PP_Instance instance_id) {
render_view->GetWebView()->mainFrame()->toWebLocalFrame();
content::Referrer referrer(frame->document().url(),
frame->document().referrerPolicy());
- render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs(
+ render_view->Send(new PDFHostMsg_PDFSaveURLAs(
render_view->GetRoutingID(), url, referrer));
}
@@ -354,7 +325,8 @@ PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) {
case PP_PDFFEATURE_HIDPI:
return PP_TRUE;
case PP_PDFFEATURE_PRINTING:
- return IsPrintingEnabled(instance) ? PP_TRUE : PP_FALSE;
+ return (print_delegate && print_delegate->IsPrintingEnabled(instance))
+ ? PP_TRUE : PP_FALSE;
}
return PP_FALSE;
}
@@ -402,7 +374,7 @@ PP_Var ModalPromptForPassword(PP_Instance instance_id, PP_Var message) {
scoped_refptr<ppapi::StringVar> message_string(
ppapi::StringVar::FromPPVar(message));
- IPC::SyncMessage* msg = new ChromeViewHostMsg_PDFModalPromptForPassword(
+ IPC::SyncMessage* msg = new PDFHostMsg_PDFModalPromptForPassword(
instance->GetRenderView()->GetRoutingID(),
message_string->value(),
&actual_value);
@@ -455,10 +427,13 @@ const PPB_PDF* PPB_PDF_Impl::GetInterface() { return &ppb_pdf; }
// static
void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) {
-#if defined(ENABLE_FULL_PRINTING)
- blink::WebElement element = GetWebElement(instance_id);
- printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
- if (helper)
- helper->PrintNode(element);
-#endif // ENABLE_FULL_PRINTING
+ if (print_delegate)
+ print_delegate->Print(instance_id);
+}
+
+void PPB_PDF_Impl::SetPrintDelegate(PPB_PDF_Impl::PrintDelegate* delegate) {
+ CHECK(!print_delegate) << "There should only be a single PrintDelegate.";
+ print_delegate = delegate;
}
+
+} // namespace pdf
« no previous file with comments | « components/pdf/renderer/ppb_pdf_impl.h ('k') | ipc/ipc_message_start.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698