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