0

[unseasoned-pdf] Respect JavaScript content settings

Parse the plugin params to identify whether scripting should be allowed
for the PDF. Pass the scripting option to PDFiumEngine.

Bug: 1111024
Change-Id: I1ade638f6ff35903d444e2472723eed3cad2f8b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3003691
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#900606}
This commit is contained in:
Daniel Hosseinian
2021-07-12 20:03:37 +00:00
committed by Chromium LUCI CQ
parent 1702f8676a
commit 1bae6fc5af
3 changed files with 10 additions and 4 deletions

@ -7,6 +7,7 @@
#include <string>
#include "base/strings/string_number_conversions.h"
#include "pdf/pdfium/pdfium_form_filler.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_plugin_params.h"
@ -35,6 +36,9 @@ absl::optional<ParsedParams> ParseWebPluginParams(
return absl::nullopt;
}
result.background_color = background_color;
} else if (params.attribute_names[i] == "javascript") {
if (params.attribute_values[i] != "allow")
result.script_option = PDFiumFormFiller::ScriptOption::kNoJavaScript;
}
}

@ -7,6 +7,7 @@
#include <string>
#include "pdf/pdfium/pdfium_form_filler.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkColor.h"
@ -32,6 +33,10 @@ struct ParsedParams {
// Whether the plugin should occupy the entire frame.
bool full_frame = false;
// Whether to execute JavaScript and maybe XFA.
PDFiumFormFiller::ScriptOption script_option =
PDFiumFormFiller::DefaultScriptOption();
};
// Creates an `ParsedParams` by parsing a `blink::WebPluginParams`. If

@ -34,7 +34,6 @@
#include "pdf/pdf_engine.h"
#include "pdf/pdf_init.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/pdfium/pdfium_form_filler.h"
#include "pdf/post_message_receiver.h"
#include "pdf/ppapi_migration/bitmap.h"
#include "pdf/ppapi_migration/graphics.h"
@ -263,9 +262,7 @@ bool PdfViewWebPlugin::InitializeCommon(
PerProcessInitializer::GetInstance().Acquire();
// TODO(crbug.com/1111024): Respect JavaScript content settings.
InitializeEngine(std::make_unique<PDFiumEngine>(
this, PDFiumFormFiller::DefaultScriptOption()));
InitializeEngine(std::make_unique<PDFiumEngine>(this, params->script_option));
LoadUrl(params->src_url, /*is_print_preview=*/false);
set_url(params->original_url);
post_message_sender_.set_container(Container());