8000 feat: add disableDialogs option to WebPreferences by ChALkeR · Pull Request #22664 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add disableDialogs option to WebPreferences #226 8000 64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000 2 changes: 2 additions & 0 deletions docs/api/browser-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,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.
* `disableDialogs` Boolean (optional) - Whether to disable dialogs
completely. Overrides `safeDialogs`. Default is `false`.
* `navigateOnDragDrop` Boolean (optional) - Whether dragging and dropping a
file or link onto the page causes a navigation. Default is `false`.
* `autoplayPolicy` String (optional) - Autoplay policy to apply to
Expand Down
7 changes: 6 additions & 1 deletion shell/browser/electron_javascript_dialog_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ void ElectronJavaScriptDialogManager::RunJavaScriptDialog(
return;
}

auto* web_preferences = WebContentsPreferences::From(web_contents);

if (web_preferences && web_preferences->IsEnabled("disableDialogs")) {
return std::move(callback).Run(false, base::string16());
}

// No default button
int default_id = -1;
int cancel_id = 0;
Expand All @@ -75,7 +81,6 @@ void ElectronJavaScriptDialogManager::RunJavaScriptDialog(

origin_counts_[origin]++;

auto* web_preferences = WebContentsPreferences::From(web_contents);
std::string checkbox;
if (origin_counts_[origin] > 1 && web_preferences &&
web_preferences->IsEnabled("safeDialogs") &&
Expand Down
0