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