Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: ui/views/window/dialog_client_view.cc

Issue 18179004: Dismiss action in tab modal dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test for Mac Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc ('k') | ui/views/window/dialog_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/window/dialog_client_view.cc
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index 117ae620ef254a29f854bbf4670ab23e4a43b4c5..d592292ed8f3044dcd6b389afa53e978501b5c6d 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -55,10 +55,11 @@ void DialogClientView::AcceptWindow() {
}
void DialogClientView::CancelWindow() {
- // Call the standard Close handler, which checks with the delegate before
- // proceeding. This checking _isn't_ done here, but in the WM_CLOSE handler,
- // so that the close box on the window also shares this code path.
- Close();
+ // Only notify the delegate once. See |notified_delegate_|'s comment.
+ if (!notified_delegate_ && GetDialogDelegate()->Cancel()) {
+ notified_delegate_ = true;
+ Close();
+ }
}
void DialogClientView::UpdateDialogButtons() {
@@ -109,16 +110,14 @@ bool DialogClientView::CanClose() {
if (notified_delegate_)
return true;
- DialogDelegate* dialog = GetDialogDelegate();
- int buttons = dialog->GetDialogButtons();
- bool close = true;
- if ((buttons & ui::DIALOG_BUTTON_CANCEL) ||
- (buttons == ui::DIALOG_BUTTON_NONE))
- close = dialog->Cancel();
- else if (buttons & ui::DIALOG_BUTTON_OK)
- close = dialog->Accept(true);
- notified_delegate_ = close;
- return close;
+ // The dialog is closing but no Accept or Cancel action has been performed
+ // before: it's a Close action.
+ if (GetDialogDelegate()->Close()) {
+ notified_delegate_ = true;
+ GetDialogDelegate()->OnClosed();
+ return true;
+ }
+ return false;
}
DialogClientView* DialogClientView::AsDialogClientView() {
@@ -403,7 +402,7 @@ gfx::Insets DialogClientView::GetButtonRowInsets() const {
void DialogClientView::Close() {
GetWidget()->Close();
- GetDialogDelegate()->OnClose();
+ GetDialogDelegate()->OnClosed();
}
} // namespace views
« no previous file with comments | « chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc ('k') | ui/views/window/dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698