Commit caa38ca9 authored by K. Moon's avatar K. Moon Committed by Commit Bot

Create PDFiumEngine directly

We no longer support PDFEngine implementations other than PDFiumEngine,
so there's no need for a PDFEngine::Create() factory that abstracts
which PDFEngine implementation is created.

This also allows OutOfProcessInstance to use PDFiumEngine directly,
rather than having to add methods to PDFEngine first.

Bug: 1076554
Change-Id: I8808038ff5ed0db58719905c2aa8157fbd4bb092
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340280Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795654}
parent 58dd2d10
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "pdf/document_layout.h" #include "pdf/document_layout.h"
#include "pdf/document_metadata.h" #include "pdf/document_metadata.h"
#include "pdf/pdf_features.h" #include "pdf/pdf_features.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/ppapi_migration/bitmap.h" #include "pdf/ppapi_migration/bitmap.h"
#include "pdf/ppapi_migration/geometry_conversions.h" #include "pdf/ppapi_migration/geometry_conversions.h"
#include "pdf/ppapi_migration/graphics.h" #include "pdf/ppapi_migration/graphics.h"
...@@ -546,7 +547,7 @@ bool OutOfProcessInstance::Init(uint32_t argc, ...@@ -546,7 +547,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
if (!stream_url) if (!stream_url)
stream_url = original_url; stream_url = original_url;
engine_ = PDFEngine::Create(this, enable_javascript); engine_ = std::make_unique<PDFiumEngine>(this, enable_javascript);
// If we're in print preview mode we don't need to load the document yet. // If we're in print preview mode we don't need to load the document yet.
// A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting // A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting
...@@ -1077,7 +1078,9 @@ void OutOfProcessInstance::DidOpen(int32_t result) { ...@@ -1077,7 +1078,9 @@ void OutOfProcessInstance::DidOpen(int32_t result) {
void OutOfProcessInstance::DidOpenPreview(int32_t result) { void OutOfProcessInstance::DidOpenPreview(int32_t result) {
if (result == PP_OK) { if (result == PP_OK) {
preview_client_ = std::make_unique<PreviewModeClient>(this); preview_client_ = std::make_unique<PreviewModeClient>(this);
preview_engine_ = PDFEngine::Create(preview_client_.get(), false); preview_engine_ =
std::make_unique<PDFiumEngine>(preview_client_.get(),
/*enable_javascript=*/false);
preview_engine_->HandleDocumentLoad(embed_preview_loader_); preview_engine_->HandleDocumentLoad(embed_preview_loader_);
} else { } else {
NOTREACHED(); NOTREACHED();
...@@ -1680,7 +1683,7 @@ void OutOfProcessInstance::HandleResetPrintPreviewModeMessage( ...@@ -1680,7 +1683,7 @@ void OutOfProcessInstance::HandleResetPrintPreviewModeMessage(
document_load_state_ = LOAD_STATE_LOADING; document_load_state_ = LOAD_STATE_LOADING;
LoadUrl(url_, /*is_print_preview=*/false); LoadUrl(url_, /*is_print_preview=*/false);
preview_engine_.reset(); preview_engine_.reset();
engine_ = PDFEngine::Create(this, false); engine_ = std::make_unique<PDFiumEngine>(this, /*enable_javascript=*/false);
engine_->SetGrayscale(dict.Get(pp::Var(kJSPrintPreviewGrayscale)).AsBool()); engine_->SetGrayscale(dict.Get(pp::Var(kJSPrintPreviewGrayscale)).AsBool());
engine_->New(url_.c_str(), /*headers=*/nullptr); engine_->New(url_.c_str(), /*headers=*/nullptr);
......
...@@ -44,6 +44,7 @@ namespace chrome_pdf { ...@@ -44,6 +44,7 @@ namespace chrome_pdf {
class Graphics; class Graphics;
class PaintReadyRect; class PaintReadyRect;
class PDFiumEngine;
class OutOfProcessInstance : public pp::Instance, class OutOfProcessInstance : public pp::Instance,
public pp::Find_Private, public pp::Find_Private,
...@@ -407,7 +408,7 @@ class OutOfProcessInstance : public pp::Instance, ...@@ -407,7 +408,7 @@ class OutOfProcessInstance : public pp::Instance,
PrintSettings print_settings_; PrintSettings print_settings_;
std::unique_ptr<PDFEngine> engine_; std::unique_ptr<PDFiumEngine> engine_;
// The PreviewModeClient used for print preview. Will be passed to // The PreviewModeClient used for print preview. Will be passed to
// |preview_engine_|. // |preview_engine_|.
...@@ -416,7 +417,7 @@ class OutOfProcessInstance : public pp::Instance, ...@@ -416,7 +417,7 @@ class OutOfProcessInstance : public pp::Instance,
// This engine is used to render the individual preview page data. This is // This engine is used to render the individual preview page data. This is
// used only in print preview mode. This will use |PreviewModeClient| // used only in print preview mode. This will use |PreviewModeClient|
// interface which has very limited access to the pp::Instance. // interface which has very limited access to the pp::Instance.
std::unique_ptr<PDFEngine> preview_engine_; std::unique_ptr<PDFiumEngine> preview_engine_;
std::string url_; std::string url_;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <stdint.h> #include <stdint.h>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -319,10 +318,6 @@ class PDFEngine { ...@@ -319,10 +318,6 @@ class PDFEngine {
pp::FloatRect bounds; pp::FloatRect bounds;
}; };
// Factory method to create an instance of the PDF Engine.
static std::unique_ptr<PDFEngine> Create(Client* client,
bool enable_javascript);
virtual ~PDFEngine() {} virtual ~PDFEngine() {}
// Most of these functions are similar to the Pepper functions of the same // Most of these functions are similar to the Pepper functions of the same
......
...@@ -436,11 +436,6 @@ PDFEngine::AccessibilityTextFieldInfo::AccessibilityTextFieldInfo( ...@@ -436,11 +436,6 @@ PDFEngine::AccessibilityTextFieldInfo::AccessibilityTextFieldInfo(
PDFEngine::AccessibilityTextFieldInfo::~AccessibilityTextFieldInfo() = default; PDFEngine::AccessibilityTextFieldInfo::~AccessibilityTextFieldInfo() = default;
std::unique_ptr<PDFEngine> PDFEngine::Create(PDFEngine::Client* client,
bool enable_javascript) {
return std::make_unique<PDFiumEngine>(client, enable_javascript);
}
PDFiumEngine::PDFiumEngine(PDFEngine::Client* client, bool enable_javascript) PDFiumEngine::PDFiumEngine(PDFEngine::Client* client, bool enable_javascript)
: client_(client), : client_(client),
form_filler_(this, enable_javascript), form_filler_(this, enable_javascript),
......
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