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

Side by Side Diff: ash/root_window_controller.cc

Issue 25736004: Fixes use after free caused by delete in RootWindowController (2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Shutdown Created 7 years, 2 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 | « no previous file | ash/root_window_controller_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 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 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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_constants.h" 10 #include "ash/ash_constants.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (shelf_->shelf_layout_manager()) 430 if (shelf_->shelf_layout_manager())
431 shelf_->shelf_layout_manager()->PrepareForShutdown(); 431 shelf_->shelf_layout_manager()->PrepareForShutdown();
432 432
433 // Close background widget first as it depends on tooltip. 433 // Close background widget first as it depends on tooltip.
434 wallpaper_controller_.reset(); 434 wallpaper_controller_.reset();
435 animating_wallpaper_controller_.reset(); 435 animating_wallpaper_controller_.reset();
436 436
437 workspace_controller_.reset(); 437 workspace_controller_.reset();
438 aura::client::SetTooltipClient(root_window_.get(), NULL); 438 aura::client::SetTooltipClient(root_window_.get(), NULL);
439 439
440 // Remove all toplevel windows first. 440 // Explicitly destroy top level windows. We do this as during part of
441 // destruction such windows may query the RootWindow for state.
441 std::queue<aura::Window*> non_toplevel_windows; 442 std::queue<aura::Window*> non_toplevel_windows;
442 non_toplevel_windows.push(root_window_.get()); 443 non_toplevel_windows.push(root_window_.get());
443 while (!non_toplevel_windows.empty()) { 444 while (!non_toplevel_windows.empty()) {
444 aura::Window* non_toplevel_window = non_toplevel_windows.front(); 445 aura::Window* non_toplevel_window = non_toplevel_windows.front();
445 non_toplevel_windows.pop(); 446 non_toplevel_windows.pop();
446 aura::WindowTracker toplevel_windows; 447 aura::WindowTracker toplevel_windows;
447 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { 448 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) {
448 aura::Window* child = non_toplevel_window->children()[i]; 449 aura::Window* child = non_toplevel_window->children()[i];
450 if (!child->owned_by_parent())
451 continue;
449 if (child->delegate()) 452 if (child->delegate())
450 toplevel_windows.Add(child); 453 toplevel_windows.Add(child);
451 else 454 else
452 non_toplevel_windows.push(child); 455 non_toplevel_windows.push(child);
453 } 456 }
454 while (!toplevel_windows.windows().empty()) 457 while (!toplevel_windows.windows().empty())
455 delete *toplevel_windows.windows().begin(); 458 delete *toplevel_windows.windows().begin();
456 } 459 }
457 // And then remove the containers. 460 // And then remove the containers.
458 while (!root_window_->children().empty()) 461 while (!root_window_->children().empty()) {
459 delete root_window_->children()[0]; 462 aura::Window* window = root_window_->children()[0];
463 if (window->owned_by_parent()) {
464 delete window;
465 } else {
466 root_window_->RemoveChild(window);
467 }
468 }
460 469
461 shelf_.reset(NULL); 470 shelf_.reset(NULL);
462 } 471 }
463 472
464 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) { 473 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) {
465 // Forget the shelf early so that shelf don't update itself using wrong 474 // Forget the shelf early so that shelf don't update itself using wrong
466 // display info. 475 // display info.
467 workspace_controller_->SetShelf(NULL); 476 workspace_controller_->SetShelf(NULL);
468 ReparentAllWindows(root_window_.get(), dst); 477 ReparentAllWindows(root_window_.get(), dst);
469 } 478 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 DisableTouchHudProjection(); 837 DisableTouchHudProjection();
829 } 838 }
830 839
831 RootWindowController* GetRootWindowController( 840 RootWindowController* GetRootWindowController(
832 const aura::RootWindow* root_window) { 841 const aura::RootWindow* root_window) {
833 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; 842 return root_window ? GetRootWindowSettings(root_window)->controller : NULL;
834 } 843 }
835 844
836 } // namespace internal 845 } // namespace internal
837 } // namespace ash 846 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698