1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# Add --disable-beforeunload to always disable beforeunload JavaScript dialogs
--- a/chrome/browser/ungoogled_flag_entries.h
+++ b/chrome/browser/ungoogled_flag_entries.h
@@ -16,4 +16,8 @@
"Disable search engine collection",
"Prevents search engines from being added automatically. ungoogled-chromium flag.",
kOsAll, SINGLE_VALUE_TYPE("disable-search-engine-collection")},
+ {"disable-beforeunload",
+ "Disable beforeunload",
+ "Disables JavaScript dialog boxes triggered by beforeunload. ungoogled-chromium flag.",
+ kOsAll, SINGLE_VALUE_TYPE("disable-beforeunload")},
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
--- a/components/javascript_dialogs/app_modal_dialog_manager.cc
+++ b/components/javascript_dialogs/app_modal_dialog_manager.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
@@ -195,7 +196,8 @@ void AppModalDialogManager::RunBeforeUnl
ChromeJavaScriptDialogExtraData* extra_data =
&javascript_dialog_extra_data_[web_contents];
- if (extra_data->suppress_javascript_messages_) {
+ if (extra_data->suppress_javascript_messages_
+ || base::CommandLine::ForCurrentProcess()->HasSwitch("disable-beforeunload")) {
// If a site harassed the user enough for them to put it on mute, then it
// lost its privilege to deny unloading.
std::move(callback).Run(true, std::u16string());
|