Commit 38715a15 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Support window.print() in iframes.

window.print() will work in iframes only if the user is interacting with
the page. This will prevent abusive experience from malicious iframes.

This CL does not have tests, because there is no infrastructure for
testing PrintTabHelper, AddScriptCommandCallback and iframes.

Bug: 881876
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Ia741e74accf69b6cee63351e04851e3068e8c3e5
Reviewed-on: https://chromium-review.googlesource.com/1213270Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589632}
parent 4cf9ed4d
......@@ -56,8 +56,9 @@ bool PrintTabHelper::OnPrintCommand(web::WebState* web_state,
const GURL& page_url,
bool interacting,
bool is_main_frame) {
if (!is_main_frame) {
// Print is only supported on main frame.
if (!is_main_frame && !interacting) {
// Ignore non user-initiated window.print() calls from iframes, to prevent
// abusive behavior from web sites.
return false;
}
DCHECK(web_state);
......
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