From 1a64b9f0c29f12601d311186efecbc4c7d681cad Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Thu, 26 Apr 2018 08:23:27 -0700 Subject: [PATCH] Disable navigating on drag/drop (#12655) * Disable navigating on drag/drop * Add a WebPreferences option to re-enable navigate on drag/drop --- atom/browser/atom_browser_client.cc | 1 + atom/browser/web_contents_preferences.cc | 2 ++ docs/api/browser-window.md | 2 ++ 3 files changed, 5 insertions(+) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 0242edb7fc74..c1a23d86240f 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -211,6 +211,7 @@ void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host, prefs->webgl1_enabled = true; prefs->webgl2_enabled = true; prefs->allow_running_insecure_content = false; + prefs->navigate_on_drag_drop = false; // Custom preferences of guest page. auto* web_contents = content::WebContents::FromRenderViewHost(host); diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index cbaee6aaf7c0..27ea03430ba1 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -284,6 +284,8 @@ void WebContentsPreferences::OverrideWebkitPrefs( } if (dict_.GetBoolean("allowRunningInsecureContent", &b)) prefs->allow_running_insecure_content = b; + if (dict_.GetBoolean("navigateOnDragDrop", &b)) + prefs->navigate_on_drag_drop = b; const base::DictionaryValue* fonts = nullptr; if (dict_.GetDictionary("defaultFontFamily", &fonts)) { base::string16 font; diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 821c0ee2f883..35f4e4242c21 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -370,6 +370,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. consecutive dialog protection is triggered. If not defined the default message would be used, note that currently the default message is in English and not localized. + * `navigateOnDragDrop` Boolean (optional) - Whether dragging and dropping a + file or link onto the page causes a navigation. Default is `false`. When setting minimum or maximum window size with `minWidth`/`maxWidth`/ `minHeight`/`maxHeight`, it only constrains the users. It won't prevent you from