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}
parent 00106048
......@@ -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',
......
......@@ -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",
......
......@@ -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;
}
......@@ -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);
};
......
......@@ -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()));
}
}
}
......
......@@ -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',
],
......
......@@ -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",
]
......
include_rules = [
"+skia/ext",
"+ui/gfx",
]
// 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
// 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_
......@@ -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) {
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment