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

Side by Side Diff: ash/wm/window_state.cc

Issue 101013002: Make sure WindowObservers are removed from window before destruction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/wm/window_state.h" 5 #include "ash/wm/window_state.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 window_show_type_ = ToWindowShowType(GetShowState()); 272 window_show_type_ = ToWindowShowType(GetShowState());
273 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old); 273 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old);
274 // TODO(oshima): Notify only when the state has changed. 274 // TODO(oshima): Notify only when the state has changed.
275 // Doing so break a few tests now. 275 // Doing so break a few tests now.
276 FOR_EACH_OBSERVER( 276 FOR_EACH_OBSERVER(
277 WindowStateObserver, observer_list_, 277 WindowStateObserver, observer_list_,
278 OnWindowShowTypeChanged(this, ToWindowShowType(old_state))); 278 OnWindowShowTypeChanged(this, ToWindowShowType(old_state)));
279 } 279 }
280 } 280 }
281 281
282 void WindowState::OnWindowDestroying(aura::Window* window) {
283 window_->RemoveObserver(this);
284 }
285
286 void WindowState::SnapWindow(WindowShowType left_or_right, 282 void WindowState::SnapWindow(WindowShowType left_or_right,
287 const gfx::Rect& bounds) { 283 const gfx::Rect& bounds) {
288 // Compute the bounds that the window will restore to. If the window does not 284 // Compute the bounds that the window will restore to. If the window does not
289 // already have restore bounds, it will be restored (when un-snapped) to the 285 // already have restore bounds, it will be restored (when un-snapped) to the
290 // last bounds that it had before getting snapped. 286 // last bounds that it had before getting snapped.
291 gfx::Rect restore_bounds_in_screen(HasRestoreBounds() ? 287 gfx::Rect restore_bounds_in_screen(HasRestoreBounds() ?
292 GetRestoreBoundsInScreen() : window_->GetBoundsInScreen()); 288 GetRestoreBoundsInScreen() : window_->GetBoundsInScreen());
293 // Set the window's restore bounds so that WorkspaceLayoutManager knows 289 // Set the window's restore bounds so that WorkspaceLayoutManager knows
294 // which width to use when the snapped window is moved to the edge. 290 // which width to use when the snapped window is moved to the edge.
295 SetRestoreBoundsInParent(bounds); 291 SetRestoreBoundsInParent(bounds);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 331 }
336 return settings; 332 return settings;
337 } 333 }
338 334
339 const WindowState* GetWindowState(const aura::Window* window) { 335 const WindowState* GetWindowState(const aura::Window* window) {
340 return GetWindowState(const_cast<aura::Window*>(window)); 336 return GetWindowState(const_cast<aura::Window*>(window));
341 } 337 }
342 338
343 } // namespace wm 339 } // namespace wm
344 } // namespace ash 340 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698