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

Side by Side Diff: ui/views/window/dialog_client_view.cc

Issue 1846033002: Switch GlobalErrorBubbleView to a BubbleDialogDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/global_error_bubble_view.cc ('k') | ui/views/window/dialog_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 void DialogClientView::UpdateDialogButtons() { 89 void DialogClientView::UpdateDialogButtons() {
90 const int buttons = GetDialogDelegate()->GetDialogButtons(); 90 const int buttons = GetDialogDelegate()->GetDialogButtons();
91 91
92 if (buttons & ui::DIALOG_BUTTON_OK) { 92 if (buttons & ui::DIALOG_BUTTON_OK) {
93 if (!ok_button_) { 93 if (!ok_button_) {
94 ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK); 94 ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK);
95 AddChildView(ok_button_); 95 AddChildView(ok_button_);
96 } 96 }
97 97
98 UpdateButton(ok_button_, ui::DIALOG_BUTTON_OK); 98 GetDialogDelegate()->UpdateButton(ok_button_, ui::DIALOG_BUTTON_OK);
99 } else if (ok_button_) { 99 } else if (ok_button_) {
100 delete ok_button_; 100 delete ok_button_;
101 ok_button_ = NULL; 101 ok_button_ = NULL;
102 } 102 }
103 103
104 if (buttons & ui::DIALOG_BUTTON_CANCEL) { 104 if (buttons & ui::DIALOG_BUTTON_CANCEL) {
105 if (!cancel_button_) { 105 if (!cancel_button_) {
106 cancel_button_ = CreateDialogButton(ui::DIALOG_BUTTON_CANCEL); 106 cancel_button_ = CreateDialogButton(ui::DIALOG_BUTTON_CANCEL);
107 AddChildView(cancel_button_); 107 AddChildView(cancel_button_);
108 } 108 }
109 109
110 UpdateButton(cancel_button_, ui::DIALOG_BUTTON_CANCEL); 110 GetDialogDelegate()->UpdateButton(cancel_button_, ui::DIALOG_BUTTON_CANCEL);
111 } else if (cancel_button_) { 111 } else if (cancel_button_) {
112 delete cancel_button_; 112 delete cancel_button_;
113 cancel_button_ = NULL; 113 cancel_button_ = NULL;
114 } 114 }
115 } 115 }
116 116
117 /////////////////////////////////////////////////////////////////////////////// 117 ///////////////////////////////////////////////////////////////////////////////
118 // DialogClientView, ClientView overrides: 118 // DialogClientView, ClientView overrides:
119 119
120 bool DialogClientView::CanClose() { 120 bool DialogClientView::CanClose() {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 button->SetStyle(Button::STYLE_BUTTON); 313 button->SetStyle(Button::STYLE_BUTTON);
314 } 314 }
315 button->SetFocusable(true); 315 button->SetFocusable(true);
316 316
317 const int kDialogMinButtonWidth = 75; 317 const int kDialogMinButtonWidth = 75;
318 button->SetMinSize(gfx::Size(kDialogMinButtonWidth, 0)); 318 button->SetMinSize(gfx::Size(kDialogMinButtonWidth, 0));
319 button->SetGroup(kButtonGroup); 319 button->SetGroup(kButtonGroup);
320 return button; 320 return button;
321 } 321 }
322 322
323 void DialogClientView::UpdateButton(LabelButton* button,
324 ui::DialogButton type) {
325 DialogDelegate* dialog = GetDialogDelegate();
326 button->SetText(dialog->GetDialogButtonLabel(type));
327 button->SetEnabled(dialog->IsDialogButtonEnabled(type));
328 button->SetIsDefault(type == dialog->GetDefaultDialogButton());
329 }
330
331 int DialogClientView::GetButtonsAndExtraViewRowHeight() const { 323 int DialogClientView::GetButtonsAndExtraViewRowHeight() const {
332 int extra_view_height = ShouldShow(extra_view_) ? 324 int extra_view_height = ShouldShow(extra_view_) ?
333 extra_view_->GetPreferredSize().height() : 0; 325 extra_view_->GetPreferredSize().height() : 0;
334 int buttons_height = std::max( 326 int buttons_height = std::max(
335 ok_button_ ? ok_button_->GetPreferredSize().height() : 0, 327 ok_button_ ? ok_button_->GetPreferredSize().height() : 0,
336 cancel_button_ ? cancel_button_->GetPreferredSize().height() : 0); 328 cancel_button_ ? cancel_button_->GetPreferredSize().height() : 0);
337 return std::max(extra_view_height, buttons_height); 329 return std::max(extra_view_height, buttons_height);
338 } 330 }
339 331
340 gfx::Insets DialogClientView::GetButtonRowInsets() const { 332 gfx::Insets DialogClientView::GetButtonRowInsets() const {
(...skipping 20 matching lines...) Expand all
361 child_views.end()); 353 child_views.end());
362 354
363 // Setup focus. 355 // Setup focus.
364 for (size_t i = 0; i < child_views.size(); i++) { 356 for (size_t i = 0; i < child_views.size(); i++) {
365 child_views[i]->SetNextFocusableView( 357 child_views[i]->SetNextFocusableView(
366 i + 1 != child_views.size() ? child_views[i + 1] : nullptr); 358 i + 1 != child_views.size() ? child_views[i + 1] : nullptr);
367 } 359 }
368 } 360 }
369 361
370 } // namespace views 362 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/global_error_bubble_view.cc ('k') | ui/views/window/dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698