Commit 48927999 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Honor JavaScript content settings in the PDF extension

Use a feature flag to allow for runtime switching between the existing
and new behaviors.

When |chrome_pdf::features::kPdfHonorJsContentSettings| is disabled,
JavaScript will be allowed to execute regardless of the content
settings.

Bug: 696650
Change-Id: Ifc45058e8dffd579952added95ac0c4630cbf350
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2202973
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773491}
parent 3383cf1b
...@@ -910,10 +910,7 @@ class PDFExtensionContentSettingJSTest ...@@ -910,10 +910,7 @@ class PDFExtensionContentSettingJSTest
} }
std::string GetDisabledJsTestFile() const { std::string GetDisabledJsTestFile() const {
// TODO(crbug.com/696650): Run nobeep_test.js when return ShouldHonorJsContentSettings() ? "nobeep_test.js" : "beep_test.js";
// |honor_js_content_settings_| once JS content settings get respected in
// the PDF extension.
return "beep_test.js";
} }
private: private:
......
...@@ -484,7 +484,7 @@ bool OutOfProcessInstance::Init(uint32_t argc, ...@@ -484,7 +484,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
text_input_ = std::make_unique<pp::TextInput_Dev>(this); text_input_ = std::make_unique<pp::TextInput_Dev>(this);
bool enable_javascript = false; bool enable_javascript = true;
const char* stream_url = nullptr; const char* stream_url = nullptr;
const char* original_url = nullptr; const char* original_url = nullptr;
const char* top_level_url = nullptr; const char* top_level_url = nullptr;
...@@ -505,6 +505,7 @@ bool OutOfProcessInstance::Init(uint32_t argc, ...@@ -505,6 +505,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
success = success =
base::StringToInt(argv[i], &top_toolbar_height_in_viewport_coords_); base::StringToInt(argv[i], &top_toolbar_height_in_viewport_coords_);
} else if (strcmp(argn[i], "javascript") == 0) { } else if (strcmp(argn[i], "javascript") == 0) {
if (base::FeatureList::IsEnabled(features::kPdfHonorJsContentSettings))
enable_javascript = (strcmp(argv[i], "allow") == 0); enable_javascript = (strcmp(argv[i], "allow") == 0);
} }
if (!success) if (!success)
...@@ -518,8 +519,7 @@ bool OutOfProcessInstance::Init(uint32_t argc, ...@@ -518,8 +519,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
stream_url = original_url; stream_url = original_url;
if (!engine_) { if (!engine_) {
// TODO(tsepez): fix lifetime issue, conditionalize javascript. engine_ = PDFEngine::Create(this, enable_javascript);
engine_ = PDFEngine::Create(this, true);
} }
// If we're in print preview mode we don't need to load the document yet. // If we're in print preview mode we don't need to load the document yet.
......
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