Chromium Code Reviews| 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/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/base/ui_base_switches.h" | 9 #include "ui/base/ui_base_switches.h" |
| 10 #include "ui/views/controls/button/text_button.h" | 10 #include "ui/views/controls/button/text_button.h" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 #include "ui/views/widget/widget_observer.h" | |
| 12 #include "ui/views/window/dialog_client_view.h" | 13 #include "ui/views/window/dialog_client_view.h" |
| 13 #include "ui/views/window/dialog_frame_view.h" | 14 #include "ui/views/window/dialog_frame_view.h" |
| 14 | 15 |
| 15 namespace views { | 16 namespace views { |
| 16 | 17 |
| 18 namespace { | |
| 19 | |
| 20 // Create a widget to host the dialog. | |
| 21 Widget* CreateDialogWidgetImpl(DialogDelegateView* dialog_delegate_view, | |
| 22 gfx::NativeWindow context, | |
| 23 gfx::NativeWindow parent) { | |
| 24 views::Widget* widget = new views::Widget; | |
| 25 views::Widget::InitParams params; | |
| 26 params.delegate = dialog_delegate_view; | |
| 27 if (DialogDelegate::UseNewStyle()) { | |
| 28 // TODO(msw): Avoid Windows native controls or support dialog transparency | |
| 29 // with a separate border Widget, like BubbleDelegateView. | |
| 30 params.transparent = views::View::get_use_acceleration_when_possible(); | |
| 31 params.remove_standard_frame = true; | |
| 32 } | |
| 33 params.context = context; | |
| 34 params.parent = parent; | |
| 35 params.top_level = true; | |
| 36 widget->Init(params); | |
| 37 return widget; | |
| 38 } | |
| 39 | |
| 40 } // namespace | |
| 41 | |
| 42 | |
| 17 //////////////////////////////////////////////////////////////////////////////// | 43 //////////////////////////////////////////////////////////////////////////////// |
| 18 // DialogDelegate: | 44 // DialogDelegate: |
| 19 | 45 |
| 20 DialogDelegate::~DialogDelegate() { | 46 DialogDelegate::~DialogDelegate() { |
| 21 } | 47 } |
| 22 | 48 |
| 23 // static | 49 // static |
| 24 bool DialogDelegate::UseNewStyle() { | 50 bool DialogDelegate::UseNewStyle() { |
| 25 static const bool use_new_style = CommandLine::ForCurrentProcess()->HasSwitch( | 51 static const bool use_new_style = CommandLine::ForCurrentProcess()->HasSwitch( |
| 26 switches::kEnableNewDialogStyle); | 52 switches::kEnableNewDialogStyle); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 return GetWidget()->client_view()->AsDialogClientView(); | 144 return GetWidget()->client_view()->AsDialogClientView(); |
| 119 } | 145 } |
| 120 | 146 |
| 121 ui::AccessibilityTypes::Role DialogDelegate::GetAccessibleWindowRole() const { | 147 ui::AccessibilityTypes::Role DialogDelegate::GetAccessibleWindowRole() const { |
| 122 return ui::AccessibilityTypes::ROLE_DIALOG; | 148 return ui::AccessibilityTypes::ROLE_DIALOG; |
| 123 } | 149 } |
| 124 | 150 |
| 125 //////////////////////////////////////////////////////////////////////////////// | 151 //////////////////////////////////////////////////////////////////////////////// |
| 126 // DialogDelegateView: | 152 // DialogDelegateView: |
| 127 | 153 |
| 128 DialogDelegateView::DialogDelegateView() { | 154 DialogDelegateView::DialogDelegateView() { } |
|
sky
2013/01/18 17:01:22
style guide actually says no spaces between braces
msw
2013/01/18 17:14:57
Done.
| |
| 129 } | |
| 130 | 155 |
| 131 DialogDelegateView::~DialogDelegateView() { | 156 DialogDelegateView::~DialogDelegateView() { } |
| 157 | |
| 158 // static | |
| 159 Widget* DialogDelegateView::CreateDialogWidget(DialogDelegateView* dialog, | |
| 160 gfx::NativeWindow context, | |
| 161 gfx::NativeWindow parent) { | |
| 162 return CreateDialogWidgetImpl(dialog, context, parent); | |
| 132 } | 163 } |
| 133 | 164 |
| 134 Widget* DialogDelegateView::GetWidget() { | 165 Widget* DialogDelegateView::GetWidget() { |
| 135 return View::GetWidget(); | 166 return View::GetWidget(); |
| 136 } | 167 } |
| 137 | 168 |
| 138 const Widget* DialogDelegateView::GetWidget() const { | 169 const Widget* DialogDelegateView::GetWidget() const { |
| 139 return View::GetWidget(); | 170 return View::GetWidget(); |
| 140 } | 171 } |
| 141 | 172 |
| 142 View* DialogDelegateView::GetContentsView() { | 173 View* DialogDelegateView::GetContentsView() { |
| 143 return this; | 174 return this; |
| 144 } | 175 } |
| 145 | 176 |
| 146 } // namespace views | 177 } // namespace views |
| OLD | NEW |