Make the pdf build target a component.
The code in pdf/ can be a GN component instead of a static_library. Add a PDF_EXPORT macro and set boundaries on what can be used from external callers. Change-Id: Ib855736f145c5708b8c62c7fd0e3622827bcc623 Reviewed-on: https://chromium-review.googlesource.com/879853 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#531314}
This commit is contained in:
13
pdf/BUILD.gn
13
pdf/BUILD.gn
@ -17,9 +17,10 @@ buildflag_header("features") {
|
||||
if (enable_pdf) {
|
||||
pdf_engine = 0 # 0 PDFium
|
||||
|
||||
static_library("pdf") {
|
||||
component("pdf") {
|
||||
deps = [
|
||||
"//base",
|
||||
"//base:i18n",
|
||||
"//gin",
|
||||
"//net",
|
||||
"//ppapi/cpp:objects",
|
||||
@ -28,6 +29,10 @@ if (enable_pdf) {
|
||||
"//ui/gfx/range",
|
||||
]
|
||||
|
||||
public = [
|
||||
"pdf.h",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"chunk_stream.h",
|
||||
"document_loader.cc",
|
||||
@ -44,6 +49,7 @@ if (enable_pdf) {
|
||||
"pdf.h",
|
||||
"pdf_engine.cc",
|
||||
"pdf_engine.h",
|
||||
"pdf_export.h",
|
||||
"preview_mode_client.cc",
|
||||
"preview_mode_client.h",
|
||||
"range_set.cc",
|
||||
@ -79,7 +85,10 @@ if (enable_pdf) {
|
||||
]
|
||||
}
|
||||
|
||||
defines = [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
|
||||
defines = [
|
||||
"PDF_IMPLEMENTATION",
|
||||
"PDFIUM_PRINT_TEXT_WITH_GDI",
|
||||
]
|
||||
if (pdf_enable_xfa) {
|
||||
defines += [ "PDF_ENABLE_XFA" ]
|
||||
}
|
||||
|
@ -15,18 +15,19 @@
|
||||
#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 DocumentLoader {
|
||||
class PDF_EXPORT DocumentLoader {
|
||||
public:
|
||||
// Number was chosen in crbug.com/78264#c8
|
||||
static constexpr uint32_t kDefaultRequestSize = 65536;
|
||||
|
||||
class Client {
|
||||
class PDF_EXPORT Client {
|
||||
public:
|
||||
virtual ~Client();
|
||||
|
||||
|
22
pdf/pdf.h
22
pdf/pdf.h
@ -5,6 +5,8 @@
|
||||
#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"
|
||||
|
||||
@ -30,10 +32,10 @@ class PDFModule : public pp::Module {
|
||||
pp::Instance* CreateInstance(PP_Instance instance) override;
|
||||
};
|
||||
|
||||
int PPP_InitializeModule(PP_Module module_id,
|
||||
PDF_EXPORT int PPP_InitializeModule(PP_Module module_id,
|
||||
PPB_GetInterface get_browser_interface);
|
||||
void PPP_ShutdownModule();
|
||||
const void* PPP_GetInterface(const char* interface_name);
|
||||
PDF_EXPORT void PPP_ShutdownModule();
|
||||
PDF_EXPORT const void* PPP_GetInterface(const char* interface_name);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Printing modes - type to convert PDF to for printing
|
||||
@ -71,7 +73,7 @@ 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.
|
||||
bool RenderPDFPageToDC(const void* pdf_buffer,
|
||||
PDF_EXPORT bool RenderPDFPageToDC(const void* pdf_buffer,
|
||||
int buffer_size,
|
||||
int page_number,
|
||||
HDC dc,
|
||||
@ -86,17 +88,17 @@ bool RenderPDFPageToDC(const void* pdf_buffer,
|
||||
bool center_in_bounds,
|
||||
bool autorotate);
|
||||
|
||||
void SetPDFEnsureTypefaceCharactersAccessible(
|
||||
PDF_EXPORT void SetPDFEnsureTypefaceCharactersAccessible(
|
||||
PDFEnsureTypefaceCharactersAccessible func);
|
||||
|
||||
void SetPDFUseGDIPrinting(bool enable);
|
||||
PDF_EXPORT void SetPDFUseGDIPrinting(bool enable);
|
||||
|
||||
void SetPDFUsePrintMode(int mode);
|
||||
PDF_EXPORT 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.
|
||||
bool GetPDFDocInfo(const void* pdf_buffer,
|
||||
PDF_EXPORT bool GetPDFDocInfo(const void* pdf_buffer,
|
||||
int buffer_size,
|
||||
int* page_count,
|
||||
double* max_page_width);
|
||||
@ -110,7 +112,7 @@ 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.
|
||||
bool GetPDFPageSizeByIndex(const void* pdf_buffer,
|
||||
PDF_EXPORT bool GetPDFPageSizeByIndex(const void* pdf_buffer,
|
||||
int pdf_buffer_size,
|
||||
int page_number,
|
||||
double* width,
|
||||
@ -128,7 +130,7 @@ 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.
|
||||
bool RenderPDFPageToBitmap(const void* pdf_buffer,
|
||||
PDF_EXPORT bool RenderPDFPageToBitmap(const void* pdf_buffer,
|
||||
int pdf_buffer_size,
|
||||
int page_number,
|
||||
void* bitmap_buffer,
|
||||
|
29
pdf/pdf_export.h
Normal file
29
pdf/pdf_export.h
Normal file
@ -0,0 +1,29 @@
|
||||
// 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_
|
@ -11,11 +11,12 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "pdf/pdf_export.h"
|
||||
#include "ui/gfx/range/range.h"
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
class RangeSet {
|
||||
class PDF_EXPORT RangeSet {
|
||||
public:
|
||||
RangeSet();
|
||||
explicit RangeSet(const gfx::Range& range);
|
||||
@ -71,7 +72,7 @@ class RangeSet {
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
PDF_EXPORT std::ostream& operator<<(std::ostream& os,
|
||||
const chrome_pdf::RangeSet& range_set);
|
||||
|
||||
#endif // PDF_RANGE_SET_H_
|
||||
|
Reference in New Issue
Block a user