Correct blacklist entry message
[chromium-blink-merge.git] / ui / views / widget / widget_delegate.cc
blobfbace27c316a297e2e82a4e5783fe91293c8a2ef
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() : default_contents_view_(NULL) {
23 void WidgetDelegate::OnWidgetMove() {
26 void WidgetDelegate::OnDisplayChanged() {
29 void WidgetDelegate::OnWorkAreaChanged() {
32 View* WidgetDelegate::GetInitiallyFocusedView() {
33 return NULL;
36 BubbleDelegateView* WidgetDelegate::AsBubbleDelegate() {
37 return NULL;
40 DialogDelegate* WidgetDelegate::AsDialogDelegate() {
41 return NULL;
44 bool WidgetDelegate::CanResize() const {
45 return false;
48 bool WidgetDelegate::CanMaximize() const {
49 return false;
52 bool WidgetDelegate::CanActivate() const {
53 return true;
56 ui::ModalType WidgetDelegate::GetModalType() const {
57 return ui::MODAL_TYPE_NONE;
60 ui::AccessibilityTypes::Role WidgetDelegate::GetAccessibleWindowRole() const {
61 return ui::AccessibilityTypes::ROLE_WINDOW;
64 string16 WidgetDelegate::GetAccessibleWindowTitle() const {
65 return GetWindowTitle();
68 string16 WidgetDelegate::GetWindowTitle() const {
69 return string16();
72 bool WidgetDelegate::ShouldShowWindowTitle() const {
73 return true;
76 bool WidgetDelegate::ShouldShowCloseButton() const {
77 return true;
80 bool WidgetDelegate::ShouldHandleSystemCommands() const {
81 const Widget* widget = GetWidget();
82 if (!widget)
83 return false;
85 return widget->non_client_view() != NULL;
88 gfx::ImageSkia WidgetDelegate::GetWindowAppIcon() {
89 // Use the window icon as app icon by default.
90 return GetWindowIcon();
93 // Returns the icon to be displayed in the window.
94 gfx::ImageSkia WidgetDelegate::GetWindowIcon() {
95 return gfx::ImageSkia();
98 bool WidgetDelegate::ShouldShowWindowIcon() const {
99 return false;
102 bool WidgetDelegate::ExecuteWindowsCommand(int command_id) {
103 return false;
106 std::string WidgetDelegate::GetWindowName() const {
107 return std::string();
110 void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds,
111 ui::WindowShowState show_state) {
112 std::string window_name = GetWindowName();
113 if (!ViewsDelegate::views_delegate || window_name.empty())
114 return;
116 ViewsDelegate::views_delegate->SaveWindowPlacement(
117 GetWidget(), window_name, bounds, show_state);
120 bool WidgetDelegate::GetSavedWindowPlacement(
121 const Widget* widget,
122 gfx::Rect* bounds,
123 ui::WindowShowState* show_state) const {
124 std::string window_name = GetWindowName();
125 if (!ViewsDelegate::views_delegate || window_name.empty())
126 return false;
128 return ViewsDelegate::views_delegate->GetSavedWindowPlacement(
129 widget, window_name, bounds, show_state);
132 bool WidgetDelegate::ShouldRestoreWindowSize() const {
133 return true;
136 View* WidgetDelegate::GetContentsView() {
137 if (!default_contents_view_)
138 default_contents_view_ = new View;
139 return default_contents_view_;
142 ClientView* WidgetDelegate::CreateClientView(Widget* widget) {
143 return new ClientView(widget, GetContentsView());
146 NonClientFrameView* WidgetDelegate::CreateNonClientFrameView(Widget* widget) {
147 return NULL;
150 View* WidgetDelegate::CreateOverlayView() {
151 return NULL;
154 bool WidgetDelegate::WillProcessWorkAreaChange() const {
155 return false;
158 bool WidgetDelegate::WidgetHasHitTestMask() const {
159 return false;
162 void WidgetDelegate::GetWidgetHitTestMask(gfx::Path* mask) const {
163 DCHECK(mask);
166 bool WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() const {
167 return false;
170 bool WidgetDelegate::ShouldDescendIntoChildForEventHandling(
171 gfx::NativeView child,
172 const gfx::Point& location) {
173 return true;
176 ////////////////////////////////////////////////////////////////////////////////
177 // WidgetDelegateView:
179 WidgetDelegateView::WidgetDelegateView() {
180 // A WidgetDelegate should be deleted on DeleteDelegate.
181 set_owned_by_client();
184 WidgetDelegateView::~WidgetDelegateView() {
187 void WidgetDelegateView::DeleteDelegate() {
188 delete this;
191 Widget* WidgetDelegateView::GetWidget() {
192 return View::GetWidget();
195 const Widget* WidgetDelegateView::GetWidget() const {
196 return View::GetWidget();
199 } // namespace views