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 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "ash/shell_delegate.h" | 50 #include "ash/shell_delegate.h" |
51 #include "ash/shell_factory.h" | 51 #include "ash/shell_factory.h" |
52 #include "ash/shell_init_params.h" | 52 #include "ash/shell_init_params.h" |
53 #include "ash/shell_window_ids.h" | 53 #include "ash/shell_window_ids.h" |
54 #include "ash/system/locale/locale_notification_controller.h" | 54 #include "ash/system/locale/locale_notification_controller.h" |
55 #include "ash/system/status_area_widget.h" | 55 #include "ash/system/status_area_widget.h" |
56 #include "ash/system/toast/toast_manager.h" | 56 #include "ash/system/toast/toast_manager.h" |
57 #include "ash/system/tray/system_tray_delegate.h" | 57 #include "ash/system/tray/system_tray_delegate.h" |
58 #include "ash/system/tray/system_tray_notifier.h" | 58 #include "ash/system/tray/system_tray_notifier.h" |
59 #include "ash/utility/partial_screenshot_controller.h" | 59 #include "ash/utility/partial_screenshot_controller.h" |
| 60 #include "ash/wm/app_list_controller.h" |
60 #include "ash/wm/ash_focus_rules.h" | 61 #include "ash/wm/ash_focus_rules.h" |
61 #include "ash/wm/ash_native_cursor_manager.h" | 62 #include "ash/wm/ash_native_cursor_manager.h" |
62 #include "ash/wm/coordinate_conversion.h" | 63 #include "ash/wm/coordinate_conversion.h" |
63 #include "ash/wm/event_client_impl.h" | 64 #include "ash/wm/event_client_impl.h" |
64 #include "ash/wm/lock_state_controller.h" | 65 #include "ash/wm/lock_state_controller.h" |
65 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 66 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
66 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | 67 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
67 #include "ash/wm/mru_window_tracker.h" | 68 #include "ash/wm/mru_window_tracker.h" |
68 #include "ash/wm/overlay_event_filter.h" | 69 #include "ash/wm/overlay_event_filter.h" |
69 #include "ash/wm/overview/window_selector_controller.h" | 70 #include "ash/wm/overview/window_selector_controller.h" |
70 #include "ash/wm/power_button_controller.h" | 71 #include "ash/wm/power_button_controller.h" |
71 #include "ash/wm/resize_shadow_controller.h" | 72 #include "ash/wm/resize_shadow_controller.h" |
72 #include "ash/wm/root_window_layout_manager.h" | 73 #include "ash/wm/root_window_layout_manager.h" |
73 #include "ash/wm/system_gesture_event_filter.h" | 74 #include "ash/wm/system_gesture_event_filter.h" |
74 #include "ash/wm/system_modal_container_event_filter.h" | 75 #include "ash/wm/system_modal_container_event_filter.h" |
75 #include "ash/wm/system_modal_container_layout_manager.h" | 76 #include "ash/wm/system_modal_container_layout_manager.h" |
76 #include "ash/wm/toplevel_window_event_handler.h" | 77 #include "ash/wm/toplevel_window_event_handler.h" |
77 #include "ash/wm/video_detector.h" | 78 #include "ash/wm/video_detector.h" |
78 #include "ash/wm/window_animations.h" | 79 #include "ash/wm/window_animations.h" |
79 #include "ash/wm/window_cycle_controller.h" | 80 #include "ash/wm/window_cycle_controller.h" |
80 #include "ash/wm/window_positioner.h" | 81 #include "ash/wm/window_positioner.h" |
81 #include "ash/wm/window_properties.h" | 82 #include "ash/wm/window_properties.h" |
82 #include "ash/wm/window_util.h" | 83 #include "ash/wm/window_util.h" |
83 #include "ash/wm/workspace_controller.h" | 84 #include "ash/wm/workspace_controller.h" |
84 #include "base/bind.h" | 85 #include "base/bind.h" |
85 #include "base/memory/ptr_util.h" | 86 #include "base/memory/ptr_util.h" |
86 #include "base/trace_event/trace_event.h" | 87 #include "base/trace_event/trace_event.h" |
87 #include "ui/app_list/shower/app_list_shower.h" | |
88 #include "ui/aura/client/aura_constants.h" | 88 #include "ui/aura/client/aura_constants.h" |
89 #include "ui/aura/env.h" | 89 #include "ui/aura/env.h" |
90 #include "ui/aura/layout_manager.h" | 90 #include "ui/aura/layout_manager.h" |
91 #include "ui/aura/window.h" | 91 #include "ui/aura/window.h" |
92 #include "ui/aura/window_event_dispatcher.h" | 92 #include "ui/aura/window_event_dispatcher.h" |
93 #include "ui/base/ui_base_switches.h" | 93 #include "ui/base/ui_base_switches.h" |
94 #include "ui/base/user_activity/user_activity_detector.h" | 94 #include "ui/base/user_activity/user_activity_detector.h" |
95 #include "ui/compositor/layer.h" | 95 #include "ui/compositor/layer.h" |
96 #include "ui/compositor/layer_animator.h" | 96 #include "ui/compositor/layer_animator.h" |
97 #include "ui/events/event_target_iterator.h" | 97 #include "ui/events/event_target_iterator.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 aura::Window* root = | 291 aura::Window* root = |
292 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); | 292 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); |
293 GetRootWindowController(root) | 293 GetRootWindowController(root) |
294 ->ShowContextMenu(location_in_screen, source_type); | 294 ->ShowContextMenu(location_in_screen, source_type); |
295 } | 295 } |
296 | 296 |
297 void Shell::ShowAppList(aura::Window* window) { | 297 void Shell::ShowAppList(aura::Window* window) { |
298 // If the context window is not given, show it on the target root window. | 298 // If the context window is not given, show it on the target root window. |
299 if (!window) | 299 if (!window) |
300 window = GetTargetRootWindow(); | 300 window = GetTargetRootWindow(); |
301 delegate_->GetAppListShower()->Show(window); | 301 if (!app_list_controller_) |
| 302 app_list_controller_.reset(new AppListController); |
| 303 app_list_controller_->Show(window); |
302 } | 304 } |
303 | 305 |
304 void Shell::DismissAppList() { | 306 void Shell::DismissAppList() { |
305 delegate_->GetAppListShower()->Dismiss(); | 307 if (!app_list_controller_) |
| 308 return; |
| 309 app_list_controller_->Dismiss(); |
306 } | 310 } |
307 | 311 |
308 void Shell::ToggleAppList(aura::Window* window) { | 312 void Shell::ToggleAppList(aura::Window* window) { |
309 if (delegate_->GetAppListShower()->IsVisible()) { | 313 if (app_list_controller_ && app_list_controller_->IsVisible()) { |
310 DismissAppList(); | 314 DismissAppList(); |
311 return; | 315 return; |
312 } | 316 } |
313 | 317 |
314 ShowAppList(window); | 318 ShowAppList(window); |
315 } | 319 } |
316 | 320 |
317 bool Shell::GetAppListTargetVisibility() const { | 321 bool Shell::GetAppListTargetVisibility() const { |
318 return delegate_->GetAppListShower()->GetTargetVisibility(); | 322 return app_list_controller_.get() && |
| 323 app_list_controller_->GetTargetVisibility(); |
| 324 } |
| 325 |
| 326 aura::Window* Shell::GetAppListWindow() { |
| 327 return app_list_controller_.get() ? app_list_controller_->GetWindow() |
| 328 : nullptr; |
| 329 } |
| 330 |
| 331 app_list::AppListView* Shell::GetAppListView() { |
| 332 return app_list_controller_.get() ? app_list_controller_->GetView() : nullptr; |
319 } | 333 } |
320 | 334 |
321 bool Shell::IsSystemModalWindowOpen() const { | 335 bool Shell::IsSystemModalWindowOpen() const { |
322 if (simulate_modal_window_open_for_testing_) | 336 if (simulate_modal_window_open_for_testing_) |
323 return true; | 337 return true; |
324 const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( | 338 const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( |
325 kShellWindowId_SystemModalContainer, nullptr); | 339 kShellWindowId_SystemModalContainer, nullptr); |
326 for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); | 340 for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); |
327 cit != containers.end(); ++cit) { | 341 cit != containers.end(); ++cit) { |
328 for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); | 342 for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 // since the latters destructor triggers events that the former is listening | 711 // since the latters destructor triggers events that the former is listening |
698 // to but no longer cares about. | 712 // to but no longer cares about. |
699 #if defined(OS_CHROMEOS) | 713 #if defined(OS_CHROMEOS) |
700 virtual_keyboard_controller_.reset(); | 714 virtual_keyboard_controller_.reset(); |
701 #endif | 715 #endif |
702 | 716 |
703 // Destroy maximize mode controller early on since it has some observers which | 717 // Destroy maximize mode controller early on since it has some observers which |
704 // need to be removed. | 718 // need to be removed. |
705 maximize_mode_controller_.reset(); | 719 maximize_mode_controller_.reset(); |
706 | 720 |
| 721 // AppList needs to be released before shelf layout manager, which is |
| 722 // destroyed with shelf container in the loop below. However, app list |
| 723 // container is now on top of shelf container and released after it. |
| 724 // TODO(xiyuan): Move it back when app list container is no longer needed. |
| 725 app_list_controller_.reset(); |
| 726 |
707 #if defined(OS_CHROMEOS) | 727 #if defined(OS_CHROMEOS) |
708 // Destroy the LastWindowClosedLogoutReminder before the | 728 // Destroy the LastWindowClosedLogoutReminder before the |
709 // LogoutConfirmationController. | 729 // LogoutConfirmationController. |
710 last_window_closed_logout_reminder_.reset(); | 730 last_window_closed_logout_reminder_.reset(); |
711 | 731 |
712 // Destroy the LogoutConfirmationController before the SystemTrayDelegate. | 732 // Destroy the LogoutConfirmationController before the SystemTrayDelegate. |
713 logout_confirmation_controller_.reset(); | 733 logout_confirmation_controller_.reset(); |
714 #endif | 734 #endif |
715 | 735 |
716 // Destroy the keyboard before closing the shelf, since it will invoke a shelf | 736 // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 | 1215 |
1196 void Shell::OnWindowActivated( | 1216 void Shell::OnWindowActivated( |
1197 aura::client::ActivationChangeObserver::ActivationReason reason, | 1217 aura::client::ActivationChangeObserver::ActivationReason reason, |
1198 aura::Window* gained_active, | 1218 aura::Window* gained_active, |
1199 aura::Window* lost_active) { | 1219 aura::Window* lost_active) { |
1200 if (gained_active) | 1220 if (gained_active) |
1201 target_root_window_ = gained_active->GetRootWindow(); | 1221 target_root_window_ = gained_active->GetRootWindow(); |
1202 } | 1222 } |
1203 | 1223 |
1204 } // namespace ash | 1224 } // namespace ash |
OLD | NEW |