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

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

Issue 7075019: Move a bunch of functions from Window onto Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months 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 | « views/window/window.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/window/window.h" 5 #include "views/window/window.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/base/l10n/l10n_font_util.h" 10 #include "ui/base/l10n/l10n_font_util.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 gfx::Rect Window::GetNormalBounds() const { 106 gfx::Rect Window::GetNormalBounds() const {
107 return native_window_->GetRestoredBounds(); 107 return native_window_->GetRestoredBounds();
108 } 108 }
109 109
110 void Window::SetWindowBounds(const gfx::Rect& bounds, 110 void Window::SetWindowBounds(const gfx::Rect& bounds,
111 gfx::NativeWindow other_window) { 111 gfx::NativeWindow other_window) {
112 native_window_->SetWindowBounds(bounds, other_window); 112 native_window_->SetWindowBounds(bounds, other_window);
113 } 113 }
114 114
115 void Window::Show() {
116 native_window_->ShowNativeWindow(
117 saved_maximized_state_ ? NativeWindow::SHOW_MAXIMIZED
118 : NativeWindow::SHOW_RESTORED);
119 // |saved_maximized_state_| only applies the first time the window is shown.
120 // If we don't reset the value the window will be shown maximized every time
121 // it is subsequently shown after being hidden.
122 saved_maximized_state_ = false;
123 }
124
125 void Window::ShowInactive() { 115 void Window::ShowInactive() {
126 native_window_->ShowNativeWindow(NativeWindow::SHOW_INACTIVE); 116 native_window_->ShowNativeWindow(NativeWindow::SHOW_INACTIVE);
127 } 117 }
128 118
129 void Window::HideWindow() {
130 native_window_->HideWindow();
131 }
132
133 void Window::DisableInactiveRendering() { 119 void Window::DisableInactiveRendering() {
134 disable_inactive_rendering_ = true; 120 disable_inactive_rendering_ = true;
135 non_client_view_->DisableInactiveRendering(disable_inactive_rendering_); 121 non_client_view_->DisableInactiveRendering(disable_inactive_rendering_);
136 } 122 }
137 123
138 void Window::Activate() {
139 native_window_->Activate();
140 }
141
142 void Window::Deactivate() {
143 native_window_->Deactivate();
144 }
145
146 void Window::Close() {
147 if (window_closed_) {
148 // It appears we can hit this code path if you close a modal dialog then
149 // close the last browser before the destructor is hit, which triggers
150 // invoking Close again.
151 return;
152 }
153
154 if (non_client_view_->CanClose()) {
155 SaveWindowPosition();
156 Widget::Close();
157 window_closed_ = true;
158 }
159 }
160
161 void Window::Maximize() {
162 native_window_->Maximize();
163 }
164
165 void Window::Minimize() {
166 native_window_->Minimize();
167 }
168
169 void Window::Restore() {
170 native_window_->Restore();
171 }
172
173 bool Window::IsActive() const {
174 return native_window_->IsActive();
175 }
176
177 bool Window::IsVisible() const {
178 return native_window_->IsVisible();
179 }
180
181 bool Window::IsMaximized() const {
182 return native_window_->IsMaximized();
183 }
184
185 bool Window::IsMinimized() const {
186 return native_window_->IsMinimized();
187 }
188
189 void Window::SetFullscreen(bool fullscreen) { 124 void Window::SetFullscreen(bool fullscreen) {
190 native_window_->SetFullscreen(fullscreen); 125 native_window_->SetFullscreen(fullscreen);
191 } 126 }
192 127
193 bool Window::IsFullscreen() const { 128 bool Window::IsFullscreen() const {
194 return native_window_->IsFullscreen(); 129 return native_window_->IsFullscreen();
195 } 130 }
196 131
197 void Window::SetUseDragFrame(bool use_drag_frame) { 132 void Window::SetUseDragFrame(bool use_drag_frame) {
198 native_window_->SetUseDragFrame(use_drag_frame); 133 native_window_->SetUseDragFrame(use_drag_frame);
(...skipping 19 matching lines...) Expand all
218 base::i18n::AdjustStringForLocaleDirection(&window_title); 153 base::i18n::AdjustStringForLocaleDirection(&window_title);
219 native_window_->SetWindowTitle(UTF16ToWide(window_title)); 154 native_window_->SetWindowTitle(UTF16ToWide(window_title));
220 } 155 }
221 156
222 void Window::UpdateWindowIcon() { 157 void Window::UpdateWindowIcon() {
223 non_client_view_->UpdateWindowIcon(); 158 non_client_view_->UpdateWindowIcon();
224 native_window_->SetWindowIcons(window_delegate_->GetWindowIcon(), 159 native_window_->SetWindowIcons(window_delegate_->GetWindowIcon(),
225 window_delegate_->GetWindowAppIcon()); 160 window_delegate_->GetWindowAppIcon());
226 } 161 }
227 162
228 void Window::SetIsAlwaysOnTop(bool always_on_top) {
229 native_window_->SetAlwaysOnTop(always_on_top);
230 }
231
232 NonClientFrameView* Window::CreateFrameViewForWindow() { 163 NonClientFrameView* Window::CreateFrameViewForWindow() {
233 NonClientFrameView* frame_view = native_window_->CreateFrameViewForWindow(); 164 NonClientFrameView* frame_view = native_window_->CreateFrameViewForWindow();
234 return frame_view ? frame_view : new CustomFrameView(this); 165 return frame_view ? frame_view : new CustomFrameView(this);
235 } 166 }
236 167
237 void Window::UpdateFrameAfterFrameChange() { 168 void Window::UpdateFrameAfterFrameChange() {
238 native_window_->UpdateFrameAfterFrameChange(); 169 native_window_->UpdateFrameAfterFrameChange();
239 } 170 }
240 171
241 gfx::NativeWindow Window::GetNativeWindow() const {
242 return native_window_->GetNativeWindow();
243 }
244
245 bool Window::ShouldUseNativeFrame() const { 172 bool Window::ShouldUseNativeFrame() const {
246 if (frame_type_ != FRAME_TYPE_DEFAULT) 173 if (frame_type_ != FRAME_TYPE_DEFAULT)
247 return frame_type_ == FRAME_TYPE_FORCE_NATIVE; 174 return frame_type_ == FRAME_TYPE_FORCE_NATIVE;
248 return native_window_->ShouldUseNativeFrame(); 175 return native_window_->ShouldUseNativeFrame();
249 } 176 }
250 177
251 void Window::DebugToggleFrameType() { 178 void Window::DebugToggleFrameType() {
252 if (frame_type_ == FRAME_TYPE_DEFAULT) { 179 if (frame_type_ == FRAME_TYPE_DEFAULT) {
253 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM : 180 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM :
254 FRAME_TYPE_FORCE_NATIVE; 181 FRAME_TYPE_FORCE_NATIVE;
255 } else { 182 } else {
256 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ? 183 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ?
257 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM; 184 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM;
258 } 185 }
259 FrameTypeChanged(); 186 FrameTypeChanged();
260 } 187 }
261 188
262 void Window::FrameTypeChanged() { 189 void Window::FrameTypeChanged() {
263 native_window_->FrameTypeChanged(); 190 native_window_->FrameTypeChanged();
264 } 191 }
265 192
266 //////////////////////////////////////////////////////////////////////////////// 193 ////////////////////////////////////////////////////////////////////////////////
194 // Window, Widget overrides:
195
196 void Window::Show() {
197 native_window_->ShowNativeWindow(
198 saved_maximized_state_ ? NativeWindow::SHOW_MAXIMIZED
199 : NativeWindow::SHOW_RESTORED);
200 // |saved_maximized_state_| only applies the first time the window is shown.
201 // If we don't reset the value the window will be shown maximized every time
202 // it is subsequently shown after being hidden.
203 saved_maximized_state_ = false;
204 }
205
206 void Window::Close() {
207 if (window_closed_) {
208 // It appears we can hit this code path if you close a modal dialog then
209 // close the last browser before the destructor is hit, which triggers
210 // invoking Close again.
211 return;
212 }
213
214 if (non_client_view_->CanClose()) {
215 SaveWindowPosition();
216 Widget::Close();
217 window_closed_ = true;
218 }
219 }
220
221 ////////////////////////////////////////////////////////////////////////////////
267 // Window, internal::NativeWindowDelegate implementation: 222 // Window, internal::NativeWindowDelegate implementation:
268 223
269 bool Window::CanActivate() const { 224 bool Window::CanActivate() const {
270 return window_delegate_->CanActivate(); 225 return window_delegate_->CanActivate();
271 } 226 }
272 227
273 bool Window::IsInactiveRenderingDisabled() const { 228 bool Window::IsInactiveRenderingDisabled() const {
274 return disable_inactive_rendering_; 229 return disable_inactive_rendering_;
275 } 230 }
276 231
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (!window_delegate_) 365 if (!window_delegate_)
411 return; 366 return;
412 367
413 bool maximized; 368 bool maximized;
414 gfx::Rect bounds; 369 gfx::Rect bounds;
415 native_window_->GetWindowBoundsAndMaximizedState(&bounds, &maximized); 370 native_window_->GetWindowBoundsAndMaximizedState(&bounds, &maximized);
416 window_delegate_->SaveWindowPlacement(bounds, maximized); 371 window_delegate_->SaveWindowPlacement(bounds, maximized);
417 } 372 }
418 373
419 } // namespace views 374 } // namespace views
OLDNEW
« no previous file with comments | « views/window/window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698