| OLD | NEW |
| 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 "ui/base/keycodes/keyboard_codes.h" | 9 #include "ui/base/keycodes/keyboard_codes.h" |
| 10 #include "ui/views/controls/button/chrome_style.h" |
| 10 #include "ui/views/controls/button/text_button.h" | 11 #include "ui/views/controls/button/text_button.h" |
| 11 #include "ui/views/layout/layout_constants.h" | 12 #include "ui/views/layout/layout_constants.h" |
| 12 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 13 #include "ui/views/window/dialog_delegate.h" | 14 #include "ui/views/window/dialog_delegate.h" |
| 14 | 15 |
| 15 namespace views { | 16 namespace views { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // The group used by the buttons. This name is chosen voluntarily big not to | 20 // The group used by the buttons. This name is chosen voluntarily big not to |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 UpdateDialogButtons(); | 283 UpdateDialogButtons(); |
| 283 | 284 |
| 284 // Use the escape key to close the window if there are no dialog buttons. | 285 // Use the escape key to close the window if there are no dialog buttons. |
| 285 if (!has_dialog_buttons()) | 286 if (!has_dialog_buttons()) |
| 286 AddAccelerator(escape); | 287 AddAccelerator(escape); |
| 287 } | 288 } |
| 288 | 289 |
| 289 TextButton* DialogClientView::CreateDialogButton(ui::DialogButton type) { | 290 TextButton* DialogClientView::CreateDialogButton(ui::DialogButton type) { |
| 290 const string16 title = GetDialogDelegate()->GetDialogButtonLabel(type); | 291 const string16 title = GetDialogDelegate()->GetDialogButtonLabel(type); |
| 291 TextButton* button = NULL; | 292 TextButton* button = NULL; |
| 292 if (DialogDelegate::UseNewStyle()) | 293 if (DialogDelegate::UseNewStyle()) { |
| 293 button = new TextButton(this, title); | 294 button = new TextButton(this, title); |
| 294 else | 295 ApplyChromeStyle(button); |
| 296 } else { |
| 295 button = new NativeTextButton(this, title); | 297 button = new NativeTextButton(this, title); |
| 298 } |
| 296 const int kDialogMinButtonWidth = 75; | 299 const int kDialogMinButtonWidth = 75; |
| 297 button->set_min_width(kDialogMinButtonWidth); | 300 button->set_min_width(kDialogMinButtonWidth); |
| 298 button->SetGroup(kButtonGroup); | 301 button->SetGroup(kButtonGroup); |
| 299 if (type == GetDialogDelegate()->GetDefaultDialogButton()) { | 302 if (type == GetDialogDelegate()->GetDefaultDialogButton()) { |
| 300 default_button_ = button; | 303 default_button_ = button; |
| 301 button->SetIsDefault(true); | 304 button->SetIsDefault(true); |
| 302 } | 305 } |
| 303 return button; | 306 return button; |
| 304 } | 307 } |
| 305 | 308 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 332 DialogDelegate* DialogClientView::GetDialogDelegate() const { | 335 DialogDelegate* DialogClientView::GetDialogDelegate() const { |
| 333 return GetWidget()->widget_delegate()->AsDialogDelegate(); | 336 return GetWidget()->widget_delegate()->AsDialogDelegate(); |
| 334 } | 337 } |
| 335 | 338 |
| 336 void DialogClientView::Close() { | 339 void DialogClientView::Close() { |
| 337 GetWidget()->Close(); | 340 GetWidget()->Close(); |
| 338 GetDialogDelegate()->OnClose(); | 341 GetDialogDelegate()->OnClose(); |
| 339 } | 342 } |
| 340 | 343 |
| 341 } // namespace views | 344 } // namespace views |
| OLD | NEW |