add-flag-to-disable-beforeunload.patch 918 B

12345678910111213141516171819202122
  1. # Add --disable-beforeunload to always disable beforeunload JavaScript dialogs
  2. --- a/components/app_modal/javascript_dialog_manager.cc
  3. +++ b/components/app_modal/javascript_dialog_manager.cc
  4. @@ -8,6 +8,7 @@
  5. #include <utility>
  6. #include "base/bind.h"
  7. +#include "base/command_line.h"
  8. #include "base/i18n/rtl.h"
  9. #include "base/macros.h"
  10. #include "base/metrics/histogram_macros.h"
  11. @@ -201,7 +202,8 @@ void JavaScriptDialogManager::RunBeforeU
  12. ChromeJavaScriptDialogExtraData* extra_data =
  13. &javascript_dialog_extra_data_[web_contents];
  14. - if (extra_data->suppress_javascript_messages_) {
  15. + if (extra_data->suppress_javascript_messages_
  16. + || base::CommandLine::ForCurrentProcess()->HasSwitch("disable-beforeunload")) {
  17. // If a site harassed the user enough for them to put it on mute, then it
  18. // lost its privilege to deny unloading.
  19. std::move(callback).Run(true, base::string16());