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 @@
#include "pdf/document_layout.h"
#include "pdf/document_metadata.h"
#include "pdf/pdf_features.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/ppapi_migration/bitmap.h"
#include "pdf/ppapi_migration/geometry_conversions.h"
#include "pdf/ppapi_migration/graphics.h"
......@@ -546,7 +547,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
if (!stream_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.
// A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting
......@@ -1077,7 +1078,9 @@ void OutOfProcessInstance::DidOpen(int32_t result) {
void OutOfProcessInstance::DidOpenPreview(int32_t result) {
if (result == PP_OK) {
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_);
} else {
NOTREACHED();
......@@ -1680,7 +1683,7 @@ void OutOfProcessInstance::HandleResetPrintPreviewModeMessage(
document_load_state_ = LOAD_STATE_LOADING;
LoadUrl(url_, /*is_print_preview=*/false);
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_->New(url_.c_str(), /*headers=*/nullptr);
......
......@@ -44,6 +44,7 @@ namespace chrome_pdf {
class Graphics;
class PaintReadyRect;
class PDFiumEngine;
class OutOfProcessInstance : public pp::Instance,
public pp::Find_Private,
......@@ -407,7 +408,7 @@ class OutOfProcessInstance : public pp::Instance,
PrintSettings print_settings_;
std::unique_ptr<PDFEngine> engine_;
std::unique_ptr<PDFiumEngine> engine_;
// The PreviewModeClient used for print preview. Will be passed to
// |preview_engine_|.
......@@ -416,7 +417,7 @@ class OutOfProcessInstance : public pp::Instance,
// This engine is used to render the individual preview page data. This is
// used only in print preview mode. This will use |PreviewModeClient|
// 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_;
......
......@@ -7,7 +7,6 @@
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
......@@ -319,10 +318,6 @@ class PDFEngine {
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() {}
// Most of these functions are similar to the Pepper functions of the same
......
......@@ -436,11 +436,6 @@ PDFEngine::AccessibilityTextFieldInfo::AccessibilityTextFieldInfo(
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)
: client_(client),
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