Replace DialogScope with UnresponsiveSuppressor

The latter is global-wide.
This commit is contained in:
Cheng Zhao 2016-07-11 15:29:03 +09:00
parent c58bddffe3
commit 7848608198
11 changed files with 67 additions and 46 deletions

View file

@ -5,6 +5,7 @@
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/native_window_views.h"
#include "atom/browser/unresponsive_suppressor.h"
#include "base/callback.h"
#include "base/files/file_util.h"
#include "base/strings/string_util.h"
@ -41,7 +42,6 @@ class FileChooserDialog {
const base::FilePath& default_path,
const Filters& filters)
: parent_(static_cast<atom::NativeWindowViews*>(parent_window)),
dialog_scope_(parent_window),
filters_(filters) {
const char* confirm_text = GTK_STOCK_OK;
@ -153,7 +153,7 @@ class FileChooserDialog {
base::FilePath AddExtensionForFilename(const gchar* filename) const;
atom::NativeWindowViews* parent_;
atom::NativeWindow::DialogScope dialog_scope_;
atom::UnresponsiveSuppressor unresponsive_suppressor_;
GtkWidget* dialog_;

View file

@ -10,6 +10,7 @@
#include <shlobj.h>
#include "atom/browser/native_window_views.h"
#include "atom/browser/unresponsive_suppressor.h"
#include "base/files/file_util.h"
#include "base/i18n/case_conversion.h"
#include "base/strings/string_util.h"
@ -108,7 +109,7 @@ class FileDialog {
}
bool Show(atom::NativeWindow* parent_window) {
atom::NativeWindow::DialogScope dialog_scope(parent_window);
atom::UnresponsiveSuppressor suppressor;
HWND window = parent_window ? static_cast<atom::NativeWindowViews*>(
parent_window)->GetAcceleratedWidget() :
NULL;

View file

@ -6,6 +6,7 @@
#include "atom/browser/browser.h"
#include "atom/browser/native_window_views.h"
#include "atom/browser/unresponsive_suppressor.h"
#include "base/callback.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@ -35,8 +36,7 @@ class GtkMessageBox {
const std::string& message,
const std::string& detail,
const gfx::ImageSkia& icon)
: dialog_scope_(parent_window),
cancel_id_(cancel_id),
: cancel_id_(cancel_id),
parent_(static_cast<NativeWindowViews*>(parent_window)) {
// Create dialog.
dialog_ = gtk_message_dialog_new(
@ -147,7 +147,7 @@ class GtkMessageBox {
CHROMEGTK_CALLBACK_1(GtkMessageBox, void, OnResponseDialog, int);
private:
atom::NativeWindow::DialogScope dialog_scope_;
atom::UnresponsiveSuppressor unresponsive_suppressor_;
// The id to return when the dialog is closed without pressing buttons.
int cancel_id_;

View file

@ -12,6 +12,7 @@
#include "atom/browser/browser.h"
#include "atom/browser/native_window_views.h"
#include "atom/browser/unresponsive_suppressor.h"
#include "base/callback.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@ -198,7 +199,7 @@ int ShowMessageBox(NativeWindow* parent,
static_cast<atom::NativeWindowViews*>(parent)->GetAcceleratedWidget() :
NULL;
NativeWindow::DialogScope dialog_scope(parent);
atom::UnresponsiveSuppressor suppressor;
return ShowMessageBoxUTF16(hwnd_parent,
type,
utf16_buttons,
@ -239,6 +240,7 @@ void ShowMessageBox(NativeWindow* parent,
}
void ShowErrorBox(const base::string16& title, const base::string16& content) {
atom::UnresponsiveSuppressor suppressor;
ShowMessageBoxUTF16(NULL, MESSAGE_BOX_TYPE_ERROR, {}, -1, 0, 0, L"Error",
title, content, gfx::ImageSkia());
}