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

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: Revert explicit RemoveChildView calls. 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..abffb5abba0467cc74e29bcf2746373b40114878 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,7 +70,7 @@ 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_);
}
@@ -272,6 +269,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