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() { |