Trigger LoadUrl() from PdfViewWebPlugin
Calls LoadUrl() from PdfViewWebPlugin with the URL from the "stream-url" attribute. Combined with crrev.com/c/2330933 (WIP), this is sufficient to start testing URL loading locally. Logs NOTIMPLEMENTED() from PdfViewWebPlugin's DocumentLoadComplete() and DocumentLoadFailed(), to make the outcome of loading obvious. Bug: 1099022 Change-Id: I94084fe42151daf5e4084749eb6ba466e2a918df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411329 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Daniel Hosseinian <dhoss@chromium.org> Commit-Queue: K. Moon <kmoon@chromium.org> Cr-Commit-Position: refs/heads/master@{#806799}
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/check_op.h"
|
||||
@ -18,12 +19,15 @@
|
||||
#include "cc/paint/paint_canvas.h"
|
||||
#include "pdf/pdf_engine.h"
|
||||
#include "pdf/pdf_init.h"
|
||||
#include "pdf/pdfium/pdfium_engine.h"
|
||||
#include "pdf/ppapi_migration/url_loader.h"
|
||||
#include "ppapi/c/pp_errors.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_string.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_associated_url_loader.h"
|
||||
@ -85,16 +89,28 @@ class PerProcessInitializer final {
|
||||
|
||||
} // namespace
|
||||
|
||||
PdfViewWebPlugin::PdfViewWebPlugin(const blink::WebPluginParams& params) {}
|
||||
PdfViewWebPlugin::PdfViewWebPlugin(const blink::WebPluginParams& params)
|
||||
: initial_params_(params) {}
|
||||
|
||||
PdfViewWebPlugin::~PdfViewWebPlugin() = default;
|
||||
|
||||
// Modeled on `OutOfProcessInstance::Init()`.
|
||||
bool PdfViewWebPlugin::Initialize(blink::WebPluginContainer* container) {
|
||||
DCHECK_EQ(container->Plugin(), this);
|
||||
container_ = container;
|
||||
|
||||
std::string stream_url;
|
||||
for (size_t i = 0; i < initial_params_.attribute_names.size(); ++i) {
|
||||
if (initial_params_.attribute_names[i] == "stream-url")
|
||||
stream_url = initial_params_.attribute_values[i].Utf8();
|
||||
}
|
||||
|
||||
// Contents of `initial_params_` no longer needed.
|
||||
initial_params_ = {};
|
||||
|
||||
PerProcessInitializer::GetInstance().Acquire();
|
||||
InitializeEngine(/*enable_javascript=*/false);
|
||||
LoadUrl(stream_url, /*is_print_preview=*/false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -225,9 +241,13 @@ PdfViewWebPlugin::SearchString(const base::char16* string,
|
||||
}
|
||||
|
||||
void PdfViewWebPlugin::DocumentLoadComplete(
|
||||
const PDFEngine::DocumentFeatures& document_features) {}
|
||||
const PDFEngine::DocumentFeatures& document_features) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void PdfViewWebPlugin::DocumentLoadFailed() {}
|
||||
void PdfViewWebPlugin::DocumentLoadFailed() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
pp::Instance* PdfViewWebPlugin::GetPluginInstance() {
|
||||
return nullptr;
|
||||
@ -287,9 +307,15 @@ std::unique_ptr<UrlLoader> PdfViewWebPlugin::CreateUrlLoaderInternal() {
|
||||
return loader;
|
||||
}
|
||||
|
||||
// Modeled on `OutOfProcessInstance::DidOpen()`.
|
||||
void PdfViewWebPlugin::DidOpen(std::unique_ptr<UrlLoader> loader,
|
||||
int32_t result) {
|
||||
NOTIMPLEMENTED();
|
||||
if (result == PP_OK) {
|
||||
if (!engine()->HandleDocumentLoad(std::move(loader)))
|
||||
DocumentLoadFailed();
|
||||
} else {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
||||
void PdfViewWebPlugin::DidOpenPreview(std::unique_ptr<UrlLoader> loader,
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include "pdf/pdf_view_plugin_base.h"
|
||||
#include "pdf/ppapi_migration/url_loader.h"
|
||||
#include "third_party/blink/public/web/web_plugin.h"
|
||||
#include "third_party/blink/public/web/web_plugin_params.h"
|
||||
|
||||
namespace blink {
|
||||
class WebPluginContainer;
|
||||
struct WebPluginParams;
|
||||
} // namespace blink
|
||||
|
||||
namespace chrome_pdf {
|
||||
@ -117,6 +117,7 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
|
||||
// Call `Destroy()` instead.
|
||||
~PdfViewWebPlugin() override;
|
||||
|
||||
blink::WebPluginParams initial_params_;
|
||||
blink::WebPluginContainer* container_ = nullptr;
|
||||
|
||||
base::WeakPtrFactory<PdfViewWebPlugin> weak_factory_{this};
|
||||
|
Reference in New Issue
Block a user