From a0dbae72c8b2d192835e01798dd4241e67a5f44f Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Thu, 8 Sep 2022 15:49:33 -0700 Subject: [PATCH] chore: remove UnresponsiveSuppressor altogether (#35507) * chore: drop unresponsive suppressor for menu_mac * also for views * header * chore: remove UnresponsiveSuppressor altogether --- filenames.gni | 2 -- .../api/electron_api_browser_window.cc | 4 +-- shell/browser/ui/file_dialog_gtk.cc | 2 -- shell/browser/ui/file_dialog_win.cc | 2 -- shell/browser/ui/message_box_gtk.cc | 3 --- shell/browser/ui/message_box_win.cc | 3 --- shell/browser/unresponsive_suppressor.cc | 27 ------------------- shell/browser/unresponsive_suppressor.h | 24 ----------------- 8 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 shell/browser/unresponsive_suppressor.cc delete mode 100644 shell/browser/unresponsive_suppressor.h diff --git a/filenames.gni b/filenames.gni index b8b9cd8eeae4..4a570da2c30d 100644 --- a/filenames.gni +++ b/filenames.gni @@ -507,8 +507,6 @@ filenames = { "shell/browser/ui/tray_icon_observer.h", "shell/browser/ui/webui/accessibility_ui.cc", "shell/browser/ui/webui/accessibility_ui.h", - "shell/browser/unresponsive_suppressor.cc", - "shell/browser/unresponsive_suppressor.h", "shell/browser/web_contents_permission_helper.cc", "shell/browser/web_contents_permission_helper.h", "shell/browser/web_contents_preferences.cc", diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index 9e28602c92d1..5b5adb540aa6 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -14,7 +14,6 @@ #include "shell/browser/api/electron_api_web_contents_view.h" #include "shell/browser/browser.h" #include "shell/browser/native_browser_view.h" -#include "shell/browser/unresponsive_suppressor.h" #include "shell/browser/web_contents_preferences.h" #include "shell/browser/window_list.h" #include "shell/common/color_util.h" @@ -506,8 +505,7 @@ void BrowserWindow::ScheduleUnresponsiveEvent(int ms) { void BrowserWindow::NotifyWindowUnresponsive() { window_unresponsive_closure_.Cancel(); - if (!window_->IsClosed() && window_->IsEnabled() && - !IsUnresponsiveEventSuppressed()) { + if (!window_->IsClosed() && window_->IsEnabled()) { Emit("unresponsive"); } } diff --git a/shell/browser/ui/file_dialog_gtk.cc b/shell/browser/ui/file_dialog_gtk.cc index 99f0e1524c36..7b0d9a3ba119 100644 --- a/shell/browser/ui/file_dialog_gtk.cc +++ b/shell/browser/ui/file_dialog_gtk.cc @@ -14,7 +14,6 @@ #include "shell/browser/native_window_views.h" #include "shell/browser/ui/file_dialog.h" #include "shell/browser/ui/gtk_util.h" -#include "shell/browser/unresponsive_suppressor.h" #include "shell/common/gin_converters/file_path_converter.h" #include "ui/base/glib/glib_signal.h" #include "ui/gtk/gtk_ui.h" // nogncheck @@ -222,7 +221,6 @@ class FileChooserDialog { void AddFilters(const Filters& filters); electron::NativeWindowViews* parent_; - electron::UnresponsiveSuppressor unresponsive_suppressor_; GtkFileChooser* dialog_; GtkWidget* preview_; diff --git a/shell/browser/ui/file_dialog_win.cc b/shell/browser/ui/file_dialog_win.cc index 7cd094d2d669..7000e33fb4c4 100644 --- a/shell/browser/ui/file_dialog_win.cc +++ b/shell/browser/ui/file_dialog_win.cc @@ -22,7 +22,6 @@ #include "base/win/registry.h" #include "shell/browser/native_window_views.h" #include "shell/browser/ui/win/dialog_thread.h" -#include "shell/browser/unresponsive_suppressor.h" #include "shell/common/gin_converters/file_path_converter.h" namespace file_dialog { @@ -102,7 +101,6 @@ static void SetDefaultFolder(IFileDialog* dialog, static HRESULT ShowFileDialog(IFileDialog* dialog, const DialogSettings& settings) { - electron::UnresponsiveSuppressor suppressor; HWND parent_window = settings.parent_window ? static_cast(settings.parent_window) diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index 6266dad29ef5..40f026cfc0b0 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -16,7 +16,6 @@ #include "shell/browser/native_window_observer.h" #include "shell/browser/native_window_views.h" #include "shell/browser/ui/gtk_util.h" -#include "shell/browser/unresponsive_suppressor.h" #include "ui/base/glib/glib_signal.h" #include "ui/gfx/image/image_skia.h" #include "ui/gtk/gtk_ui.h" // nogncheck @@ -187,8 +186,6 @@ class GtkMessageBox : public NativeWindowObserver { CHROMEG_CALLBACK_0(GtkMessageBox, void, OnCheckboxToggled, GtkWidget*); private: - electron::UnresponsiveSuppressor unresponsive_suppressor_; - // The id of the dialog. absl::optional id_; diff --git a/shell/browser/ui/message_box_win.cc b/shell/browser/ui/message_box_win.cc index 02499bf9c9c2..f2d1b2b12643 100644 --- a/shell/browser/ui/message_box_win.cc +++ b/shell/browser/ui/message_box_win.cc @@ -20,7 +20,6 @@ #include "shell/browser/browser.h" #include "shell/browser/native_window_views.h" #include "shell/browser/ui/win/dialog_thread.h" -#include "shell/browser/unresponsive_suppressor.h" #include "ui/gfx/icon_util.h" #include "ui/gfx/image/image_skia.h" @@ -275,7 +274,6 @@ DialogResult ShowTaskDialogUTF8(const MessageBoxSettings& settings, } // namespace int ShowMessageBoxSync(const MessageBoxSettings& settings) { - electron::UnresponsiveSuppressor suppressor; DialogResult result = ShowTaskDialogUTF8(settings, nullptr); return result.button_id; } @@ -326,7 +324,6 @@ void CloseMessageBox(int id) { } void ShowErrorBox(const std::u16string& title, const std::u16string& content) { - electron::UnresponsiveSuppressor suppressor; ShowTaskDialogWstr(nullptr, MessageBoxType::kError, {}, -1, 0, false, u"Error", title, content, u"", false, gfx::ImageSkia(), nullptr); diff --git a/shell/browser/unresponsive_suppressor.cc b/shell/browser/unresponsive_suppressor.cc deleted file mode 100644 index 289b71d5c2ec..000000000000 --- a/shell/browser/unresponsive_suppressor.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "shell/browser/unresponsive_suppressor.h" - -namespace electron { - -namespace { - -int g_suppress_level = 0; - -} // namespace - -bool IsUnresponsiveEventSuppressed() { - return g_suppress_level > 0; -} - -UnresponsiveSuppressor::UnresponsiveSuppressor() { - g_suppress_level++; -} - -UnresponsiveSuppressor::~UnresponsiveSuppressor() { - g_suppress_level--; -} - -} // namespace electron diff --git a/shell/browser/unresponsive_suppressor.h b/shell/browser/unresponsive_suppressor.h deleted file mode 100644 index adb34363e237..000000000000 --- a/shell/browser/unresponsive_suppressor.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ELECTRON_SHELL_BROWSER_UNRESPONSIVE_SUPPRESSOR_H_ -#define ELECTRON_SHELL_BROWSER_UNRESPONSIVE_SUPPRESSOR_H_ - -namespace electron { - -bool IsUnresponsiveEventSuppressed(); - -class UnresponsiveSuppressor { - public: - UnresponsiveSuppressor(); - ~UnresponsiveSuppressor(); - - // disable copy - UnresponsiveSuppressor(const UnresponsiveSuppressor&) = delete; - UnresponsiveSuppressor& operator=(const UnresponsiveSuppressor&) = delete; -}; - -} // namespace electron - -#endif // ELECTRON_SHELL_BROWSER_UNRESPONSIVE_SUPPRESSOR_H_