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

Side by Side Diff: ash/shell.cc

Issue 9535025: Remove the singleton instance get/delete methods from RootWindow (yay) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | « ash/shell.h ('k') | ash/shell/shell_main.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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/app_list/app_list.h" 9 #include "ash/app_list/app_list.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 264
265 internal::WorkspaceController* Shell::TestApi::workspace_controller() { 265 internal::WorkspaceController* Shell::TestApi::workspace_controller() {
266 return shell_->workspace_controller_.get(); 266 return shell_->workspace_controller_.get();
267 } 267 }
268 268
269 //////////////////////////////////////////////////////////////////////////////// 269 ////////////////////////////////////////////////////////////////////////////////
270 // Shell, public: 270 // Shell, public:
271 271
272 Shell::Shell(ShellDelegate* delegate) 272 Shell::Shell(ShellDelegate* delegate)
273 : root_filter_(new internal::RootWindowEventFilter), 273 : root_window_(new aura::RootWindow),
274 #if !defined(OS_MACOSX)
275 nested_dispatcher_controller_(new NestedDispatcherController),
276 accelerator_controller_(new AcceleratorController),
277 #endif
278 delegate_(delegate), 274 delegate_(delegate),
279 audio_controller_(NULL), 275 audio_controller_(NULL),
280 brightness_controller_(NULL), 276 brightness_controller_(NULL),
281 shelf_(NULL), 277 shelf_(NULL),
282 window_mode_(MODE_OVERLAPPING), 278 window_mode_(MODE_OVERLAPPING),
283 desktop_background_mode_(BACKGROUND_IMAGE), 279 desktop_background_mode_(BACKGROUND_IMAGE),
284 root_window_layout_(NULL), 280 root_window_layout_(NULL),
285 status_widget_(NULL) { 281 status_widget_(NULL) {
286 // Pass ownership of the filter to the root window.
287 GetRootWindow()->SetEventFilter(root_filter_);
288 } 282 }
289 283
290 Shell::~Shell() { 284 Shell::~Shell() {
291 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); 285 RemoveRootWindowEventFilter(partial_screenshot_filter_.get());
292 RemoveRootWindowEventFilter(input_method_filter_.get()); 286 RemoveRootWindowEventFilter(input_method_filter_.get());
293 RemoveRootWindowEventFilter(window_modality_controller_.get()); 287 RemoveRootWindowEventFilter(window_modality_controller_.get());
294 #if !defined(OS_MACOSX) 288 #if !defined(OS_MACOSX)
295 RemoveRootWindowEventFilter(accelerator_filter_.get()); 289 RemoveRootWindowEventFilter(accelerator_filter_.get());
296 #endif 290 #endif
297 291
(...skipping 15 matching lines...) Expand all
313 // Delete containers now so that child windows does not access 307 // Delete containers now so that child windows does not access
314 // observers when they are destructed. 308 // observers when they are destructed.
315 aura::RootWindow* root_window = GetRootWindow(); 309 aura::RootWindow* root_window = GetRootWindow();
316 while (!root_window->children().empty()) { 310 while (!root_window->children().empty()) {
317 aura::Window* child = root_window->children()[0]; 311 aura::Window* child = root_window->children()[0];
318 delete child; 312 delete child;
319 } 313 }
320 314
321 // These need a valid Shell instance to clean up properly, so explicitly 315 // These need a valid Shell instance to clean up properly, so explicitly
322 // delete them before invalidating the instance. 316 // delete them before invalidating the instance.
317 // Alphabetical.
318 activation_controller_.reset();
323 drag_drop_controller_.reset(); 319 drag_drop_controller_.reset();
320 shadow_controller_.reset();
324 window_cycle_controller_.reset(); 321 window_cycle_controller_.reset();
325 322
326 // Launcher widget has a InputMethodBridge that references to 323 // Launcher widget has a InputMethodBridge that references to
327 // input_method_filter_'s input_method_. So explicitly release launcher_ 324 // input_method_filter_'s input_method_. So explicitly release launcher_
328 // before input_method_filter_. And this needs to be after we delete all 325 // before input_method_filter_. And this needs to be after we delete all
329 // containers in case there are still live browser windows which access 326 // containers in case there are still live browser windows which access
330 // LauncherModel during close. 327 // LauncherModel during close.
331 launcher_.reset(); 328 launcher_.reset();
332 329
333 DCHECK(instance_ == this); 330 DCHECK(instance_ == this);
(...skipping 15 matching lines...) Expand all
349 } 346 }
350 347
351 // static 348 // static
352 void Shell::DeleteInstance() { 349 void Shell::DeleteInstance() {
353 delete instance_; 350 delete instance_;
354 instance_ = NULL; 351 instance_ = NULL;
355 } 352 }
356 353
357 // static 354 // static
358 aura::RootWindow* Shell::GetRootWindow() { 355 aura::RootWindow* Shell::GetRootWindow() {
359 return aura::RootWindow::GetInstance(); 356 return GetInstance()->root_window_.get();
360 } 357 }
361 358
362 void Shell::Init() { 359 void Shell::Init() {
360 root_filter_ = new internal::RootWindowEventFilter;
361 #if !defined(OS_MACOSX)
362 nested_dispatcher_controller_.reset(new NestedDispatcherController);
363 accelerator_controller_.reset(new AcceleratorController);
364 #endif
365 // Pass ownership of the filter to the root window.
366 GetRootWindow()->SetEventFilter(root_filter_);
367
363 DCHECK(!GetRootWindowEventFilterCount()); 368 DCHECK(!GetRootWindowEventFilterCount());
364 369
365 // PartialScreenshotEventFilter must be the first one to capture key 370 // PartialScreenshotEventFilter must be the first one to capture key
366 // events when the taking partial screenshot UI is there. 371 // events when the taking partial screenshot UI is there.
367 partial_screenshot_filter_.reset(new internal::PartialScreenshotEventFilter); 372 partial_screenshot_filter_.reset(new internal::PartialScreenshotEventFilter);
368 AddRootWindowEventFilter(partial_screenshot_filter_.get()); 373 AddRootWindowEventFilter(partial_screenshot_filter_.get());
369 374
370 // Then AcceleratorFilter and InputMethodEventFilter must be added (in this 375 // Then AcceleratorFilter and InputMethodEventFilter must be added (in this
371 // order) since they have the second highest priority. 376 // order) since they have the second highest priority.
372 DCHECK_EQ(1U, GetRootWindowEventFilterCount()); 377 DCHECK_EQ(1U, GetRootWindowEventFilterCount());
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 660
656 // Create the desktop background image. 661 // Create the desktop background image.
657 SetDesktopBackgroundMode(BACKGROUND_IMAGE); 662 SetDesktopBackgroundMode(BACKGROUND_IMAGE);
658 } 663 }
659 664
660 void Shell::ResetLayoutManager(int container_id) { 665 void Shell::ResetLayoutManager(int container_id) {
661 GetContainer(container_id)->SetLayoutManager(NULL); 666 GetContainer(container_id)->SetLayoutManager(NULL);
662 } 667 }
663 668
664 } // namespace ash 669 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.h ('k') | ash/shell/shell_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698