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

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

Issue 290553002: Refactor menu dependency on aura/wm SetShadowType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for sky Created 6 years, 7 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 | Annotate | Revision Log
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_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 #include "ui/wm/core/shadow_types.h"
17 16
18 namespace views { 17 namespace views {
19 18
20 //////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////
21 // DialogDelegate: 20 // DialogDelegate:
22 21
23 DialogDelegate::~DialogDelegate() { 22 DialogDelegate::~DialogDelegate() {
24 } 23 }
25 24
26 // static 25 // static
27 Widget* DialogDelegate::CreateDialogWidget(DialogDelegate* dialog, 26 Widget* DialogDelegate::CreateDialogWidget(DialogDelegate* dialog,
28 gfx::NativeView context, 27 gfx::NativeView context,
29 gfx::NativeView parent) { 28 gfx::NativeView parent) {
30 views::Widget* widget = new views::Widget; 29 views::Widget* widget = new views::Widget;
31 views::Widget::InitParams params; 30 views::Widget::InitParams params;
32 params.delegate = dialog; 31 params.delegate = dialog;
33 if (!dialog || dialog->UseNewStyleForThisDialog()) { 32 if (!dialog || dialog->UseNewStyleForThisDialog()) {
34 params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; 33 params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW;
35 params.remove_standard_frame = true; 34 params.remove_standard_frame = true;
36 } 35 }
37 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 36 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
38 // Dialogs on Linux always have custom frames. 37 // Dialogs on Linux always have custom frames.
39 params.remove_standard_frame = true; 38 params.remove_standard_frame = true;
40 #endif 39 #endif
41 params.context = context; 40 params.context = context;
42 params.parent = parent; 41 params.parent = parent;
43 params.top_level = true; 42 params.top_level = true;
43 // TODO(msw): Add a matching shadow type and remove the bubble frame border?
44 params.shadow_type = views::Widget::InitParams::NO_SHADOW;
44 widget->Init(params); 45 widget->Init(params);
45 return widget; 46 return widget;
46 } 47 }
47 48
48 View* DialogDelegate::CreateExtraView() { 49 View* DialogDelegate::CreateExtraView() {
49 return NULL; 50 return NULL;
50 } 51 }
51 52
52 View* DialogDelegate::CreateTitlebarExtraView() { 53 View* DialogDelegate::CreateTitlebarExtraView() {
53 return NULL; 54 return NULL;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 scoped_ptr<BubbleBorder> border(new BubbleBorder( 160 scoped_ptr<BubbleBorder> border(new BubbleBorder(
160 BubbleBorder::FLOAT, BubbleBorder::SMALL_SHADOW, SK_ColorRED)); 161 BubbleBorder::FLOAT, BubbleBorder::SMALL_SHADOW, SK_ColorRED));
161 border->set_use_theme_background_color(true); 162 border->set_use_theme_background_color(true);
162 frame->SetBubbleBorder(border.Pass()); 163 frame->SetBubbleBorder(border.Pass());
163 DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate(); 164 DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate();
164 if (delegate) { 165 if (delegate) {
165 View* titlebar_view = delegate->CreateTitlebarExtraView(); 166 View* titlebar_view = delegate->CreateTitlebarExtraView();
166 if (titlebar_view) 167 if (titlebar_view)
167 frame->SetTitlebarExtraView(titlebar_view); 168 frame->SetTitlebarExtraView(titlebar_view);
168 } 169 }
169 // TODO(msw): Add a matching shadow type and remove the bubble frame border?
170 wm::SetShadowType(widget->GetNativeWindow(), wm::SHADOW_TYPE_NONE);
171 return frame; 170 return frame;
172 } 171 }
173 172
174 bool DialogDelegate::UseNewStyleForThisDialog() const { 173 bool DialogDelegate::UseNewStyleForThisDialog() const {
175 return true; 174 return true;
176 } 175 }
177 176
178 const DialogClientView* DialogDelegate::GetDialogClientView() const { 177 const DialogClientView* DialogDelegate::GetDialogClientView() const {
179 return GetWidget()->client_view()->AsDialogClientView(); 178 return GetWidget()->client_view()->AsDialogClientView();
180 } 179 }
(...skipping 26 matching lines...) Expand all
207 206
208 const Widget* DialogDelegateView::GetWidget() const { 207 const Widget* DialogDelegateView::GetWidget() const {
209 return View::GetWidget(); 208 return View::GetWidget();
210 } 209 }
211 210
212 View* DialogDelegateView::GetContentsView() { 211 View* DialogDelegateView::GetContentsView() {
213 return this; 212 return this;
214 } 213 }
215 214
216 } // namespace views 215 } // namespace views
OLDNEW
« ui/views/widget/widget.h ('K') | « ui/views/widget/widget_hwnd_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698