[unseasoned-pdf] Initialize plugin's URL for PdfViewWebPlugin.
Initialize PdfViewWebPlugin's URL during initialization process, which should be similar to its Pepper equivalent OutOfProcessInstance::Init(). The URL value will be needed for implementing file saving. Bug: 1213294 Change-Id: I0b3b4370c4a10ebc9868ab0df21ca44bd85e69e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2921943 Commit-Queue: Hui Yingst <nigi@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#890035}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5b00b4b5c3
commit
eb6c245411
@ -183,9 +183,15 @@ bool PdfViewWebPlugin::InitializeCommon(
|
||||
std::unique_ptr<ContainerWrapper> container_wrapper) {
|
||||
container_wrapper_ = std::move(container_wrapper);
|
||||
|
||||
std::string original_url;
|
||||
std::string stream_url;
|
||||
// TODO(https://crbug.com/1199558): Make a helper method to parse
|
||||
// `initial_params_` without processing the results, and add a unit test for
|
||||
// it.
|
||||
for (size_t i = 0; i < initial_params_.attribute_names.size(); ++i) {
|
||||
if (initial_params_.attribute_names[i] == "stream-url") {
|
||||
if (initial_params_.attribute_names[i] == "src") {
|
||||
original_url = initial_params_.attribute_values[i].Utf8();
|
||||
} else if (initial_params_.attribute_names[i] == "stream-url") {
|
||||
stream_url = initial_params_.attribute_values[i].Utf8();
|
||||
} else if (initial_params_.attribute_names[i] == "full-frame") {
|
||||
set_full_frame(true);
|
||||
@ -202,9 +208,16 @@ bool PdfViewWebPlugin::InitializeCommon(
|
||||
// Contents of `initial_params_` no longer needed.
|
||||
initial_params_ = {};
|
||||
|
||||
if (original_url.empty())
|
||||
return false;
|
||||
|
||||
if (stream_url.empty())
|
||||
stream_url = original_url;
|
||||
|
||||
PerProcessInitializer::GetInstance().Acquire();
|
||||
InitializeEngine(PDFiumFormFiller::ScriptOption::kNoJavaScript);
|
||||
LoadUrl(stream_url, /*is_print_preview=*/false);
|
||||
set_url(original_url);
|
||||
post_message_sender_.set_container(Container());
|
||||
return true;
|
||||
}
|
||||
|
@ -151,8 +151,13 @@ class PdfViewWebPluginTest : public testing::Test {
|
||||
~PdfViewWebPluginTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
// Set a dummy URL for initializing the plugin.
|
||||
blink::WebPluginParams params;
|
||||
params.attribute_names.push_back(blink::WebString("src"));
|
||||
params.attribute_values.push_back(blink::WebString("dummy.pdf"));
|
||||
|
||||
plugin_ = std::unique_ptr<PdfViewWebPlugin, PluginDeleter>(
|
||||
new PdfViewWebPlugin(blink::WebPluginParams()));
|
||||
new PdfViewWebPlugin(params));
|
||||
|
||||
auto wrapper = std::make_unique<FakeContainerWrapper>(plugin_.get());
|
||||
wrapper_ptr_ = wrapper.get();
|
||||
|
Reference in New Issue
Block a user