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