0

Revert PDF component build CLs.

This is a manual revert of r531314, r531339, and r531347.
Win7 Tests (dbg) fails with an Import Address Table patching failure.

Change-Id: I76c629f36e40cab315ab0ded2d7b2342ffdfbc6f
Reviewed-on: https://chromium-review.googlesource.com/882198
Reviewed-by: Joe Downing <joedow@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531424}
This commit is contained in:
Lei Zhang
2018-01-24 03:50:32 +00:00
committed by Commit Bot
parent 329ac9a721
commit 602ed720f0
10 changed files with 132 additions and 213 deletions

@ -149,7 +149,7 @@
#if BUILDFLAG(ENABLE_PLUGINS) && (defined(CHROME_MULTIPLE_DLL_CHILD) || \
!defined(CHROME_MULTIPLE_DLL_BROWSER))
#include "pdf/pdf_ppapi.h"
#include "pdf/pdf.h"
#endif
#if !defined(CHROME_MULTIPLE_DLL_CHILD)

@ -4,7 +4,6 @@
import("//build/buildflag_header.gni")
import("//build/config/features.gni")
import("//build/config/jumbo.gni")
import("//pdf/features.gni")
import("//testing/test.gni")
import("//third_party/pdfium/pdfium.gni")
@ -18,10 +17,9 @@ buildflag_header("features") {
if (enable_pdf) {
pdf_engine = 0 # 0 PDFium
jumbo_component("pdf") {
static_library("pdf") {
deps = [
"//base",
"//base:i18n",
"//gin",
"//net",
"//ppapi/cpp:objects",
@ -30,11 +28,6 @@ if (enable_pdf) {
"//ui/gfx/range",
]
public = [
"pdf.h",
"pdf_ppapi.h",
]
sources = [
"chunk_stream.h",
"document_loader.cc",
@ -51,9 +44,6 @@ if (enable_pdf) {
"pdf.h",
"pdf_engine.cc",
"pdf_engine.h",
"pdf_export.h",
"pdf_ppapi.cc",
"pdf_ppapi.h",
"preview_mode_client.cc",
"preview_mode_client.h",
"range_set.cc",
@ -89,10 +79,7 @@ if (enable_pdf) {
]
}
defines = [
"PDF_IMPLEMENTATION",
"PDFIUM_PRINT_TEXT_WITH_GDI",
]
defines = [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
if (pdf_enable_xfa) {
defines += [ "PDF_ENABLE_XFA" ]
}

@ -15,19 +15,18 @@
#include <vector>
#include "pdf/chunk_stream.h"
#include "pdf/pdf_export.h"
#include "ppapi/utility/completion_callback_factory.h"
namespace chrome_pdf {
class URLLoaderWrapper;
class PDF_EXPORT DocumentLoader {
class DocumentLoader {
public:
// Number was chosen in crbug.com/78264#c8
static constexpr uint32_t kDefaultRequestSize = 65536;
class PDF_EXPORT Client {
class Client {
public:
virtual ~Client();

@ -329,12 +329,12 @@ pp::Var ModalDialog(const pp::Instance* instance,
const std::string& type,
const std::string& message,
const std::string& default_answer) {
const PPB_Instance_Private* ppb_interface =
const PPB_Instance_Private* interface =
reinterpret_cast<const PPB_Instance_Private*>(
pp::Module::Get()->GetBrowserInterface(
PPB_INSTANCE_PRIVATE_INTERFACE));
pp::VarPrivate window(
pp::PASS_REF, ppb_interface->GetWindowObject(instance->pp_instance()));
pp::VarPrivate window(pp::PASS_REF,
interface->GetWindowObject(instance->pp_instance()));
if (default_answer.empty())
return window.Call(type, message);
return window.Call(type, message, default_answer);

@ -10,12 +10,75 @@
#include <windows.h>
#endif
#include "base/command_line.h"
#include "base/logging.h"
#include "pdf/out_of_process_instance.h"
#include "pdf/pdf_ppapi.h"
#include "ppapi/c/ppp.h"
#include "ppapi/cpp/private/internal_module.h"
#include "ppapi/cpp/private/pdf.h"
#include "v8/include/v8.h"
namespace chrome_pdf {
namespace {
bool g_sdk_initialized_via_pepper = false;
} // namespace
PDFModule::PDFModule() = default;
PDFModule::~PDFModule() {
if (g_sdk_initialized_via_pepper) {
ShutdownSDK();
g_sdk_initialized_via_pepper = false;
}
}
bool PDFModule::Init() {
return true;
}
pp::Instance* PDFModule::CreateInstance(PP_Instance instance) {
if (!g_sdk_initialized_via_pepper) {
v8::StartupData natives;
v8::StartupData snapshot;
pp::PDF::GetV8ExternalSnapshotData(pp::InstanceHandle(instance),
&natives.data, &natives.raw_size,
&snapshot.data, &snapshot.raw_size);
if (natives.data) {
v8::V8::SetNativesDataBlob(&natives);
v8::V8::SetSnapshotDataBlob(&snapshot);
}
if (!InitializeSDK())
return nullptr;
g_sdk_initialized_via_pepper = true;
}
return new OutOfProcessInstance(instance);
}
// Implementation of Global PPP functions ---------------------------------
int32_t PPP_InitializeModule(PP_Module module_id,
PPB_GetInterface get_browser_interface) {
std::unique_ptr<PDFModule> module(new PDFModule);
if (!module->InternalInit(module_id, get_browser_interface))
return PP_ERROR_FAILED;
pp::InternalSetModuleSingleton(module.release());
return PP_OK;
}
void PPP_ShutdownModule() {
delete pp::Module::Get();
pp::InternalSetModuleSingleton(nullptr);
}
const void* PPP_GetInterface(const char* interface_name) {
auto* module = pp::Module::Get();
return module ? module->GetPluginInterface(interface_name) : nullptr;
}
#if defined(OS_WIN)
bool RenderPDFPageToDC(const void* pdf_buffer,
int buffer_size,
@ -31,7 +94,7 @@ bool RenderPDFPageToDC(const void* pdf_buffer,
bool keep_aspect_ratio,
bool center_in_bounds,
bool autorotate) {
if (!IsSDKInitializedViaPepper()) {
if (!g_sdk_initialized_via_pepper) {
if (!InitializeSDK()) {
return false;
}
@ -44,7 +107,7 @@ bool RenderPDFPageToDC(const void* pdf_buffer,
autorotate);
bool ret = engine_exports->RenderPDFPageToDC(pdf_buffer, buffer_size,
page_number, settings, dc);
if (!IsSDKInitializedViaPepper())
if (!g_sdk_initialized_via_pepper)
ShutdownSDK();
return ret;
@ -68,14 +131,14 @@ bool GetPDFDocInfo(const void* pdf_buffer,
int buffer_size,
int* page_count,
double* max_page_width) {
if (!IsSDKInitializedViaPepper()) {
if (!g_sdk_initialized_via_pepper) {
if (!InitializeSDK())
return false;
}
PDFEngineExports* engine_exports = PDFEngineExports::Get();
bool ret = engine_exports->GetPDFDocInfo(pdf_buffer, buffer_size, page_count,
max_page_width);
if (!IsSDKInitializedViaPepper())
if (!g_sdk_initialized_via_pepper)
ShutdownSDK();
return ret;
@ -86,7 +149,7 @@ bool GetPDFPageSizeByIndex(const void* pdf_buffer,
int page_number,
double* width,
double* height) {
if (!IsSDKInitializedViaPepper()) {
if (!g_sdk_initialized_via_pepper) {
if (!chrome_pdf::InitializeSDK())
return false;
}
@ -94,7 +157,7 @@ bool GetPDFPageSizeByIndex(const void* pdf_buffer,
chrome_pdf::PDFEngineExports::Get();
bool ret = engine_exports->GetPDFPageSizeByIndex(pdf_buffer, pdf_buffer_size,
page_number, width, height);
if (!IsSDKInitializedViaPepper())
if (!g_sdk_initialized_via_pepper)
chrome_pdf::ShutdownSDK();
return ret;
}
@ -107,7 +170,7 @@ bool RenderPDFPageToBitmap(const void* pdf_buffer,
int bitmap_height,
int dpi,
bool autorotate) {
if (!IsSDKInitializedViaPepper()) {
if (!g_sdk_initialized_via_pepper) {
if (!InitializeSDK())
return false;
}
@ -117,7 +180,7 @@ bool RenderPDFPageToBitmap(const void* pdf_buffer,
autorotate);
bool ret = engine_exports->RenderPDFPageToBitmap(
pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer);
if (!IsSDKInitializedViaPepper())
if (!g_sdk_initialized_via_pepper)
ShutdownSDK();
return ret;

@ -5,8 +5,6 @@
#ifndef PDF_PDF_H_
#define PDF_PDF_H_
#include "build/build_config.h"
#include "pdf/pdf_export.h"
#include "ppapi/c/ppb.h"
#include "ppapi/cpp/module.h"
@ -22,6 +20,21 @@ typedef void (*PDFEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
namespace chrome_pdf {
class PDFModule : public pp::Module {
public:
PDFModule();
~PDFModule() override;
// pp::Module implementation.
bool Init() override;
pp::Instance* CreateInstance(PP_Instance instance) override;
};
int PPP_InitializeModule(PP_Module module_id,
PPB_GetInterface get_browser_interface);
void PPP_ShutdownModule();
const void* PPP_GetInterface(const char* interface_name);
#if defined(OS_WIN)
// Printing modes - type to convert PDF to for printing
enum PrintingMode {
@ -58,35 +71,35 @@ enum PrintingMode {
// |autorotate| specifies whether the final image should be rotated to match
// the output bound.
// Returns false if the document or the page number are not valid.
PDF_EXPORT bool RenderPDFPageToDC(const void* pdf_buffer,
int buffer_size,
int page_number,
HDC dc,
int dpi,
int bounds_origin_x,
int bounds_origin_y,
int bounds_width,
int bounds_height,
bool fit_to_bounds,
bool stretch_to_bounds,
bool keep_aspect_ratio,
bool center_in_bounds,
bool autorotate);
bool RenderPDFPageToDC(const void* pdf_buffer,
int buffer_size,
int page_number,
HDC dc,
int dpi,
int bounds_origin_x,
int bounds_origin_y,
int bounds_width,
int bounds_height,
bool fit_to_bounds,
bool stretch_to_bounds,
bool keep_aspect_ratio,
bool center_in_bounds,
bool autorotate);
PDF_EXPORT void SetPDFEnsureTypefaceCharactersAccessible(
void SetPDFEnsureTypefaceCharactersAccessible(
PDFEnsureTypefaceCharactersAccessible func);
PDF_EXPORT void SetPDFUseGDIPrinting(bool enable);
void SetPDFUseGDIPrinting(bool enable);
PDF_EXPORT void SetPDFUsePrintMode(int mode);
void SetPDFUsePrintMode(int mode);
#endif // defined(OS_WIN)
// |page_count| and |max_page_width| are optional and can be NULL.
// Returns false if the document is not valid.
PDF_EXPORT bool GetPDFDocInfo(const void* pdf_buffer,
int buffer_size,
int* page_count,
double* max_page_width);
bool GetPDFDocInfo(const void* pdf_buffer,
int buffer_size,
int* page_count,
double* max_page_width);
// Gets the dimensions of a specific page in a document.
// |pdf_buffer| is the buffer that contains the entire PDF document to be
@ -97,11 +110,11 @@ PDF_EXPORT bool GetPDFDocInfo(const void* pdf_buffer,
// |width| is the output for the width of the page in points.
// |height| is the output for the height of the page in points.
// Returns false if the document or the page number are not valid.
PDF_EXPORT bool GetPDFPageSizeByIndex(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
double* width,
double* height);
bool GetPDFPageSizeByIndex(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
double* width,
double* height);
// Renders PDF page into 4-byte per pixel BGRA color bitmap.
// |pdf_buffer| is the buffer that contains the entire PDF document to be
@ -115,14 +128,14 @@ PDF_EXPORT bool GetPDFPageSizeByIndex(const void* pdf_buffer,
// |autorotate| specifies whether the final image should be rotated to match
// the output bound.
// Returns false if the document or the page number are not valid.
PDF_EXPORT bool RenderPDFPageToBitmap(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
void* bitmap_buffer,
int bitmap_width,
int bitmap_height,
int dpi,
bool autorotate);
bool RenderPDFPageToBitmap(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
void* bitmap_buffer,
int bitmap_width,
int bitmap_height,
int dpi,
bool autorotate);
} // namespace chrome_pdf

@ -1,29 +0,0 @@
// Copyright 2018 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 PDF_PDF_EXPORT_H_
#define PDF_PDF_EXPORT_H_
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(PDF_IMPLEMENTATION)
#define PDF_EXPORT __declspec(dllexport)
#else
#define PDF_EXPORT __declspec(dllimport)
#endif // defined(PDF_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(PDF_IMPLEMENTATION)
#define PDF_EXPORT __attribute__((visibility("default")))
#else
#define PDF_EXPORT
#endif
#endif
#else // defined(COMPONENT_BUILD)
#define PDF_EXPORT
#endif
#endif // PDF_PDF_EXPORT_H_

@ -1,89 +0,0 @@
// Copyright 2018 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 "pdf/pdf_ppapi.h"
#include <memory>
#include "pdf/out_of_process_instance.h"
#include "ppapi/c/ppp.h"
#include "ppapi/cpp/private/internal_module.h"
#include "ppapi/cpp/private/pdf.h"
#include "v8/include/v8.h"
namespace chrome_pdf {
namespace {
bool g_sdk_initialized_via_pepper = false;
class PDFModule : public pp::Module {
public:
PDFModule();
~PDFModule() override;
// pp::Module implementation.
bool Init() override;
pp::Instance* CreateInstance(PP_Instance instance) override;
};
PDFModule::PDFModule() = default;
PDFModule::~PDFModule() {
if (g_sdk_initialized_via_pepper) {
ShutdownSDK();
g_sdk_initialized_via_pepper = false;
}
}
bool PDFModule::Init() {
return true;
}
pp::Instance* PDFModule::CreateInstance(PP_Instance instance) {
if (!g_sdk_initialized_via_pepper) {
v8::StartupData natives;
v8::StartupData snapshot;
pp::PDF::GetV8ExternalSnapshotData(pp::InstanceHandle(instance),
&natives.data, &natives.raw_size,
&snapshot.data, &snapshot.raw_size);
if (natives.data) {
v8::V8::SetNativesDataBlob(&natives);
v8::V8::SetSnapshotDataBlob(&snapshot);
}
if (!InitializeSDK())
return nullptr;
g_sdk_initialized_via_pepper = true;
}
return new OutOfProcessInstance(instance);
}
} // namespace
int32_t PPP_InitializeModule(PP_Module module_id,
PPB_GetInterface get_browser_interface) {
auto module = std::make_unique<PDFModule>();
if (!module->InternalInit(module_id, get_browser_interface))
return PP_ERROR_FAILED;
pp::InternalSetModuleSingleton(module.release());
return PP_OK;
}
void PPP_ShutdownModule() {
delete pp::Module::Get();
pp::InternalSetModuleSingleton(nullptr);
}
const void* PPP_GetInterface(const char* interface_name) {
auto* module = pp::Module::Get();
return module ? module->GetPluginInterface(interface_name) : nullptr;
}
bool IsSDKInitializedViaPepper() {
return g_sdk_initialized_via_pepper;
}
} // namespace chrome_pdf

@ -1,24 +0,0 @@
// Copyright 2018 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 PDF_PDF_PPAPI_H_
#define PDF_PDF_PPAPI_H_
#include "build/build_config.h"
#include "pdf/pdf_export.h"
#include "ppapi/c/ppb.h"
#include "ppapi/cpp/module.h"
namespace chrome_pdf {
PDF_EXPORT int PPP_InitializeModule(PP_Module module_id,
PPB_GetInterface get_browser_interface);
PDF_EXPORT void PPP_ShutdownModule();
PDF_EXPORT const void* PPP_GetInterface(const char* interface_name);
bool IsSDKInitializedViaPepper();
} // namespace chrome_pdf
#endif // PDF_PDF_PPAPI_H_

@ -11,12 +11,11 @@
#include <set>
#include <string>
#include "pdf/pdf_export.h"
#include "ui/gfx/range/range.h"
namespace chrome_pdf {
class PDF_EXPORT RangeSet {
class RangeSet {
public:
RangeSet();
explicit RangeSet(const gfx::Range& range);
@ -72,7 +71,7 @@ class PDF_EXPORT RangeSet {
} // namespace chrome_pdf
PDF_EXPORT std::ostream& operator<<(std::ostream& os,
const chrome_pdf::RangeSet& range_set);
std::ostream& operator<<(std::ostream& os,
const chrome_pdf::RangeSet& range_set);
#endif // PDF_RANGE_SET_H_