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

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

Issue 1730893002: Revert of Remove DialogDelegate::OnClosed() which is redundant with (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « ui/views/window/dialog_client_view.h ('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 5f069efeb02c523fd6f00b722cdef1ab5d8dce24..f6567a290acced9eca464dded26de5d10b45b2bc 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -58,24 +58,25 @@
cancel_button_(NULL),
extra_view_(NULL),
footnote_view_(NULL),
- delegate_allowed_close_(false) {}
+ notified_delegate_(false) {
+}
DialogClientView::~DialogClientView() {
}
void DialogClientView::AcceptWindow() {
- // Only notify the delegate once. See |delegate_allowed_close_|'s comment.
- if (!delegate_allowed_close_ && GetDialogDelegate()->Accept(false)) {
- delegate_allowed_close_ = true;
- GetWidget()->Close();
+ // Only notify the delegate once. See |notified_delegate_|'s comment.
+ if (!notified_delegate_ && GetDialogDelegate()->Accept(false)) {
+ notified_delegate_ = true;
+ Close();
}
}
void DialogClientView::CancelWindow() {
- // Only notify the delegate once. See |delegate_allowed_close_|'s comment.
- if (!delegate_allowed_close_ && GetDialogDelegate()->Cancel()) {
- delegate_allowed_close_ = true;
- GetWidget()->Close();
+ // Only notify the delegate once. See |notified_delegate_|'s comment.
+ if (!notified_delegate_ && GetDialogDelegate()->Cancel()) {
+ notified_delegate_ = true;
+ Close();
}
}
@@ -121,11 +122,17 @@
// DialogClientView, ClientView overrides:
bool DialogClientView::CanClose() {
- // If the dialog is closing but no Accept or Cancel action has been performed
- // before, it's a Close action.
- if (!delegate_allowed_close_)
- delegate_allowed_close_ = GetDialogDelegate()->Close();
- return delegate_allowed_close_;
+ if (notified_delegate_)
+ return true;
+
+ // 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() {
@@ -232,7 +239,7 @@
bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) {
DCHECK_EQ(accelerator.key_code(), ui::VKEY_ESCAPE);
- GetWidget()->Close();
+ Close();
return true;
}
@@ -293,7 +300,7 @@
cancel_button_(NULL),
extra_view_(NULL),
footnote_view_(NULL),
- delegate_allowed_close_(false) {}
+ notified_delegate_(false) {}
DialogDelegate* DialogClientView::GetDialogDelegate() const {
return GetWidget()->widget_delegate()->AsDialogDelegate();
@@ -374,7 +381,10 @@
kButtonVEdgeMarginNew, kButtonHEdgeMarginNew);
}
-
+void DialogClientView::Close() {
+ GetWidget()->Close();
+ GetDialogDelegate()->OnClosed();
+}
void DialogClientView::SetupFocusChain() {
// Create a vector of child views in the order of intended focus.
« no previous file with comments | « ui/views/window/dialog_client_view.h ('k') | ui/views/window/dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698