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

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: Rebase 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
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 abffb5abba0467cc74e29bcf2746373b40114878..92484ee073a619a9bf1dd7ca92a5fda4655bedf1 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -54,10 +54,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() {
@@ -108,16 +109,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 Dismiss action.
+ if (GetDialogDelegate()->Dismiss()) {
+ notified_delegate_ = true;
+ GetDialogDelegate()->OnClose();
+ return true;
+ }
+ return false;
}
DialogClientView* DialogClientView::AsDialogClientView() {

Powered by Google App Engine
This is Rietveld 408576698