feat: add disableDialogs option to WebPreferences (#22395)
Allows to disable dialogs completely in a similar way of how safeDialogs option can be used. Overrides safeDialogs option.
This commit is contained in:
parent
282a44e747
commit
d731a676f5
2 changed files with 8 additions and 1 deletions
|
@ -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
|
consecutive dialog protection is triggered. If not defined the default
|
||||||
message would be used, note that currently the default message is in
|
message would be used, note that currently the default message is in
|
||||||
English and not localized.
|
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
|
* `navigateOnDragDrop` Boolean (optional) - Whether dragging and dropping a
|
||||||
file or link onto the page causes a navigation. Default is `false`.
|
file or link onto the page causes a navigation. Default is `false`.
|
||||||
* `autoplayPolicy` String (optional) - Autoplay policy to apply to
|
* `autoplayPolicy` String (optional) - Autoplay policy to apply to
|
||||||
|
|
|
@ -61,6 +61,12 @@ void ElectronJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
return;
|
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
|
// No default button
|
||||||
int default_id = -1;
|
int default_id = -1;
|
||||||
int cancel_id = 0;
|
int cancel_id = 0;
|
||||||
|
@ -75,7 +81,6 @@ void ElectronJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
|
|
||||||
origin_counts_[origin]++;
|
origin_counts_[origin]++;
|
||||||
|
|
||||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
|
||||||
std::string checkbox;
|
std::string checkbox;
|
||||||
if (origin_counts_[origin] > 1 && web_preferences &&
|
if (origin_counts_[origin] > 1 && web_preferences &&
|
||||||
web_preferences->IsEnabled("safeDialogs") &&
|
web_preferences->IsEnabled("safeDialogs") &&
|
||||||
|
|
Loading…
Reference in a new issue