| 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_delegate.h" | 5 #include "ui/views/window/dialog_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/base/ui_base_switches.h" |
| 8 #include "ui/views/controls/button/text_button.h" | 10 #include "ui/views/controls/button/text_button.h" |
| 9 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 10 #include "ui/views/window/dialog_client_view.h" | 12 #include "ui/views/window/dialog_client_view.h" |
| 13 #include "ui/views/window/dialog_frame_view.h" |
| 11 | 14 |
| 12 namespace views { | 15 namespace views { |
| 13 | 16 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 15 // DialogDelegate: | 18 // DialogDelegate: |
| 16 | 19 |
| 20 // static |
| 21 bool DialogDelegate::UseNewStyle() { |
| 22 static const bool use_new_style = CommandLine::ForCurrentProcess()->HasSwitch( |
| 23 switches::kEnableNewDialogStyle); |
| 24 return use_new_style; |
| 25 } |
| 26 |
| 17 DialogDelegate* DialogDelegate::AsDialogDelegate() { return this; } | 27 DialogDelegate* DialogDelegate::AsDialogDelegate() { return this; } |
| 18 | 28 |
| 19 DialogDelegate::~DialogDelegate() { | 29 DialogDelegate::~DialogDelegate() { |
| 20 } | 30 } |
| 21 | 31 |
| 22 int DialogDelegate::GetDialogButtons() const { | 32 int DialogDelegate::GetDialogButtons() const { |
| 23 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; | 33 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| 24 } | 34 } |
| 25 | 35 |
| 26 int DialogDelegate::GetDefaultDialogButton() const { | 36 int DialogDelegate::GetDefaultDialogButton() const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 } | 48 } |
| 39 | 49 |
| 40 bool DialogDelegate::IsDialogButtonEnabled(ui::DialogButton button) const { | 50 bool DialogDelegate::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 41 return true; | 51 return true; |
| 42 } | 52 } |
| 43 | 53 |
| 44 bool DialogDelegate::IsDialogButtonVisible(ui::DialogButton button) const { | 54 bool DialogDelegate::IsDialogButtonVisible(ui::DialogButton button) const { |
| 45 return true; | 55 return true; |
| 46 } | 56 } |
| 47 | 57 |
| 48 bool DialogDelegate::UseChromeStyle() const { | |
| 49 return false; | |
| 50 } | |
| 51 | |
| 52 bool DialogDelegate::AreAcceleratorsEnabled(ui::DialogButton button) { | 58 bool DialogDelegate::AreAcceleratorsEnabled(ui::DialogButton button) { |
| 53 return true; | 59 return true; |
| 54 } | 60 } |
| 55 | 61 |
| 56 View* DialogDelegate::GetExtraView() { | 62 View* DialogDelegate::GetExtraView() { |
| 57 return NULL; | 63 return NULL; |
| 58 } | 64 } |
| 59 | 65 |
| 60 bool DialogDelegate::GetSizeExtraViewHeightToButtons() { | 66 bool DialogDelegate::GetSizeExtraViewHeightToButtons() { |
| 61 return false; | 67 return false; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 87 } | 93 } |
| 88 | 94 |
| 89 if (default_button & ui::DIALOG_BUTTON_OK) | 95 if (default_button & ui::DIALOG_BUTTON_OK) |
| 90 return dcv->ok_button(); | 96 return dcv->ok_button(); |
| 91 if (default_button & ui::DIALOG_BUTTON_CANCEL) | 97 if (default_button & ui::DIALOG_BUTTON_CANCEL) |
| 92 return dcv->cancel_button(); | 98 return dcv->cancel_button(); |
| 93 return NULL; | 99 return NULL; |
| 94 } | 100 } |
| 95 | 101 |
| 96 ClientView* DialogDelegate::CreateClientView(Widget* widget) { | 102 ClientView* DialogDelegate::CreateClientView(Widget* widget) { |
| 97 DialogClientView::StyleParams params = UseChromeStyle() ? | 103 return new DialogClientView(widget, GetContentsView()); |
| 98 DialogClientView::GetChromeStyleParams() : | 104 } |
| 99 DialogClientView::StyleParams(); | |
| 100 | 105 |
| 101 return new DialogClientView(widget, GetContentsView(), params); | 106 NonClientFrameView* DialogDelegate::CreateNonClientFrameView(Widget* widget) { |
| 107 return UseNewStyle() ? new DialogFrameView() : |
| 108 WidgetDelegate::CreateNonClientFrameView(widget); |
| 102 } | 109 } |
| 103 | 110 |
| 104 const DialogClientView* DialogDelegate::GetDialogClientView() const { | 111 const DialogClientView* DialogDelegate::GetDialogClientView() const { |
| 105 return GetWidget()->client_view()->AsDialogClientView(); | 112 return GetWidget()->client_view()->AsDialogClientView(); |
| 106 } | 113 } |
| 107 | 114 |
| 108 DialogClientView* DialogDelegate::GetDialogClientView() { | 115 DialogClientView* DialogDelegate::GetDialogClientView() { |
| 109 return GetWidget()->client_view()->AsDialogClientView(); | 116 return GetWidget()->client_view()->AsDialogClientView(); |
| 110 } | 117 } |
| 111 | 118 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 123 } | 130 } |
| 124 | 131 |
| 125 Widget* DialogDelegateView::GetWidget() { | 132 Widget* DialogDelegateView::GetWidget() { |
| 126 return View::GetWidget(); | 133 return View::GetWidget(); |
| 127 } | 134 } |
| 128 | 135 |
| 129 const Widget* DialogDelegateView::GetWidget() const { | 136 const Widget* DialogDelegateView::GetWidget() const { |
| 130 return View::GetWidget(); | 137 return View::GetWidget(); |
| 131 } | 138 } |
| 132 | 139 |
| 140 View* DialogDelegateView::GetContentsView() { |
| 141 return this; |
| 142 } |
| 143 |
| 133 } // namespace views | 144 } // namespace views |
| OLD | NEW |