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 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/accelerators/focus_manager_factory.h" | 10 #include "ash/accelerators/focus_manager_factory.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 RemovePreTargetHandler(mouse_cursor_filter_.get()); | 252 RemovePreTargetHandler(mouse_cursor_filter_.get()); |
253 RemovePreTargetHandler(system_gesture_filter_.get()); | 253 RemovePreTargetHandler(system_gesture_filter_.get()); |
254 RemovePreTargetHandler(event_transformation_handler_.get()); | 254 RemovePreTargetHandler(event_transformation_handler_.get()); |
255 #if !defined(OS_MACOSX) | 255 #if !defined(OS_MACOSX) |
256 RemovePreTargetHandler(accelerator_filter_.get()); | 256 RemovePreTargetHandler(accelerator_filter_.get()); |
257 #endif | 257 #endif |
258 | 258 |
259 // TooltipController is deleted with the Shell so removing its references. | 259 // TooltipController is deleted with the Shell so removing its references. |
260 RemovePreTargetHandler(tooltip_controller_.get()); | 260 RemovePreTargetHandler(tooltip_controller_.get()); |
261 | 261 |
262 // AppList needs to be released before shelf layout manager, which is | 262 // AppList needs to clean up it dependency on Shell and closes its opened |
263 // destroyed with launcher container in the loop below. However, app list | 263 // UI (if any) before closing all RootWindows. However, the controller |
264 // container is now on top of launcher container and released after it. | 264 // instance is still needed so that sub views (e.g. app menu button on |
265 // TODO(xiyuan): Move it back when app list container is no longer needed. | 265 // the shelf) could properly clean up. |
266 app_list_controller_.reset(); | 266 app_list_controller_->Shutdown(); |
267 | 267 |
268 // Destroy SystemTrayDelegate before destroying the status area(s). | 268 // Destroy SystemTrayDelegate before destroying the status area(s). |
269 system_tray_delegate_->Shutdown(); | 269 system_tray_delegate_->Shutdown(); |
270 system_tray_delegate_.reset(); | 270 system_tray_delegate_.reset(); |
271 | 271 |
272 // Destroy all child windows including widgets. | 272 // Destroy all child windows including widgets. |
273 display_controller_->CloseChildWindows(); | 273 display_controller_->CloseChildWindows(); |
274 | 274 |
275 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems | 275 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
276 // needs to remove observers from it. | 276 // needs to remove observers from it. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 } | 579 } |
580 | 580 |
581 // Create system_tray_notifier_ before the delegate. | 581 // Create system_tray_notifier_ before the delegate. |
582 system_tray_notifier_.reset(new ash::SystemTrayNotifier()); | 582 system_tray_notifier_.reset(new ash::SystemTrayNotifier()); |
583 | 583 |
584 // Initialize system_tray_delegate_ before initializing StatusAreaWidget. | 584 // Initialize system_tray_delegate_ before initializing StatusAreaWidget. |
585 system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); | 585 system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); |
586 if (!system_tray_delegate_) | 586 if (!system_tray_delegate_) |
587 system_tray_delegate_.reset(SystemTrayDelegate::CreateDummyDelegate()); | 587 system_tray_delegate_.reset(SystemTrayDelegate::CreateDummyDelegate()); |
588 | 588 |
| 589 // Creates app_list_controller_ before the launcher because app list |
| 590 // button observes it for UI visibility. |
| 591 app_list_controller_.reset(new internal::AppListController(this)); |
| 592 |
589 // Creates StatusAreaWidget. | 593 // Creates StatusAreaWidget. |
590 root_window_controller->InitForPrimaryDisplay(); | 594 root_window_controller->InitForPrimaryDisplay(); |
591 | 595 |
592 // Initialize system_tray_delegate_ after StatusAreaWidget is created. | 596 // Initialize system_tray_delegate_ after StatusAreaWidget is created. |
593 system_tray_delegate_->Initialize(); | 597 system_tray_delegate_->Initialize(); |
594 | 598 |
595 display_controller_->InitSecondaryDisplays(); | 599 display_controller_->InitSecondaryDisplays(); |
596 | 600 |
597 // Force Layout | 601 // Force Layout |
598 root_window_controller->root_window_layout()->OnWindowResized(); | 602 root_window_controller->root_window_layout()->OnWindowResized(); |
(...skipping 30 matching lines...) Expand all Loading... |
629 // return the primary root). Investigate why/how this is | 633 // return the primary root). Investigate why/how this is |
630 // happening. crbug.com/165214. | 634 // happening. crbug.com/165214. |
631 internal::RootWindowController* rwc = GetRootWindowController(root); | 635 internal::RootWindowController* rwc = GetRootWindowController(root); |
632 CHECK(rwc) << "root=" << root | 636 CHECK(rwc) << "root=" << root |
633 << ", location:" << location_in_screen.ToString(); | 637 << ", location:" << location_in_screen.ToString(); |
634 if (rwc) | 638 if (rwc) |
635 rwc->ShowContextMenu(location_in_screen); | 639 rwc->ShowContextMenu(location_in_screen); |
636 } | 640 } |
637 | 641 |
638 void Shell::ToggleAppList(aura::Window* window) { | 642 void Shell::ToggleAppList(aura::Window* window) { |
639 // If the context window is not given, show it on the active root window. | 643 app_list_controller_->Toggle(window); |
640 if (!window) | |
641 window = GetActiveRootWindow(); | |
642 if (!app_list_controller_) | |
643 app_list_controller_.reset(new internal::AppListController); | |
644 app_list_controller_->SetVisible(!app_list_controller_->IsVisible(), window); | |
645 } | 644 } |
646 | 645 |
647 bool Shell::GetAppListTargetVisibility() const { | 646 bool Shell::GetAppListTargetVisibility() const { |
648 return app_list_controller_.get() && | 647 return app_list_controller_->GetTargetVisibility(); |
649 app_list_controller_->GetTargetVisibility(); | |
650 } | 648 } |
651 | 649 |
652 aura::Window* Shell::GetAppListWindow() { | 650 aura::Window* Shell::GetAppListWindow() { |
653 return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; | 651 return app_list_controller_->GetWindow(); |
654 } | 652 } |
655 | 653 |
656 bool Shell::IsSystemModalWindowOpen() const { | 654 bool Shell::IsSystemModalWindowOpen() const { |
657 if (simulate_modal_window_open_for_testing_) | 655 if (simulate_modal_window_open_for_testing_) |
658 return true; | 656 return true; |
659 const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( | 657 const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( |
660 internal::kShellWindowId_SystemModalContainer, NULL); | 658 internal::kShellWindowId_SystemModalContainer, NULL); |
661 for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); | 659 for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); |
662 cit != containers.end(); ++cit) { | 660 cit != containers.end(); ++cit) { |
663 for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); | 661 for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 //////////////////////////////////////////////////////////////////////////////// | 947 //////////////////////////////////////////////////////////////////////////////// |
950 // Shell, aura::client::ActivationChangeObserver implementation: | 948 // Shell, aura::client::ActivationChangeObserver implementation: |
951 | 949 |
952 void Shell::OnWindowActivated(aura::Window* gained_active, | 950 void Shell::OnWindowActivated(aura::Window* gained_active, |
953 aura::Window* lost_active) { | 951 aura::Window* lost_active) { |
954 if (gained_active) | 952 if (gained_active) |
955 active_root_window_ = gained_active->GetRootWindow(); | 953 active_root_window_ = gained_active->GetRootWindow(); |
956 } | 954 } |
957 | 955 |
958 } // namespace ash | 956 } // namespace ash |
OLD | NEW |