GN: Fix clean build of cloud_policy_proto_generated_compile_proto failing
[chromium-blink-merge.git] / ui / views / widget / widget_delegate.cc
blobe62aa92847e67feb742e9451dda687b6fd920ac3
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
3 // found in the LICENSE file.
5 #include "ui/views/widget/widget_delegate.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/gfx/image/image_skia.h"
9 #include "ui/views/bubble/bubble_delegate.h"
10 #include "ui/views/view.h"
11 #include "ui/views/views_delegate.h"
12 #include "ui/views/widget/widget.h"
13 #include "ui/views/window/client_view.h"
15 namespace views {
17 ////////////////////////////////////////////////////////////////////////////////
18 // WidgetDelegate:
20 WidgetDelegate::WidgetDelegate()
21 : default_contents_view_(NULL),
22 can_activate_(true) {
25 void WidgetDelegate::OnWidgetMove() {
28 void WidgetDelegate::OnDisplayChanged() {
31 void WidgetDelegate::OnWorkAreaChanged() {
34 View* WidgetDelegate::GetInitiallyFocusedView() {
35 return NULL;
38 BubbleDelegateView* WidgetDelegate::AsBubbleDelegate() {
39 return NULL;
42 DialogDelegate* WidgetDelegate::AsDialogDelegate() {
43 return NULL;
46 bool WidgetDelegate::CanResize() const {
47 return false;
50 bool WidgetDelegate::CanMaximize() const {
51 return false;
54 bool WidgetDelegate::CanMinimize() const {
55 return false;
58 bool WidgetDelegate::CanActivate() const {
59 return can_activate_;
62 ui::ModalType WidgetDelegate::GetModalType() const {
63 return ui::MODAL_TYPE_NONE;
66 ui::AXRole WidgetDelegate::GetAccessibleWindowRole() const {
67 return ui::AX_ROLE_WINDOW;
70 base::string16 WidgetDelegate::GetAccessibleWindowTitle() const {
71 return GetWindowTitle();
74 base::string16 WidgetDelegate::GetWindowTitle() const {
75 return base::string16();
78 bool WidgetDelegate::ShouldShowWindowTitle() const {
79 return true;
82 bool WidgetDelegate::ShouldShowCloseButton() const {
83 return true;
86 bool WidgetDelegate::ShouldHandleSystemCommands() const {
87 const Widget* widget = GetWidget();
88 if (!widget)
89 return false;
91 return widget->non_client_view() != NULL;
94 gfx::ImageSkia WidgetDelegate::GetWindowAppIcon() {
95 // Use the window icon as app icon by default.
96 return GetWindowIcon();
99 // Returns the icon to be displayed in the window.
100 gfx::ImageSkia WidgetDelegate::GetWindowIcon() {
101 return gfx::ImageSkia();
104 bool WidgetDelegate::ShouldShowWindowIcon() const {
105 return false;
108 bool WidgetDelegate::ExecuteWindowsCommand(int command_id) {
109 return false;
112 std::string WidgetDelegate::GetWindowName() const {
113 return std::string();
116 void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds,
117 ui::WindowShowState show_state) {
118 std::string window_name = GetWindowName();
119 if (!ViewsDelegate::GetInstance() || window_name.empty())
120 return;
122 ViewsDelegate::GetInstance()->SaveWindowPlacement(GetWidget(), window_name,
123 bounds, show_state);
126 bool WidgetDelegate::GetSavedWindowPlacement(
127 const Widget* widget,
128 gfx::Rect* bounds,
129 ui::WindowShowState* show_state) const {
130 std::string window_name = GetWindowName();
131 if (!ViewsDelegate::GetInstance() || window_name.empty())
132 return false;
134 return ViewsDelegate::GetInstance()->GetSavedWindowPlacement(
135 widget, window_name, bounds, show_state);
138 bool WidgetDelegate::ShouldRestoreWindowSize() const {
139 return true;
142 View* WidgetDelegate::GetContentsView() {
143 if (!default_contents_view_)
144 default_contents_view_ = new View;
145 return default_contents_view_;
148 ClientView* WidgetDelegate::CreateClientView(Widget* widget) {
149 return new ClientView(widget, GetContentsView());
152 NonClientFrameView* WidgetDelegate::CreateNonClientFrameView(Widget* widget) {
153 return NULL;
156 View* WidgetDelegate::CreateOverlayView() {
157 return NULL;
160 bool WidgetDelegate::WillProcessWorkAreaChange() const {
161 return false;
164 bool WidgetDelegate::WidgetHasHitTestMask() const {
165 return false;
168 void WidgetDelegate::GetWidgetHitTestMask(gfx::Path* mask) const {
169 DCHECK(mask);
172 bool WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() const {
173 return false;
176 bool WidgetDelegate::ShouldDescendIntoChildForEventHandling(
177 gfx::NativeView child,
178 const gfx::Point& location) {
179 return true;
182 ////////////////////////////////////////////////////////////////////////////////
183 // WidgetDelegateView:
185 // static
186 const char WidgetDelegateView::kViewClassName[] = "WidgetDelegateView";
188 WidgetDelegateView::WidgetDelegateView() {
189 // A WidgetDelegate should be deleted on DeleteDelegate.
190 set_owned_by_client();
193 WidgetDelegateView::~WidgetDelegateView() {
196 void WidgetDelegateView::DeleteDelegate() {
197 delete this;
200 Widget* WidgetDelegateView::GetWidget() {
201 return View::GetWidget();
204 const Widget* WidgetDelegateView::GetWidget() const {
205 return View::GetWidget();
208 const char* WidgetDelegateView::GetClassName() const {
209 return kViewClassName;
212 } // namespace views