blob: 8f1917bd2eff1ea6e14611fa2943ead9236e4aa2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "views/window/dialog_delegate.h"
#include "base/logging.h"
#include "views/controls/button/text_button.h"
#include "views/widget/widget.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// DialogDelegate:
DialogDelegate* DialogDelegate::AsDialogDelegate() { return this; }
int DialogDelegate::GetDialogButtons() const {
return ui::MessageBoxFlags::DIALOGBUTTON_OK |
ui::MessageBoxFlags::DIALOGBUTTON_CANCEL;
}
bool DialogDelegate::AreAcceleratorsEnabled(
ui::MessageBoxFlags::DialogButton button) {
return true;
}
string16 DialogDelegate::GetDialogButtonLabel(
ui::MessageBoxFlags::DialogButton button) const {
// Empty string results in defaults for
// ui::MessageBoxFlags::DIALOGBUTTON_OK
// ui::MessageBoxFlags::DIALOGBUTTON_CANCEL.
return string16();
}
View* DialogDelegate::GetExtraView() {
return NULL;
}
bool DialogDelegate::GetSizeExtraViewHeightToButtons() {
return false;
}
int DialogDelegate::GetDefaultDialogButton() const {
if (GetDialogButtons() & MessageBoxFlags::DIALOGBUTTON_OK)
return MessageBoxFlags::DIALOGBUTTON_OK;
if (GetDialogButtons() & MessageBoxFlags::DIALOGBUTTON_CANCEL)
return MessageBoxFlags::DIALOGBUTTON_CANCEL;
return MessageBoxFlags::DIALOGBUTTON_NONE;
}
bool DialogDelegate::IsDialogButtonEnabled(
ui::MessageBoxFlags::DialogButton button) const {
return true;
}
bool DialogDelegate::IsDialogButtonVisible(
ui::MessageBoxFlags::DialogButton button) const {
return true;
}
bool DialogDelegate::Cancel() {
return true;
}
bool DialogDelegate::Accept(bool window_closiang) {
return Accept();
}
bool DialogDelegate::Accept() {
return true;
}
View* DialogDelegate::GetInitiallyFocusedView() {
// Focus the default button if any.
const DialogClientView* dcv = GetDialogClientView();
int default_button = GetDefaultDialogButton();
if (default_button == MessageBoxFlags::DIALOGBUTTON_NONE)
return NULL;
if ((default_button & GetDialogButtons()) == 0) {
// The default button is a button we don't have.
NOTREACHED();
return NULL;
}
if (default_button & MessageBoxFlags::DIALOGBUTTON_OK)
return dcv->ok_button();
if (default_button & MessageBoxFlags::DIALOGBUTTON_CANCEL)
return dcv->cancel_button();
return NULL;
}
ClientView* DialogDelegate::CreateClientView(Widget* widget) {
return new DialogClientView(widget, GetContentsView());
}
const DialogClientView* DialogDelegate::GetDialogClientView() const {
return GetWidget()->client_view()->AsDialogClientView();
}
DialogClientView* DialogDelegate::GetDialogClientView() {
return GetWidget()->client_view()->AsDialogClientView();
}
ui::AccessibilityTypes::Role DialogDelegate::GetAccessibleWindowRole() const {
return ui::AccessibilityTypes::ROLE_DIALOG;
}
////////////////////////////////////////////////////////////////////////////////
// DialogDelegateView:
DialogDelegateView::DialogDelegateView() {
}
DialogDelegateView::~DialogDelegateView() {
}
Widget* DialogDelegateView::GetWidget() {
return View::GetWidget();
}
const Widget* DialogDelegateView::GetWidget() const {
return View::GetWidget();
}
} // namespace views
|