0

Add skeletal PdfViewWebPlugin

Creates a skeletal blink::WebPlugin counterpart to the Pepper-based
OutOfProcessInstance. This will support migrating the PDF viewer from a
Pepper plugin to a plain Blink plugin.

Note that the ultimate intent is _not_ to run the PDF viewer as a plain
Blink plugin, without other changes to isolate it. This is just a
starting point for the final implementation.

Bug: 1085334
Change-Id: I6bea3ddd7fc1b27879af5cd5614071cb02491d77
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2328030
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: vmpstr <vmpstr@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795565}
This commit is contained in:
K. Moon
2020-08-06 18:51:39 +00:00
committed by Commit Bot
parent 2db086556c
commit c2361af351
4 changed files with 150 additions and 0 deletions

@ -46,6 +46,7 @@ if (enable_pdf) {
":internal",
":out_of_process_instance",
":pdf",
":pdf_view_web_plugin",
"//base",
"//ppapi/cpp:objects",
"//ppapi/cpp/private:internal_module",
@ -230,6 +231,25 @@ if (enable_pdf) {
]
}
# Eventual replacement for out_of_process_instance.
source_set("pdf_view_web_plugin") {
visibility = [ ":*" ]
sources = [
"pdf_view_web_plugin.cc",
"pdf_view_web_plugin.h",
]
configs += [ ":pdf_common_config" ]
deps = [
"//base",
"//cc/paint",
"//third_party/blink/public:blink_headers",
"//ui/base/cursor:cursor_base",
]
}
source_set("pdf_test_utils") {
visibility = [ ":*" ]

@ -1,8 +1,11 @@
include_rules = [
"+cc/paint",
"+net",
"+ppapi",
"+printing/units.h",
"+third_party/blink/public",
"+third_party/skia/include/core",
"+ui/base/cursor/cursor.h",
"+ui/base/window_open_disposition.h",
"+ui/events/keycodes/keyboard_codes.h",
"+ui/gfx/geometry",

@ -0,0 +1,74 @@
// Copyright 2020 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_view_web_plugin.h"
#include <stddef.h>
#include "base/check_op.h"
#include "cc/paint/paint_canvas.h"
#include "third_party/blink/public/common/input/web_coalesced_input_event.h"
#include "third_party/blink/public/common/metrics/document_update_reason.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-shared.h"
#include "third_party/blink/public/platform/web_input_event_result.h"
#include "third_party/blink/public/platform/web_rect.h"
#include "third_party/blink/public/platform/web_url_error.h"
#include "third_party/blink/public/platform/web_url_response.h"
#include "third_party/blink/public/web/web_plugin_container.h"
#include "third_party/blink/public/web/web_plugin_params.h"
#include "ui/base/cursor/cursor.h"
namespace chrome_pdf {
PdfViewWebPlugin::PdfViewWebPlugin(const blink::WebPluginParams& params) {}
PdfViewWebPlugin::~PdfViewWebPlugin() = default;
bool PdfViewWebPlugin::Initialize(blink::WebPluginContainer* container) {
DCHECK_EQ(container->Plugin(), this);
container_ = container;
return true;
}
void PdfViewWebPlugin::Destroy() {
container_ = nullptr;
delete this;
}
blink::WebPluginContainer* PdfViewWebPlugin::Container() const {
return container_;
}
void PdfViewWebPlugin::UpdateAllLifecyclePhases(
blink::DocumentUpdateReason reason) {}
void PdfViewWebPlugin::Paint(cc::PaintCanvas* canvas,
const blink::WebRect& rect) {}
void PdfViewWebPlugin::UpdateGeometry(const blink::WebRect& window_rect,
const blink::WebRect& clip_rect,
const blink::WebRect& unobscured_rect,
bool is_visible) {}
void PdfViewWebPlugin::UpdateFocus(bool focused,
blink::mojom::FocusType focus_type) {}
void PdfViewWebPlugin::UpdateVisibility(bool visibility) {}
blink::WebInputEventResult PdfViewWebPlugin::HandleInputEvent(
const blink::WebCoalescedInputEvent& event,
ui::Cursor* cursor) {
return blink::WebInputEventResult::kNotHandled;
}
void PdfViewWebPlugin::DidReceiveResponse(
const blink::WebURLResponse& response) {}
void PdfViewWebPlugin::DidReceiveData(const char* data, size_t data_length) {}
void PdfViewWebPlugin::DidFinishLoading() {}
void PdfViewWebPlugin::DidFailLoading(const blink::WebURLError& error) {}
} // namespace chrome_pdf

53
pdf/pdf_view_web_plugin.h Normal file

@ -0,0 +1,53 @@
// Copyright 2020 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_VIEW_WEB_PLUGIN_H_
#define PDF_PDF_VIEW_WEB_PLUGIN_H_
#include "third_party/blink/public/web/web_plugin.h"
namespace blink {
class WebPluginContainer;
struct WebPluginParams;
} // namespace blink
namespace chrome_pdf {
// Skeleton for a `blink::WebPlugin` to replace `OutOfProcessInstance`.
class PdfViewWebPlugin final : public blink::WebPlugin {
public:
explicit PdfViewWebPlugin(const blink::WebPluginParams& params);
PdfViewWebPlugin(const PdfViewWebPlugin& other) = delete;
PdfViewWebPlugin& operator=(const PdfViewWebPlugin& other) = delete;
// blink::WebPlugin:
bool Initialize(blink::WebPluginContainer* container) override;
void Destroy() override;
blink::WebPluginContainer* Container() const override;
void UpdateAllLifecyclePhases(blink::DocumentUpdateReason reason) override;
void Paint(cc::PaintCanvas* canvas, const blink::WebRect& rect) override;
void UpdateGeometry(const blink::WebRect& window_rect,
const blink::WebRect& clip_rect,
const blink::WebRect& unobscured_rect,
bool is_visible) override;
void UpdateFocus(bool focused, blink::mojom::FocusType focus_type) override;
void UpdateVisibility(bool visibility) override;
blink::WebInputEventResult HandleInputEvent(
const blink::WebCoalescedInputEvent& event,
ui::Cursor* cursor) override;
void DidReceiveResponse(const blink::WebURLResponse& response) override;
void DidReceiveData(const char* data, size_t data_length) override;
void DidFinishLoading() override;
void DidFailLoading(const blink::WebURLError& error) override;
private:
// Call `Destroy()` instead.
~PdfViewWebPlugin() override;
blink::WebPluginContainer* container_ = nullptr;
};
} // namespace chrome_pdf
#endif // PDF_PDF_VIEW_WEB_PLUGIN_H_