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

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

Issue 11571023: Move ash/wm's DialogFrameView to ui/views/window; etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reorder DialogDelegate functions; inline Get*Params into WidgetExample::ButtonPressed; etc. Created 8 years 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
« no previous file with comments | « ui/views/window/dialog_delegate.h ('k') | ui/views/window/dialog_frame_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
17 DialogDelegate* DialogDelegate::AsDialogDelegate() { return this; } 20 DialogDelegate::~DialogDelegate() {
21 }
18 22
19 DialogDelegate::~DialogDelegate() { 23 // static
24 bool DialogDelegate::UseNewStyle() {
25 static const bool use_new_style = CommandLine::ForCurrentProcess()->HasSwitch(
26 switches::kEnableNewDialogStyle);
27 return use_new_style;
20 } 28 }
21 29
22 int DialogDelegate::GetDialogButtons() const { 30 int DialogDelegate::GetDialogButtons() const {
23 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; 31 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
24 } 32 }
25 33
26 int DialogDelegate::GetDefaultDialogButton() const { 34 int DialogDelegate::GetDefaultDialogButton() const {
27 if (GetDialogButtons() & ui::DIALOG_BUTTON_OK) 35 if (GetDialogButtons() & ui::DIALOG_BUTTON_OK)
28 return ui::DIALOG_BUTTON_OK; 36 return ui::DIALOG_BUTTON_OK;
29 if (GetDialogButtons() & ui::DIALOG_BUTTON_CANCEL) 37 if (GetDialogButtons() & ui::DIALOG_BUTTON_CANCEL)
30 return ui::DIALOG_BUTTON_CANCEL; 38 return ui::DIALOG_BUTTON_CANCEL;
31 return ui::DIALOG_BUTTON_NONE; 39 return ui::DIALOG_BUTTON_NONE;
32 } 40 }
33 41
34 string16 DialogDelegate::GetDialogButtonLabel(ui::DialogButton button) const { 42 string16 DialogDelegate::GetDialogButtonLabel(ui::DialogButton button) const {
35 // Empty string results in defaults for 43 // Empty string results in defaults for
36 // ui::DIALOG_BUTTON_OK or ui::DIALOG_BUTTON_CANCEL. 44 // ui::DIALOG_BUTTON_OK or ui::DIALOG_BUTTON_CANCEL.
37 return string16(); 45 return string16();
38 } 46 }
39 47
40 bool DialogDelegate::IsDialogButtonEnabled(ui::DialogButton button) const { 48 bool DialogDelegate::IsDialogButtonEnabled(ui::DialogButton button) const {
41 return true; 49 return true;
42 } 50 }
43 51
44 bool DialogDelegate::IsDialogButtonVisible(ui::DialogButton button) const { 52 bool DialogDelegate::IsDialogButtonVisible(ui::DialogButton button) const {
45 return true; 53 return true;
46 } 54 }
47 55
48 bool DialogDelegate::UseChromeStyle() const {
49 return false;
50 }
51
52 bool DialogDelegate::AreAcceleratorsEnabled(ui::DialogButton button) { 56 bool DialogDelegate::AreAcceleratorsEnabled(ui::DialogButton button) {
53 return true; 57 return true;
54 } 58 }
55 59
56 View* DialogDelegate::GetExtraView() { 60 View* DialogDelegate::GetExtraView() {
57 return NULL; 61 return NULL;
58 } 62 }
59 63
60 bool DialogDelegate::GetSizeExtraViewHeightToButtons() { 64 bool DialogDelegate::GetSizeExtraViewHeightToButtons() {
61 return false; 65 return false;
(...skipping 24 matching lines...) Expand all
86 return NULL; 90 return NULL;
87 } 91 }
88 92
89 if (default_button & ui::DIALOG_BUTTON_OK) 93 if (default_button & ui::DIALOG_BUTTON_OK)
90 return dcv->ok_button(); 94 return dcv->ok_button();
91 if (default_button & ui::DIALOG_BUTTON_CANCEL) 95 if (default_button & ui::DIALOG_BUTTON_CANCEL)
92 return dcv->cancel_button(); 96 return dcv->cancel_button();
93 return NULL; 97 return NULL;
94 } 98 }
95 99
100 DialogDelegate* DialogDelegate::AsDialogDelegate() {
101 return this;
102 }
103
96 ClientView* DialogDelegate::CreateClientView(Widget* widget) { 104 ClientView* DialogDelegate::CreateClientView(Widget* widget) {
97 DialogClientView::StyleParams params = UseChromeStyle() ? 105 return new DialogClientView(widget, GetContentsView());
98 DialogClientView::GetChromeStyleParams() : 106 }
99 DialogClientView::StyleParams();
100 107
101 return new DialogClientView(widget, GetContentsView(), params); 108 NonClientFrameView* DialogDelegate::CreateNonClientFrameView(Widget* widget) {
109 return UseNewStyle() ? new DialogFrameView() :
110 WidgetDelegate::CreateNonClientFrameView(widget);
102 } 111 }
103 112
104 const DialogClientView* DialogDelegate::GetDialogClientView() const { 113 const DialogClientView* DialogDelegate::GetDialogClientView() const {
105 return GetWidget()->client_view()->AsDialogClientView(); 114 return GetWidget()->client_view()->AsDialogClientView();
106 } 115 }
107 116
108 DialogClientView* DialogDelegate::GetDialogClientView() { 117 DialogClientView* DialogDelegate::GetDialogClientView() {
109 return GetWidget()->client_view()->AsDialogClientView(); 118 return GetWidget()->client_view()->AsDialogClientView();
110 } 119 }
111 120
(...skipping 11 matching lines...) Expand all
123 } 132 }
124 133
125 Widget* DialogDelegateView::GetWidget() { 134 Widget* DialogDelegateView::GetWidget() {
126 return View::GetWidget(); 135 return View::GetWidget();
127 } 136 }
128 137
129 const Widget* DialogDelegateView::GetWidget() const { 138 const Widget* DialogDelegateView::GetWidget() const {
130 return View::GetWidget(); 139 return View::GetWidget();
131 } 140 }
132 141
142 View* DialogDelegateView::GetContentsView() {
143 return this;
144 }
145
133 } // namespace views 146 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/dialog_delegate.h ('k') | ui/views/window/dialog_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698