[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> |
dcheng | cbf0d9d | 2015-12-27 22:49:23 | [diff] [blame] | 9 | #include <utility> |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 10 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 11 | #include "ash/accelerators/accelerator_controller.h" |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 12 | #include "ash/accelerators/accelerator_delegate.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 13 | #include "ash/accelerators/ash_focus_manager_factory.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 14 | #include "ash/accelerators/magnifier_key_scroller.h" |
| 15 | #include "ash/accelerators/spoken_feedback_toggler.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 16 | #include "ash/accessibility_delegate.h" |
sky | 15ef0aa | 2017-01-20 18:55:59 | [diff] [blame] | 17 | #include "ash/app_list/app_list_delegate_impl.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 18 | #include "ash/ash_constants.h" |
moshayedi | c229a52 | 2017-05-05 18:14:26 | [diff] [blame] | 19 | #include "ash/ash_switches.h" |
[email protected] | 55398d2 | 2013-10-10 19:49:20 | [diff] [blame] | 20 | #include "ash/autoclick/autoclick_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 21 | #include "ash/cast_config_controller.h" |
Scott Violet | d64dac1 | 2017-06-02 21:50:08 | [diff] [blame] | 22 | #include "ash/display/ash_display_controller.h" |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 23 | #include "ash/display/cursor_window_controller.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 24 | #include "ash/display/display_color_manager_chromeos.h" |
stevenjb | 537c5c3f | 2016-01-20 23:38:12 | [diff] [blame] | 25 | #include "ash/display/display_configuration_controller.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 26 | #include "ash/display/display_error_observer_chromeos.h" |
[email protected] | 682990f | 2013-01-10 06:49:11 | [diff] [blame] | 27 | #include "ash/display/event_transformation_handler.h" |
[email protected] | 9154587 | 2012-11-21 13:58:27 | [diff] [blame] | 28 | #include "ash/display/mouse_cursor_event_filter.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 29 | #include "ash/display/projecting_observer_chromeos.h" |
| 30 | #include "ash/display/resolution_notification_controller.h" |
rjkroege | 2c930540 | 2016-09-07 00:21:45 | [diff] [blame] | 31 | #include "ash/display/screen_ash.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 32 | #include "ash/display/screen_orientation_controller_chromeos.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 33 | #include "ash/display/screen_position_controller.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 34 | #include "ash/display/shutdown_observer_chromeos.h" |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 35 | #include "ash/display/window_tree_host_manager.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 36 | #include "ash/drag_drop/drag_drop_controller.h" |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 37 | #include "ash/first_run/first_run_helper_impl.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 38 | #include "ash/focus_cycler.h" |
| 39 | #include "ash/frame/custom_frame_view_ash.h" |
| 40 | #include "ash/gpu_support.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 41 | #include "ash/high_contrast/high_contrast_controller.h" |
Vladislav Kaznacheev | 6d6aaff | 2017-07-22 04:06:32 | [diff] [blame] | 42 | #include "ash/highlighter/highlighter_controller.h" |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 43 | #include "ash/host/ash_window_tree_host_init_params.h" |
James Cook | bb02673 | 2017-06-09 23:01:55 | [diff] [blame] | 44 | #include "ash/ime/ime_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 45 | #include "ash/keyboard/keyboard_ui.h" |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 46 | #include "ash/laser/laser_pointer_controller.h" |
xiaoyinh | 2bbdd10 | 2017-05-18 23:29:42 | [diff] [blame] | 47 | #include "ash/login/lock_screen_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 48 | #include "ash/login_status.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 49 | #include "ash/magnifier/magnification_controller.h" |
[email protected] | 77f7c13 | 2012-11-15 06:52:54 | [diff] [blame] | 50 | #include "ash/magnifier/partial_magnification_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 51 | #include "ash/media_controller.h" |
| 52 | #include "ash/new_window_controller.h" |
| 53 | #include "ash/palette_delegate.h" |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 54 | #include "ash/public/cpp/config.h" |
msw | 109806d | 2017-06-02 20:11:57 | [diff] [blame] | 55 | #include "ash/public/cpp/shelf_model.h" |
jamescook | 8800b823 | 2016-10-19 12:46:27 | [diff] [blame] | 56 | #include "ash/public/cpp/shell_window_ids.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 57 | #include "ash/root_window_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 58 | #include "ash/session/session_controller.h" |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 59 | #include "ash/shelf/shelf.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 60 | #include "ash/shelf/shelf_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 61 | #include "ash/shelf/shelf_window_watcher.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 62 | #include "ash/shell_delegate.h" |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 63 | #include "ash/shell_init_params.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 64 | #include "ash/shell_observer.h" |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 65 | #include "ash/shell_port.h" |
Scott Violet | 22a7b921 | 2017-07-20 19:05:19 | [diff] [blame] | 66 | #include "ash/shell_port_classic.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 67 | #include "ash/shutdown_controller.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 68 | #include "ash/sticky_keys/sticky_keys_controller.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 69 | #include "ash/system/bluetooth/bluetooth_notification_controller.h" |
| 70 | #include "ash/system/bluetooth/tray_bluetooth_helper.h" |
| 71 | #include "ash/system/brightness/brightness_controller_chromeos.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 72 | #include "ash/system/brightness_control_delegate.h" |
Lann Martin | b999140 | 2017-06-23 22:25:08 | [diff] [blame] | 73 | #include "ash/system/keyboard_brightness/keyboard_brightness_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 74 | #include "ash/system/keyboard_brightness_control_delegate.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 75 | #include "ash/system/locale/locale_notification_controller.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 76 | #include "ash/system/network/sms_observer.h" |
| 77 | #include "ash/system/network/vpn_list.h" |
afakhry | e4fae85 | 2017-05-09 18:49:06 | [diff] [blame] | 78 | #include "ash/system/night_light/night_light_controller.h" |
Sammie Quon | 4d7dba6 | 2017-08-03 23:18:17 | [diff] [blame] | 79 | #include "ash/system/palette/palette_tray.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 80 | #include "ash/system/power/power_event_observer.h" |
| 81 | #include "ash/system/power/power_status.h" |
| 82 | #include "ash/system/power/video_activity_notifier.h" |
| 83 | #include "ash/system/screen_layout_observer.h" |
James Cook | dc04112 | 2017-08-01 14:03:22 | [diff] [blame] | 84 | #include "ash/system/session/logout_button_tray.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 85 | #include "ash/system/session/logout_confirmation_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 86 | #include "ash/system/status_area_widget.h" |
| 87 | #include "ash/system/toast/toast_manager.h" |
| 88 | #include "ash/system/tray/system_tray_controller.h" |
| 89 | #include "ash/system/tray/system_tray_delegate.h" |
| 90 | #include "ash/system/tray/system_tray_notifier.h" |
James Cook | 9807235 | 2017-08-07 18:00:07 | [diff] [blame] | 91 | #include "ash/system/tray_caps_lock.h" |
kylechar | 55f0eaf2 | 2017-01-11 22:57:37 | [diff] [blame] | 92 | #include "ash/touch/ash_touch_transform_controller.h" |
tbarzic | c78da1ff9 | 2017-05-08 20:46:15 | [diff] [blame] | 93 | #include "ash/tray_action/tray_action.h" |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 94 | #include "ash/utility/screenshot_controller.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 95 | #include "ash/virtual_keyboard_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 96 | #include "ash/wallpaper/wallpaper_controller.h" |
| 97 | #include "ash/wallpaper/wallpaper_delegate.h" |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 98 | #include "ash/wm/ash_focus_rules.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 99 | #include "ash/wm/container_finder.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 100 | #include "ash/wm/event_client_impl.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 101 | #include "ash/wm/immersive_context_ash.h" |
sky | b7b5409 | 2016-08-19 16:00:09 | [diff] [blame] | 102 | #include "ash/wm/immersive_handler_factory_ash.h" |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 103 | #include "ash/wm/lock_state_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 104 | #include "ash/wm/mru_window_tracker.h" |
erg | 36cfb95 | 2017-06-21 19:41:45 | [diff] [blame] | 105 | #include "ash/wm/native_cursor_manager_ash_classic.h" |
| 106 | #include "ash/wm/native_cursor_manager_ash_mus.h" |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 107 | #include "ash/wm/overlay_event_filter.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 108 | #include "ash/wm/overview/window_selector_controller.h" |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 109 | #include "ash/wm/power_button_controller.h" |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 110 | #include "ash/wm/resize_shadow_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 111 | #include "ash/wm/root_window_finder.h" |
hidehiko | 6821ca4 | 2016-06-18 11:12:23 | [diff] [blame] | 112 | #include "ash/wm/screen_pinning_controller.h" |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 113 | #include "ash/wm/splitview/split_view_controller.h" |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 114 | #include "ash/wm/system_gesture_event_filter.h" |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 115 | #include "ash/wm/system_modal_container_event_filter.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 116 | #include "ash/wm/system_modal_container_layout_manager.h" |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 117 | #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
| 118 | #include "ash/wm/tablet_mode/tablet_mode_window_manager.h" |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 119 | #include "ash/wm/toplevel_window_event_handler.h" |
[email protected] | 9633a9d2 | 2012-01-21 16:40:58 | [diff] [blame] | 120 | #include "ash/wm/video_detector.h" |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 121 | #include "ash/wm/window_animations.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 122 | #include "ash/wm/window_cycle_controller.h" |
| 123 | #include "ash/wm/window_positioner.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 124 | #include "ash/wm/window_properties.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 125 | #include "ash/wm/window_util.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 126 | #include "ash/wm/workspace_controller.h" |
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 127 | #include "base/bind.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 128 | #include "base/bind_helpers.h" |
jamescook | fda15900 | 2016-10-21 18:48:57 | [diff] [blame] | 129 | #include "base/command_line.h" |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 130 | #include "base/memory/ptr_util.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 131 | #include "base/sys_info.h" |
tzik | 0dd58d4 | 2017-02-15 08:26:52 | [diff] [blame] | 132 | #include "base/threading/sequenced_worker_pool.h" |
primiano | 7182d7b | 2015-01-30 18:02:03 | [diff] [blame] | 133 | #include "base/trace_event/trace_event.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 134 | #include "chromeos/audio/audio_a11y_controller.h" |
| 135 | #include "chromeos/chromeos_switches.h" |
| 136 | #include "chromeos/dbus/dbus_thread_manager.h" |
reveman | 2415898 | 2017-01-10 05:58:45 | [diff] [blame] | 137 | #include "chromeos/system/devicemode.h" |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 138 | #include "components/prefs/pref_registry_simple.h" |
| 139 | #include "components/prefs/pref_service.h" |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 140 | #include "services/preferences/public/cpp/pref_service_factory.h" |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 141 | #include "services/preferences/public/interfaces/preferences.mojom.h" |
derat | 94887a2 | 2017-01-20 18:17:25 | [diff] [blame] | 142 | #include "services/service_manager/public/cpp/connector.h" |
| 143 | #include "services/ui/public/interfaces/constants.mojom.h" |
sky | 7db5ccf | 2017-03-14 21:52:29 | [diff] [blame] | 144 | #include "ui/app_list/presenter/app_list.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 145 | #include "ui/aura/client/aura_constants.h" |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 146 | #include "ui/aura/env.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 147 | #include "ui/aura/layout_manager.h" |
sky | 6861271 | 2017-04-27 04:45:04 | [diff] [blame] | 148 | #include "ui/aura/mus/focus_synchronizer.h" |
derat | 94887a2 | 2017-01-20 18:17:25 | [diff] [blame] | 149 | #include "ui/aura/mus/user_activity_forwarder.h" |
sky | 6861271 | 2017-04-27 04:45:04 | [diff] [blame] | 150 | #include "ui/aura/mus/window_tree_client.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 151 | #include "ui/aura/window.h" |
[email protected] | fcc51c95 | 2014-02-21 21:31:26 | [diff] [blame] | 152 | #include "ui/aura/window_event_dispatcher.h" |
[email protected] | 2d481774 | 2012-12-17 20:16:18 | [diff] [blame] | 153 | #include "ui/base/ui_base_switches.h" |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 154 | #include "ui/base/user_activity/user_activity_detector.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 155 | #include "ui/chromeos/user_activity_power_manager_notifier.h" |
[email protected] | 116302fc | 2012-05-05 21:45:41 | [diff] [blame] | 156 | #include "ui/compositor/layer.h" |
| 157 | #include "ui/compositor/layer_animator.h" |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 158 | #include "ui/display/display.h" |
sky | 2f68b6f | 2017-05-21 16:08:39 | [diff] [blame] | 159 | #include "ui/display/manager/chromeos/default_touch_transform_setter.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 160 | #include "ui/display/manager/chromeos/display_change_observer.h" |
| 161 | #include "ui/display/manager/chromeos/display_configurator.h" |
sky | 7265b1cc | 2017-05-22 23:11:03 | [diff] [blame] | 162 | #include "ui/display/manager/chromeos/touch_transform_setter.h" |
rjkroege | 72f8154f | 2016-10-29 00:49:02 | [diff] [blame] | 163 | #include "ui/display/manager/display_manager.h" |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 164 | #include "ui/display/screen.h" |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 165 | #include "ui/display/types/native_display_delegate.h" |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 166 | #include "ui/events/event_target_iterator.h" |
sky | 4ec2be8 | 2017-01-06 17:38:32 | [diff] [blame] | 167 | #include "ui/gfx/geometry/insets.h" |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 168 | #include "ui/gfx/image/image_skia.h" |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 169 | #include "ui/keyboard/keyboard_controller.h" |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 170 | #include "ui/keyboard/keyboard_switches.h" |
yhanada | 8909a54 | 2017-07-11 10:06:19 | [diff] [blame] | 171 | #include "ui/keyboard/keyboard_ui.h" |
[email protected] | f1d5c3a | 2013-04-23 17:42:56 | [diff] [blame] | 172 | #include "ui/keyboard/keyboard_util.h" |
[email protected] | d7f30a7 | 2013-10-05 05:09:41 | [diff] [blame] | 173 | #include "ui/views/corewm/tooltip_aura.h" |
[email protected] | a1b7a82 | 2013-02-23 19:08:04 | [diff] [blame] | 174 | #include "ui/views/corewm/tooltip_controller.h" |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 175 | #include "ui/views/focus/focus_manager_factory.h" |
[email protected] | c13be0d | 2011-11-22 02:09:58 | [diff] [blame] | 176 | #include "ui/views/widget/native_widget_aura.h" |
| 177 | #include "ui/views/widget/widget.h" |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 178 | #include "ui/wm/core/accelerator_filter.h" |
[email protected] | ee3ed1077 | 2014-03-11 22:02:01 | [diff] [blame] | 179 | #include "ui/wm/core/compound_event_filter.h" |
| 180 | #include "ui/wm/core/focus_controller.h" |
[email protected] | ee3ed1077 | 2014-03-11 22:02:01 | [diff] [blame] | 181 | #include "ui/wm/core/shadow_controller.h" |
| 182 | #include "ui/wm/core/visibility_controller.h" |
| 183 | #include "ui/wm/core/window_modality_controller.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 184 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 185 | namespace ash { |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 186 | |
| 187 | namespace { |
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 188 | |
[email protected] | 615922f | 2012-02-07 02:41:15 | [diff] [blame] | 189 | using aura::Window; |
[email protected] | 3f02dc5 | 2011-10-21 19:36:45 | [diff] [blame] | 190 | using views::Widget; |
| 191 | |
jamescook | 518dccbd | 2017-05-18 04:57:07 | [diff] [blame] | 192 | bool g_is_browser_process_with_mash = false; |
| 193 | |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 194 | // A Corewm VisibilityController subclass that calls the Ash animation routine |
| 195 | // 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] | 196 | class AshVisibilityController : public ::wm::VisibilityController { |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 197 | public: |
| 198 | AshVisibilityController() {} |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 199 | ~AshVisibilityController() override {} |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 200 | |
| 201 | private: |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 202 | // Overridden from ::wm::VisibilityController: |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 203 | bool CallAnimateOnChildWindowVisibilityChanged(aura::Window* window, |
| 204 | bool visible) override { |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 205 | return AnimateOnChildWindowVisibilityChanged(window, visible); |
| 206 | } |
| 207 | |
| 208 | DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); |
| 209 | }; |
| 210 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 211 | } // namespace |
| 212 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 213 | // static |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 214 | Shell* Shell::instance_ = nullptr; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 215 | // static |
sky | 00f98a37 | 2017-01-11 06:03:49 | [diff] [blame] | 216 | aura::WindowTreeClient* Shell::window_tree_client_ = nullptr; |
| 217 | // static |
sky | a8b222f | 2017-01-12 15:47:13 | [diff] [blame] | 218 | aura::WindowManagerClient* Shell::window_manager_client_ = nullptr; |
| 219 | // static |
[email protected] | 9488d4d | 2012-02-29 18:32:37 | [diff] [blame] | 220 | bool Shell::initially_hide_cursor_ = false; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 221 | |
| 222 | //////////////////////////////////////////////////////////////////////////////// |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 223 | // Shell, public: |
| 224 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 225 | // static |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 226 | Shell* Shell::CreateInstance(const ShellInitParams& init_params) { |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 227 | CHECK(!instance_); |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 228 | ShellPort* shell_port = init_params.shell_port; |
| 229 | if (!shell_port) |
| 230 | shell_port = new ShellPortClassic(); |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 231 | instance_ = new Shell(base::WrapUnique<ShellDelegate>(init_params.delegate), |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 232 | base::WrapUnique<ShellPort>(shell_port)); |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 233 | instance_->Init(init_params); |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 234 | return instance_; |
| 235 | } |
| 236 | |
| 237 | // static |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 238 | Shell* Shell::Get() { |
jamescook | 518dccbd | 2017-05-18 04:57:07 | [diff] [blame] | 239 | CHECK(!g_is_browser_process_with_mash) // Implies null |instance_|. |
| 240 | << "Ash is running in its own process so Shell::Get() will return null. " |
| 241 | "The browser process must use the mojo interfaces in //ash/public to " |
| 242 | "access ash. See ash/README.md for details."; |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 243 | CHECK(instance_); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 244 | return instance_; |
| 245 | } |
| 246 | |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 247 | // static |
[email protected] | b3b7bcd | 2012-03-06 19:35:45 | [diff] [blame] | 248 | bool Shell::HasInstance() { |
| 249 | return !!instance_; |
| 250 | } |
| 251 | |
| 252 | // static |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 253 | void Shell::DeleteInstance() { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 254 | delete instance_; |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 255 | } |
| 256 | |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 257 | // static |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 258 | RootWindowController* Shell::GetPrimaryRootWindowController() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 259 | CHECK(HasInstance()); |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 260 | return RootWindowController::ForWindow(GetPrimaryRootWindow()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | // static |
| 264 | Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 265 | CHECK(HasInstance()); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 266 | RootWindowControllerList root_window_controllers; |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 267 | for (aura::Window* root : GetAllRootWindows()) |
| 268 | root_window_controllers.push_back(RootWindowController::ForWindow(root)); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 269 | return root_window_controllers; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | // static |
thanhph | c90f49ca | 2017-03-03 17:48:53 | [diff] [blame] | 273 | RootWindowController* Shell::GetRootWindowControllerWithDisplayId( |
| 274 | int64_t display_id) { |
| 275 | CHECK(HasInstance()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 276 | aura::Window* root = GetRootWindowForDisplayId(display_id); |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 277 | return root ? RootWindowController::ForWindow(root) : nullptr; |
thanhph | c90f49ca | 2017-03-03 17:48:53 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | // static |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 281 | aura::Window* Shell::GetRootWindowForDisplayId(int64_t display_id) { |
| 282 | CHECK(HasInstance()); |
| 283 | return instance_->window_tree_host_manager_->GetRootWindowForDisplayId( |
| 284 | display_id); |
| 285 | } |
| 286 | |
| 287 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 288 | aura::Window* Shell::GetPrimaryRootWindow() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 289 | CHECK(HasInstance()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 290 | return instance_->window_tree_host_manager_->GetPrimaryRootWindow(); |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 291 | } |
| 292 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 293 | // static |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 294 | aura::Window* Shell::GetRootWindowForNewWindows() { |
| 295 | CHECK(Shell::HasInstance()); |
sky | cb4be5b | 2017-04-06 17:52:45 | [diff] [blame] | 296 | Shell* shell = Shell::Get(); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 297 | if (shell->scoped_root_window_for_new_windows_) |
| 298 | return shell->scoped_root_window_for_new_windows_; |
| 299 | return shell->root_window_for_new_windows_; |
mfomitchev | a1a8aa6 | 2016-05-03 16:23:26 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | // static |
[email protected] | c9390bd | 2013-11-08 20:33:13 | [diff] [blame] | 303 | aura::Window::Windows Shell::GetAllRootWindows() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 304 | CHECK(HasInstance()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 305 | return instance_->window_tree_host_manager_->GetAllRootWindows(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | // static |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 309 | aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 310 | return root_window->GetChildById(container_id); |
| 311 | } |
| 312 | |
| 313 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 314 | const aura::Window* Shell::GetContainer(const aura::Window* root_window, |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 315 | int container_id) { |
| 316 | return root_window->GetChildById(container_id); |
| 317 | } |
| 318 | |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 319 | // static |
jamescook | 0dfe563 | 2017-04-05 18:49:02 | [diff] [blame] | 320 | Config Shell::GetAshConfig() { |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 321 | return Get()->shell_port_->GetAshConfig(); |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 322 | } |
| 323 | |
moshayedi | c229a52 | 2017-05-05 18:14:26 | [diff] [blame] | 324 | // static |
| 325 | bool Shell::ShouldUseIMEService() { |
| 326 | return Shell::GetAshConfig() == Config::MASH || |
| 327 | (Shell::GetAshConfig() == Config::MUS && |
| 328 | base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 329 | switches::kUseIMEService)); |
| 330 | } |
| 331 | |
afakhry | e4fae85 | 2017-05-09 18:49:06 | [diff] [blame] | 332 | // static |
Wenzhao Zang | 56c29293 | 2017-08-02 04:58:34 | [diff] [blame] | 333 | void Shell::RegisterLocalStatePrefs(PrefRegistrySimple* registry) { |
Sammie Quon | 4d7dba6 | 2017-08-03 23:18:17 | [diff] [blame] | 334 | PaletteTray::RegisterLocalStatePrefs(registry); |
Wenzhao Zang | 56c29293 | 2017-08-02 04:58:34 | [diff] [blame] | 335 | WallpaperController::RegisterLocalStatePrefs(registry); |
| 336 | } |
| 337 | |
| 338 | // static |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 339 | void Shell::RegisterProfilePrefs(PrefRegistrySimple* registry) { |
James Cook | dc04112 | 2017-08-01 14:03:22 | [diff] [blame] | 340 | LogoutButtonTray::RegisterProfilePrefs(registry); |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 341 | NightLightController::RegisterProfilePrefs(registry); |
afakhry | e4fae85 | 2017-05-09 18:49:06 | [diff] [blame] | 342 | } |
| 343 | |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 344 | views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 345 | views::Widget* widget) { |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 346 | // Use translucent-style window frames for dialogs. |
[email protected] | 85501fe | 2013-10-18 10:15:27 | [diff] [blame] | 347 | return new CustomFrameViewAsh(widget); |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 348 | } |
| 349 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 350 | void Shell::SetDisplayWorkAreaInsets(Window* contains, |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 351 | const gfx::Insets& insets) { |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 352 | window_tree_host_manager_->UpdateWorkAreaOfDisplayNearestWindow(contains, |
| 353 | insets); |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 354 | } |
| 355 | |
[email protected] | 58868abf | 2014-01-17 23:45:33 | [diff] [blame] | 356 | void Shell::OnCastingSessionStartedOrStopped(bool started) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 357 | for (auto& observer : shell_observers_) |
ericwilligers | 5eff47d | 2016-10-17 19:19:18 | [diff] [blame] | 358 | observer.OnCastingSessionStartedOrStopped(started); |
[email protected] | 58868abf | 2014-01-17 23:45:33 | [diff] [blame] | 359 | } |
| 360 | |
varkha | c71444e5 | 2017-05-25 22:51:34 | [diff] [blame] | 361 | void Shell::OnRootWindowAdded(aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 362 | for (auto& observer : shell_observers_) |
ericwilligers | 5eff47d | 2016-10-17 19:19:18 | [diff] [blame] | 363 | observer.OnRootWindowAdded(root_window); |
[email protected] | 0e3e7cb | 2014-04-12 05:18:25 | [diff] [blame] | 364 | } |
| 365 | |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 366 | void Shell::CreateKeyboard() { |
Keigo Oka | e82281a | 2017-06-14 13:59:14 | [diff] [blame] | 367 | if (keyboard::IsKeyboardEnabled()) { |
| 368 | if (keyboard::KeyboardController::GetInstance()) { |
| 369 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 370 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 371 | iter != controllers.end(); ++iter) { |
| 372 | (*iter)->DeactivateKeyboard( |
| 373 | keyboard::KeyboardController::GetInstance()); |
| 374 | } |
| 375 | } |
| 376 | keyboard::KeyboardController::ResetInstance( |
| 377 | new keyboard::KeyboardController(shell_delegate_->CreateKeyboardUI(), |
| 378 | virtual_keyboard_controller_.get())); |
| 379 | for (auto& observer : shell_observers_) |
| 380 | observer.OnKeyboardControllerCreated(); |
| 381 | } |
| 382 | |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 383 | GetPrimaryRootWindowController()->ActivateKeyboard( |
| 384 | keyboard::KeyboardController::GetInstance()); |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 385 | } |
| 386 | |
Keigo Oka | c7617a4 | 2017-06-14 11:33:24 | [diff] [blame] | 387 | void Shell::DestroyKeyboard() { |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 388 | // TODO(jamescook): Move keyboard create and hide into ShellPort. |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 389 | keyboard_ui_->Hide(); |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 390 | if (keyboard::KeyboardController::GetInstance()) { |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 391 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 392 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 393 | iter != controllers.end(); ++iter) { |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 394 | (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 395 | } |
| 396 | } |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 397 | keyboard::KeyboardController::ResetInstance(nullptr); |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 398 | } |
| 399 | |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 400 | bool Shell::ShouldSaveDisplaySettings() { |
sky | 2c5eae8 | 2017-06-06 01:46:58 | [diff] [blame] | 401 | // This function is only called from Chrome, hence the DCHECK for not-MASH. |
sky | e5fd122 | 2017-04-12 18:43:23 | [diff] [blame] | 402 | DCHECK(GetAshConfig() != Config::MASH); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 403 | return !( |
| 404 | screen_orientation_controller_->ignore_display_configuration_updates() || |
| 405 | resolution_notification_controller_->DoesNotificationTimeout()); |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 406 | } |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 407 | |
afakhry | 9e0a18b3 | 2017-06-05 19:23:14 | [diff] [blame] | 408 | NightLightController* Shell::night_light_controller() { |
| 409 | DCHECK(NightLightController::IsFeatureEnabled()); |
| 410 | return night_light_controller_.get(); |
| 411 | } |
| 412 | |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 413 | ShelfModel* Shell::shelf_model() { |
| 414 | return shelf_controller_->model(); |
| 415 | } |
| 416 | |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 417 | ::wm::ActivationClient* Shell::activation_client() { |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 418 | return focus_controller_.get(); |
| 419 | } |
| 420 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 421 | void Shell::UpdateShelfVisibility() { |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 422 | for (aura::Window* root : GetAllRootWindows()) |
| 423 | Shelf::ForWindow(root)->UpdateVisibilityState(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 424 | } |
| 425 | |
James Cook | 6d51c918 | 2017-08-04 01:31:00 | [diff] [blame] | 426 | PrefService* Shell::GetActiveUserPrefService() const { |
| 427 | if (shell_port_->GetAshConfig() == Config::MASH) |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 428 | return profile_pref_service_mash_.get(); |
James Cook | 6d51c918 | 2017-08-04 01:31:00 | [diff] [blame] | 429 | |
| 430 | return shell_delegate_->GetActiveUserPrefService(); |
| 431 | } |
| 432 | |
Wenzhao Zang | 44240fb | 2017-07-13 01:36:54 | [diff] [blame] | 433 | PrefService* Shell::GetLocalStatePrefService() const { |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 434 | if (shell_port_->GetAshConfig() == Config::MASH) |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 435 | return local_state_mash_.get(); |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 436 | |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 437 | return local_state_non_mash_; |
Wenzhao Zang | 44240fb | 2017-07-13 01:36:54 | [diff] [blame] | 438 | } |
| 439 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 440 | WebNotificationTray* Shell::GetWebNotificationTray() { |
jamescook | 612205f | 2016-05-26 06:02:11 | [diff] [blame] | 441 | return GetPrimaryRootWindowController() |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 442 | ->GetStatusAreaWidget() |
jamescook | 612205f | 2016-05-26 06:02:11 | [diff] [blame] | 443 | ->web_notification_tray(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 444 | } |
| 445 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 446 | bool Shell::HasPrimaryStatusArea() { |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 447 | return !!GetPrimaryRootWindowController()->GetStatusAreaWidget(); |
[email protected] | 31f19e3 | 2012-10-30 22:31:23 | [diff] [blame] | 448 | } |
| 449 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 450 | SystemTray* Shell::GetPrimarySystemTray() { |
| 451 | return GetPrimaryRootWindowController()->GetSystemTray(); |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 452 | } |
| 453 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 454 | void Shell::SetTouchHudProjectionEnabled(bool enabled) { |
| 455 | if (is_touch_hud_projection_enabled_ == enabled) |
| 456 | return; |
| 457 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 458 | is_touch_hud_projection_enabled_ = enabled; |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 459 | for (auto& observer : shell_observers_) |
ericwilligers | 5eff47d | 2016-10-17 19:19:18 | [diff] [blame] | 460 | observer.OnTouchHudProjectionToggled(enabled); |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 461 | } |
| 462 | |
msw | a7e8a5f | 2016-03-01 04:15:06 | [diff] [blame] | 463 | FirstRunHelper* Shell::CreateFirstRunHelper() { |
| 464 | return new FirstRunHelperImpl; |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 465 | } |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 466 | |
yawano | dc5533b3 | 2017-02-23 11:04:38 | [diff] [blame] | 467 | void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { |
| 468 | window_tree_host_manager_->cursor_window_controller() |
| 469 | ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); |
| 470 | } |
| 471 | |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 472 | void Shell::SetCursorCompositingEnabled(bool enabled) { |
erg | 36cfb95 | 2017-06-21 19:41:45 | [diff] [blame] | 473 | if (GetAshConfig() != Config::MASH) { |
| 474 | // TODO: needs to work in mash. http://crbug.com/705592. |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 475 | window_tree_host_manager_->cursor_window_controller() |
| 476 | ->SetCursorCompositingEnabled(enabled); |
| 477 | native_cursor_manager_->SetNativeCursorEnabled(!enabled); |
| 478 | } |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 479 | } |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 480 | |
[email protected] | f946670 | 2012-09-17 16:35:27 | [diff] [blame] | 481 | void Shell::DoInitialWorkspaceAnimation() { |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 482 | return GetPrimaryRootWindowController() |
| 483 | ->workspace_controller() |
| 484 | ->DoInitialAnimation(); |
[email protected] | f946670 | 2012-09-17 16:35:27 | [diff] [blame] | 485 | } |
| 486 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 487 | bool Shell::IsSplitViewModeActive() const { |
| 488 | return split_view_controller_->IsSplitViewModeActive(); |
| 489 | } |
| 490 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 491 | void Shell::AddShellObserver(ShellObserver* observer) { |
| 492 | shell_observers_.AddObserver(observer); |
| 493 | } |
| 494 | |
| 495 | void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 496 | shell_observers_.RemoveObserver(observer); |
| 497 | } |
| 498 | |
sky | 7db5ccf | 2017-03-14 21:52:29 | [diff] [blame] | 499 | void Shell::ShowAppList() { |
| 500 | // Show the app list on the default display for new windows. |
msw | ad3d955 | 2017-05-18 21:23:36 | [diff] [blame] | 501 | app_list_->Show(display::Screen::GetScreen() |
| 502 | ->GetDisplayNearestWindow(GetRootWindowForNewWindows()) |
| 503 | .id()); |
sky | 7db5ccf | 2017-03-14 21:52:29 | [diff] [blame] | 504 | } |
| 505 | |
MinChen | eafaa52e | 2017-07-31 18:32:52 | [diff] [blame] | 506 | void Shell::UpdateAppListYPositionAndOpacity(int y_position_in_screen, |
| 507 | float app_list_background_opacity, |
| 508 | bool is_end_gesture) { |
| 509 | app_list_->UpdateYPositionAndOpacity( |
| 510 | y_position_in_screen, app_list_background_opacity, is_end_gesture); |
MinChen | d646ae0 | 2017-07-21 23:07:17 | [diff] [blame] | 511 | } |
| 512 | |
sky | 7db5ccf | 2017-03-14 21:52:29 | [diff] [blame] | 513 | void Shell::DismissAppList() { |
| 514 | app_list_->Dismiss(); |
| 515 | } |
| 516 | |
| 517 | void Shell::ToggleAppList() { |
| 518 | // Toggle the app list on the default display for new windows. |
| 519 | app_list_->ToggleAppList( |
msw | ad3d955 | 2017-05-18 21:23:36 | [diff] [blame] | 520 | display::Screen::GetScreen() |
| 521 | ->GetDisplayNearestWindow(GetRootWindowForNewWindows()) |
| 522 | .id()); |
sky | 7db5ccf | 2017-03-14 21:52:29 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | bool Shell::IsAppListVisible() const { |
| 526 | return app_list_->IsVisible(); |
| 527 | } |
| 528 | |
| 529 | bool Shell::GetAppListTargetVisibility() const { |
| 530 | return app_list_->GetTargetVisibility(); |
| 531 | } |
| 532 | |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 533 | void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { |
varkha | 5967963 | 2017-06-01 00:42:05 | [diff] [blame] | 534 | for (auto* root_window_controller : GetAllRootWindowControllers()) |
| 535 | root_window_controller->UpdateAfterLoginStatusChange(status); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 536 | } |
| 537 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 538 | void Shell::NotifyOverviewModeStarting() { |
| 539 | for (auto& observer : shell_observers_) |
| 540 | observer.OnOverviewModeStarting(); |
| 541 | } |
| 542 | |
| 543 | void Shell::NotifyOverviewModeEnded() { |
| 544 | for (auto& observer : shell_observers_) |
| 545 | observer.OnOverviewModeEnded(); |
| 546 | } |
| 547 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 548 | void Shell::NotifySplitViewModeStarting() { |
| 549 | for (auto& observer : shell_observers_) |
| 550 | observer.OnSplitViewModeStarting(); |
| 551 | } |
| 552 | |
| 553 | void Shell::NotifySplitViewModeEnded() { |
| 554 | for (auto& observer : shell_observers_) |
| 555 | observer.OnSplitViewModeEnded(); |
| 556 | } |
| 557 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 558 | void Shell::NotifyFullscreenStateChanged(bool is_fullscreen, |
varkha | c71444e5 | 2017-05-25 22:51:34 | [diff] [blame] | 559 | aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 560 | for (auto& observer : shell_observers_) |
| 561 | observer.OnFullscreenStateChanged(is_fullscreen, root_window); |
| 562 | } |
| 563 | |
varkha | 19d7e6c5 | 2017-05-25 21:15:30 | [diff] [blame] | 564 | void Shell::NotifyPinnedStateChanged(aura::Window* pinned_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 565 | for (auto& observer : shell_observers_) |
| 566 | observer.OnPinnedStateChanged(pinned_window); |
| 567 | } |
| 568 | |
xiyuan | 3816018 | 2017-03-14 22:50:13 | [diff] [blame] | 569 | void Shell::NotifyVirtualKeyboardActivated(bool activated, |
sky | 97f9a743 | 2017-05-09 05:14:31 | [diff] [blame] | 570 | aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 571 | for (auto& observer : shell_observers_) |
xiyuan | 3816018 | 2017-03-14 22:50:13 | [diff] [blame] | 572 | observer.OnVirtualKeyboardStateChanged(activated, root_window); |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 573 | } |
| 574 | |
varkha | 6b016b0f | 2017-05-26 16:14:18 | [diff] [blame] | 575 | void Shell::NotifyShelfCreatedForRootWindow(aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 576 | for (auto& observer : shell_observers_) |
| 577 | observer.OnShelfCreatedForRootWindow(root_window); |
| 578 | } |
| 579 | |
varkha | 6b016b0f | 2017-05-26 16:14:18 | [diff] [blame] | 580 | void Shell::NotifyShelfAlignmentChanged(aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 581 | for (auto& observer : shell_observers_) |
| 582 | observer.OnShelfAlignmentChanged(root_window); |
| 583 | } |
| 584 | |
varkha | 6b016b0f | 2017-05-26 16:14:18 | [diff] [blame] | 585 | void Shell::NotifyShelfAutoHideBehaviorChanged(aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 586 | for (auto& observer : shell_observers_) |
| 587 | observer.OnShelfAutoHideBehaviorChanged(root_window); |
| 588 | } |
| 589 | |
jamescook | 518dccbd | 2017-05-18 04:57:07 | [diff] [blame] | 590 | // static |
| 591 | void Shell::SetIsBrowserProcessWithMash() { |
| 592 | g_is_browser_process_with_mash = true; |
| 593 | } |
| 594 | |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 595 | void Shell::SetLocalStatePrefService(PrefService* local_state) { |
| 596 | DCHECK(GetAshConfig() != Config::MASH); |
| 597 | DCHECK(local_state); |
| 598 | local_state_non_mash_ = local_state; |
| 599 | |
| 600 | for (auto& observer : shell_observers_) |
| 601 | observer.OnLocalStatePrefServiceInitialized(local_state_non_mash_); |
| 602 | } |
| 603 | |
muyuanli | d766f2e | 2017-06-26 20:17:19 | [diff] [blame] | 604 | void Shell::NotifyAppListVisibilityChanged(bool visible, |
| 605 | aura::Window* root_window) { |
newcomer | 2febb983 | 2017-06-12 17:00:23 | [diff] [blame] | 606 | for (auto& observer : shell_observers_) |
| 607 | observer.OnAppListVisibilityChanged(visible, root_window); |
| 608 | } |
| 609 | |
muyuanli | d766f2e | 2017-06-26 20:17:19 | [diff] [blame] | 610 | void Shell::NotifyVoiceInteractionStatusChanged(bool running) { |
| 611 | for (auto& observer : shell_observers_) |
| 612 | observer.OnVoiceInteractionStatusChanged(running); |
| 613 | } |
| 614 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 615 | //////////////////////////////////////////////////////////////////////////////// |
| 616 | // Shell, private: |
| 617 | |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 618 | Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 619 | std::unique_ptr<ShellPort> shell_port) |
| 620 | : shell_port_(std::move(shell_port)), |
Scott Violet | d64dac1 | 2017-06-02 21:50:08 | [diff] [blame] | 621 | ash_display_controller_(base::MakeUnique<AshDisplayController>()), |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 622 | brightness_control_delegate_( |
| 623 | base::MakeUnique<system::BrightnessControllerChromeos>()), |
| 624 | cast_config_(base::MakeUnique<CastConfigController>()), |
| 625 | focus_cycler_(base::MakeUnique<FocusCycler>()), |
James Cook | f0c78fc | 2017-06-15 14:42:55 | [diff] [blame] | 626 | ime_controller_(base::MakeUnique<ImeController>()), |
sky | 5ab1647 | 2017-03-21 19:35:08 | [diff] [blame] | 627 | immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 628 | keyboard_brightness_control_delegate_( |
| 629 | base::MakeUnique<KeyboardBrightnessController>()), |
| 630 | locale_notification_controller_( |
| 631 | base::MakeUnique<LocaleNotificationController>()), |
xiaoyinh | 2bbdd10 | 2017-05-18 23:29:42 | [diff] [blame] | 632 | lock_screen_controller_(base::MakeUnique<LockScreenController>()), |
sky | 5ab1647 | 2017-03-21 19:35:08 | [diff] [blame] | 633 | media_controller_(base::MakeUnique<MediaController>()), |
| 634 | new_window_controller_(base::MakeUnique<NewWindowController>()), |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 635 | session_controller_(base::MakeUnique<SessionController>()), |
| 636 | shelf_controller_(base::MakeUnique<ShelfController>()), |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 637 | shell_delegate_(std::move(shell_delegate)), |
sky | 5b45ed8 | 2017-03-27 02:54:23 | [diff] [blame] | 638 | shutdown_controller_(base::MakeUnique<ShutdownController>()), |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 639 | system_tray_controller_(base::MakeUnique<SystemTrayController>()), |
sky | 5b45ed8 | 2017-03-27 02:54:23 | [diff] [blame] | 640 | system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), |
tbarzic | c78da1ff9 | 2017-05-08 20:46:15 | [diff] [blame] | 641 | tray_action_(base::MakeUnique<TrayAction>()), |
sky | 5b45ed8 | 2017-03-27 02:54:23 | [diff] [blame] | 642 | vpn_list_(base::MakeUnique<VpnList>()), |
| 643 | window_cycle_controller_(base::MakeUnique<WindowCycleController>()), |
| 644 | window_selector_controller_(base::MakeUnique<WindowSelectorController>()), |
sky | 7db5ccf | 2017-03-14 21:52:29 | [diff] [blame] | 645 | app_list_(base::MakeUnique<app_list::AppList>()), |
yusukes | 1168eda | 2016-04-27 07:52:08 | [diff] [blame] | 646 | link_handler_model_factory_(nullptr), |
jamescook | ac672433 | 2017-03-21 02:54:43 | [diff] [blame] | 647 | tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), |
kylechar | 7a067ec | 2017-01-07 01:16:28 | [diff] [blame] | 648 | display_configurator_(new display::DisplayConfigurator()), |
sadrul | 7a8785e | 2016-02-12 21:54:35 | [diff] [blame] | 649 | native_cursor_manager_(nullptr), |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 650 | simulate_modal_window_open_for_testing_(false), |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 651 | is_touch_hud_projection_enabled_(false), |
| 652 | weak_factory_(this) { |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 653 | // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 654 | // state on ShellPortClassic. http://crbug.com/671246. |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 655 | |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 656 | gpu_support_.reset(shell_delegate_->CreateGPUSupport()); |
| 657 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 658 | display_manager_.reset(ScreenAsh::CreateDisplayManager()); |
| 659 | window_tree_host_manager_ = base::MakeUnique<WindowTreeHostManager>(); |
| 660 | user_metrics_recorder_ = base::MakeUnique<UserMetricsRecorder>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 661 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 662 | PowerStatus::Initialize(); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 663 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 664 | session_controller_->AddObserver(this); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | Shell::~Shell() { |
| 668 | TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); |
| 669 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 670 | const Config config = shell_port_->GetAshConfig(); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 671 | |
Scott Violet | 41562d1c | 2017-06-26 15:15:48 | [diff] [blame] | 672 | user_metrics_recorder_->OnShellShuttingDown(); |
bruthig | c24d11f | 2015-06-09 21:30:03 | [diff] [blame] | 673 | |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 674 | shell_delegate_->PreShutdown(); |
[email protected] | 050e7718 | 2014-03-25 15:29:16 | [diff] [blame] | 675 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 676 | // Remove the focus from any window. This will prevent overhead and side |
| 677 | // effects (e.g. crashes) from changing focus during shutdown. |
| 678 | // See bug crbug.com/134502. |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 679 | aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 680 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 681 | // Please keep in reverse order as in Init() because it's easy to miss one. |
| 682 | split_view_controller_.reset(); |
| 683 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 684 | if (window_modality_controller_) |
| 685 | window_modality_controller_.reset(); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 686 | |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 687 | RemovePreTargetHandler(magnifier_key_scroll_handler_.get()); |
| 688 | magnifier_key_scroll_handler_.reset(); |
| 689 | |
| 690 | RemovePreTargetHandler(speech_feedback_handler_.get()); |
| 691 | speech_feedback_handler_.reset(); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 692 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 693 | RemovePreTargetHandler(overlay_filter_.get()); |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 694 | overlay_filter_.reset(); |
| 695 | |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 696 | RemovePreTargetHandler(accelerator_filter_.get()); |
| 697 | RemovePreTargetHandler(event_transformation_handler_.get()); |
| 698 | RemovePreTargetHandler(toplevel_window_event_handler_.get()); |
| 699 | RemovePostTargetHandler(toplevel_window_event_handler_.get()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 700 | RemovePreTargetHandler(system_gesture_filter_.get()); |
| 701 | RemovePreTargetHandler(mouse_cursor_filter_.get()); |
hariank | 0dd03dd | 2016-07-14 23:47:33 | [diff] [blame] | 702 | RemovePreTargetHandler(modality_filter_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 703 | |
| 704 | // TooltipController is deleted with the Shell so removing its references. |
| 705 | RemovePreTargetHandler(tooltip_controller_.get()); |
| 706 | |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 707 | screen_orientation_controller_.reset(); |
yiyix | a68ade51 | 2016-09-01 17:38:13 | [diff] [blame] | 708 | screen_layout_observer_.reset(); |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 709 | |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 710 | // Destroy the virtual keyboard controller before the tablet mode controller |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 711 | // since the latters destructor triggers events that the former is listening |
| 712 | // to but no longer cares about. |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 713 | virtual_keyboard_controller_.reset(); |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 714 | |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 715 | // Destroy tablet mode controller early on since it has some observers which |
[email protected] | 5ed2b64 | 2014-03-04 00:06:57 | [diff] [blame] | 716 | // need to be removed. |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 717 | tablet_mode_controller_.reset(); |
[email protected] | 5ed2b64 | 2014-03-04 00:06:57 | [diff] [blame] | 718 | |
jdufault | 551152e | 2016-01-27 19:48:43 | [diff] [blame] | 719 | // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
| 720 | // layout. |
Keigo Oka | c7617a4 | 2017-06-14 11:33:24 | [diff] [blame] | 721 | DestroyKeyboard(); |
jdufault | 551152e | 2016-01-27 19:48:43 | [diff] [blame] | 722 | |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 723 | toast_manager_.reset(); |
yoshiki | 32f5163 | 2016-03-24 01:24:43 | [diff] [blame] | 724 | |
jdufault | 551152e | 2016-01-27 19:48:43 | [diff] [blame] | 725 | // Destroy SystemTrayDelegate before destroying the status area(s). Make sure |
| 726 | // to deinitialize the shelf first, as it is initialized after the delegate. |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 727 | for (aura::Window* root : GetAllRootWindows()) |
| 728 | Shelf::ForWindow(root)->ShutdownShelfWidget(); |
jamescook | ac672433 | 2017-03-21 02:54:43 | [diff] [blame] | 729 | tray_bluetooth_helper_.reset(); |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 730 | DeleteSystemTrayDelegate(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 731 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 732 | // Drag-and-drop must be canceled prior to close all windows. |
| 733 | drag_drop_controller_.reset(); |
| 734 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 735 | // Controllers who have WindowObserver added must be deleted |
| 736 | // before |window_tree_host_manager_| is deleted. |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 737 | |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 738 | // VideoActivityNotifier must be deleted before |video_detector_| is |
| 739 | // deleted because it's observing video activity through |
derat | 83b76139 | 2016-07-11 16:44:44 | [diff] [blame] | 740 | // VideoDetector::Observer interface. |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 741 | video_activity_notifier_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 742 | video_detector_.reset(); |
[email protected] | 0e3e7cb | 2014-04-12 05:18:25 | [diff] [blame] | 743 | high_contrast_controller_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 744 | |
| 745 | shadow_controller_.reset(); |
| 746 | resize_shadow_controller_.reset(); |
| 747 | |
sky | 37f0dd1 | 2016-07-19 18:00:59 | [diff] [blame] | 748 | // Has to happen before ~MruWindowTracker. |
sky | 5b45ed8 | 2017-03-27 02:54:23 | [diff] [blame] | 749 | window_cycle_controller_.reset(); |
| 750 | window_selector_controller_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 751 | |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 752 | CloseAllRootWindowChildWindows(); |
| 753 | |
afakhry | 5815939 | 2015-05-22 02:45:52 | [diff] [blame] | 754 | // MruWindowTracker must be destroyed after all windows have been deleted to |
| 755 | // avoid a possible crash when Shell is destroyed from a non-normal shutdown |
| 756 | // path. (crbug.com/485438). |
sky | 5ab1647 | 2017-03-21 19:35:08 | [diff] [blame] | 757 | mru_window_tracker_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 758 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 759 | // These need a valid Shell instance to clean up properly, so explicitly |
| 760 | // delete them before invalidating the instance. |
| 761 | // Alphabetical. TODO(oshima): sort. |
| 762 | magnification_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 763 | tooltip_controller_.reset(); |
| 764 | event_client_.reset(); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 765 | toplevel_window_event_handler_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 766 | visibility_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 767 | |
| 768 | power_button_controller_.reset(); |
| 769 | lock_state_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 770 | |
hidehiko | 6821ca4 | 2016-06-18 11:12:23 | [diff] [blame] | 771 | screen_pinning_controller_.reset(); |
| 772 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 773 | resolution_notification_controller_.reset(); |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 774 | screenshot_controller_.reset(); |
[email protected] | 8ab613cf | 2014-05-12 09:39:49 | [diff] [blame] | 775 | mouse_cursor_filter_.reset(); |
hariank | 0dd03dd | 2016-07-14 23:47:33 | [diff] [blame] | 776 | modality_filter_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 777 | |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 778 | touch_transformer_controller_.reset(); |
warx | 533c8f6 | 2016-04-12 01:19:43 | [diff] [blame] | 779 | audio_a11y_controller_.reset(); |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 780 | laser_pointer_controller_.reset(); |
| 781 | partial_magnification_controller_.reset(); |
Vladislav Kaznacheev | 6d6aaff | 2017-07-22 04:06:32 | [diff] [blame] | 782 | highlighter_controller_.reset(); |
warx | 533c8f6 | 2016-04-12 01:19:43 | [diff] [blame] | 783 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 784 | // This also deletes all RootWindows. Note that we invoke Shutdown() on |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 785 | // WindowTreeHostManager before resetting |window_tree_host_manager_|, since |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 786 | // destruction of its owned RootWindowControllers relies on the value. |
rjkroege | 2c930540 | 2016-09-07 00:21:45 | [diff] [blame] | 787 | ScreenAsh::CreateScreenForShutdown(); |
stevenjb | 537c5c3f | 2016-01-20 23:38:12 | [diff] [blame] | 788 | display_configuration_controller_.reset(); |
dtseng | 4ae0a88 | 2016-04-15 21:39:27 | [diff] [blame] | 789 | |
sky | 15ef0aa | 2017-01-20 18:55:59 | [diff] [blame] | 790 | // AppListDelegateImpl depends upon AppList. |
| 791 | app_list_delegate_impl_.reset(); |
| 792 | |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 793 | // These members access Shell in their destructors. |
| 794 | wallpaper_controller_.reset(); |
| 795 | accessibility_delegate_.reset(); |
| 796 | |
| 797 | // Balances the Install() in Initialize(). |
| 798 | views::FocusManagerFactory::Install(nullptr); |
| 799 | |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 800 | // ShelfWindowWatcher has window observers and a pointer to the shelf model. |
| 801 | shelf_window_watcher_.reset(); |
| 802 | |
| 803 | // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC |
| 804 | // shelf items in Chrome) so explicitly shutdown early. |
| 805 | shelf_model()->DestroyItemDelegates(); |
| 806 | |
msw | 5138f3d | 2017-04-20 00:22:07 | [diff] [blame] | 807 | // Notify the ShellDelegate that the shelf is shutting down. |
msw | 5c06364c | 2017-04-27 02:49:06 | [diff] [blame] | 808 | // TODO(msw): Refine ChromeLauncherController lifetime management. |
msw | 5138f3d | 2017-04-20 00:22:07 | [diff] [blame] | 809 | shell_delegate_->ShelfShutdown(); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 810 | |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 811 | // Removes itself as an observer of |pref_service_|. |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 812 | shelf_controller_.reset(); |
| 813 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 814 | shell_port_->Shutdown(); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 815 | window_tree_host_manager_->Shutdown(); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 816 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 817 | // Depends on |focus_controller_|, so must be destroyed before. |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 818 | window_tree_host_manager_.reset(); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 819 | focus_controller_->RemoveObserver(this); |
sky | 6861271 | 2017-04-27 04:45:04 | [diff] [blame] | 820 | if (config != Config::CLASSIC && |
| 821 | window_tree_client_->focus_synchronizer()->active_focus_client() == |
| 822 | focus_controller_.get()) { |
| 823 | window_tree_client_->focus_synchronizer()->SetSingletonFocusClient(nullptr); |
| 824 | } |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 825 | focus_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 826 | screen_position_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 827 | |
robert.bradford | ab05249 | 2015-05-06 11:09:56 | [diff] [blame] | 828 | display_color_manager_.reset(); |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 829 | if (display_change_observer_) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 830 | display_configurator_->RemoveObserver(display_change_observer_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 831 | if (display_error_observer_) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 832 | display_configurator_->RemoveObserver(display_error_observer_.get()); |
jdufault | 88fb7665 | 2015-04-30 22:36:43 | [diff] [blame] | 833 | if (projecting_observer_) { |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 834 | display_configurator_->RemoveObserver(projecting_observer_.get()); |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 835 | RemoveShellObserver(projecting_observer_.get()); |
jdufault | 88fb7665 | 2015-04-30 22:36:43 | [diff] [blame] | 836 | } |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 837 | display_change_observer_.reset(); |
kylechar | 98748a5 | 2016-12-03 01:33:22 | [diff] [blame] | 838 | shutdown_observer_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 839 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 840 | PowerStatus::Shutdown(); |
pneubeck | 8be1f542 | 2014-10-09 16:46:18 | [diff] [blame] | 841 | |
| 842 | // Ensure that DBusThreadManager outlives this Shell. |
| 843 | DCHECK(chromeos::DBusThreadManager::IsInitialized()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 844 | |
sky | 88bd4be6 | 2016-06-09 17:34:41 | [diff] [blame] | 845 | // Needs to happen right before |instance_| is reset. |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 846 | shell_port_.reset(); |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 847 | session_controller_->RemoveObserver(this); |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 848 | wallpaper_delegate_.reset(); |
afakhry | 2150156 | 2017-05-19 22:52:40 | [diff] [blame] | 849 | // NightLightController depeneds on the PrefService and must be destructed |
| 850 | // before it. crbug.com/724231. |
| 851 | night_light_controller_ = nullptr; |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 852 | profile_pref_service_mash_.reset(); |
| 853 | local_state_mash_.reset(); |
| 854 | local_state_non_mash_ = nullptr; |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 855 | shell_delegate_.reset(); |
sky | 88bd4be6 | 2016-06-09 17:34:41 | [diff] [blame] | 856 | |
Scott Violet | 17a6172 | 2017-06-19 17:54:31 | [diff] [blame] | 857 | for (auto& observer : shell_observers_) |
| 858 | observer.OnShellDestroyed(); |
| 859 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 860 | DCHECK(instance_ == this); |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 861 | instance_ = nullptr; |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 862 | } |
| 863 | |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 864 | void Shell::Init(const ShellInitParams& init_params) { |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 865 | const Config config = shell_port_->GetAshConfig(); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 866 | |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 867 | if (NightLightController::IsFeatureEnabled()) |
| 868 | night_light_controller_ = base::MakeUnique<NightLightController>(); |
afakhry | 9e0a18b3 | 2017-06-05 19:23:14 | [diff] [blame] | 869 | |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 870 | wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate(); |
| 871 | |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 872 | // Connector can be null in tests. |
sky | e5fd122 | 2017-04-12 18:43:23 | [diff] [blame] | 873 | if (config == Config::MASH && shell_delegate_->GetShellConnector()) { |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 874 | // Connect to local state prefs now, but wait for an active user before |
| 875 | // connecting to the profile pref service. The login screen has a temporary |
| 876 | // user profile that is not associated with a real user. |
Taiju Tsuiki | 36c517d | 2017-05-18 06:45:43 | [diff] [blame] | 877 | auto pref_registry = base::MakeRefCounted<PrefRegistrySimple>(); |
Wenzhao Zang | 56c29293 | 2017-08-02 04:58:34 | [diff] [blame] | 878 | RegisterLocalStatePrefs(pref_registry.get()); |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 879 | prefs::ConnectToPrefService( |
Sam McNally | 538fca1e | 2017-07-14 03:10:43 | [diff] [blame] | 880 | shell_delegate_->GetShellConnector(), std::move(pref_registry), |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 881 | base::Bind(&Shell::OnLocalStatePrefServiceInitialized, |
| 882 | weak_factory_.GetWeakPtr()), |
| 883 | prefs::mojom::kLocalStateServiceName); |
jonross | c4ba1060 | 2017-04-07 20:51:05 | [diff] [blame] | 884 | } |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 885 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 886 | // Some delegates access ShellPort during their construction. Create them here |
| 887 | // instead of the ShellPort constructor. |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 888 | accessibility_delegate_.reset(shell_delegate_->CreateAccessibilityDelegate()); |
| 889 | palette_delegate_ = shell_delegate_->CreatePaletteDelegate(); |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 890 | toast_manager_ = base::MakeUnique<ToastManager>(); |
| 891 | |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 892 | // Install the custom factory early on so that views::FocusManagers for Tray, |
| 893 | // Shelf, and WallPaper could be created by the factory. |
| 894 | views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 895 | |
James Cook | 08fc8ce2 | 2017-06-15 18:28:41 | [diff] [blame] | 896 | wallpaper_controller_ = base::MakeUnique<WallpaperController>(); |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 897 | |
sky | e5fd122 | 2017-04-12 18:43:23 | [diff] [blame] | 898 | if (config == Config::MASH) |
sky | 15ef0aa | 2017-01-20 18:55:59 | [diff] [blame] | 899 | app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); |
| 900 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 901 | // TODO(sky): move creation to ShellPort. |
sky | e5fd122 | 2017-04-12 18:43:23 | [diff] [blame] | 902 | if (config != Config::MASH) |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 903 | immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); |
sky | b7b5409 | 2016-08-19 16:00:09 | [diff] [blame] | 904 | |
sky | 5ab1647 | 2017-03-21 19:35:08 | [diff] [blame] | 905 | window_positioner_ = base::MakeUnique<WindowPositioner>(); |
sky | 984c189 | 2016-04-20 00:00:34 | [diff] [blame] | 906 | |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 907 | if (config == Config::CLASSIC) { |
erg | 36cfb95 | 2017-06-21 19:41:45 | [diff] [blame] | 908 | native_cursor_manager_ = new NativeCursorManagerAshClassic; |
| 909 | cursor_manager_ = base::MakeUnique<CursorManager>( |
| 910 | base::WrapUnique(native_cursor_manager_)); |
| 911 | } else if (config == Config::MUS) { |
| 912 | native_cursor_manager_ = new NativeCursorManagerAshMus; |
| 913 | cursor_manager_ = base::MakeUnique<CursorManager>( |
| 914 | base::WrapUnique(native_cursor_manager_)); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 915 | } |
sky | fee520c | 2016-02-11 19:57:46 | [diff] [blame] | 916 | |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 917 | shell_delegate_->PreInit(); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 918 | bool display_initialized = display_manager_->InitFromCommandLine(); |
| 919 | if (!display_initialized && config != Config::CLASSIC) { |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 920 | // Run display configuration off device in mus mode. |
| 921 | display_manager_->set_configure_displays(true); |
| 922 | display_configurator_->set_configure_display(true); |
| 923 | } |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 924 | display_configuration_controller_ = |
| 925 | base::MakeUnique<DisplayConfigurationController>( |
| 926 | display_manager_.get(), window_tree_host_manager_.get()); |
| 927 | display_configurator_->Init(shell_port_->CreateNativeDisplayDelegate(), |
| 928 | !gpu_support_->IsPanelFittingDisabled()); |
[email protected] | 0249a653 | 2013-10-31 06:53:34 | [diff] [blame] | 929 | |
pneubeck | 8be1f542 | 2014-10-09 16:46:18 | [diff] [blame] | 930 | // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. |
| 931 | chromeos::DBusThreadManager* dbus_thread_manager = |
| 932 | chromeos::DBusThreadManager::Get(); |
| 933 | projecting_observer_.reset( |
| 934 | new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 935 | display_configurator_->AddObserver(projecting_observer_.get()); |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 936 | AddShellObserver(projecting_observer_.get()); |
[email protected] | 72bce52 | 2014-02-10 21:11:26 | [diff] [blame] | 937 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 938 | if (!display_initialized && |
| 939 | (config != Config::CLASSIC || chromeos::IsRunningAsSystemCompositor())) { |
kylechar | f2e4e41 | 2016-12-04 04:21:35 | [diff] [blame] | 940 | display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( |
kylechar | 98748a5 | 2016-12-03 01:33:22 | [diff] [blame] | 941 | display_configurator_.get(), display_manager_.get()); |
| 942 | |
| 943 | shutdown_observer_ = |
| 944 | base::MakeUnique<ShutdownObserver>(display_configurator_.get()); |
| 945 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 946 | // Register |display_change_observer_| first so that the rest of |
| 947 | // observer gets invoked after the root windows are configured. |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 948 | display_configurator_->AddObserver(display_change_observer_.get()); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 949 | display_error_observer_.reset(new DisplayErrorObserver()); |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 950 | display_configurator_->AddObserver(display_error_observer_.get()); |
| 951 | display_configurator_->set_state_controller(display_change_observer_.get()); |
| 952 | display_configurator_->set_mirroring_controller(display_manager_.get()); |
| 953 | display_configurator_->ForceInitialConfigure( |
jamescook | fda15900 | 2016-10-21 18:48:57 | [diff] [blame] | 954 | base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 955 | chromeos::switches::kFirstExecAfterBoot) |
| 956 | ? kChromeOsBootColor |
| 957 | : 0); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 958 | display_initialized = true; |
| 959 | } |
James Cook | 8ba362c | 2017-06-16 16:39:16 | [diff] [blame] | 960 | display_color_manager_ = |
| 961 | base::MakeUnique<DisplayColorManager>(display_configurator_.get()); |
stevenjb | 537c5c3f | 2016-01-20 23:38:12 | [diff] [blame] | 962 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 963 | if (!display_initialized) |
[email protected] | 0249a653 | 2013-10-31 06:53:34 | [diff] [blame] | 964 | display_manager_->InitDefaultDisplay(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 965 | |
newcomer | 2febb983 | 2017-06-12 17:00:23 | [diff] [blame] | 966 | if (config == Config::CLASSIC) { |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 967 | display_manager_->RefreshFontParams(); |
[email protected] | 68d6080e | 2014-08-21 23:06:32 | [diff] [blame] | 968 | |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 969 | aura::Env::GetInstance()->set_context_factory(init_params.context_factory); |
| 970 | aura::Env::GetInstance()->set_context_factory_private( |
| 971 | init_params.context_factory_private); |
| 972 | } |
[email protected] | ecca62b | 2013-10-09 16:18:53 | [diff] [blame] | 973 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 974 | // The WindowModalityController needs to be at the front of the input event |
| 975 | // pretarget handler list to ensure that it processes input events when modal |
| 976 | // windows are active. |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 977 | window_modality_controller_.reset(new ::wm::WindowModalityController(this)); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 978 | |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 979 | env_filter_.reset(new ::wm::CompoundEventFilter); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 980 | AddPreTargetHandler(env_filter_.get()); |
| 981 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 982 | // FocusController takes ownership of AshFocusRules. |
| 983 | focus_controller_ = |
| 984 | base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); |
| 985 | focus_controller_->AddObserver(this); |
sky | 6861271 | 2017-04-27 04:45:04 | [diff] [blame] | 986 | if (config != Config::CLASSIC) { |
| 987 | window_tree_client_->focus_synchronizer()->SetSingletonFocusClient( |
| 988 | focus_controller_.get()); |
| 989 | } |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 990 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 991 | screen_position_controller_.reset(new ScreenPositionController); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 992 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 993 | window_tree_host_manager_->Start(); |
| 994 | AshWindowTreeHostInitParams ash_init_params; |
| 995 | window_tree_host_manager_->CreatePrimaryHost(ash_init_params); |
| 996 | |
msw | ad3d955 | 2017-05-18 21:23:36 | [diff] [blame] | 997 | root_window_for_new_windows_ = GetPrimaryRootWindow(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 998 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 999 | resolution_notification_controller_ = |
| 1000 | base::MakeUnique<ResolutionNotificationController>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1001 | |
derat | c6250a0 | 2017-01-25 05:51:53 | [diff] [blame] | 1002 | if (cursor_manager_) { |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 1003 | cursor_manager_->SetDisplay( |
| 1004 | display::Screen::GetScreen()->GetPrimaryDisplay()); |
derat | c6250a0 | 2017-01-25 05:51:53 | [diff] [blame] | 1005 | } |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1006 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 1007 | accelerator_controller_ = shell_port_->CreateAcceleratorController(); |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 1008 | tablet_mode_controller_ = base::MakeUnique<TabletModeController>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1009 | |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 1010 | magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 1011 | AddPreTargetHandler(magnifier_key_scroll_handler_.get()); |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 1012 | speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler(); |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 1013 | AddPreTargetHandler(speech_feedback_handler_.get()); |
[email protected] | 3dff2ef | 2014-02-09 22:50:39 | [diff] [blame] | 1014 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1015 | // The order in which event filters are added is significant. |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1016 | |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 1017 | // ui::UserActivityDetector passes events to observers, so let them get |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1018 | // rewritten first. |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 1019 | user_activity_detector_.reset(new ui::UserActivityDetector); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1020 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1021 | overlay_filter_.reset(new OverlayEventFilter); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1022 | AddPreTargetHandler(overlay_filter_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1023 | |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 1024 | accelerator_filter_.reset(new ::wm::AcceleratorFilter( |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 1025 | std::unique_ptr<::wm::AcceleratorDelegate>(new AcceleratorDelegate), |
sky | 81a2d79 | 2017-03-17 19:14:39 | [diff] [blame] | 1026 | accelerator_controller_->accelerator_history())); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1027 | AddPreTargetHandler(accelerator_filter_.get()); |
| 1028 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1029 | event_transformation_handler_.reset(new EventTransformationHandler); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1030 | AddPreTargetHandler(event_transformation_handler_.get()); |
| 1031 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 1032 | toplevel_window_event_handler_ = |
| 1033 | base::MakeUnique<ToplevelWindowEventHandler>(); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 1034 | |
sky | 83b1bb1 | 2017-04-24 20:29:28 | [diff] [blame] | 1035 | if (config != Config::MASH) { |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1036 | system_gesture_filter_.reset(new SystemGestureEventFilter); |
| 1037 | AddPreTargetHandler(system_gesture_filter_.get()); |
| 1038 | } |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1039 | |
[email protected] | 354520b | 2014-06-21 04:31:01 | [diff] [blame] | 1040 | sticky_keys_controller_.reset(new StickyKeysController); |
sky | 1385715 | 2017-03-29 15:46:04 | [diff] [blame] | 1041 | screen_pinning_controller_ = base::MakeUnique<ScreenPinningController>(); |
[email protected] | 354520b | 2014-06-21 04:31:01 | [diff] [blame] | 1042 | |
jamescook | d9f152f | 2016-11-15 00:53:08 | [diff] [blame] | 1043 | lock_state_controller_ = |
sky | 5b45ed8 | 2017-03-27 02:54:23 | [diff] [blame] | 1044 | base::MakeUnique<LockStateController>(shutdown_controller_.get()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 1045 | power_button_controller_.reset( |
| 1046 | new PowerButtonController(lock_state_controller_.get())); |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 1047 | // Pass the initial display state to PowerButtonController. |
| 1048 | power_button_controller_->OnDisplayModeChanged( |
[email protected] | bcec7fb6 | 2014-04-08 20:59:09 | [diff] [blame] | 1049 | display_configurator_->cached_displays()); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 1050 | |
derat | 036f91b9 | 2017-05-05 00:33:18 | [diff] [blame] | 1051 | // Forward user activity from the window server to |user_activity_detector_|. |
derat | 94887a2 | 2017-01-20 18:17:25 | [diff] [blame] | 1052 | // The connector is unavailable in some tests. |
derat | 036f91b9 | 2017-05-05 00:33:18 | [diff] [blame] | 1053 | if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS && |
| 1054 | shell_delegate_->GetShellConnector()) { |
derat | 94887a2 | 2017-01-20 18:17:25 | [diff] [blame] | 1055 | ui::mojom::UserActivityMonitorPtr user_activity_monitor; |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 1056 | shell_delegate_->GetShellConnector()->BindInterface(ui::mojom::kServiceName, |
| 1057 | &user_activity_monitor); |
derat | 94887a2 | 2017-01-20 18:17:25 | [diff] [blame] | 1058 | user_activity_forwarder_ = base::MakeUnique<aura::UserActivityForwarder>( |
| 1059 | std::move(user_activity_monitor), user_activity_detector_.get()); |
| 1060 | } |
| 1061 | |
Scott Violet | 361833fb | 2017-06-21 22:25:20 | [diff] [blame] | 1062 | // In mash drag and drop is handled by mus. |
| 1063 | if (config != Config::MASH) |
| 1064 | drag_drop_controller_ = base::MakeUnique<DragDropController>(); |
| 1065 | |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 1066 | // |screenshot_controller_| needs to be created (and prepended as a |
mukai | 19274bdd | 2015-02-24 22:37:48 | [diff] [blame] | 1067 | // pre-target handler) at this point, because |mouse_cursor_filter_| needs to |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 1068 | // process mouse events prior to screenshot session. |
mukai | 19274bdd | 2015-02-24 22:37:48 | [diff] [blame] | 1069 | // See http://crbug.com/459214 |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 1070 | screenshot_controller_.reset(new ScreenshotController()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1071 | mouse_cursor_filter_ = base::MakeUnique<MouseCursorEventFilter>(); |
| 1072 | PrependPreTargetHandler(mouse_cursor_filter_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1073 | |
| 1074 | // Create Controllers that may need root window. |
| 1075 | // TODO(oshima): Move as many controllers before creating |
| 1076 | // RootWindowController as possible. |
| 1077 | visibility_controller_.reset(new AshVisibilityController); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1078 | |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 1079 | laser_pointer_controller_.reset(new LaserPointerController()); |
| 1080 | partial_magnification_controller_.reset(new PartialMagnificationController()); |
Vladislav Kaznacheev | 6d6aaff | 2017-07-22 04:06:32 | [diff] [blame] | 1081 | highlighter_controller_.reset(new HighlighterController()); |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 1082 | |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 1083 | magnification_controller_.reset(MagnificationController::CreateInstance()); |
sky | 5ab1647 | 2017-03-21 19:35:08 | [diff] [blame] | 1084 | mru_window_tracker_ = base::MakeUnique<MruWindowTracker>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1085 | |
[email protected] | 55398d2 | 2013-10-10 19:49:20 | [diff] [blame] | 1086 | autoclick_controller_.reset(AutoclickController::CreateInstance()); |
| 1087 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1088 | high_contrast_controller_.reset(new HighContrastController); |
| 1089 | video_detector_.reset(new VideoDetector); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1090 | |
oshima | ebbe6377 | 2015-02-19 18:41:32 | [diff] [blame] | 1091 | tooltip_controller_.reset(new views::corewm::TooltipController( |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 1092 | std::unique_ptr<views::corewm::Tooltip>(new views::corewm::TooltipAura))); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1093 | AddPreTargetHandler(tooltip_controller_.get()); |
| 1094 | |
hariank | 0dd03dd | 2016-07-14 23:47:33 | [diff] [blame] | 1095 | modality_filter_.reset(new SystemModalContainerEventFilter(this)); |
| 1096 | AddPreTargetHandler(modality_filter_.get()); |
| 1097 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1098 | event_client_.reset(new EventClientImpl); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1099 | |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1100 | // Must occur after Shell has installed its early pre-target handlers (for |
| 1101 | // example, WindowModalityController). |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 1102 | shell_port_->CreatePointerWatcherAdapter(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1103 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1104 | resize_shadow_controller_.reset(new ResizeShadowController()); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1105 | shadow_controller_.reset(new ::wm::ShadowController(focus_controller_.get())); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1106 | |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 1107 | SetSystemTrayDelegate( |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 1108 | base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1109 | |
jamescook | ac672433 | 2017-03-21 02:54:43 | [diff] [blame] | 1110 | // May trigger initialization of the Bluetooth adapter. |
| 1111 | tray_bluetooth_helper_->Initialize(); |
| 1112 | |
kylechar | 55f0eaf2 | 2017-01-11 22:57:37 | [diff] [blame] | 1113 | // Create AshTouchTransformController before |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 1114 | // WindowTreeHostManager::InitDisplays() |
kylechar | 55f0eaf2 | 2017-01-11 22:57:37 | [diff] [blame] | 1115 | // since AshTouchTransformController listens on |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 1116 | // WindowTreeHostManager::Observer::OnDisplaysInitialized(). |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1117 | touch_transformer_controller_ = base::MakeUnique<AshTouchTransformController>( |
| 1118 | display_configurator_.get(), display_manager_.get(), |
| 1119 | shell_port_->CreateTouchTransformDelegate()); |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 1120 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 1121 | keyboard_ui_ = shell_port_->CreateKeyboardUI(); |
sky | fee520c | 2016-02-11 19:57:46 | [diff] [blame] | 1122 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1123 | window_tree_host_manager_->InitHosts(); |
| 1124 | shell_port_->OnHostsInitialized(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1125 | |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 1126 | // Needs to be created after InitDisplays() since it may cause the virtual |
| 1127 | // keyboard to be deployed. |
sky | 83b1bb1 | 2017-04-24 20:29:28 | [diff] [blame] | 1128 | if (config != Config::MASH) |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1129 | virtual_keyboard_controller_.reset(new VirtualKeyboardController); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 1130 | |
warx | 533c8f6 | 2016-04-12 01:19:43 | [diff] [blame] | 1131 | audio_a11y_controller_.reset(new chromeos::AudioA11yController); |
warx | 533c8f6 | 2016-04-12 01:19:43 | [diff] [blame] | 1132 | |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 1133 | // Initialize the wallpaper after the RootWindowController has been created, |
| 1134 | // otherwise the widget will not paint when restoring after a browser crash. |
| 1135 | // Also, initialize after display initialization to ensure correct sizing. |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 1136 | wallpaper_delegate_->InitializeWallpaper(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1137 | |
sadrul | 7a8785e | 2016-02-12 21:54:35 | [diff] [blame] | 1138 | if (cursor_manager_) { |
| 1139 | if (initially_hide_cursor_) |
| 1140 | cursor_manager_->HideCursor(); |
erg | eeba7c62 | 2017-04-25 18:06:16 | [diff] [blame] | 1141 | cursor_manager_->SetCursor(ui::CursorType::kPointer); |
sadrul | 7a8785e | 2016-02-12 21:54:35 | [diff] [blame] | 1142 | } |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1143 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1144 | power_event_observer_.reset(new PowerEventObserver()); |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 1145 | user_activity_notifier_.reset( |
[email protected] | b0fa701 | 2014-04-16 12:50:57 | [diff] [blame] | 1146 | new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 1147 | video_activity_notifier_.reset( |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1148 | new VideoActivityNotifier(video_detector_.get())); |
| 1149 | bluetooth_notification_controller_.reset(new BluetoothNotificationController); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1150 | screen_orientation_controller_ = |
| 1151 | base::MakeUnique<ScreenOrientationController>(); |
| 1152 | screen_layout_observer_.reset(new ScreenLayoutObserver()); |
yiyix | 90cfee2 | 2017-02-16 05:38:18 | [diff] [blame] | 1153 | sms_observer_.reset(new SmsObserver()); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 1154 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 1155 | split_view_controller_.reset(new SplitViewController()); |
| 1156 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1157 | // The compositor thread and main message loop have to be running in |
| 1158 | // order to create mirror window. Run it after the main message loop |
| 1159 | // is started. |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1160 | display_manager_->CreateMirrorWindowAsyncIfAny(); |
bruthig | c24d11f | 2015-06-09 21:30:03 | [diff] [blame] | 1161 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 1162 | for (auto& observer : shell_observers_) |
ericwilligers | 5eff47d | 2016-10-17 19:19:18 | [diff] [blame] | 1163 | observer.OnShellInitialized(); |
phweiss | 0bf64c5 | 2015-11-17 12:56:18 | [diff] [blame] | 1164 | |
Scott Violet | 41562d1c | 2017-06-26 15:15:48 | [diff] [blame] | 1165 | user_metrics_recorder_->OnShellInitialized(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1166 | } |
| 1167 | |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame] | 1168 | void Shell::InitRootWindow(aura::Window* root_window) { |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1169 | DCHECK(focus_controller_); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1170 | DCHECK(visibility_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1171 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1172 | aura::client::SetFocusClient(root_window, focus_controller_.get()); |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1173 | ::wm::SetActivationClient(root_window, focus_controller_.get()); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1174 | root_window->AddPreTargetHandler(focus_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1175 | aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
Scott Violet | 361833fb | 2017-06-21 22:25:20 | [diff] [blame] | 1176 | if (drag_drop_controller_) { |
| 1177 | DCHECK_NE(Config::MASH, GetAshConfig()); |
| 1178 | aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
| 1179 | } else { |
| 1180 | DCHECK_EQ(Config::MASH, GetAshConfig()); |
| 1181 | } |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 1182 | aura::client::SetScreenPositionClient(root_window, |
| 1183 | screen_position_controller_.get()); |
sadrul | 7a8785e | 2016-02-12 21:54:35 | [diff] [blame] | 1184 | aura::client::SetCursorClient(root_window, cursor_manager_.get()); |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1185 | ::wm::SetTooltipClient(root_window, tooltip_controller_.get()); |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 1186 | aura::client::SetEventClient(root_window, event_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1187 | |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1188 | ::wm::SetWindowMoveClient(root_window, toplevel_window_event_handler_.get()); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 1189 | root_window->AddPreTargetHandler(toplevel_window_event_handler_.get()); |
| 1190 | root_window->AddPostTargetHandler(toplevel_window_event_handler_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1191 | } |
| 1192 | |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 1193 | void Shell::SetSystemTrayDelegate( |
| 1194 | std::unique_ptr<SystemTrayDelegate> delegate) { |
| 1195 | DCHECK(delegate); |
| 1196 | system_tray_delegate_ = std::move(delegate); |
| 1197 | system_tray_delegate_->Initialize(); |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 1198 | // Accesses ShellPort in its constructor. |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 1199 | logout_confirmation_controller_.reset(new LogoutConfirmationController( |
| 1200 | base::Bind(&SystemTrayController::SignOut, |
| 1201 | base::Unretained(system_tray_controller_.get())))); |
| 1202 | } |
| 1203 | |
| 1204 | void Shell::DeleteSystemTrayDelegate() { |
| 1205 | DCHECK(system_tray_delegate_); |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 1206 | // Accesses ShellPort in its destructor. |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 1207 | logout_confirmation_controller_.reset(); |
| 1208 | system_tray_delegate_.reset(); |
| 1209 | } |
| 1210 | |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1211 | void Shell::CloseAllRootWindowChildWindows() { |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 1212 | for (aura::Window* root : GetAllRootWindows()) { |
| 1213 | RootWindowController* controller = RootWindowController::ForWindow(root); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1214 | if (controller) { |
| 1215 | controller->CloseChildWindows(); |
| 1216 | } else { |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 1217 | while (!root->children().empty()) { |
| 1218 | aura::Window* child = root->children()[0]; |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1219 | delete child; |
| 1220 | } |
| 1221 | } |
| 1222 | } |
| 1223 | } |
| 1224 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1225 | bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 1226 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 1227 | for (RootWindowController* controller : controllers) { |
| 1228 | if (controller->CanWindowReceiveEvents(window)) |
[email protected] | 602022b | 2014-03-31 17:07:31 | [diff] [blame] | 1229 | return true; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1230 | } |
| 1231 | return false; |
| 1232 | } |
| 1233 | |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 1234 | //////////////////////////////////////////////////////////////////////////////// |
| 1235 | // Shell, ui::EventTarget overrides: |
| 1236 | |
[email protected] | 869f635 | 2012-12-06 20:47:17 | [diff] [blame] | 1237 | bool Shell::CanAcceptEvent(const ui::Event& event) { |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 1238 | return true; |
| 1239 | } |
| 1240 | |
| 1241 | ui::EventTarget* Shell::GetParentTarget() { |
[email protected] | ff027885 | 2013-11-05 22:35:48 | [diff] [blame] | 1242 | return aura::Env::GetInstance(); |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 1243 | } |
| 1244 | |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 1245 | std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { |
| 1246 | return std::unique_ptr<ui::EventTargetIterator>(); |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 1247 | } |
| 1248 | |
| 1249 | ui::EventTargeter* Shell::GetEventTargeter() { |
| 1250 | NOTREACHED(); |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 1251 | return nullptr; |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 1252 | } |
| 1253 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1254 | void Shell::OnWindowActivated( |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1255 | ::wm::ActivationChangeObserver::ActivationReason reason, |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1256 | aura::Window* gained_active, |
| 1257 | aura::Window* lost_active) { |
msw | ad3d955 | 2017-05-18 21:23:36 | [diff] [blame] | 1258 | if (gained_active) |
| 1259 | root_window_for_new_windows_ = gained_active->GetRootWindow(); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1260 | } |
| 1261 | |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1262 | void Shell::OnActiveUserSessionChanged(const AccountId& account_id) { |
| 1263 | if (GetAshConfig() == Config::MASH && shell_delegate_->GetShellConnector()) { |
James Cook | 6d51c918 | 2017-08-04 01:31:00 | [diff] [blame] | 1264 | // NOTE: |profile_pref_service_| will point to the previous user's profile |
| 1265 | // while the connection is being made. |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1266 | auto pref_registry = base::MakeRefCounted<PrefRegistrySimple>(); |
| 1267 | RegisterProfilePrefs(pref_registry.get()); |
James Cook | 9807235 | 2017-08-07 18:00:07 | [diff] [blame] | 1268 | RegisterForeignPrefs(pref_registry.get()); |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1269 | prefs::ConnectToPrefService( |
| 1270 | shell_delegate_->GetShellConnector(), pref_registry, |
| 1271 | base::Bind(&Shell::OnProfilePrefServiceInitialized, |
| 1272 | weak_factory_.GetWeakPtr()), |
| 1273 | prefs::mojom::kForwarderServiceName); |
| 1274 | return; |
| 1275 | } |
| 1276 | |
| 1277 | // On classic ash user profile prefs are available immediately after login. |
| 1278 | // The login screen temporary profile is never available. |
| 1279 | PrefService* profile_prefs = shell_delegate_->GetActiveUserPrefService(); |
| 1280 | for (auto& observer : shell_observers_) |
| 1281 | observer.OnActiveUserPrefServiceChanged(profile_prefs); |
| 1282 | } |
| 1283 | |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 1284 | void Shell::OnSessionStateChanged(session_manager::SessionState state) { |
jamescook | 788b4fc | 2017-05-18 16:16:06 | [diff] [blame] | 1285 | // Initialize the shelf when a session becomes active. It's safe to do this |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 1286 | // multiple times (e.g. initial login vs. multiprofile add session). |
| 1287 | if (state == session_manager::SessionState::ACTIVE) { |
jamescook | 788b4fc | 2017-05-18 16:16:06 | [diff] [blame] | 1288 | InitializeShelf(); |
oka | c21941d | 2017-06-20 17:54:44 | [diff] [blame] | 1289 | } |
| 1290 | // Recreates keyboard on user profile change, to refresh keyboard |
| 1291 | // extensions with the new profile and the extensions call proper IME. |
| 1292 | // |LOGGED_IN_NOT_ACTIVE| is needed so that the virtual keyboard works on |
| 1293 | // supervised user creation. crbug.com/712873 |
| 1294 | // |ACTIVE| is also needed for guest user workflow. |
| 1295 | if ((state == session_manager::SessionState::LOGGED_IN_NOT_ACTIVE || |
| 1296 | state == session_manager::SessionState::ACTIVE) && |
| 1297 | keyboard::IsKeyboardEnabled()) { |
sky | e5fd122 | 2017-04-12 18:43:23 | [diff] [blame] | 1298 | if (GetAshConfig() != Config::MASH) { |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 1299 | // Recreate the keyboard after initial login and after multiprofile login. |
| 1300 | CreateKeyboard(); |
| 1301 | } |
| 1302 | } |
Scott Violet | 0c0dcde | 2017-08-04 21:48:18 | [diff] [blame] | 1303 | |
| 1304 | shell_port_->UpdateSystemModalAndBlockingContainers(); |
xiyuan | 233f4e7 | 2017-04-06 06:59:56 | [diff] [blame] | 1305 | } |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 1306 | |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 1307 | void Shell::OnLoginStatusChanged(LoginStatus login_status) { |
xiyuan | 233f4e7 | 2017-04-06 06:59:56 | [diff] [blame] | 1308 | UpdateAfterLoginStatusChange(login_status); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 1309 | } |
| 1310 | |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 1311 | void Shell::OnLockStateChanged(bool locked) { |
xiyuan | 7ebbf7f | 2017-04-10 16:49:10 | [diff] [blame] | 1312 | #ifndef NDEBUG |
| 1313 | // Make sure that there is no system modal in Lock layer when unlocked. |
| 1314 | if (!locked) { |
| 1315 | aura::Window::Windows containers = wm::GetContainersFromAllRootWindows( |
| 1316 | kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow()); |
| 1317 | for (aura::Window* container : containers) |
| 1318 | DCHECK(container->children().empty()); |
| 1319 | } |
| 1320 | #endif |
| 1321 | } |
| 1322 | |
jamescook | 788b4fc | 2017-05-18 16:16:06 | [diff] [blame] | 1323 | void Shell::InitializeShelf() { |
| 1324 | // Must occur after SessionController creation and user login. |
| 1325 | DCHECK(session_controller()); |
| 1326 | DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); |
| 1327 | |
| 1328 | // Notify the ShellDelegate that the shelf is being initialized. |
| 1329 | // TODO(msw): Refine ChromeLauncherController lifetime management. |
| 1330 | shell_delegate_->ShelfInit(); |
| 1331 | |
| 1332 | if (!shelf_window_watcher_) |
| 1333 | shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model()); |
| 1334 | |
| 1335 | for (RootWindowController* root : GetAllRootWindowControllers()) |
| 1336 | root->InitializeShelf(); |
| 1337 | } |
| 1338 | |
James Cook | 9807235 | 2017-08-07 18:00:07 | [diff] [blame] | 1339 | // static |
| 1340 | void Shell::RegisterForeignPrefs(PrefRegistrySimple* registry) { |
| 1341 | DCHECK_EQ(GetAshConfig(), Config::MASH); |
| 1342 | // Request access to prefs used by ash but owned by chrome. |
| 1343 | // See //services/preferences/README.md |
| 1344 | TrayCapsLock::RegisterForeignPrefs(registry); |
| 1345 | } |
| 1346 | |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1347 | void Shell::OnProfilePrefServiceInitialized( |
James Cook | 0ff197f | 2017-08-07 17:26:38 | [diff] [blame] | 1348 | std::unique_ptr<PrefService> pref_service) { |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 1349 | DCHECK(GetAshConfig() == Config::MASH); |
James Cook | 0ff197f | 2017-08-07 17:26:38 | [diff] [blame] | 1350 | // Keep the old PrefService object alive so OnActiveUserPrefServiceChanged() |
| 1351 | // clients can unregister pref observers on the old service. |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 1352 | std::unique_ptr<PrefService> old_service = |
| 1353 | std::move(profile_pref_service_mash_); |
| 1354 | profile_pref_service_mash_ = std::move(pref_service); |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1355 | // |pref_service| can be null if can't connect to Chrome (as happens when |
sky | 7bd582ae | 2017-04-12 21:43:33 | [diff] [blame] | 1356 | // running mash outside of chrome --mash and chrome isn't built). |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1357 | for (auto& observer : shell_observers_) |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 1358 | observer.OnActiveUserPrefServiceChanged(profile_pref_service_mash_.get()); |
James Cook | 0ff197f | 2017-08-07 17:26:38 | [diff] [blame] | 1359 | // |old_service| is deleted. |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 1360 | } |
| 1361 | |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 1362 | void Shell::OnLocalStatePrefServiceInitialized( |
| 1363 | std::unique_ptr<::PrefService> pref_service) { |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 1364 | DCHECK(GetAshConfig() == Config::MASH); |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1365 | // |pref_service| is null if can't connect to Chrome (as happens when |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 1366 | // running mash outside of chrome --mash and chrome isn't built). |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame^] | 1367 | local_state_mash_ = std::move(pref_service); |
| 1368 | |
| 1369 | for (auto& observer : shell_observers_) |
| 1370 | observer.OnLocalStatePrefServiceInitialized(local_state_mash_.get()); |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 1371 | } |
| 1372 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 1373 | } // namespace ash |