[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 5 | #include "ash/shell.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 6 | |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 7 | #include <algorithm> |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 8 | #include <string> |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 9 | |
[email protected] | 87847948 | 2013-09-18 10:29:19 | [diff] [blame] | 10 | #include "ash/accelerators/accelerator_controller.h" |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 11 | #include "ash/accelerators/accelerator_delegate.h" |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 12 | #include "ash/accelerators/focus_manager_factory.h" |
[email protected] | 567c269 | 2014-05-28 02:40:55 | [diff] [blame] | 13 | #include "ash/accelerators/nested_accelerator_delegate.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 14 | #include "ash/ash_switches.h" |
[email protected] | 55398d2 | 2013-10-10 19:49:20 | [diff] [blame] | 15 | #include "ash/autoclick/autoclick_controller.h" |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 16 | #include "ash/desktop_background/desktop_background_controller.h" |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 17 | #include "ash/desktop_background/desktop_background_view.h" |
[email protected] | 81abb103 | 2012-11-13 18:55:41 | [diff] [blame] | 18 | #include "ash/desktop_background/user_wallpaper_delegate.h" |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 19 | #include "ash/display/cursor_window_controller.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 20 | #include "ash/display/display_controller.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 21 | #include "ash/display/display_manager.h" |
[email protected] | 682990f | 2013-01-10 06:49:11 | [diff] [blame] | 22 | #include "ash/display/event_transformation_handler.h" |
[email protected] | 9154587 | 2012-11-21 13:58:27 | [diff] [blame] | 23 | #include "ash/display/mouse_cursor_event_filter.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 24 | #include "ash/display/screen_position_controller.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 25 | #include "ash/drag_drop/drag_drop_controller.h" |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 26 | #include "ash/first_run/first_run_helper_impl.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 27 | #include "ash/focus_cycler.h" |
[email protected] | 400a61c | 2014-03-13 19:40:23 | [diff] [blame] | 28 | #include "ash/frame/custom_frame_view_ash.h" |
[email protected] | 1d2a721 | 2014-01-16 06:09:48 | [diff] [blame] | 29 | #include "ash/gpu_support.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 30 | #include "ash/high_contrast/high_contrast_controller.h" |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 31 | #include "ash/host/ash_window_tree_host_init_params.h" |
[email protected] | 7a80cdd | 2013-09-26 09:20:53 | [diff] [blame] | 32 | #include "ash/keyboard_uma_event_filter.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 33 | #include "ash/magnifier/magnification_controller.h" |
[email protected] | 77f7c13 | 2012-11-15 06:52:54 | [diff] [blame] | 34 | #include "ash/magnifier/partial_magnification_controller.h" |
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 35 | #include "ash/media_delegate.h" |
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 36 | #include "ash/new_window_delegate.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 37 | #include "ash/root_window_controller.h" |
[email protected] | fdf74bf | 2014-04-30 21:24:02 | [diff] [blame] | 38 | #include "ash/session/session_state_delegate.h" |
[email protected] | 976624f | 2013-09-19 21:58:49 | [diff] [blame] | 39 | #include "ash/shelf/app_list_shelf_item_delegate.h" |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 40 | #include "ash/shelf/shelf_delegate.h" |
[email protected] | c25ff50 | 2013-12-04 13:52:48 | [diff] [blame] | 41 | #include "ash/shelf/shelf_item_delegate.h" |
| 42 | #include "ash/shelf/shelf_item_delegate_manager.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 43 | #include "ash/shelf/shelf_layout_manager.h" |
[email protected] | 64936bf | 2013-11-14 19:48:36 | [diff] [blame] | 44 | #include "ash/shelf/shelf_model.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 45 | #include "ash/shelf/shelf_widget.h" |
[email protected] | 055a56d | 2013-12-06 12:13:36 | [diff] [blame] | 46 | #include "ash/shelf/shelf_window_watcher.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 47 | #include "ash/shell_delegate.h" |
| 48 | #include "ash/shell_factory.h" |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 49 | #include "ash/shell_init_params.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 50 | #include "ash/shell_window_ids.h" |
[email protected] | a9a4046 | 2013-07-31 06:22:56 | [diff] [blame] | 51 | #include "ash/system/locale/locale_notification_controller.h" |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 52 | #include "ash/system/status_area_widget.h" |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 53 | #include "ash/system/tray/system_tray_delegate.h" |
[email protected] | 83b2b84c | 2012-11-14 01:11:00 | [diff] [blame] | 54 | #include "ash/system/tray/system_tray_notifier.h" |
mukai | 19274bdd | 2015-02-24 22:37:48 | [diff] [blame] | 55 | #include "ash/utility/partial_screenshot_controller.h" |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 56 | #include "ash/wm/app_list_controller.h" |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 57 | #include "ash/wm/ash_focus_rules.h" |
[email protected] | c0ff034 | 2013-02-27 00:41:29 | [diff] [blame] | 58 | #include "ash/wm/ash_native_cursor_manager.h" |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 59 | #include "ash/wm/coordinate_conversion.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 60 | #include "ash/wm/event_client_impl.h" |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 61 | #include "ash/wm/lock_state_controller.h" |
[email protected] | 58fb353d | 2014-04-04 03:28:05 | [diff] [blame] | 62 | #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
[email protected] | e55b7345 | 2014-02-20 13:18:04 | [diff] [blame] | 63 | #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
[email protected] | 66c5c411 | 2013-07-31 07:10:59 | [diff] [blame] | 64 | #include "ash/wm/mru_window_tracker.h" |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 65 | #include "ash/wm/overlay_event_filter.h" |
[email protected] | 09f35d74 | 2013-08-23 00:39:39 | [diff] [blame] | 66 | #include "ash/wm/overview/window_selector_controller.h" |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 67 | #include "ash/wm/power_button_controller.h" |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 68 | #include "ash/wm/resize_shadow_controller.h" |
[email protected] | a3301dc | 2011-12-23 16:34:51 | [diff] [blame] | 69 | #include "ash/wm/root_window_layout_manager.h" |
[email protected] | 4299321 | 2012-04-30 23:42:04 | [diff] [blame] | 70 | #include "ash/wm/screen_dimmer.h" |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 71 | #include "ash/wm/system_gesture_event_filter.h" |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 72 | #include "ash/wm/system_modal_container_event_filter.h" |
[email protected] | 4244d699 | 2012-01-23 17:14:33 | [diff] [blame] | 73 | #include "ash/wm/system_modal_container_layout_manager.h" |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 74 | #include "ash/wm/toplevel_window_event_handler.h" |
[email protected] | 9633a9d2 | 2012-01-21 16:40:58 | [diff] [blame] | 75 | #include "ash/wm/video_detector.h" |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 76 | #include "ash/wm/window_animations.h" |
[email protected] | dd1e1ac | 2014-05-13 03:44:09 | [diff] [blame] | 77 | #include "ash/wm/window_cycle_controller.h" |
[email protected] | e9a7131 | 2013-10-04 03:20:01 | [diff] [blame] | 78 | #include "ash/wm/window_positioner.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 79 | #include "ash/wm/window_properties.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 80 | #include "ash/wm/window_util.h" |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 81 | #include "ash/wm/workspace_controller.h" |
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 82 | #include "base/bind.h" |
primiano | 7182d7b | 2015-01-30 18:02:03 | [diff] [blame] | 83 | #include "base/trace_event/trace_event.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 84 | #include "ui/aura/client/aura_constants.h" |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 85 | #include "ui/aura/env.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 86 | #include "ui/aura/layout_manager.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 87 | #include "ui/aura/window.h" |
[email protected] | fcc51c95 | 2014-02-21 21:31:26 | [diff] [blame] | 88 | #include "ui/aura/window_event_dispatcher.h" |
[email protected] | 2d481774 | 2012-12-17 20:16:18 | [diff] [blame] | 89 | #include "ui/base/ui_base_switches.h" |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 90 | #include "ui/base/user_activity/user_activity_detector.h" |
[email protected] | 116302fc | 2012-05-05 21:45:41 | [diff] [blame] | 91 | #include "ui/compositor/layer.h" |
| 92 | #include "ui/compositor/layer_animator.h" |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 93 | #include "ui/events/event_target_iterator.h" |
[email protected] | 7da9c4c | 2012-06-12 14:43:01 | [diff] [blame] | 94 | #include "ui/gfx/display.h" |
Avi Drissman | fefc2f8 | 2014-12-22 19:25:29 | [diff] [blame] | 95 | #include "ui/gfx/geometry/size.h" |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 96 | #include "ui/gfx/image/image_skia.h" |
[email protected] | b82c42c4 | 2012-04-25 20:03:41 | [diff] [blame] | 97 | #include "ui/gfx/screen.h" |
[email protected] | f1d5c3a | 2013-04-23 17:42:56 | [diff] [blame] | 98 | #include "ui/keyboard/keyboard.h" |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 99 | #include "ui/keyboard/keyboard_controller.h" |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 100 | #include "ui/keyboard/keyboard_switches.h" |
[email protected] | f1d5c3a | 2013-04-23 17:42:56 | [diff] [blame] | 101 | #include "ui/keyboard/keyboard_util.h" |
[email protected] | 8393aa6 | 2013-01-23 19:40:10 | [diff] [blame] | 102 | #include "ui/message_center/message_center.h" |
[email protected] | d7f30a7 | 2013-10-05 05:09:41 | [diff] [blame] | 103 | #include "ui/views/corewm/tooltip_aura.h" |
[email protected] | a1b7a82 | 2013-02-23 19:08:04 | [diff] [blame] | 104 | #include "ui/views/corewm/tooltip_controller.h" |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 105 | #include "ui/views/focus/focus_manager_factory.h" |
[email protected] | c13be0d | 2011-11-22 02:09:58 | [diff] [blame] | 106 | #include "ui/views/widget/native_widget_aura.h" |
| 107 | #include "ui/views/widget/widget.h" |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 108 | #include "ui/wm/core/accelerator_filter.h" |
[email protected] | ee3ed1077 | 2014-03-11 22:02:01 | [diff] [blame] | 109 | #include "ui/wm/core/compound_event_filter.h" |
| 110 | #include "ui/wm/core/focus_controller.h" |
| 111 | #include "ui/wm/core/input_method_event_filter.h" |
[email protected] | 567c269 | 2014-05-28 02:40:55 | [diff] [blame] | 112 | #include "ui/wm/core/nested_accelerator_controller.h" |
[email protected] | ee3ed1077 | 2014-03-11 22:02:01 | [diff] [blame] | 113 | #include "ui/wm/core/shadow_controller.h" |
| 114 | #include "ui/wm/core/visibility_controller.h" |
| 115 | #include "ui/wm/core/window_modality_controller.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 116 | |
[email protected] | 37ce571b | 2013-06-28 05:28:45 | [diff] [blame] | 117 | #if defined(OS_CHROMEOS) |
| 118 | #if defined(USE_X11) |
[email protected] | 82f884d6ffb | 2014-04-15 03:34:54 | [diff] [blame] | 119 | #include "ui/gfx/x/x11_types.h" |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 120 | #endif // defined(USE_X11) |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 121 | #include "ash/accelerators/magnifier_key_scroller.h" |
| 122 | #include "ash/accelerators/spoken_feedback_toggler.h" |
[email protected] | 44d444c | 2013-01-30 01:47:44 | [diff] [blame] | 123 | #include "ash/ash_constants.h" |
robert.bradford | ab05249 | 2015-05-06 11:09:56 | [diff] [blame] | 124 | #include "ash/content/display/display_color_manager_chromeos.h" |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 125 | #include "ash/content/display/screen_orientation_controller_chromeos.h" |
[email protected] | c1234a4 | 2013-08-20 09:35:40 | [diff] [blame] | 126 | #include "ash/display/display_change_observer_chromeos.h" |
[email protected] | 129aad8 | 2014-04-24 23:17:04 | [diff] [blame] | 127 | #include "ash/display/display_configurator_animation.h" |
[email protected] | c1234a4 | 2013-08-20 09:35:40 | [diff] [blame] | 128 | #include "ash/display/display_error_observer_chromeos.h" |
[email protected] | 72bce52 | 2014-02-10 21:11:26 | [diff] [blame] | 129 | #include "ash/display/projecting_observer_chromeos.h" |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 130 | #include "ash/display/resolution_notification_controller.h" |
[email protected] | 08bdabed | 2013-12-20 07:52:28 | [diff] [blame] | 131 | #include "ash/sticky_keys/sticky_keys_controller.h" |
[email protected] | b314272 | 2014-03-04 06:59:50 | [diff] [blame] | 132 | #include "ash/system/chromeos/bluetooth/bluetooth_notification_controller.h" |
[email protected] | 25cae45 | 2013-09-26 10:15:03 | [diff] [blame] | 133 | #include "ash/system/chromeos/brightness/brightness_controller_chromeos.h" |
[email protected] | 5162505 | 2013-10-10 01:40:16 | [diff] [blame] | 134 | #include "ash/system/chromeos/power/power_event_observer.h" |
[email protected] | 37ce571b | 2013-06-28 05:28:45 | [diff] [blame] | 135 | #include "ash/system/chromeos/power/power_status.h" |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 136 | #include "ash/system/chromeos/power/video_activity_notifier.h" |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 137 | #include "ash/system/chromeos/session/last_window_closed_logout_reminder.h" |
[email protected] | 0dc8551 | 2014-03-13 13:26:41 | [diff] [blame] | 138 | #include "ash/system/chromeos/session/logout_confirmation_controller.h" |
dnicoara | 8c3bd1e6 | 2014-10-30 19:53:39 | [diff] [blame] | 139 | #include "ash/touch/touch_transformer_controller.h" |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 140 | #include "ash/virtual_keyboard_controller.h" |
[email protected] | 0dc8551 | 2014-03-13 13:26:41 | [diff] [blame] | 141 | #include "base/bind_helpers.h" |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 142 | #include "base/sys_info.h" |
pneubeck | 8be1f542 | 2014-10-09 16:46:18 | [diff] [blame] | 143 | #include "chromeos/dbus/dbus_thread_manager.h" |
[email protected] | b0fa701 | 2014-04-16 12:50:57 | [diff] [blame] | 144 | #include "ui/chromeos/user_activity_power_manager_notifier.h" |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 145 | #include "ui/display/chromeos/display_configurator.h" |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 146 | #endif // defined(OS_CHROMEOS) |
| 147 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 148 | namespace ash { |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 149 | |
| 150 | namespace { |
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 151 | |
[email protected] | 615922f | 2012-02-07 02:41:15 | [diff] [blame] | 152 | using aura::Window; |
[email protected] | 3f02dc5 | 2011-10-21 19:36:45 | [diff] [blame] | 153 | using views::Widget; |
| 154 | |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 155 | // A Corewm VisibilityController subclass that calls the Ash animation routine |
| 156 | // so we can pick up our extended animations. See ash/wm/window_animations.h. |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 157 | class AshVisibilityController : public ::wm::VisibilityController { |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 158 | public: |
| 159 | AshVisibilityController() {} |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 160 | ~AshVisibilityController() override {} |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 161 | |
| 162 | private: |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 163 | // Overridden from ::wm::VisibilityController: |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 164 | bool CallAnimateOnChildWindowVisibilityChanged(aura::Window* window, |
| 165 | bool visible) override { |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 166 | return AnimateOnChildWindowVisibilityChanged(window, visible); |
| 167 | } |
| 168 | |
| 169 | DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); |
| 170 | }; |
| 171 | |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 172 | AshWindowTreeHostInitParams ShellInitParamsToAshWindowTreeHostInitParams( |
| 173 | const ShellInitParams& shell_init_params) { |
| 174 | AshWindowTreeHostInitParams ash_init_params; |
| 175 | #if defined(OS_WIN) |
| 176 | ash_init_params.remote_hwnd = shell_init_params.remote_hwnd; |
| 177 | #endif |
| 178 | return ash_init_params; |
| 179 | } |
| 180 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 181 | } // namespace |
| 182 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 183 | // static |
| 184 | Shell* Shell::instance_ = NULL; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 185 | // static |
[email protected] | 9488d4d | 2012-02-29 18:32:37 | [diff] [blame] | 186 | bool Shell::initially_hide_cursor_ = false; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 187 | |
| 188 | //////////////////////////////////////////////////////////////////////////////// |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 189 | // Shell, public: |
| 190 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 191 | // static |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 192 | Shell* Shell::CreateInstance(const ShellInitParams& init_params) { |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 193 | CHECK(!instance_); |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 194 | instance_ = new Shell(init_params.delegate); |
| 195 | instance_->Init(init_params); |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 196 | return instance_; |
| 197 | } |
| 198 | |
| 199 | // static |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 200 | Shell* Shell::GetInstance() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 201 | CHECK(instance_); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 202 | return instance_; |
| 203 | } |
| 204 | |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 205 | // static |
[email protected] | b3b7bcd | 2012-03-06 19:35:45 | [diff] [blame] | 206 | bool Shell::HasInstance() { |
| 207 | return !!instance_; |
| 208 | } |
| 209 | |
| 210 | // static |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 211 | void Shell::DeleteInstance() { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 212 | delete instance_; |
| 213 | instance_ = NULL; |
| 214 | } |
| 215 | |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 216 | // static |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 217 | RootWindowController* Shell::GetPrimaryRootWindowController() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 218 | CHECK(HasInstance()); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 219 | return GetRootWindowController(GetPrimaryRootWindow()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | // static |
| 223 | Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 224 | CHECK(HasInstance()); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 225 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 226 | GetAllRootWindowControllers(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 230 | aura::Window* Shell::GetPrimaryRootWindow() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 231 | CHECK(HasInstance()); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 232 | return GetInstance()->display_controller()->GetPrimaryRootWindow(); |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 233 | } |
| 234 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 235 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 236 | aura::Window* Shell::GetTargetRootWindow() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 237 | CHECK(HasInstance()); |
[email protected] | b42910f | 2013-08-01 11:45:29 | [diff] [blame] | 238 | Shell* shell = GetInstance(); |
| 239 | if (shell->scoped_target_root_window_) |
| 240 | return shell->scoped_target_root_window_; |
| 241 | return shell->target_root_window_; |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 242 | } |
| 243 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 244 | // static |
[email protected] | ffabb1e | 2012-10-12 19:51:17 | [diff] [blame] | 245 | gfx::Screen* Shell::GetScreen() { |
[email protected] | 5fdb45b | 2012-10-23 20:26:28 | [diff] [blame] | 246 | return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
[email protected] | ffabb1e | 2012-10-12 19:51:17 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | // static |
[email protected] | c9390bd | 2013-11-08 20:33:13 | [diff] [blame] | 250 | aura::Window::Windows Shell::GetAllRootWindows() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 251 | CHECK(HasInstance()); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 252 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 253 | GetAllRootWindows(); |
| 254 | } |
| 255 | |
| 256 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 257 | aura::Window* Shell::GetContainer(aura::Window* root_window, |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 258 | int container_id) { |
| 259 | return root_window->GetChildById(container_id); |
| 260 | } |
| 261 | |
| 262 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 263 | const aura::Window* Shell::GetContainer(const aura::Window* root_window, |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 264 | int container_id) { |
| 265 | return root_window->GetChildById(container_id); |
| 266 | } |
| 267 | |
| 268 | // static |
[email protected] | 429433f | 2012-12-28 20:14:46 | [diff] [blame] | 269 | std::vector<aura::Window*> Shell::GetContainersFromAllRootWindows( |
| 270 | int container_id, |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 271 | aura::Window* priority_root) { |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 272 | std::vector<aura::Window*> containers; |
[email protected] | c9390bd | 2013-11-08 20:33:13 | [diff] [blame] | 273 | aura::Window::Windows root_windows = GetAllRootWindows(); |
| 274 | for (aura::Window::Windows::const_iterator it = root_windows.begin(); |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 275 | it != root_windows.end(); ++it) { |
| 276 | aura::Window* container = (*it)->GetChildById(container_id); |
[email protected] | 429433f | 2012-12-28 20:14:46 | [diff] [blame] | 277 | if (container) { |
| 278 | if (priority_root && priority_root->Contains(container)) |
| 279 | containers.insert(containers.begin(), container); |
| 280 | else |
| 281 | containers.push_back(container); |
| 282 | } |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 283 | } |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 284 | return containers; |
| 285 | } |
| 286 | |
[email protected] | 940fb1c | 2013-06-18 16:54:28 | [diff] [blame] | 287 | void Shell::ShowContextMenu(const gfx::Point& location_in_screen, |
| 288 | ui::MenuSourceType source_type) { |
[email protected] | fcb123d | 2013-04-17 15:58:49 | [diff] [blame] | 289 | // No context menus if there is no session with an active user. |
[email protected] | c8d19f8 | 2013-05-18 09:09:41 | [diff] [blame] | 290 | if (!session_state_delegate_->NumberOfLoggedInUsers()) |
[email protected] | f60c623 | 2012-08-24 18:55:03 | [diff] [blame] | 291 | return; |
| 292 | // No context menus when screen is locked. |
[email protected] | fcb123d | 2013-04-17 15:58:49 | [diff] [blame] | 293 | if (session_state_delegate_->IsScreenLocked()) |
[email protected] | f60c623 | 2012-08-24 18:55:03 | [diff] [blame] | 294 | return; |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 295 | |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 296 | aura::Window* root = |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 297 | wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 298 | GetRootWindowController(root) |
| 299 | ->ShowContextMenu(location_in_screen, source_type); |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 300 | } |
| 301 | |
[email protected] | 1b46780 | 2014-08-15 16:03:06 | [diff] [blame] | 302 | void Shell::ShowAppList(aura::Window* window) { |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 303 | // If the context window is not given, show it on the target root window. |
[email protected] | ec67bc8a | 2013-05-06 17:44:42 | [diff] [blame] | 304 | if (!window) |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 305 | window = GetTargetRootWindow(); |
[email protected] | ec67bc8a | 2013-05-06 17:44:42 | [diff] [blame] | 306 | if (!app_list_controller_) |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 307 | app_list_controller_.reset(new AppListController); |
calamity | 51802a7 | 2014-08-27 02:11:28 | [diff] [blame] | 308 | app_list_controller_->Show(window); |
[email protected] | 1b46780 | 2014-08-15 16:03:06 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | void Shell::DismissAppList() { |
| 312 | if (!app_list_controller_) |
| 313 | return; |
calamity | 51802a7 | 2014-08-27 02:11:28 | [diff] [blame] | 314 | app_list_controller_->Dismiss(); |
[email protected] | 1b46780 | 2014-08-15 16:03:06 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | void Shell::ToggleAppList(aura::Window* window) { |
[email protected] | 5fe7603 | 2014-08-19 02:20:58 | [diff] [blame] | 318 | if (app_list_controller_ && app_list_controller_->IsVisible()) { |
[email protected] | 1b46780 | 2014-08-15 16:03:06 | [diff] [blame] | 319 | DismissAppList(); |
| 320 | return; |
| 321 | } |
| 322 | |
| 323 | ShowAppList(window); |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 324 | } |
| 325 | |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 326 | bool Shell::GetAppListTargetVisibility() const { |
[email protected] | ec67bc8a | 2013-05-06 17:44:42 | [diff] [blame] | 327 | return app_list_controller_.get() && |
| 328 | app_list_controller_->GetTargetVisibility(); |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 329 | } |
| 330 | |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 331 | aura::Window* Shell::GetAppListWindow() { |
[email protected] | ec67bc8a | 2013-05-06 17:44:42 | [diff] [blame] | 332 | return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 333 | } |
| 334 | |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 335 | app_list::AppListView* Shell::GetAppListView() { |
| 336 | return app_list_controller_.get() ? app_list_controller_->GetView() : NULL; |
| 337 | } |
| 338 | |
[email protected] | dc0973937 | 2012-11-15 20:17:39 | [diff] [blame] | 339 | bool Shell::IsSystemModalWindowOpen() const { |
[email protected] | 852a55d | 2012-10-17 13:30:30 | [diff] [blame] | 340 | if (simulate_modal_window_open_for_testing_) |
| 341 | return true; |
[email protected] | 429433f | 2012-12-28 20:14:46 | [diff] [blame] | 342 | const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 343 | kShellWindowId_SystemModalContainer, NULL); |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 344 | for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); |
| 345 | cit != containers.end(); ++cit) { |
| 346 | for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); |
| 347 | wit != (*cit)->children().end(); ++wit) { |
| 348 | if ((*wit)->GetProperty(aura::client::kModalKey) == |
| 349 | ui::MODAL_TYPE_SYSTEM && (*wit)->TargetVisibility()) { |
| 350 | return true; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | return false; |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 355 | } |
| 356 | |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 357 | views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 358 | views::Widget* widget) { |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 359 | // Use translucent-style window frames for dialogs. |
[email protected] | 85501fe | 2013-10-18 10:15:27 | [diff] [blame] | 360 | return new CustomFrameViewAsh(widget); |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 361 | } |
| 362 | |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 363 | void Shell::RotateFocus(Direction direction) { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 364 | focus_cycler_->RotateFocus(direction == FORWARD ? FocusCycler::FORWARD |
| 365 | : FocusCycler::BACKWARD); |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 366 | } |
| 367 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 368 | void Shell::SetDisplayWorkAreaInsets(Window* contains, |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 369 | const gfx::Insets& insets) { |
[email protected] | b898424 | 2013-07-12 07:55:38 | [diff] [blame] | 370 | if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( |
| 371 | contains, insets)) { |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 372 | return; |
[email protected] | b898424 | 2013-07-12 07:55:38 | [diff] [blame] | 373 | } |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 374 | FOR_EACH_OBSERVER(ShellObserver, observers_, |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 375 | OnDisplayWorkAreaInsetsChanged()); |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 376 | } |
| 377 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 378 | void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 379 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
| 380 | } |
| 381 | |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 382 | void Shell::OnLoginUserProfilePrepared() { |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 383 | CreateShelf(); |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 384 | CreateKeyboard(); |
| 385 | } |
| 386 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 387 | void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 388 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 389 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 390 | iter != controllers.end(); ++iter) |
| 391 | (*iter)->UpdateAfterLoginStatusChange(status); |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 392 | } |
| 393 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 394 | void Shell::OnAppTerminating() { |
| 395 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
| 396 | } |
| 397 | |
| 398 | void Shell::OnLockStateChanged(bool locked) { |
| 399 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); |
[email protected] | ae29814 | 2013-08-10 15:30:29 | [diff] [blame] | 400 | #ifndef NDEBUG |
| 401 | // Make sure that there is no system modal in Lock layer when unlocked. |
| 402 | if (!locked) { |
| 403 | std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 404 | kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow()); |
[email protected] | ae29814 | 2013-08-10 15:30:29 | [diff] [blame] | 405 | for (std::vector<aura::Window*>::const_iterator iter = containers.begin(); |
| 406 | iter != containers.end(); ++iter) { |
| 407 | DCHECK_EQ(0u, (*iter)->children().size()); |
| 408 | } |
| 409 | } |
| 410 | #endif |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 411 | } |
| 412 | |
[email protected] | 58868abf | 2014-01-17 23:45:33 | [diff] [blame] | 413 | void Shell::OnCastingSessionStartedOrStopped(bool started) { |
spang | b844ef0 | 2014-12-11 01:37:52 | [diff] [blame] | 414 | #if defined(OS_CHROMEOS) |
jdufault | 88fb7665 | 2015-04-30 22:36:43 | [diff] [blame] | 415 | FOR_EACH_OBSERVER(ShellObserver, observers_, |
| 416 | OnCastingSessionStartedOrStopped(started)); |
[email protected] | 58868abf | 2014-01-17 23:45:33 | [diff] [blame] | 417 | #endif |
| 418 | } |
| 419 | |
[email protected] | de42bcc | 2014-03-04 05:17:00 | [diff] [blame] | 420 | void Shell::OnOverviewModeStarting() { |
| 421 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnOverviewModeStarting()); |
| 422 | } |
| 423 | |
bruthig | d7cf765b | 2015-01-20 19:32:27 | [diff] [blame] | 424 | void Shell::OnOverviewModeEnded() { |
| 425 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnOverviewModeEnded()); |
[email protected] | de42bcc | 2014-03-04 05:17:00 | [diff] [blame] | 426 | } |
| 427 | |
[email protected] | 02a8005 | 2014-03-14 05:45:23 | [diff] [blame] | 428 | void Shell::OnMaximizeModeStarted() { |
| 429 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnMaximizeModeStarted()); |
| 430 | } |
| 431 | |
| 432 | void Shell::OnMaximizeModeEnded() { |
| 433 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnMaximizeModeEnded()); |
| 434 | } |
| 435 | |
[email protected] | 0e3e7cb | 2014-04-12 05:18:25 | [diff] [blame] | 436 | void Shell::OnRootWindowAdded(aura::Window* root_window) { |
| 437 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnRootWindowAdded(root_window)); |
| 438 | } |
| 439 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 440 | void Shell::CreateShelf() { |
[email protected] | 8c0ec43 | 2013-05-10 04:33:39 | [diff] [blame] | 441 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 442 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 443 | iter != controllers.end(); ++iter) |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 444 | (*iter)->shelf()->CreateShelf(); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 445 | } |
| 446 | |
[email protected] | b8642ec | 2014-04-17 05:20:39 | [diff] [blame] | 447 | void Shell::OnShelfCreatedForRootWindow(aura::Window* root_window) { |
| 448 | FOR_EACH_OBSERVER(ShellObserver, |
| 449 | observers_, |
| 450 | OnShelfCreatedForRootWindow(root_window)); |
| 451 | } |
| 452 | |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 453 | void Shell::CreateKeyboard() { |
| 454 | // TODO(bshe): Primary root window controller may not be the controller to |
| 455 | // attach virtual keyboard. See http://crbug.com/303429 |
| 456 | InitKeyboard(); |
bshe | 9858b4a | 2014-09-16 20:46:38 | [diff] [blame] | 457 | GetPrimaryRootWindowController()-> |
| 458 | ActivateKeyboard(keyboard::KeyboardController::GetInstance()); |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 459 | } |
| 460 | |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 461 | void Shell::DeactivateKeyboard() { |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 462 | if (keyboard::KeyboardController::GetInstance()) { |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 463 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 464 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 465 | iter != controllers.end(); ++iter) { |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 466 | (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 467 | } |
| 468 | } |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 469 | keyboard::KeyboardController::ResetInstance(NULL); |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 470 | } |
| 471 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 472 | void Shell::ShowShelf() { |
[email protected] | 8c0ec43 | 2013-05-10 04:33:39 | [diff] [blame] | 473 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 474 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 475 | iter != controllers.end(); ++iter) |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 476 | (*iter)->ShowShelf(); |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 477 | } |
| 478 | |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 479 | void Shell::AddShellObserver(ShellObserver* observer) { |
| 480 | observers_.AddObserver(observer); |
| 481 | } |
| 482 | |
| 483 | void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 484 | observers_.RemoveObserver(observer); |
| 485 | } |
| 486 | |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 487 | #if defined(OS_CHROMEOS) |
| 488 | bool Shell::ShouldSaveDisplaySettings() { |
oshima | 55ef921 | 2015-04-27 23:27:03 | [diff] [blame] | 489 | // TODO(oshima): Allow saving the settings even in unified desktop mode. |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 490 | return !(screen_orientation_controller_ |
| 491 | ->ignore_display_configuration_updates() || |
oshima | 55ef921 | 2015-04-27 23:27:03 | [diff] [blame] | 492 | resolution_notification_controller_->DoesNotificationTimeout()) && |
| 493 | !switches::UnifiedDesktopEnabled(); |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 494 | } |
| 495 | #endif |
| 496 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 497 | void Shell::UpdateShelfVisibility() { |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 498 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 499 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 500 | iter != controllers.end(); ++iter) |
| 501 | if ((*iter)->shelf()) |
| 502 | (*iter)->UpdateShelfVisibility(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 503 | } |
| 504 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 505 | void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 506 | aura::Window* root_window) { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 507 | ash::ShelfLayoutManager::ForShelf(root_window)->SetAutoHideBehavior(behavior); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 508 | } |
| 509 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 510 | ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 511 | aura::Window* root_window) const { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 512 | return ash::ShelfLayoutManager::ForShelf(root_window)->auto_hide_behavior(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 513 | } |
| 514 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 515 | void Shell::SetShelfAlignment(ShelfAlignment alignment, |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 516 | aura::Window* root_window) { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 517 | if (ash::ShelfLayoutManager::ForShelf(root_window)->SetAlignment(alignment)) { |
[email protected] | f89f751 | 2012-12-17 19:21:18 | [diff] [blame] | 518 | FOR_EACH_OBSERVER( |
| 519 | ShellObserver, observers_, OnShelfAlignmentChanged(root_window)); |
| 520 | } |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 521 | } |
| 522 | |
[email protected] | 76bc463 | 2014-06-16 19:07:46 | [diff] [blame] | 523 | ShelfAlignment Shell::GetShelfAlignment(const aura::Window* root_window) { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 524 | return GetRootWindowController(root_window) |
| 525 | ->GetShelfLayoutManager() |
| 526 | ->GetAlignment(); |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 527 | } |
| 528 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 529 | void Shell::SetDimming(bool should_dim) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 530 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 531 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 532 | iter != controllers.end(); ++iter) |
| 533 | (*iter)->screen_dimmer()->SetDimming(should_dim); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 534 | } |
| 535 | |
[email protected] | 375069e | 2013-10-04 13:54:31 | [diff] [blame] | 536 | void Shell::NotifyFullscreenStateChange(bool is_fullscreen, |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 537 | aura::Window* root_window) { |
[email protected] | 375069e | 2013-10-04 13:54:31 | [diff] [blame] | 538 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged( |
| 539 | is_fullscreen, root_window)); |
| 540 | } |
| 541 | |
[email protected] | 090c4f1 | 2012-10-29 18:56:42 | [diff] [blame] | 542 | void Shell::CreateModalBackground(aura::Window* window) { |
[email protected] | 7f7f65c | 2013-04-17 16:47:13 | [diff] [blame] | 543 | if (!modality_filter_) { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 544 | modality_filter_.reset(new SystemModalContainerEventFilter(this)); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 545 | AddPreTargetHandler(modality_filter_.get()); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 546 | } |
| 547 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 548 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 549 | iter != controllers.end(); ++iter) |
[email protected] | 090c4f1 | 2012-10-29 18:56:42 | [diff] [blame] | 550 | (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | void Shell::OnModalWindowRemoved(aura::Window* removed) { |
| 554 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 555 | bool activated = false; |
| 556 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 557 | iter != controllers.end() && !activated; ++iter) { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 558 | activated = (*iter)->GetSystemModalLayoutManager(removed)-> |
| 559 | ActivateNextModalWindow(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 560 | } |
| 561 | if (!activated) { |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 562 | RemovePreTargetHandler(modality_filter_.get()); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 563 | modality_filter_.reset(); |
| 564 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 565 | iter != controllers.end(); ++iter) |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 566 | (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 567 | } |
| 568 | } |
| 569 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 570 | WebNotificationTray* Shell::GetWebNotificationTray() { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 571 | return GetPrimaryRootWindowController()->shelf()-> |
| 572 | status_area_widget()->web_notification_tray(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 573 | } |
| 574 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 575 | bool Shell::HasPrimaryStatusArea() { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 576 | ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf(); |
| 577 | return shelf && shelf->status_area_widget(); |
[email protected] | 31f19e3 | 2012-10-30 22:31:23 | [diff] [blame] | 578 | } |
| 579 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 580 | SystemTray* Shell::GetPrimarySystemTray() { |
| 581 | return GetPrimaryRootWindowController()->GetSystemTray(); |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 582 | } |
| 583 | |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 584 | ShelfDelegate* Shell::GetShelfDelegate() { |
| 585 | if (!shelf_delegate_) { |
[email protected] | 64936bf | 2013-11-14 19:48:36 | [diff] [blame] | 586 | shelf_model_.reset(new ShelfModel); |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 587 | // Creates ShelfItemDelegateManager before ShelfDelegate. |
[email protected] | c25ff50 | 2013-12-04 13:52:48 | [diff] [blame] | 588 | shelf_item_delegate_manager_.reset( |
| 589 | new ShelfItemDelegateManager(shelf_model_.get())); |
[email protected] | 6777f63 | 2013-10-15 02:38:41 | [diff] [blame] | 590 | |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 591 | shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get())); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 592 | scoped_ptr<ShelfItemDelegate> controller(new AppListShelfItemDelegate); |
[email protected] | 6777f63 | 2013-10-15 02:38:41 | [diff] [blame] | 593 | |
[email protected] | 64936bf | 2013-11-14 19:48:36 | [diff] [blame] | 594 | // Finding the shelf model's location of the app list and setting its |
[email protected] | c25ff50 | 2013-12-04 13:52:48 | [diff] [blame] | 595 | // ShelfItemDelegate. |
[email protected] | b7b4dec | 2013-11-18 06:16:12 | [diff] [blame] | 596 | int app_list_index = shelf_model_->GetItemIndexForType(TYPE_APP_LIST); |
[email protected] | 3fced99a | 2013-10-23 17:16:25 | [diff] [blame] | 597 | DCHECK_GE(app_list_index, 0); |
[email protected] | eec097142 | 2014-02-03 23:51:27 | [diff] [blame] | 598 | ShelfID app_list_id = shelf_model_->items()[app_list_index].id; |
[email protected] | 6777f63 | 2013-10-15 02:38:41 | [diff] [blame] | 599 | DCHECK(app_list_id); |
[email protected] | c25ff50 | 2013-12-04 13:52:48 | [diff] [blame] | 600 | shelf_item_delegate_manager_->SetShelfItemDelegate(app_list_id, |
| 601 | controller.Pass()); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 602 | shelf_window_watcher_.reset(new ShelfWindowWatcher( |
| 603 | shelf_model_.get(), shelf_item_delegate_manager_.get())); |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 604 | } |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 605 | return shelf_delegate_.get(); |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 606 | } |
| 607 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 608 | void Shell::SetTouchHudProjectionEnabled(bool enabled) { |
| 609 | if (is_touch_hud_projection_enabled_ == enabled) |
| 610 | return; |
| 611 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 612 | is_touch_hud_projection_enabled_ = enabled; |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 613 | FOR_EACH_OBSERVER(ShellObserver, observers_, |
| 614 | OnTouchHudProjectionToggled(enabled)); |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 615 | } |
| 616 | |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 617 | #if defined(OS_CHROMEOS) |
| 618 | ash::FirstRunHelper* Shell::CreateFirstRunHelper() { |
| 619 | return new ash::FirstRunHelperImpl; |
| 620 | } |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 621 | |
| 622 | void Shell::SetCursorCompositingEnabled(bool enabled) { |
| 623 | display_controller_->cursor_window_controller()->SetCursorCompositingEnabled( |
| 624 | enabled); |
| 625 | native_cursor_manager_->SetNativeCursorEnabled(!enabled); |
| 626 | } |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 627 | #endif // defined(OS_CHROMEOS) |
| 628 | |
[email protected] | f946670 | 2012-09-17 16:35:27 | [diff] [blame] | 629 | void Shell::DoInitialWorkspaceAnimation() { |
| 630 | return GetPrimaryRootWindowController()->workspace_controller()-> |
| 631 | DoInitialAnimation(); |
| 632 | } |
| 633 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 634 | //////////////////////////////////////////////////////////////////////////////// |
| 635 | // Shell, private: |
| 636 | |
| 637 | Shell::Shell(ShellDelegate* delegate) |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 638 | : target_root_window_(NULL), |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 639 | scoped_target_root_window_(NULL), |
| 640 | delegate_(delegate), |
| 641 | window_positioner_(new WindowPositioner), |
| 642 | activation_client_(NULL), |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 643 | #if defined(OS_CHROMEOS) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 644 | display_configurator_(new ui::DisplayConfigurator()), |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 645 | #endif // defined(OS_CHROMEOS) |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 646 | native_cursor_manager_(new AshNativeCursorManager), |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 647 | cursor_manager_( |
jonross | 8834fc4 | 2014-12-19 17:29:19 | [diff] [blame] | 648 | scoped_ptr<::wm::NativeCursorManager>(native_cursor_manager_)), |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 649 | simulate_modal_window_open_for_testing_(false), |
[email protected] | 99edff3e | 2014-01-31 18:20:36 | [diff] [blame] | 650 | is_touch_hud_projection_enabled_(false) { |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 651 | DCHECK(delegate_.get()); |
[email protected] | 99edff3e | 2014-01-31 18:20:36 | [diff] [blame] | 652 | gpu_support_.reset(delegate_->CreateGPUSupport()); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 653 | display_manager_.reset(new DisplayManager); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 654 | display_controller_.reset(new DisplayController); |
[email protected] | 5d2ea36 | 2013-12-13 08:10:18 | [diff] [blame] | 655 | user_metrics_recorder_.reset(new UserMetricsRecorder); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 656 | |
| 657 | #if defined(OS_CHROMEOS) |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 658 | PowerStatus::Initialize(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 659 | #endif |
| 660 | } |
| 661 | |
| 662 | Shell::~Shell() { |
| 663 | TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); |
| 664 | |
[email protected] | 050e7718 | 2014-03-25 15:29:16 | [diff] [blame] | 665 | delegate_->PreShutdown(); |
| 666 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 667 | views::FocusManagerFactory::Install(NULL); |
| 668 | |
| 669 | // Remove the focus from any window. This will prevent overhead and side |
| 670 | // effects (e.g. crashes) from changing focus during shutdown. |
| 671 | // See bug crbug.com/134502. |
| 672 | aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(NULL); |
| 673 | |
| 674 | // Please keep in same order as in Init() because it's easy to miss one. |
| 675 | if (window_modality_controller_) |
| 676 | window_modality_controller_.reset(); |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 677 | #if defined(OS_CHROMEOS) |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 678 | RemovePreTargetHandler(magnifier_key_scroll_handler_.get()); |
| 679 | magnifier_key_scroll_handler_.reset(); |
| 680 | |
| 681 | RemovePreTargetHandler(speech_feedback_handler_.get()); |
| 682 | speech_feedback_handler_.reset(); |
[email protected] | 3dff2ef | 2014-02-09 22:50:39 | [diff] [blame] | 683 | #endif |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 684 | RemovePreTargetHandler(overlay_filter_.get()); |
| 685 | RemovePreTargetHandler(input_method_filter_.get()); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 686 | RemovePreTargetHandler(accelerator_filter_.get()); |
| 687 | RemovePreTargetHandler(event_transformation_handler_.get()); |
| 688 | RemovePreTargetHandler(toplevel_window_event_handler_.get()); |
| 689 | RemovePostTargetHandler(toplevel_window_event_handler_.get()); |
[email protected] | 342d56a | 2013-12-20 23:01:02 | [diff] [blame] | 690 | RemovePreTargetHandler(system_gesture_filter_.get()); |
| 691 | RemovePreTargetHandler(keyboard_metrics_filter_.get()); |
[email protected] | 8ab613cf | 2014-05-12 09:39:49 | [diff] [blame] | 692 | RemovePreTargetHandler(mouse_cursor_filter_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 693 | |
| 694 | // TooltipController is deleted with the Shell so removing its references. |
| 695 | RemovePreTargetHandler(tooltip_controller_.get()); |
| 696 | |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 697 | #if defined(OS_CHROMEOS) |
| 698 | screen_orientation_controller_.reset(); |
| 699 | #endif |
| 700 | |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 701 | // Destroy the virtual keyboard controller before the maximize mode controller |
| 702 | // since the latters destructor triggers events that the former is listening |
| 703 | // to but no longer cares about. |
| 704 | #if defined(OS_CHROMEOS) |
| 705 | virtual_keyboard_controller_.reset(); |
| 706 | #endif |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 707 | |
[email protected] | 2a57beb5 | 2014-06-09 20:02:26 | [diff] [blame] | 708 | // Destroy maximize mode controller early on since it has some observers which |
[email protected] | 5ed2b64 | 2014-03-04 00:06:57 | [diff] [blame] | 709 | // need to be removed. |
[email protected] | 58fb353d | 2014-04-04 03:28:05 | [diff] [blame] | 710 | maximize_mode_controller_.reset(); |
[email protected] | 5ed2b64 | 2014-03-04 00:06:57 | [diff] [blame] | 711 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 712 | // AppList needs to be released before shelf layout manager, which is |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 713 | // destroyed with shelf container in the loop below. However, app list |
| 714 | // container is now on top of shelf container and released after it. |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 715 | // TODO(xiyuan): Move it back when app list container is no longer needed. |
| 716 | app_list_controller_.reset(); |
| 717 | |
[email protected] | 0dc8551 | 2014-03-13 13:26:41 | [diff] [blame] | 718 | #if defined(OS_CHROMEOS) |
[email protected] | ded3249 | 2014-03-14 10:09:28 | [diff] [blame] | 719 | // Destroy the LastWindowClosedLogoutReminder before the |
| 720 | // LogoutConfirmationController. |
| 721 | last_window_closed_logout_reminder_.reset(); |
| 722 | |
[email protected] | 7b3f91ee | 2014-03-06 11:41:40 | [diff] [blame] | 723 | // Destroy the LogoutConfirmationController before the SystemTrayDelegate. |
| 724 | logout_confirmation_controller_.reset(); |
[email protected] | 0dc8551 | 2014-03-13 13:26:41 | [diff] [blame] | 725 | #endif |
[email protected] | 7b3f91ee | 2014-03-06 11:41:40 | [diff] [blame] | 726 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 727 | // Destroy SystemTrayDelegate before destroying the status area(s). |
| 728 | system_tray_delegate_->Shutdown(); |
| 729 | system_tray_delegate_.reset(); |
| 730 | |
| 731 | locale_notification_controller_.reset(); |
| 732 | |
| 733 | // Drag-and-drop must be canceled prior to close all windows. |
| 734 | drag_drop_controller_.reset(); |
| 735 | |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 736 | // Controllers who have WindowObserver added must be deleted |
| 737 | // before |display_controller_| is deleted. |
| 738 | |
| 739 | #if defined(OS_CHROMEOS) |
| 740 | // VideoActivityNotifier must be deleted before |video_detector_| is |
| 741 | // deleted because it's observing video activity through |
| 742 | // VideoDetectorObserver interface. |
| 743 | video_activity_notifier_.reset(); |
| 744 | #endif // defined(OS_CHROMEOS) |
| 745 | video_detector_.reset(); |
[email protected] | 0e3e7cb | 2014-04-12 05:18:25 | [diff] [blame] | 746 | high_contrast_controller_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 747 | |
| 748 | shadow_controller_.reset(); |
| 749 | resize_shadow_controller_.reset(); |
| 750 | |
[email protected] | dd1e1ac | 2014-05-13 03:44:09 | [diff] [blame] | 751 | window_cycle_controller_.reset(); |
[email protected] | 3a47292 | 2013-12-16 18:00:54 | [diff] [blame] | 752 | window_selector_controller_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 753 | |
| 754 | // |shelf_window_watcher_| has a weak pointer to |shelf_Model_| |
| 755 | // and has window observers. |
| 756 | shelf_window_watcher_.reset(); |
| 757 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 758 | // Destroy all child windows including widgets. |
| 759 | display_controller_->CloseChildWindows(); |
afakhry | 5815939 | 2015-05-22 02:45:52 | [diff] [blame^] | 760 | // MruWindowTracker must be destroyed after all windows have been deleted to |
| 761 | // avoid a possible crash when Shell is destroyed from a non-normal shutdown |
| 762 | // path. (crbug.com/485438). |
| 763 | mru_window_tracker_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 764 | |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 765 | // Chrome implementation of shelf delegate depends on FocusClient, |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 766 | // so must be deleted before |focus_client_|. |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 767 | shelf_delegate_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 768 | focus_client_.reset(); |
| 769 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 770 | // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
| 771 | // needs to remove observers from it. |
| 772 | system_tray_notifier_.reset(); |
| 773 | |
| 774 | // These need a valid Shell instance to clean up properly, so explicitly |
| 775 | // delete them before invalidating the instance. |
| 776 | // Alphabetical. TODO(oshima): sort. |
| 777 | magnification_controller_.reset(); |
| 778 | partial_magnification_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 779 | tooltip_controller_.reset(); |
| 780 | event_client_.reset(); |
[email protected] | 567c269 | 2014-05-28 02:40:55 | [diff] [blame] | 781 | nested_accelerator_controller_.reset(); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 782 | toplevel_window_event_handler_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 783 | visibility_controller_.reset(); |
[email protected] | c25ff50 | 2013-12-04 13:52:48 | [diff] [blame] | 784 | // |shelf_item_delegate_manager_| observes |shelf_model_|. It must be |
[email protected] | 64936bf | 2013-11-14 19:48:36 | [diff] [blame] | 785 | // destroyed before |shelf_model_| is destroyed. |
[email protected] | c25ff50 | 2013-12-04 13:52:48 | [diff] [blame] | 786 | shelf_item_delegate_manager_.reset(); |
[email protected] | 64936bf | 2013-11-14 19:48:36 | [diff] [blame] | 787 | shelf_model_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 788 | |
| 789 | power_button_controller_.reset(); |
| 790 | lock_state_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 791 | |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 792 | #if defined(OS_CHROMEOS) |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 793 | resolution_notification_controller_.reset(); |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 794 | #endif |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 795 | desktop_background_controller_.reset(); |
mukai | 19274bdd | 2015-02-24 22:37:48 | [diff] [blame] | 796 | partial_screenshot_controller_.reset(); |
[email protected] | 8ab613cf | 2014-05-12 09:39:49 | [diff] [blame] | 797 | mouse_cursor_filter_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 798 | |
dnicoara | 8c3bd1e6 | 2014-10-30 19:53:39 | [diff] [blame] | 799 | #if defined(OS_CHROMEOS) |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 800 | touch_transformer_controller_.reset(); |
dnicoara | 8c3bd1e6 | 2014-10-30 19:53:39 | [diff] [blame] | 801 | #endif // defined(OS_CHROMEOS) |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 802 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 803 | // This also deletes all RootWindows. Note that we invoke Shutdown() on |
| 804 | // DisplayController before resetting |display_controller_|, since destruction |
| 805 | // of its owned RootWindowControllers relies on the value. |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 806 | display_manager_->CreateScreenForShutdown(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 807 | display_controller_->Shutdown(); |
| 808 | display_controller_.reset(); |
| 809 | screen_position_controller_.reset(); |
[email protected] | f3ab6eff5 | 2013-10-24 03:29:38 | [diff] [blame] | 810 | accessibility_delegate_.reset(); |
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 811 | new_window_delegate_.reset(); |
| 812 | media_delegate_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 813 | |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 814 | keyboard::KeyboardController::ResetInstance(NULL); |
| 815 | |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 816 | #if defined(OS_CHROMEOS) |
robert.bradford | ab05249 | 2015-05-06 11:09:56 | [diff] [blame] | 817 | display_color_manager_.reset(); |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 818 | if (display_change_observer_) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 819 | display_configurator_->RemoveObserver(display_change_observer_.get()); |
[email protected] | 129aad8 | 2014-04-24 23:17:04 | [diff] [blame] | 820 | if (display_configurator_animation_) |
| 821 | display_configurator_->RemoveObserver( |
| 822 | display_configurator_animation_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 823 | if (display_error_observer_) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 824 | display_configurator_->RemoveObserver(display_error_observer_.get()); |
jdufault | 88fb7665 | 2015-04-30 22:36:43 | [diff] [blame] | 825 | if (projecting_observer_) { |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 826 | display_configurator_->RemoveObserver(projecting_observer_.get()); |
jdufault | 88fb7665 | 2015-04-30 22:36:43 | [diff] [blame] | 827 | RemoveShellObserver(projecting_observer_.get()); |
| 828 | } |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 829 | display_change_observer_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 830 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 831 | PowerStatus::Shutdown(); |
pneubeck | 8be1f542 | 2014-10-09 16:46:18 | [diff] [blame] | 832 | |
| 833 | // Ensure that DBusThreadManager outlives this Shell. |
| 834 | DCHECK(chromeos::DBusThreadManager::IsInitialized()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 835 | #endif |
| 836 | |
| 837 | DCHECK(instance_ == this); |
| 838 | instance_ = NULL; |
| 839 | } |
| 840 | |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 841 | void Shell::Init(const ShellInitParams& init_params) { |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 842 | delegate_->PreInit(); |
[email protected] | 0249a653 | 2013-10-31 06:53:34 | [diff] [blame] | 843 | bool display_initialized = display_manager_->InitFromCommandLine(); |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 844 | #if defined(OS_CHROMEOS) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 845 | display_configurator_->Init(!gpu_support_->IsPanelFittingDisabled()); |
[email protected] | 129aad8 | 2014-04-24 23:17:04 | [diff] [blame] | 846 | display_configurator_animation_.reset(new DisplayConfiguratorAnimation()); |
| 847 | display_configurator_->AddObserver(display_configurator_animation_.get()); |
[email protected] | 0249a653 | 2013-10-31 06:53:34 | [diff] [blame] | 848 | |
pneubeck | 8be1f542 | 2014-10-09 16:46:18 | [diff] [blame] | 849 | // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. |
| 850 | chromeos::DBusThreadManager* dbus_thread_manager = |
| 851 | chromeos::DBusThreadManager::Get(); |
| 852 | projecting_observer_.reset( |
| 853 | new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 854 | display_configurator_->AddObserver(projecting_observer_.get()); |
jdufault | 88fb7665 | 2015-04-30 22:36:43 | [diff] [blame] | 855 | AddShellObserver(projecting_observer_.get()); |
[email protected] | 72bce52 | 2014-02-10 21:11:26 | [diff] [blame] | 856 | |
[email protected] | 0249a653 | 2013-10-31 06:53:34 | [diff] [blame] | 857 | if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 858 | display_change_observer_.reset(new DisplayChangeObserver); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 859 | // Register |display_change_observer_| first so that the rest of |
| 860 | // observer gets invoked after the root windows are configured. |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 861 | display_configurator_->AddObserver(display_change_observer_.get()); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 862 | display_error_observer_.reset(new DisplayErrorObserver()); |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 863 | display_configurator_->AddObserver(display_error_observer_.get()); |
| 864 | display_configurator_->set_state_controller(display_change_observer_.get()); |
| 865 | display_configurator_->set_mirroring_controller(display_manager_.get()); |
| 866 | display_configurator_->ForceInitialConfigure( |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 867 | delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); |
| 868 | display_initialized = true; |
| 869 | } |
robert.bradford | ab05249 | 2015-05-06 11:09:56 | [diff] [blame] | 870 | display_color_manager_.reset( |
| 871 | new DisplayColorManager(display_configurator_.get())); |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 872 | #endif // defined(OS_CHROMEOS) |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 873 | if (!display_initialized) |
[email protected] | 0249a653 | 2013-10-31 06:53:34 | [diff] [blame] | 874 | display_manager_->InitDefaultDisplay(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 875 | |
mukai | 5dad2e7 | 2014-12-16 00:00:30 | [diff] [blame] | 876 | display_manager_->RefreshFontParams(); |
[email protected] | 68d6080e | 2014-08-21 23:06:32 | [diff] [blame] | 877 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 878 | // Install the custom factory first so that views::FocusManagers for Tray, |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 879 | // Shelf, and WallPaper could be created by the factory. |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 880 | views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 881 | |
[email protected] | 5b883abb | 2014-05-05 06:44:10 | [diff] [blame] | 882 | aura::Env::CreateInstance(true); |
[email protected] | fa69f2b6 | 2014-05-22 21:47:58 | [diff] [blame] | 883 | aura::Env::GetInstance()->set_context_factory(init_params.context_factory); |
[email protected] | ecca62b | 2013-10-09 16:18:53 | [diff] [blame] | 884 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 885 | // The WindowModalityController needs to be at the front of the input event |
| 886 | // pretarget handler list to ensure that it processes input events when modal |
| 887 | // windows are active. |
| 888 | window_modality_controller_.reset( |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 889 | new ::wm::WindowModalityController(this)); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 890 | |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 891 | env_filter_.reset(new ::wm::CompoundEventFilter); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 892 | AddPreTargetHandler(env_filter_.get()); |
| 893 | |
afakhry | cae0618f | 2015-01-12 17:57:43 | [diff] [blame] | 894 | wm::AshFocusRules* focus_rules = new wm::AshFocusRules(); |
| 895 | |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 896 | ::wm::FocusController* focus_controller = |
afakhry | cae0618f | 2015-01-12 17:57:43 | [diff] [blame] | 897 | new ::wm::FocusController(focus_rules); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 898 | focus_client_.reset(focus_controller); |
| 899 | activation_client_ = focus_controller; |
| 900 | activation_client_->AddObserver(this); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 901 | focus_cycler_.reset(new FocusCycler()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 902 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 903 | screen_position_controller_.reset(new ScreenPositionController); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 904 | |
| 905 | display_controller_->Start(); |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 906 | display_controller_->CreatePrimaryHost( |
| 907 | ShellInitParamsToAshWindowTreeHostInitParams(init_params)); |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 908 | aura::Window* root_window = display_controller_->GetPrimaryRootWindow(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 909 | target_root_window_ = root_window; |
| 910 | |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 911 | #if defined(OS_CHROMEOS) |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 912 | resolution_notification_controller_.reset( |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 913 | new ResolutionNotificationController); |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 914 | #endif |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 915 | |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 916 | cursor_manager_.SetDisplay(GetScreen()->GetPrimaryDisplay()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 917 | |
[email protected] | 567c269 | 2014-05-28 02:40:55 | [diff] [blame] | 918 | nested_accelerator_controller_.reset( |
| 919 | new ::wm::NestedAcceleratorController(new NestedAcceleratorDelegate)); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 920 | accelerator_controller_.reset(new AcceleratorController); |
[email protected] | 58fb353d | 2014-04-04 03:28:05 | [diff] [blame] | 921 | maximize_mode_controller_.reset(new MaximizeModeController()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 922 | |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 923 | #if defined(OS_CHROMEOS) |
| 924 | magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 925 | AddPreTargetHandler(magnifier_key_scroll_handler_.get()); |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 926 | speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler(); |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 927 | AddPreTargetHandler(speech_feedback_handler_.get()); |
[email protected] | 3dff2ef | 2014-02-09 22:50:39 | [diff] [blame] | 928 | #endif |
| 929 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 930 | // The order in which event filters are added is significant. |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 931 | |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 932 | // ui::UserActivityDetector passes events to observers, so let them get |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 933 | // rewritten first. |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 934 | user_activity_detector_.reset(new ui::UserActivityDetector); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 935 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 936 | overlay_filter_.reset(new OverlayEventFilter); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 937 | AddPreTargetHandler(overlay_filter_.get()); |
| 938 | AddShellObserver(overlay_filter_.get()); |
| 939 | |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 940 | input_method_filter_.reset(new ::wm::InputMethodEventFilter( |
[email protected] | 2374d181 | 2014-03-04 03:42:27 | [diff] [blame] | 941 | root_window->GetHost()->GetAcceleratedWidget())); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 942 | AddPreTargetHandler(input_method_filter_.get()); |
| 943 | |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 944 | accelerator_filter_.reset(new ::wm::AcceleratorFilter( |
afakhry | 5546373 | 2014-11-21 21:06:16 | [diff] [blame] | 945 | scoped_ptr< ::wm::AcceleratorDelegate>(new AcceleratorDelegate).Pass(), |
| 946 | accelerator_controller_->accelerator_history())); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 947 | AddPreTargetHandler(accelerator_filter_.get()); |
| 948 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 949 | event_transformation_handler_.reset(new EventTransformationHandler); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 950 | AddPreTargetHandler(event_transformation_handler_.get()); |
| 951 | |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 952 | toplevel_window_event_handler_.reset(new ToplevelWindowEventHandler); |
| 953 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 954 | system_gesture_filter_.reset(new SystemGestureEventFilter); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 955 | AddPreTargetHandler(system_gesture_filter_.get()); |
| 956 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 957 | keyboard_metrics_filter_.reset(new KeyboardUMAEventFilter); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 958 | AddPreTargetHandler(keyboard_metrics_filter_.get()); |
| 959 | |
| 960 | // The keyboard system must be initialized before the RootWindowController is |
| 961 | // created. |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 962 | #if defined(OS_CHROMEOS) |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 963 | keyboard::InitializeKeyboard(); |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 964 | #endif |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 965 | |
[email protected] | 354520b | 2014-06-21 04:31:01 | [diff] [blame] | 966 | #if defined(OS_CHROMEOS) |
| 967 | sticky_keys_controller_.reset(new StickyKeysController); |
| 968 | #endif |
| 969 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 970 | lock_state_controller_.reset(new LockStateController); |
| 971 | power_button_controller_.reset(new PowerButtonController( |
| 972 | lock_state_controller_.get())); |
[email protected] | 94545ca9 | 2014-03-29 01:17:59 | [diff] [blame] | 973 | #if defined(OS_CHROMEOS) |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 974 | // Pass the initial display state to PowerButtonController. |
| 975 | power_button_controller_->OnDisplayModeChanged( |
[email protected] | bcec7fb6 | 2014-04-08 20:59:09 | [diff] [blame] | 976 | display_configurator_->cached_displays()); |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 977 | #endif |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 978 | AddShellObserver(lock_state_controller_.get()); |
| 979 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 980 | drag_drop_controller_.reset(new DragDropController); |
mukai | 19274bdd | 2015-02-24 22:37:48 | [diff] [blame] | 981 | // |partial_screenshot_controller_| needs to be created (and prepended as a |
| 982 | // pre-target handler) at this point, because |mouse_cursor_filter_| needs to |
| 983 | // process mouse events prior to partial screenshot session. |
| 984 | // See http://crbug.com/459214 |
| 985 | partial_screenshot_controller_.reset(new PartialScreenshotController()); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 986 | mouse_cursor_filter_.reset(new MouseCursorEventFilter()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 987 | PrependPreTargetHandler(mouse_cursor_filter_.get()); |
| 988 | |
| 989 | // Create Controllers that may need root window. |
| 990 | // TODO(oshima): Move as many controllers before creating |
| 991 | // RootWindowController as possible. |
| 992 | visibility_controller_.reset(new AshVisibilityController); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 993 | |
| 994 | magnification_controller_.reset( |
| 995 | MagnificationController::CreateInstance()); |
afakhry | cae0618f | 2015-01-12 17:57:43 | [diff] [blame] | 996 | mru_window_tracker_.reset(new MruWindowTracker(activation_client_, |
| 997 | focus_rules)); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 998 | |
| 999 | partial_magnification_controller_.reset( |
| 1000 | new PartialMagnificationController()); |
| 1001 | |
[email protected] | 55398d2 | 2013-10-10 19:49:20 | [diff] [blame] | 1002 | autoclick_controller_.reset(AutoclickController::CreateInstance()); |
| 1003 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1004 | high_contrast_controller_.reset(new HighContrastController); |
| 1005 | video_detector_.reset(new VideoDetector); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1006 | window_selector_controller_.reset(new WindowSelectorController()); |
[email protected] | dd1e1ac | 2014-05-13 03:44:09 | [diff] [blame] | 1007 | window_cycle_controller_.reset(new WindowCycleController()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1008 | |
oshima | ebbe6377 | 2015-02-19 18:41:32 | [diff] [blame] | 1009 | tooltip_controller_.reset(new views::corewm::TooltipController( |
| 1010 | scoped_ptr<views::corewm::Tooltip>(new views::corewm::TooltipAura))); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1011 | AddPreTargetHandler(tooltip_controller_.get()); |
| 1012 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1013 | event_client_.reset(new EventClientImpl); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1014 | |
| 1015 | // This controller needs to be set before SetupManagedWindowMode. |
| 1016 | desktop_background_controller_.reset(new DesktopBackgroundController()); |
| 1017 | user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); |
| 1018 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1019 | session_state_delegate_.reset(delegate_->CreateSessionStateDelegate()); |
[email protected] | f3ab6eff5 | 2013-10-24 03:29:38 | [diff] [blame] | 1020 | accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); |
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 1021 | new_window_delegate_.reset(delegate_->CreateNewWindowDelegate()); |
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 1022 | media_delegate_.reset(delegate_->CreateMediaDelegate()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1023 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1024 | resize_shadow_controller_.reset(new ResizeShadowController()); |
[email protected] | d74caa8 | 2014-03-10 20:52:56 | [diff] [blame] | 1025 | shadow_controller_.reset( |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 1026 | new ::wm::ShadowController(activation_client_)); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1027 | |
| 1028 | // Create system_tray_notifier_ before the delegate. |
| 1029 | system_tray_notifier_.reset(new ash::SystemTrayNotifier()); |
| 1030 | |
| 1031 | // Initialize system_tray_delegate_ before initializing StatusAreaWidget. |
| 1032 | system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); |
| 1033 | DCHECK(system_tray_delegate_.get()); |
| 1034 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1035 | locale_notification_controller_.reset(new LocaleNotificationController); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1036 | |
| 1037 | // Initialize system_tray_delegate_ after StatusAreaWidget is created. |
| 1038 | system_tray_delegate_->Initialize(); |
| 1039 | |
[email protected] | 0dc8551 | 2014-03-13 13:26:41 | [diff] [blame] | 1040 | #if defined(OS_CHROMEOS) |
[email protected] | 7b3f91ee | 2014-03-06 11:41:40 | [diff] [blame] | 1041 | // Create the LogoutConfirmationController after the SystemTrayDelegate. |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1042 | logout_confirmation_controller_.reset(new LogoutConfirmationController( |
| 1043 | base::Bind(&SystemTrayDelegate::SignOut, |
| 1044 | base::Unretained(system_tray_delegate_.get())))); |
[email protected] | 7b3f91ee | 2014-03-06 11:41:40 | [diff] [blame] | 1045 | |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 1046 | // Create TouchTransformerController before DisplayController::InitDisplays() |
| 1047 | // since TouchTransformerController listens on |
| 1048 | // DisplayController::Observer::OnDisplaysInitialized(). |
| 1049 | touch_transformer_controller_.reset(new TouchTransformerController()); |
dnicoara | 8c3bd1e6 | 2014-10-30 19:53:39 | [diff] [blame] | 1050 | #endif // defined(OS_CHROMEOS) |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 1051 | |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 1052 | display_controller_->InitDisplays(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1053 | |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 1054 | #if defined(OS_CHROMEOS) |
| 1055 | // Needs to be created after InitDisplays() since it may cause the virtual |
| 1056 | // keyboard to be deployed. |
| 1057 | virtual_keyboard_controller_.reset(new VirtualKeyboardController); |
| 1058 | #endif // defined(OS_CHROMEOS) |
| 1059 | |
[email protected] | a356579 | 2013-10-18 12:52:37 | [diff] [blame] | 1060 | // It needs to be created after RootWindowController has been created |
| 1061 | // (which calls OnWindowResized has been called, otherwise the |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1062 | // widget will not paint when restoring after a browser crash. Also it needs |
| 1063 | // to be created after InitSecondaryDisplays() to initialize the wallpapers in |
| 1064 | // the correct size. |
| 1065 | user_wallpaper_delegate_->InitializeWallpaper(); |
| 1066 | |
| 1067 | if (initially_hide_cursor_) |
| 1068 | cursor_manager_.HideCursor(); |
| 1069 | cursor_manager_.SetCursor(ui::kCursorPointer); |
| 1070 | |
[email protected] | 5c04d3a9 | 2013-10-08 19:17:19 | [diff] [blame] | 1071 | #if defined(OS_CHROMEOS) |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 1072 | // Set accelerator controller delegates. |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1073 | accelerator_controller_->SetBrightnessControlDelegate( |
| 1074 | scoped_ptr<ash::BrightnessControlDelegate>( |
| 1075 | new ash::system::BrightnessControllerChromeos).Pass()); |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 1076 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1077 | power_event_observer_.reset(new PowerEventObserver()); |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 1078 | user_activity_notifier_.reset( |
[email protected] | b0fa701 | 2014-04-16 12:50:57 | [diff] [blame] | 1079 | new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 1080 | video_activity_notifier_.reset( |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1081 | new VideoActivityNotifier(video_detector_.get())); |
| 1082 | bluetooth_notification_controller_.reset(new BluetoothNotificationController); |
| 1083 | last_window_closed_logout_reminder_.reset(new LastWindowClosedLogoutReminder); |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 1084 | screen_orientation_controller_.reset(new ScreenOrientationController()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1085 | #endif |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1086 | // The compositor thread and main message loop have to be running in |
| 1087 | // order to create mirror window. Run it after the main message loop |
| 1088 | // is started. |
oshima | c8089b8 | 2014-11-12 21:43:50 | [diff] [blame] | 1089 | display_manager_->CreateMirrorWindowAsyncIfAny(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1090 | } |
| 1091 | |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 1092 | void Shell::InitKeyboard() { |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1093 | if (keyboard::IsKeyboardEnabled()) { |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 1094 | if (keyboard::KeyboardController::GetInstance()) { |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1095 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 1096 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 1097 | iter != controllers.end(); ++iter) { |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 1098 | (*iter)->DeactivateKeyboard( |
| 1099 | keyboard::KeyboardController::GetInstance()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1100 | } |
| 1101 | } |
| 1102 | keyboard::KeyboardControllerProxy* proxy = |
| 1103 | delegate_->CreateKeyboardControllerProxy(); |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 1104 | keyboard::KeyboardController::ResetInstance( |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1105 | new keyboard::KeyboardController(proxy)); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1106 | } |
| 1107 | } |
| 1108 | |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame] | 1109 | void Shell::InitRootWindow(aura::Window* root_window) { |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 1110 | DCHECK(activation_client_); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1111 | DCHECK(visibility_controller_.get()); |
| 1112 | DCHECK(drag_drop_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1113 | |
[email protected] | 8cfb672 | 2012-11-28 03:28:46 | [diff] [blame] | 1114 | aura::client::SetFocusClient(root_window, focus_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1115 | input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 1116 | aura::client::SetActivationClient(root_window, activation_client_); |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 1117 | ::wm::FocusController* focus_controller = |
| 1118 | static_cast< ::wm::FocusController*>(activation_client_); |
[email protected] | 37533821 | 2013-09-05 22:14:52 | [diff] [blame] | 1119 | root_window->AddPreTargetHandler(focus_controller); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1120 | aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
| 1121 | aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 1122 | aura::client::SetScreenPositionClient(root_window, |
| 1123 | screen_position_controller_.get()); |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 1124 | aura::client::SetCursorClient(root_window, &cursor_manager_); |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 1125 | aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 1126 | aura::client::SetEventClient(root_window, event_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1127 | |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 1128 | aura::client::SetWindowMoveClient(root_window, |
| 1129 | toplevel_window_event_handler_.get()); |
| 1130 | root_window->AddPreTargetHandler(toplevel_window_event_handler_.get()); |
| 1131 | root_window->AddPostTargetHandler(toplevel_window_event_handler_.get()); |
| 1132 | |
[email protected] | 567c269 | 2014-05-28 02:40:55 | [diff] [blame] | 1133 | if (nested_accelerator_controller_) { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1134 | aura::client::SetDispatcherClient(root_window, |
[email protected] | 567c269 | 2014-05-28 02:40:55 | [diff] [blame] | 1135 | nested_accelerator_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1136 | } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1137 | } |
| 1138 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1139 | bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 1140 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 1141 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 1142 | iter != controllers.end(); ++iter) { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1143 | SystemModalContainerLayoutManager* layout_manager = |
[email protected] | bb0c7cd4 | 2013-05-20 23:39:45 | [diff] [blame] | 1144 | (*iter)->GetSystemModalLayoutManager(window); |
| 1145 | if (layout_manager && layout_manager->CanWindowReceiveEvents(window)) |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1146 | return true; |
[email protected] | 602022b | 2014-03-31 17:07:31 | [diff] [blame] | 1147 | // Allow events to fall through to the virtual keyboard even if displaying |
| 1148 | // a system modal dialog. |
| 1149 | if ((*iter)->IsVirtualKeyboardWindow(window)) |
| 1150 | return true; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1151 | } |
[email protected] | 602022b | 2014-03-31 17:07:31 | [diff] [blame] | 1152 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1153 | return false; |
| 1154 | } |
| 1155 | |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 1156 | //////////////////////////////////////////////////////////////////////////////// |
| 1157 | // Shell, ui::EventTarget overrides: |
| 1158 | |
[email protected] | 869f635 | 2012-12-06 20:47:17 | [diff] [blame] | 1159 | bool Shell::CanAcceptEvent(const ui::Event& event) { |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 1160 | return true; |
| 1161 | } |
| 1162 | |
| 1163 | ui::EventTarget* Shell::GetParentTarget() { |
[email protected] | ff027885 | 2013-11-05 22:35:48 | [diff] [blame] | 1164 | return aura::Env::GetInstance(); |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 1165 | } |
| 1166 | |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 1167 | scoped_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { |
| 1168 | return scoped_ptr<ui::EventTargetIterator>(); |
| 1169 | } |
| 1170 | |
| 1171 | ui::EventTargeter* Shell::GetEventTargeter() { |
| 1172 | NOTREACHED(); |
| 1173 | return NULL; |
| 1174 | } |
| 1175 | |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 1176 | void Shell::OnEvent(ui::Event* event) { |
[email protected] | 1ae36165 | 2012-12-12 22:39:51 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | //////////////////////////////////////////////////////////////////////////////// |
| 1180 | // Shell, aura::client::ActivationChangeObserver implementation: |
| 1181 | |
| 1182 | void Shell::OnWindowActivated(aura::Window* gained_active, |
| 1183 | aura::Window* lost_active) { |
[email protected] | d219a19 | 2012-12-14 00:08:18 | [diff] [blame] | 1184 | if (gained_active) |
[email protected] | b42910f | 2013-08-01 11:45:29 | [diff] [blame] | 1185 | target_root_window_ = gained_active->GetRootWindow(); |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 1186 | } |
| 1187 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 1188 | } // namespace ash |