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

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

Issue 17127003: Refine DialogClientView button code and unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary override. Created 7 years, 6 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/view_unittest.cc ('k') | ui/views/window/dialog_client_view_unittest.cc » ('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 08d2cfc4996faacbbc6f01f1975bbce9ecfba884..bb24e7c80b480d9302663a3a8e0692341d75c84c 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -43,9 +43,6 @@ DialogClientView::DialogClientView(Widget* owner, View* contents_view)
}
DialogClientView::~DialogClientView() {
- if (focus_manager_)
- focus_manager_->RemoveFocusChangeListener(this);
- focus_manager_ = NULL;
}
void DialogClientView::AcceptWindow() {
@@ -73,13 +70,14 @@ void DialogClientView::UpdateDialogButtons() {
if (buttons & ui::DIALOG_BUTTON_OK) {
if (!ok_button_) {
ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK);
- if (buttons & ui::DIALOG_BUTTON_CANCEL)
+ if (!(buttons & ui::DIALOG_BUTTON_CANCEL))
ok_button_->AddAccelerator(escape);
AddChildView(ok_button_);
}
UpdateButton(ok_button_, ui::DIALOG_BUTTON_OK);
} else if (ok_button_) {
+ RemoveChildView(ok_button_);
sky 2013/06/17 20:30:14 Is there a particular reason you are adding this?
msw 2013/06/17 21:10:56 Ah, solely out of ignorance; updated this and simp
delete ok_button_;
ok_button_ = NULL;
}
@@ -93,6 +91,7 @@ void DialogClientView::UpdateDialogButtons() {
UpdateButton(cancel_button_, ui::DIALOG_BUTTON_CANCEL);
} else if (cancel_button_) {
+ RemoveChildView(cancel_button_);
delete cancel_button_;
cancel_button_ = NULL;
}
@@ -272,6 +271,17 @@ void DialogClientView::ViewHierarchyChanged(
UpdateDialogButtons();
CreateExtraView();
CreateFootnoteView();
+ } else if (!details.is_add && details.child == this) {
+ if (focus_manager_)
+ focus_manager_->RemoveFocusChangeListener(this);
+ focus_manager_ = NULL;
+ } else if (!details.is_add) {
+ if (details.child == default_button_)
+ default_button_ = NULL;
+ if (details.child == ok_button_)
+ ok_button_ = NULL;
+ if (details.child == cancel_button_)
+ cancel_button_ = NULL;
}
}
« no previous file with comments | « ui/views/view_unittest.cc ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698