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

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

Issue 6976040: Revert 86914 - Move a bunch of functions from Window onto Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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
115 void Window::ShowInactive() { 125 void Window::ShowInactive() {
116 native_window_->ShowNativeWindow(NativeWindow::SHOW_INACTIVE); 126 native_window_->ShowNativeWindow(NativeWindow::SHOW_INACTIVE);
117 } 127 }
118 128
129 void Window::HideWindow() {
130 native_window_->HideWindow();
131 }
132
119 void Window::DisableInactiveRendering() { 133 void Window::DisableInactiveRendering() {
120 disable_inactive_rendering_ = true; 134 disable_inactive_rendering_ = true;
121 non_client_view_->DisableInactiveRendering(disable_inactive_rendering_); 135 non_client_view_->DisableInactiveRendering(disable_inactive_rendering_);
122 } 136 }
123 137
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
124 void Window::SetFullscreen(bool fullscreen) { 189 void Window::SetFullscreen(bool fullscreen) {
125 native_window_->SetFullscreen(fullscreen); 190 native_window_->SetFullscreen(fullscreen);
126 } 191 }
127 192
128 bool Window::IsFullscreen() const { 193 bool Window::IsFullscreen() const {
129 return native_window_->IsFullscreen(); 194 return native_window_->IsFullscreen();
130 } 195 }
131 196
132 void Window::SetUseDragFrame(bool use_drag_frame) { 197 void Window::SetUseDragFrame(bool use_drag_frame) {
133 native_window_->SetUseDragFrame(use_drag_frame); 198 native_window_->SetUseDragFrame(use_drag_frame);
(...skipping 19 matching lines...) Expand all
153 base::i18n::AdjustStringForLocaleDirection(&window_title); 218 base::i18n::AdjustStringForLocaleDirection(&window_title);
154 native_window_->SetWindowTitle(UTF16ToWide(window_title)); 219 native_window_->SetWindowTitle(UTF16ToWide(window_title));
155 } 220 }
156 221
157 void Window::UpdateWindowIcon() { 222 void Window::UpdateWindowIcon() {
158 non_client_view_->UpdateWindowIcon(); 223 non_client_view_->UpdateWindowIcon();
159 native_window_->SetWindowIcons(window_delegate_->GetWindowIcon(), 224 native_window_->SetWindowIcons(window_delegate_->GetWindowIcon(),
160 window_delegate_->GetWindowAppIcon()); 225 window_delegate_->GetWindowAppIcon());
161 } 226 }
162 227
228 void Window::SetIsAlwaysOnTop(bool always_on_top) {
229 native_window_->SetAlwaysOnTop(always_on_top);
230 }
231
163 NonClientFrameView* Window::CreateFrameViewForWindow() { 232 NonClientFrameView* Window::CreateFrameViewForWindow() {
164 NonClientFrameView* frame_view = native_window_->CreateFrameViewForWindow(); 233 NonClientFrameView* frame_view = native_window_->CreateFrameViewForWindow();
165 return frame_view ? frame_view : new CustomFrameView(this); 234 return frame_view ? frame_view : new CustomFrameView(this);
166 } 235 }
167 236
168 void Window::UpdateFrameAfterFrameChange() { 237 void Window::UpdateFrameAfterFrameChange() {
169 native_window_->UpdateFrameAfterFrameChange(); 238 native_window_->UpdateFrameAfterFrameChange();
170 } 239 }
171 240
241 gfx::NativeWindow Window::GetNativeWindow() const {
242 return native_window_->GetNativeWindow();
243 }
244
172 bool Window::ShouldUseNativeFrame() const { 245 bool Window::ShouldUseNativeFrame() const {
173 if (frame_type_ != FRAME_TYPE_DEFAULT) 246 if (frame_type_ != FRAME_TYPE_DEFAULT)
174 return frame_type_ == FRAME_TYPE_FORCE_NATIVE; 247 return frame_type_ == FRAME_TYPE_FORCE_NATIVE;
175 return native_window_->ShouldUseNativeFrame(); 248 return native_window_->ShouldUseNativeFrame();
176 } 249 }
177 250
178 void Window::DebugToggleFrameType() { 251 void Window::DebugToggleFrameType() {
179 if (frame_type_ == FRAME_TYPE_DEFAULT) { 252 if (frame_type_ == FRAME_TYPE_DEFAULT) {
180 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM : 253 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM :
181 FRAME_TYPE_FORCE_NATIVE; 254 FRAME_TYPE_FORCE_NATIVE;
182 } else { 255 } else {
183 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ? 256 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ?
184 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM; 257 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM;
185 } 258 }
186 FrameTypeChanged(); 259 FrameTypeChanged();
187 } 260 }
188 261
189 void Window::FrameTypeChanged() { 262 void Window::FrameTypeChanged() {
190 native_window_->FrameTypeChanged(); 263 native_window_->FrameTypeChanged();
191 } 264 }
192 265
193 //////////////////////////////////////////////////////////////////////////////// 266 ////////////////////////////////////////////////////////////////////////////////
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 ////////////////////////////////////////////////////////////////////////////////
222 // Window, internal::NativeWindowDelegate implementation: 267 // Window, internal::NativeWindowDelegate implementation:
223 268
224 bool Window::CanActivate() const { 269 bool Window::CanActivate() const {
225 return window_delegate_->CanActivate(); 270 return window_delegate_->CanActivate();
226 } 271 }
227 272
228 bool Window::IsInactiveRenderingDisabled() const { 273 bool Window::IsInactiveRenderingDisabled() const {
229 return disable_inactive_rendering_; 274 return disable_inactive_rendering_;
230 } 275 }
231 276
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (!window_delegate_) 410 if (!window_delegate_)
366 return; 411 return;
367 412
368 bool maximized; 413 bool maximized;
369 gfx::Rect bounds; 414 gfx::Rect bounds;
370 native_window_->GetWindowBoundsAndMaximizedState(&bounds, &maximized); 415 native_window_->GetWindowBoundsAndMaximizedState(&bounds, &maximized);
371 window_delegate_->SaveWindowPlacement(bounds, maximized); 416 window_delegate_->SaveWindowPlacement(bounds, maximized);
372 } 417 }
373 418
374 } // namespace views 419 } // 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