diff options
author | Sadrul Habib Chowdhury <sadrul@chromium.org> | 2014-08-28 14:19:50 -0400 |
---|---|---|
committer | Sadrul Habib Chowdhury <sadrul@chromium.org> | 2014-08-28 18:32:14 +0000 |
commit | a1733ee3921edbf62acd0c8128b4160852997761 (patch) | |
tree | bf92fc66eed191790174fdf0b1c403bcf3a01eae | |
parent | 0010604872a581f795e079b62f2c2376661a88ea (diff) | |
download | chromium_src-a1733ee3921edbf62acd0c8128b4160852997761.zip chromium_src-a1733ee3921edbf62acd0c8128b4160852997761.tar.gz chromium_src-a1733ee3921edbf62acd0c8128b4160852997761.tar.bz2 |
pdf: Move PepperPDFHost into the pdf component.
Move PepperPDFHost out of //chrome into the pdf component at //components/pdf.
With this change, the IPC messages in the component is used only by the
component itself, and nothing outside of the component uses these IPC messages
anymore.
BUG=401242
R=raymes@chromium.org, senorblanco@chromium.org, sky@chromium.org, thestig@chromium.org
Review URL: https://codereview.chromium.org/505243003
Cr-Commit-Position: refs/heads/master@{#292416}
-rw-r--r-- | chrome/chrome_renderer.gypi | 2 | ||||
-rw-r--r-- | chrome/renderer/DEPS | 1 | ||||
-rw-r--r-- | chrome/renderer/pepper/chrome_pdf_print_client.cc | 7 | ||||
-rw-r--r-- | chrome/renderer/pepper/chrome_pdf_print_client.h | 2 | ||||
-rw-r--r-- | chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc | 6 | ||||
-rw-r--r-- | components/pdf.gypi | 2 | ||||
-rw-r--r-- | components/pdf/renderer/BUILD.gn | 2 | ||||
-rw-r--r-- | components/pdf/renderer/DEPS | 4 | ||||
-rw-r--r-- | components/pdf/renderer/pepper_pdf_host.cc (renamed from chrome/renderer/pepper/pepper_pdf_host.cc) | 30 | ||||
-rw-r--r-- | components/pdf/renderer/pepper_pdf_host.h (renamed from chrome/renderer/pepper/pepper_pdf_host.h) | 12 | ||||
-rw-r--r-- | components/pdf/renderer/ppb_pdf_impl.cc | 11 | ||||
-rw-r--r-- | components/pdf/renderer/ppb_pdf_impl.h | 9 |
12 files changed, 46 insertions, 42 deletions
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index 1d4c6f6c..9e6a242 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -202,8 +202,6 @@ 'renderer/pepper/pepper_flash_renderer_host.h', 'renderer/pepper/pepper_helper.cc', 'renderer/pepper/pepper_helper.h', - 'renderer/pepper/pepper_pdf_host.cc', - 'renderer/pepper/pepper_pdf_host.h', 'renderer/pepper/pepper_shared_memory_message_filter.cc', 'renderer/pepper/pepper_shared_memory_message_filter.h', 'renderer/pepper/pepper_uma_host.cc', diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index 9437474..3e29439 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -12,7 +12,6 @@ include_rules = [ "+components/nacl/common", "+components/nacl/renderer", "+components/password_manager/content/renderer", - "+components/pdf/common", "+components/pdf/renderer", "+components/plugins/renderer", "+components/signin/core/common", diff --git a/chrome/renderer/pepper/chrome_pdf_print_client.cc b/chrome/renderer/pepper/chrome_pdf_print_client.cc index 32d1e09..51ab320 100644 --- a/chrome/renderer/pepper/chrome_pdf_print_client.cc +++ b/chrome/renderer/pepper/chrome_pdf_print_client.cc @@ -44,9 +44,12 @@ bool ChromePDFPrintClient::IsPrintingEnabled(PP_Instance instance_id) { return helper && helper->IsPrintingEnabled(); } -void ChromePDFPrintClient::Print(PP_Instance instance_id) { +bool ChromePDFPrintClient::Print(PP_Instance instance_id) { blink::WebElement element = GetWebElement(instance_id); printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); - if (helper) + if (helper) { helper->PrintNode(element); + return true; + } + return false; } diff --git a/chrome/renderer/pepper/chrome_pdf_print_client.h b/chrome/renderer/pepper/chrome_pdf_print_client.h index 0ae3224..feb84a6 100644 --- a/chrome/renderer/pepper/chrome_pdf_print_client.h +++ b/chrome/renderer/pepper/chrome_pdf_print_client.h @@ -16,7 +16,7 @@ class ChromePDFPrintClient : public pdf::PPB_PDF_Impl::PrintClient { private: // pdf::PPB_PDF_Impl::PrintClient: virtual bool IsPrintingEnabled(PP_Instance instance_id) OVERRIDE; - virtual void Print(PP_Instance instance_id) OVERRIDE; + virtual bool Print(PP_Instance instance_id) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(ChromePDFPrintClient); }; diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc index 789a86a..c0edcb4 100644 --- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc +++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc @@ -10,13 +10,13 @@ #include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h" #include "chrome/renderer/pepper/pepper_flash_menu_host.h" #include "chrome/renderer/pepper/pepper_flash_renderer_host.h" -#include "chrome/renderer/pepper/pepper_pdf_host.h" #include "chrome/renderer/pepper/pepper_uma_host.h" +#include "components/pdf/renderer/pepper_pdf_host.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "ppapi/host/ppapi_host.h" #include "ppapi/host/resource_host.h" -#include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppapi_message_utils.h" +#include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/ppapi_permissions.h" using ppapi::host::ResourceHost; @@ -90,7 +90,7 @@ scoped_ptr<ResourceHost> ChromeRendererPepperHostFactory::CreateResourceHost( switch (message.type()) { case PpapiHostMsg_PDF_Create::ID: { return scoped_ptr<ResourceHost>( - new PepperPDFHost(host_, instance, params.pp_resource())); + new pdf::PepperPDFHost(host_, instance, params.pp_resource())); } } } diff --git a/components/pdf.gypi b/components/pdf.gypi index 80061c6..a9fb72f 100644 --- a/components/pdf.gypi +++ b/components/pdf.gypi @@ -46,6 +46,8 @@ 'pdf_common', ], 'sources': [ + 'pdf/renderer/pepper_pdf_host.cc', + 'pdf/renderer/pepper_pdf_host.h', 'pdf/renderer/ppb_pdf_impl.cc', 'pdf/renderer/ppb_pdf_impl.h', ], diff --git a/components/pdf/renderer/BUILD.gn b/components/pdf/renderer/BUILD.gn index e2cfaeb..f072d26 100644 --- a/components/pdf/renderer/BUILD.gn +++ b/components/pdf/renderer/BUILD.gn @@ -6,6 +6,8 @@ import("//build/config/features.gni") static_library("renderer") { sources = [ + "pepper_pdf_host.cc", + "pepper_pdf_host.h", "ppb_pdf_impl.cc", "ppb_pdf_impl.h", ] diff --git a/components/pdf/renderer/DEPS b/components/pdf/renderer/DEPS new file mode 100644 index 0000000..b4762c10 --- /dev/null +++ b/components/pdf/renderer/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+skia/ext", + "+ui/gfx", +] diff --git a/chrome/renderer/pepper/pepper_pdf_host.cc b/components/pdf/renderer/pepper_pdf_host.cc index 0c22c92..c720ca8 100644 --- a/chrome/renderer/pepper/pepper_pdf_host.cc +++ b/components/pdf/renderer/pepper_pdf_host.cc @@ -1,12 +1,12 @@ -// Copyright (c) 2013 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/pepper_pdf_host.h" +#include "components/pdf/renderer/pepper_pdf_host.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/renderer/printing/print_web_view_helper.h" #include "components/pdf/common/pdf_messages.h" +#include "components/pdf/renderer/ppb_pdf_impl.h" #include "content/app/resources/grit/content_resources.h" #include "content/app/strings/grit/content_strings.h" #include "content/public/common/referrer.h" @@ -101,6 +101,8 @@ const ResourceImageInfo kResourceImageMap[] = { } // namespace +namespace pdf { + PepperPDFHost::PepperPDFHost(content::RendererPpapiHost* host, PP_Instance instance, PP_Resource resource) @@ -215,24 +217,8 @@ int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( int32_t PepperPDFHost::OnHostMsgPrint( ppapi::host::HostMessageContext* context) { -#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); - if (print_view_helper) { - print_view_helper->PrintNode(element); - return PP_OK; - } -#endif - return PP_ERROR_FAILED; + return PPB_PDF_Impl::InvokePrintingForInstance(pp_instance()) ? PP_OK : + PP_ERROR_FAILED; } int32_t PepperPDFHost::OnHostMsgSaveAs( @@ -390,3 +376,5 @@ bool PepperPDFHost::CreateImageData( return true; } + +} // namespace pdf diff --git a/chrome/renderer/pepper/pepper_pdf_host.h b/components/pdf/renderer/pepper_pdf_host.h index 6e1d5a6..2fa49af 100644 --- a/chrome/renderer/pepper/pepper_pdf_host.h +++ b/components/pdf/renderer/pepper_pdf_host.h @@ -1,9 +1,9 @@ -// Copyright (c) 2013 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. -#ifndef CHROME_RENDERER_PEPPER_PEPPER_PDF_HOST_H_ -#define CHROME_RENDERER_PEPPER_PEPPER_PDF_HOST_H_ +#ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ +#define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ #include <string> @@ -34,6 +34,8 @@ struct HostMessageContext; } } +namespace pdf { + class PepperPDFHost : public ppapi::host::ResourceHost { public: PepperPDFHost(content::RendererPpapiHost* host, @@ -82,4 +84,6 @@ class PepperPDFHost : public ppapi::host::ResourceHost { DISALLOW_COPY_AND_ASSIGN(PepperPDFHost); }; -#endif // CHROME_RENDERER_PEPPER_PEPPER_PDF_HOST_H_ +} // namespace pdf + +#endif // COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_ diff --git a/components/pdf/renderer/ppb_pdf_impl.cc b/components/pdf/renderer/ppb_pdf_impl.cc index 716ff9a..a26c740 100644 --- a/components/pdf/renderer/ppb_pdf_impl.cc +++ b/components/pdf/renderer/ppb_pdf_impl.cc @@ -322,6 +322,10 @@ void SaveAs(PP_Instance instance_id) { new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); } +void Print(PP_Instance instance) { + PPB_PDF_Impl::InvokePrintingForInstance(instance); +} + PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) { switch (feature) { case PP_PDFFEATURE_HIDPI: @@ -416,7 +420,7 @@ const PPB_PDF ppb_pdf = { // &UserMetricsRecordAction, // &HasUnsupportedFeature, // &SaveAs, // - &PPB_PDF_Impl::InvokePrintingForInstance, // + &Print, // &IsFeatureEnabled, // &GetResourceImageForScale, // &ModalPromptForPassword, // @@ -433,9 +437,8 @@ const PPB_PDF* PPB_PDF_Impl::GetInterface() { } // static -void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { - if (g_print_client) - g_print_client->Print(instance_id); +bool PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { + return g_print_client ? g_print_client->Print(instance_id) : false; } void PPB_PDF_Impl::SetPrintClient(PPB_PDF_Impl::PrintClient* client) { diff --git a/components/pdf/renderer/ppb_pdf_impl.h b/components/pdf/renderer/ppb_pdf_impl.h index 2cd5a44..5feeee3 100644 --- a/components/pdf/renderer/ppb_pdf_impl.h +++ b/components/pdf/renderer/ppb_pdf_impl.h @@ -22,8 +22,8 @@ class PPB_PDF_Impl { virtual bool IsPrintingEnabled(PP_Instance instance_id) = 0; // Invokes the "Print" command for the plugin instance identified by - // |instance_id|. - virtual void Print(PP_Instance instance_id) = 0; + // |instance_id|. Returns whether the "Print" command was issued or not. + virtual bool Print(PP_Instance instance_id) = 0; }; // Returns a pointer to the interface implementing PPB_PDF that is exposed @@ -31,8 +31,9 @@ class PPB_PDF_Impl { static const PPB_PDF* GetInterface(); // Invokes the "Print" command for the given instance as if the user right - // clicked on it and selected "Print". - static void InvokePrintingForInstance(PP_Instance instance); + // clicked on it and selected "Print". Returns if the "Print" command was + // issued or not. + static bool InvokePrintingForInstance(PP_Instance instance); // The caller retains the ownership of |print_client|. The client is // allowed to be set only once, and when set, the client must outlive the |