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/logging.h" | 7 #include "base/logging.h" |
8 #include "grit/ui_strings.h" | 8 #include "grit/ui_strings.h" |
9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
10 #include "ui/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
11 #include "ui/views/bubble/bubble_frame_view.h" | 11 #include "ui/views/bubble/bubble_frame_view.h" |
12 #include "ui/views/controls/button/label_button.h" | 12 #include "ui/views/controls/button/label_button.h" |
13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
14 #include "ui/views/widget/widget_observer.h" | 14 #include "ui/views/widget/widget_observer.h" |
15 #include "ui/views/window/dialog_client_view.h" | 15 #include "ui/views/window/dialog_client_view.h" |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 | 18 |
19 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
20 // DialogDelegate: | 20 // DialogDelegate: |
21 | 21 |
22 DialogDelegate::~DialogDelegate() { | 22 DialogDelegate::~DialogDelegate() { |
23 } | 23 } |
24 | 24 |
25 // static | 25 // static |
26 Widget* DialogDelegate::CreateDialogWidget(DialogDelegate* dialog, | 26 Widget* DialogDelegate::CreateDialogWidget(WidgetDelegate* delegate, |
27 gfx::NativeView context, | 27 gfx::NativeView context, |
28 gfx::NativeView parent) { | 28 gfx::NativeView parent) { |
29 views::Widget* widget = new views::Widget; | 29 views::Widget* widget = new views::Widget; |
30 views::Widget::InitParams params; | 30 views::Widget::InitParams params; |
31 params.delegate = dialog; | 31 params.delegate = delegate; |
| 32 DialogDelegate* dialog = delegate->AsDialogDelegate(); |
32 if (!dialog || dialog->UseNewStyleForThisDialog()) { | 33 if (!dialog || dialog->UseNewStyleForThisDialog()) { |
33 params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; | 34 params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; |
34 params.remove_standard_frame = true; | 35 params.remove_standard_frame = true; |
| 36 // The bubble frame includes its own shadow; remove any native shadowing. |
| 37 params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE; |
35 } | 38 } |
36 params.context = context; | 39 params.context = context; |
37 params.parent = parent; | 40 params.parent = parent; |
38 // TODO(msw): Add a matching shadow type and remove the bubble frame border? | 41 // Web-modal (ui::MODAL_TYPE_CHILD) dialogs with parents are marked as child |
39 params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE; | 42 // widgets to prevent top-level window behavior (independent movement, etc). |
| 43 params.child = parent && (delegate->GetModalType() == ui::MODAL_TYPE_CHILD); |
40 widget->Init(params); | 44 widget->Init(params); |
41 return widget; | 45 return widget; |
42 } | 46 } |
43 | 47 |
44 View* DialogDelegate::CreateExtraView() { | 48 View* DialogDelegate::CreateExtraView() { |
45 return NULL; | 49 return NULL; |
46 } | 50 } |
47 | 51 |
48 View* DialogDelegate::CreateTitlebarExtraView() { | 52 View* DialogDelegate::CreateTitlebarExtraView() { |
49 return NULL; | 53 return NULL; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 205 |
202 const Widget* DialogDelegateView::GetWidget() const { | 206 const Widget* DialogDelegateView::GetWidget() const { |
203 return View::GetWidget(); | 207 return View::GetWidget(); |
204 } | 208 } |
205 | 209 |
206 View* DialogDelegateView::GetContentsView() { | 210 View* DialogDelegateView::GetContentsView() { |
207 return this; | 211 return this; |
208 } | 212 } |
209 | 213 |
210 } // namespace views | 214 } // namespace views |
OLD | NEW |