[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / ui / views / widget / widget_delegate.cc
blob7e1f67e19c3bdfddfcd5917ba409016d83505692
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::CanActivate() const {
55 return can_activate_;
58 ui::ModalType WidgetDelegate::GetModalType() const {
59 return ui::MODAL_TYPE_NONE;
62 ui::AXRole WidgetDelegate::GetAccessibleWindowRole() const {
63 return ui::AX_ROLE_WINDOW;
66 base::string16 WidgetDelegate::GetAccessibleWindowTitle() const {
67 return GetWindowTitle();
70 base::string16 WidgetDelegate::GetWindowTitle() const {
71 return base::string16();
74 bool WidgetDelegate::ShouldShowWindowTitle() const {
75 return true;
78 bool WidgetDelegate::ShouldShowCloseButton() const {
79 return true;
82 bool WidgetDelegate::ShouldHandleSystemCommands() const {
83 const Widget* widget = GetWidget();
84 if (!widget)
85 return false;
87 return widget->non_client_view() != NULL;
90 gfx::ImageSkia WidgetDelegate::GetWindowAppIcon() {
91 // Use the window icon as app icon by default.
92 return GetWindowIcon();
95 // Returns the icon to be displayed in the window.
96 gfx::ImageSkia WidgetDelegate::GetWindowIcon() {
97 return gfx::ImageSkia();
100 bool WidgetDelegate::ShouldShowWindowIcon() const {
101 return false;
104 bool WidgetDelegate::ExecuteWindowsCommand(int command_id) {
105 return false;
108 std::string WidgetDelegate::GetWindowName() const {
109 return std::string();
112 void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds,
113 ui::WindowShowState show_state) {
114 std::string window_name = GetWindowName();
115 if (!ViewsDelegate::views_delegate || window_name.empty())
116 return;
118 ViewsDelegate::views_delegate->SaveWindowPlacement(
119 GetWidget(), window_name, bounds, show_state);
122 bool WidgetDelegate::GetSavedWindowPlacement(
123 const Widget* widget,
124 gfx::Rect* bounds,
125 ui::WindowShowState* show_state) const {
126 std::string window_name = GetWindowName();
127 if (!ViewsDelegate::views_delegate || window_name.empty())
128 return false;
130 return ViewsDelegate::views_delegate->GetSavedWindowPlacement(
131 widget, window_name, bounds, show_state);
134 bool WidgetDelegate::ShouldRestoreWindowSize() const {
135 return true;
138 View* WidgetDelegate::GetContentsView() {
139 if (!default_contents_view_)
140 default_contents_view_ = new View;
141 return default_contents_view_;
144 ClientView* WidgetDelegate::CreateClientView(Widget* widget) {
145 return new ClientView(widget, GetContentsView());
148 NonClientFrameView* WidgetDelegate::CreateNonClientFrameView(Widget* widget) {
149 return NULL;
152 View* WidgetDelegate::CreateOverlayView() {
153 return NULL;
156 bool WidgetDelegate::WillProcessWorkAreaChange() const {
157 return false;
160 bool WidgetDelegate::WidgetHasHitTestMask() const {
161 return false;
164 void WidgetDelegate::GetWidgetHitTestMask(gfx::Path* mask) const {
165 DCHECK(mask);
168 bool WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() const {
169 return false;
172 bool WidgetDelegate::ShouldDescendIntoChildForEventHandling(
173 gfx::NativeView child,
174 const gfx::Point& location) {
175 return true;
178 ////////////////////////////////////////////////////////////////////////////////
179 // WidgetDelegateView:
181 WidgetDelegateView::WidgetDelegateView() {
182 // A WidgetDelegate should be deleted on DeleteDelegate.
183 set_owned_by_client();
186 WidgetDelegateView::~WidgetDelegateView() {
189 void WidgetDelegateView::DeleteDelegate() {
190 delete this;
193 Widget* WidgetDelegateView::GetWidget() {
194 return View::GetWidget();
197 const Widget* WidgetDelegateView::GetWidget() const {
198 return View::GetWidget();
201 } // namespace views