[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> |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 8 | #include <memory> |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 9 | #include <string> |
dcheng | cbf0d9d | 2015-12-27 22:49:23 | [diff] [blame] | 10 | #include <utility> |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 11 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 12 | #include "ash/accelerators/accelerator_controller.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" |
Scott Violet | f5db250 | 2018-10-05 15:19:39 | [diff] [blame] | 15 | #include "ash/accelerators/pre_target_accelerator_handler.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 16 | #include "ash/accelerators/spoken_feedback_toggler.h" |
Steven Bennetts | 368a1c8 | 2019-01-11 20:45:22 | [diff] [blame] | 17 | #include "ash/accelerometer/accelerometer_reader.h" |
James Cook | ec14495 | 2017-09-01 00:05:16 | [diff] [blame] | 18 | #include "ash/accessibility/accessibility_controller.h" |
James Cook | 37b7d10 | 2017-10-06 04:35:19 | [diff] [blame] | 19 | #include "ash/accessibility/accessibility_delegate.h" |
Qiang Xu | a959100 | 2018-03-15 22:29:31 | [diff] [blame] | 20 | #include "ash/accessibility/accessibility_focus_ring_controller.h" |
David Tseng | 6792dc8 | 2018-05-04 19:18:41 | [diff] [blame] | 21 | #include "ash/accessibility/key_accessibility_enabler.h" |
Jiaquan He | 4b48f91 | 2018-03-01 03:59:39 | [diff] [blame] | 22 | #include "ash/app_list/app_list_controller_impl.h" |
David Black | 00fdce3 | 2018-05-10 20:59:14 | [diff] [blame] | 23 | #include "ash/assistant/assistant_controller.h" |
[email protected] | 55398d2 | 2013-10-10 19:49:20 | [diff] [blame] | 24 | #include "ash/autoclick/autoclick_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 25 | #include "ash/cast_config_controller.h" |
James Cook | 1d323b3 | 2019-01-02 19:42:29 | [diff] [blame] | 26 | #include "ash/components/tap_visualizer/public/mojom/tap_visualizer.mojom.h" |
Quan Nguyen | af67b64d | 2018-11-29 19:21:48 | [diff] [blame] | 27 | #include "ash/contained_shell/contained_shell_controller.h" |
Jeffrey Kardatzke | f108f02 | 2018-04-17 17:52:35 | [diff] [blame] | 28 | #include "ash/dbus/ash_dbus_services.h" |
Toni Barzic | d623831 | 2018-03-02 18:26:13 | [diff] [blame] | 29 | #include "ash/detachable_base/detachable_base_handler.h" |
Toni Barzic | 550419f | 2018-03-08 03:56:21 | [diff] [blame] | 30 | #include "ash/detachable_base/detachable_base_notification_controller.h" |
Scott Violet | d64dac1 | 2017-06-02 21:50:08 | [diff] [blame] | 31 | #include "ash/display/ash_display_controller.h" |
Steven Bennetts | 2a9b438 | 2018-04-26 23:41:19 | [diff] [blame] | 32 | #include "ash/display/cros_display_config.h" |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 33 | #include "ash/display/cursor_window_controller.h" |
Mitsuru Oshima | f51c8b4 | 2018-03-17 01:41:32 | [diff] [blame] | 34 | #include "ash/display/display_color_manager.h" |
stevenjb | 537c5c3f | 2016-01-20 23:38:12 | [diff] [blame] | 35 | #include "ash/display/display_configuration_controller.h" |
Steven Bennetts | 9b21fa3 | 2018-04-13 23:45:55 | [diff] [blame] | 36 | #include "ash/display/display_configuration_observer.h" |
Mitsuru Oshima | f51c8b4 | 2018-03-17 01:41:32 | [diff] [blame] | 37 | #include "ash/display/display_error_observer.h" |
Scott Violet | bed23cb | 2018-08-22 19:56:12 | [diff] [blame] | 38 | #include "ash/display/display_output_protection.h" |
Steven Bennetts | 3688c603 | 2018-04-13 01:14:23 | [diff] [blame] | 39 | #include "ash/display/display_prefs.h" |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 40 | #include "ash/display/display_shutdown_observer.h" |
[email protected] | 682990f | 2013-01-10 06:49:11 | [diff] [blame] | 41 | #include "ash/display/event_transformation_handler.h" |
[email protected] | 9154587 | 2012-11-21 13:58:27 | [diff] [blame] | 42 | #include "ash/display/mouse_cursor_event_filter.h" |
Qiang Xu | d77a90c | 2018-02-20 19:43:29 | [diff] [blame] | 43 | #include "ash/display/persistent_window_controller.h" |
Mitsuru Oshima | f51c8b4 | 2018-03-17 01:41:32 | [diff] [blame] | 44 | #include "ash/display/projecting_observer.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 45 | #include "ash/display/resolution_notification_controller.h" |
rjkroege | 2c930540 | 2016-09-07 00:21:45 | [diff] [blame] | 46 | #include "ash/display/screen_ash.h" |
Mitsuru Oshima | ddfde355 | 2018-03-22 09:12:13 | [diff] [blame] | 47 | #include "ash/display/screen_orientation_controller.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 48 | #include "ash/display/screen_position_controller.h" |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 49 | #include "ash/display/window_tree_host_manager.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 50 | #include "ash/drag_drop/drag_drop_controller.h" |
Mike Wasserman | 5623bac2 | 2018-04-30 17:24:32 | [diff] [blame] | 51 | #include "ash/events/event_rewriter_controller.h" |
James Cook | f539884 | 2018-04-16 20:15:24 | [diff] [blame] | 52 | #include "ash/first_run/first_run_helper.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 53 | #include "ash/focus_cycler.h" |
Evan Stade | 5f09e657 | 2018-08-10 17:48:15 | [diff] [blame] | 54 | #include "ash/frame/non_client_frame_view_ash.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 55 | #include "ash/high_contrast/high_contrast_controller.h" |
Vladislav Kaznacheev | 6d6aaff | 2017-07-22 04:06:32 | [diff] [blame] | 56 | #include "ash/highlighter/highlighter_controller.h" |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 57 | #include "ash/host/ash_window_tree_host_init_params.h" |
James Cook | bb02673 | 2017-06-09 23:01:55 | [diff] [blame] | 58 | #include "ash/ime/ime_controller.h" |
Xiyuan Xia | 5f1046e | 2018-06-01 16:04:44 | [diff] [blame] | 59 | #include "ash/ime/ime_focus_handler.h" |
Steven Bennetts | a0ea3094 | 2018-10-11 22:27:51 | [diff] [blame] | 60 | #include "ash/keyboard/ash_keyboard_controller.h" |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 61 | #include "ash/laser/laser_pointer_controller.h" |
Jacob Dufault | ffd9b0d | 2017-11-15 23:07:16 | [diff] [blame] | 62 | #include "ash/login/login_screen_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 63 | #include "ash/login_status.h" |
Ahmed Fakhry | 4bf3f74 | 2018-02-06 17:33:36 | [diff] [blame] | 64 | #include "ash/magnifier/docked_magnifier_controller.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 65 | #include "ash/magnifier/magnification_controller.h" |
[email protected] | 77f7c13 | 2012-11-15 06:52:54 | [diff] [blame] | 66 | #include "ash/magnifier/partial_magnification_controller.h" |
Becca Hughes | 446aaccf | 2019-01-15 04:51:17 | [diff] [blame] | 67 | #include "ash/media/media_controller.h" |
Becca Hughes | c6a0a06 | 2018-10-25 16:54:13 | [diff] [blame] | 68 | #include "ash/media/media_notification_controller.h" |
Scott Violet | 3c554ae | 2017-12-13 02:25:41 | [diff] [blame] | 69 | #include "ash/metrics/time_to_first_present_recorder.h" |
Kyle Horimoto | 9fc84fc2 | 2018-04-27 19:45:15 | [diff] [blame] | 70 | #include "ash/multi_device_setup/multi_device_notification_presenter.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 71 | #include "ash/new_window_controller.h" |
Vladislav Kaznacheev | 92edf62e | 2017-10-13 22:08:01 | [diff] [blame] | 72 | #include "ash/note_taking_controller.h" |
Qiang Xu | d8e897e | 2018-05-24 20:07:57 | [diff] [blame] | 73 | #include "ash/policy/policy_recommendation_restorer.h" |
Steven Bennetts | 93d3e5b1 | 2018-05-05 01:14:50 | [diff] [blame] | 74 | #include "ash/public/cpp/ash_constants.h" |
Ahmed Fakhry | 4af48e4 | 2018-02-28 17:45:38 | [diff] [blame] | 75 | #include "ash/public/cpp/ash_features.h" |
Evan Stade | 7d0e823 | 2017-10-04 02:01:36 | [diff] [blame] | 76 | #include "ash/public/cpp/ash_switches.h" |
msw | 109806d | 2017-06-02 20:11:57 | [diff] [blame] | 77 | #include "ash/public/cpp/shelf_model.h" |
jamescook | 8800b823 | 2016-10-19 12:46:27 | [diff] [blame] | 78 | #include "ash/public/cpp/shell_window_ids.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 79 | #include "ash/root_window_controller.h" |
James Cook | 5e9d340 | 2017-11-01 00:20:12 | [diff] [blame] | 80 | #include "ash/screenshot_delegate.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 81 | #include "ash/session/session_controller.h" |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 82 | #include "ash/shelf/shelf.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 83 | #include "ash/shelf/shelf_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 84 | #include "ash/shelf/shelf_window_watcher.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 85 | #include "ash/shell_delegate.h" |
[email protected] | 1b4c747 | 2014-05-15 18:32:23 | [diff] [blame] | 86 | #include "ash/shell_init_params.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 87 | #include "ash/shell_observer.h" |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 88 | #include "ash/shell_state.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 89 | #include "ash/shutdown_controller.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 90 | #include "ash/sticky_keys/sticky_keys_controller.h" |
Tetsui Ohkubo | 01421b3 | 2018-05-30 16:54:59 | [diff] [blame] | 91 | #include "ash/system/audio/display_speaker_controller.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 92 | #include "ash/system/bluetooth/bluetooth_notification_controller.h" |
Sonny Sasaka | 55f69fc | 2017-08-28 21:29:37 | [diff] [blame] | 93 | #include "ash/system/bluetooth/bluetooth_power_controller.h" |
Giovanni Ortuño Urquidi | 55aa5d8f | 2018-10-10 05:33:34 | [diff] [blame] | 94 | #include "ash/system/bluetooth/tray_bluetooth_helper_experimental.h" |
| 95 | #include "ash/system/bluetooth/tray_bluetooth_helper_legacy.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 96 | #include "ash/system/brightness/brightness_controller_chromeos.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 97 | #include "ash/system/brightness_control_delegate.h" |
Tetsui Ohkubo | 5e249953 | 2018-04-04 02:01:39 | [diff] [blame] | 98 | #include "ash/system/caps_lock_notification_controller.h" |
Lann Martin | b999140 | 2017-06-23 22:25:08 | [diff] [blame] | 99 | #include "ash/system/keyboard_brightness/keyboard_brightness_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 100 | #include "ash/system/keyboard_brightness_control_delegate.h" |
Tatsuhisa Yamaguchi | 440e2d2e | 2018-12-05 09:16:31 | [diff] [blame] | 101 | #include "ash/system/locale/locale_update_controller.h" |
Tetsui Ohkubo | 8d354c3 | 2018-10-11 01:23:28 | [diff] [blame] | 102 | #include "ash/system/message_center/message_center_controller.h" |
Tetsui Ohkubo | 2172293 | 2018-03-02 02:56:56 | [diff] [blame] | 103 | #include "ash/system/model/system_tray_model.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 104 | #include "ash/system/network/sms_observer.h" |
| 105 | #include "ash/system/network/vpn_list.h" |
afakhry | e4fae85 | 2017-05-09 18:49:06 | [diff] [blame] | 106 | #include "ash/system/night_light/night_light_controller.h" |
Sammie Quon | 4d7dba6 | 2017-08-03 23:18:17 | [diff] [blame] | 107 | #include "ash/system/palette/palette_tray.h" |
Sammie Quon | 6c4e2b1f | 2017-10-13 16:54:18 | [diff] [blame] | 108 | #include "ash/system/palette/palette_welcome_bubble.h" |
Toni Barzic | 9d0c82f4 | 2017-12-06 00:53:52 | [diff] [blame] | 109 | #include "ash/system/power/backlights_forced_off_setter.h" |
Sammie Quon | 95c6a1c | 2017-09-12 19:16:55 | [diff] [blame] | 110 | #include "ash/system/power/peripheral_battery_notifier.h" |
Qiang Xu | 0a86020f | 2017-10-12 08:34:54 | [diff] [blame] | 111 | #include "ash/system/power/power_button_controller.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 112 | #include "ash/system/power/power_event_observer.h" |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 113 | #include "ash/system/power/power_prefs.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 114 | #include "ash/system/power/power_status.h" |
| 115 | #include "ash/system/power/video_activity_notifier.h" |
| 116 | #include "ash/system/screen_layout_observer.h" |
Tetsui Ohkubo | 54d5022 | 2018-05-10 01:58:11 | [diff] [blame] | 117 | #include "ash/system/screen_security/screen_switch_check_controller.h" |
James Cook | dc04112 | 2017-08-01 14:03:22 | [diff] [blame] | 118 | #include "ash/system/session/logout_button_tray.h" |
James Cook | a35a1e2 | 2017-04-08 02:33:08 | [diff] [blame] | 119 | #include "ash/system/session/logout_confirmation_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 120 | #include "ash/system/status_area_widget.h" |
Tetsui Ohkubo | 269b579 | 2018-04-26 01:06:32 | [diff] [blame] | 121 | #include "ash/system/system_notification_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 122 | #include "ash/system/toast/toast_manager.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 123 | #include "ash/system/tray/system_tray_notifier.h" |
kylechar | 55f0eaf2 | 2017-01-11 22:57:37 | [diff] [blame] | 124 | #include "ash/touch/ash_touch_transform_controller.h" |
Qiang Xu | f1400a36 | 2017-09-14 02:28:30 | [diff] [blame] | 125 | #include "ash/touch/touch_devices_controller.h" |
tbarzic | c78da1ff9 | 2017-05-08 20:46:15 | [diff] [blame] | 126 | #include "ash/tray_action/tray_action.h" |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 127 | #include "ash/utility/screenshot_controller.h" |
Yue Li | a33960a | 2017-11-01 22:06:07 | [diff] [blame] | 128 | #include "ash/voice_interaction/voice_interaction_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 129 | #include "ash/wallpaper/wallpaper_controller.h" |
Scott Violet | 737fb75 | 2018-04-11 15:35:22 | [diff] [blame] | 130 | #include "ash/wayland/wayland_server_controller.h" |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 131 | #include "ash/wm/ash_focus_rules.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 132 | #include "ash/wm/container_finder.h" |
James Cook | 698fc366 | 2018-07-27 16:05:01 | [diff] [blame] | 133 | #include "ash/wm/cursor_manager_chromeos.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 134 | #include "ash/wm/event_client_impl.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 135 | #include "ash/wm/immersive_context_ash.h" |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 136 | #include "ash/wm/lock_state_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 137 | #include "ash/wm/mru_window_tracker.h" |
James Cook | bc2758b4 | 2018-09-07 16:20:37 | [diff] [blame] | 138 | #include "ash/wm/native_cursor_manager_ash.h" |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 139 | #include "ash/wm/non_client_frame_controller.h" |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 140 | #include "ash/wm/overlay_event_filter.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 141 | #include "ash/wm/overview/window_selector_controller.h" |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 142 | #include "ash/wm/resize_shadow_controller.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 143 | #include "ash/wm/root_window_finder.h" |
hidehiko | 6821ca4 | 2016-06-18 11:12:23 | [diff] [blame] | 144 | #include "ash/wm/screen_pinning_controller.h" |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 145 | #include "ash/wm/splitview/split_view_controller.h" |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 146 | #include "ash/wm/system_gesture_event_filter.h" |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 147 | #include "ash/wm/system_modal_container_event_filter.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 148 | #include "ash/wm/system_modal_container_layout_manager.h" |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 149 | #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
| 150 | #include "ash/wm/tablet_mode/tablet_mode_window_manager.h" |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 151 | #include "ash/wm/toplevel_window_event_handler.h" |
[email protected] | 9633a9d2 | 2012-01-21 16:40:58 | [diff] [blame] | 152 | #include "ash/wm/video_detector.h" |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 153 | #include "ash/wm/window_animations.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 154 | #include "ash/wm/window_cycle_controller.h" |
| 155 | #include "ash/wm/window_positioner.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 156 | #include "ash/wm/window_properties.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 157 | #include "ash/wm/window_util.h" |
Sammie Quon | 55741866 | 2018-04-25 18:45:51 | [diff] [blame] | 158 | #include "ash/wm/wm_shadow_controller_delegate.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 159 | #include "ash/wm/workspace_controller.h" |
James Cook | cc2d170 | 2018-12-13 21:20:08 | [diff] [blame] | 160 | #include "ash/ws/ax_ash_window_utils.h" |
Scott Violet | b7f4df2 | 2018-05-17 04:43:12 | [diff] [blame] | 161 | #include "ash/ws/window_service_owner.h" |
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 162 | #include "base/bind.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 163 | #include "base/bind_helpers.h" |
jamescook | fda15900 | 2016-10-21 18:48:57 | [diff] [blame] | 164 | #include "base/command_line.h" |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 165 | #include "base/memory/ptr_util.h" |
Sebastien Marchand | 75a7cdf | 2018-11-13 23:47:03 | [diff] [blame] | 166 | #include "base/system/sys_info.h" |
Steven Bennetts | 368a1c8 | 2019-01-11 20:45:22 | [diff] [blame] | 167 | #include "base/task/post_task.h" |
| 168 | #include "base/task/task_traits.h" |
primiano | 7182d7b | 2015-01-30 18:02:03 | [diff] [blame] | 169 | #include "base/trace_event/trace_event.h" |
Toni Barzic | 85c9e080 | 2018-03-30 02:46:01 | [diff] [blame] | 170 | #include "chromeos/dbus/dbus_thread_manager.h" |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 171 | #include "chromeos/dbus/power_policy_controller.h" |
reveman | 2415898 | 2017-01-10 05:58:45 | [diff] [blame] | 172 | #include "chromeos/system/devicemode.h" |
Scott Violet | 737fb75 | 2018-04-11 15:35:22 | [diff] [blame] | 173 | #include "components/exo/file_helper.h" |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 174 | #include "components/prefs/pref_registry_simple.h" |
| 175 | #include "components/prefs/pref_service.h" |
Saman Sami | 3fb310d | 2017-11-09 16:51:54 | [diff] [blame] | 176 | #include "components/viz/host/host_frame_sink_manager.h" |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 177 | #include "services/preferences/public/cpp/pref_service_factory.h" |
Ken Rockot | f7f533e | 2018-02-11 02:21:33 | [diff] [blame] | 178 | #include "services/preferences/public/mojom/preferences.mojom.h" |
derat | 94887a2 | 2017-01-20 18:17:25 | [diff] [blame] | 179 | #include "services/service_manager/public/cpp/connector.h" |
Xiyuan Xia | ebf96b7 | 2018-09-07 21:04:34 | [diff] [blame] | 180 | #include "services/ws/public/cpp/host/gpu_interface_provider.h" |
Scott Violet | 9f98425 | 2018-08-27 19:02:13 | [diff] [blame] | 181 | #include "services/ws/window_service.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 182 | #include "ui/aura/client/aura_constants.h" |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 183 | #include "ui/aura/env.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 184 | #include "ui/aura/layout_manager.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 185 | #include "ui/aura/window.h" |
[email protected] | fcc51c95 | 2014-02-21 21:31:26 | [diff] [blame] | 186 | #include "ui/aura/window_event_dispatcher.h" |
Scott Violet | 6c0eb696 | 2018-06-20 01:31:26 | [diff] [blame] | 187 | #include "ui/base/ui_base_features.h" |
[email protected] | 2d481774 | 2012-12-17 20:16:18 | [diff] [blame] | 188 | #include "ui/base/ui_base_switches.h" |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 189 | #include "ui/base/user_activity/user_activity_detector.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 190 | #include "ui/chromeos/user_activity_power_manager_notifier.h" |
[email protected] | 116302fc | 2012-05-05 21:45:41 | [diff] [blame] | 191 | #include "ui/compositor/layer.h" |
| 192 | #include "ui/compositor/layer_animator.h" |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 193 | #include "ui/display/display.h" |
Joone Hur | d3ae873 | 2018-04-17 18:05:09 | [diff] [blame] | 194 | #include "ui/display/manager/default_touch_transform_setter.h" |
| 195 | #include "ui/display/manager/display_change_observer.h" |
| 196 | #include "ui/display/manager/display_configurator.h" |
rjkroege | 72f8154f | 2016-10-29 00:49:02 | [diff] [blame] | 197 | #include "ui/display/manager/display_manager.h" |
Joone Hur | d3ae873 | 2018-04-17 18:05:09 | [diff] [blame] | 198 | #include "ui/display/manager/touch_transform_setter.h" |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 199 | #include "ui/display/screen.h" |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 200 | #include "ui/display/types/native_display_delegate.h" |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 201 | #include "ui/events/event_target_iterator.h" |
sky | 4ec2be8 | 2017-01-06 17:38:32 | [diff] [blame] | 202 | #include "ui/gfx/geometry/insets.h" |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 203 | #include "ui/gfx/image/image_skia.h" |
Jun Mukai | f235779 | 2018-12-20 19:58:00 | [diff] [blame] | 204 | #include "ui/keyboard/keyboard_ui_factory.h" |
James Cook | 9db56d7 | 2018-08-01 03:21:31 | [diff] [blame] | 205 | #include "ui/ozone/public/ozone_platform.h" |
[email protected] | d7f30a7 | 2013-10-05 05:09:41 | [diff] [blame] | 206 | #include "ui/views/corewm/tooltip_aura.h" |
[email protected] | a1b7a82 | 2013-02-23 19:08:04 | [diff] [blame] | 207 | #include "ui/views/corewm/tooltip_controller.h" |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 208 | #include "ui/views/focus/focus_manager_factory.h" |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 209 | #include "ui/views/mus/window_manager_frame_values.h" |
[email protected] | c13be0d | 2011-11-22 02:09:58 | [diff] [blame] | 210 | #include "ui/views/widget/native_widget_aura.h" |
| 211 | #include "ui/views/widget/widget.h" |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 212 | #include "ui/wm/core/accelerator_filter.h" |
[email protected] | ee3ed1077 | 2014-03-11 22:02:01 | [diff] [blame] | 213 | #include "ui/wm/core/compound_event_filter.h" |
| 214 | #include "ui/wm/core/focus_controller.h" |
[email protected] | ee3ed1077 | 2014-03-11 22:02:01 | [diff] [blame] | 215 | #include "ui/wm/core/shadow_controller.h" |
| 216 | #include "ui/wm/core/visibility_controller.h" |
| 217 | #include "ui/wm/core/window_modality_controller.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 218 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 219 | namespace ash { |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 220 | |
| 221 | namespace { |
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 222 | |
[email protected] | 615922f | 2012-02-07 02:41:15 | [diff] [blame] | 223 | using aura::Window; |
[email protected] | 3f02dc5 | 2011-10-21 19:36:45 | [diff] [blame] | 224 | using views::Widget; |
| 225 | |
jamescook | 518dccbd | 2017-05-18 04:57:07 | [diff] [blame] | 226 | bool g_is_browser_process_with_mash = false; |
| 227 | |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 228 | // A Corewm VisibilityController subclass that calls the Ash animation routine |
| 229 | // 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] | 230 | class AshVisibilityController : public ::wm::VisibilityController { |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 231 | public: |
Chris Watkins | c24daf6 | 2017-11-28 03:43:09 | [diff] [blame] | 232 | AshVisibilityController() = default; |
| 233 | ~AshVisibilityController() override = default; |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 234 | |
| 235 | private: |
[email protected] | e319c7e | 2014-03-14 19:56:14 | [diff] [blame] | 236 | // Overridden from ::wm::VisibilityController: |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 237 | bool CallAnimateOnChildWindowVisibilityChanged(aura::Window* window, |
| 238 | bool visible) override { |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 239 | return AnimateOnChildWindowVisibilityChanged(window, visible); |
| 240 | } |
| 241 | |
| 242 | DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); |
| 243 | }; |
| 244 | |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 245 | // Registers prefs whose default values are same in user and signin prefs. |
| 246 | void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test) { |
| 247 | AccessibilityController::RegisterProfilePrefs(registry, for_test); |
yileili | b394a207 | 2018-12-07 18:33:28 | [diff] [blame] | 248 | AssistantController::RegisterProfilePrefs(registry); |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 249 | BluetoothPowerController::RegisterProfilePrefs(registry); |
Qiang Xu | dcf11e3 | 2018-04-25 17:10:17 | [diff] [blame] | 250 | DockedMagnifierController::RegisterProfilePrefs(registry, for_test); |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 251 | LoginScreenController::RegisterProfilePrefs(registry, for_test); |
| 252 | LogoutButtonTray::RegisterProfilePrefs(registry); |
yoshiki iguchi | 7162372 | 2018-08-10 19:44:45 | [diff] [blame] | 253 | MessageCenterController::RegisterProfilePrefs(registry); |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 254 | NightLightController::RegisterProfilePrefs(registry); |
| 255 | PaletteTray::RegisterProfilePrefs(registry); |
| 256 | PaletteWelcomeBubble::RegisterProfilePrefs(registry); |
| 257 | ShelfController::RegisterProfilePrefs(registry); |
Michael Giuffrida | c997aa7 | 2018-08-31 23:38:59 | [diff] [blame] | 258 | TouchDevicesController::RegisterProfilePrefs(registry); |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 259 | CapsLockNotificationController::RegisterProfilePrefs(registry, for_test); |
| 260 | } |
| 261 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 262 | } // namespace |
| 263 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 264 | // static |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 265 | Shell* Shell::instance_ = nullptr; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 266 | |
| 267 | //////////////////////////////////////////////////////////////////////////////// |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 268 | // Shell, public: |
| 269 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 270 | // static |
Scott Violet | c8a1c6c | 2017-11-29 23:17:36 | [diff] [blame] | 271 | Shell* Shell::CreateInstance(ShellInitParams init_params) { |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 272 | CHECK(!instance_); |
James Cook | fa4838e | 2018-08-08 16:30:15 | [diff] [blame] | 273 | instance_ = new Shell(std::move(init_params.delegate), init_params.connector); |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 274 | instance_->Init(init_params.context_factory, |
| 275 | init_params.context_factory_private, |
| 276 | std::move(init_params.initial_display_prefs), |
Jun Mukai | f235779 | 2018-12-20 19:58:00 | [diff] [blame] | 277 | std::move(init_params.gpu_interface_provider), |
| 278 | std::move(init_params.keyboard_ui_factory)); |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 279 | return instance_; |
| 280 | } |
| 281 | |
| 282 | // static |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 283 | Shell* Shell::Get() { |
jamescook | 518dccbd | 2017-05-18 04:57:07 | [diff] [blame] | 284 | CHECK(!g_is_browser_process_with_mash) // Implies null |instance_|. |
| 285 | << "Ash is running in its own process so Shell::Get() will return null. " |
| 286 | "The browser process must use the mojo interfaces in //ash/public to " |
| 287 | "access ash. See ash/README.md for details."; |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 288 | CHECK(instance_); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 289 | return instance_; |
| 290 | } |
| 291 | |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 292 | // static |
[email protected] | b3b7bcd | 2012-03-06 19:35:45 | [diff] [blame] | 293 | bool Shell::HasInstance() { |
| 294 | return !!instance_; |
| 295 | } |
| 296 | |
| 297 | // static |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 298 | void Shell::DeleteInstance() { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 299 | delete instance_; |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 300 | } |
| 301 | |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 302 | // static |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 303 | RootWindowController* Shell::GetPrimaryRootWindowController() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 304 | CHECK(HasInstance()); |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 305 | return RootWindowController::ForWindow(GetPrimaryRootWindow()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | // static |
| 309 | Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 310 | CHECK(HasInstance()); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 311 | RootWindowControllerList root_window_controllers; |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 312 | for (aura::Window* root : GetAllRootWindows()) |
| 313 | root_window_controllers.push_back(RootWindowController::ForWindow(root)); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 314 | return root_window_controllers; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | // static |
thanhph | c90f49ca | 2017-03-03 17:48:53 | [diff] [blame] | 318 | RootWindowController* Shell::GetRootWindowControllerWithDisplayId( |
| 319 | int64_t display_id) { |
| 320 | CHECK(HasInstance()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 321 | aura::Window* root = GetRootWindowForDisplayId(display_id); |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 322 | return root ? RootWindowController::ForWindow(root) : nullptr; |
thanhph | c90f49ca | 2017-03-03 17:48:53 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | // static |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 326 | aura::Window* Shell::GetRootWindowForDisplayId(int64_t display_id) { |
| 327 | CHECK(HasInstance()); |
| 328 | return instance_->window_tree_host_manager_->GetRootWindowForDisplayId( |
| 329 | display_id); |
| 330 | } |
| 331 | |
| 332 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 333 | aura::Window* Shell::GetPrimaryRootWindow() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 334 | CHECK(HasInstance()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 335 | return instance_->window_tree_host_manager_->GetPrimaryRootWindow(); |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 336 | } |
| 337 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 338 | // static |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 339 | aura::Window* Shell::GetRootWindowForNewWindows() { |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 340 | return Shell::Get()->shell_state_->GetRootWindowForNewWindows(); |
mfomitchev | a1a8aa6 | 2016-05-03 16:23:26 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | // static |
[email protected] | c9390bd | 2013-11-08 20:33:13 | [diff] [blame] | 344 | aura::Window::Windows Shell::GetAllRootWindows() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 345 | CHECK(HasInstance()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 346 | return instance_->window_tree_host_manager_->GetAllRootWindows(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | // static |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 350 | aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 351 | return root_window->GetChildById(container_id); |
| 352 | } |
| 353 | |
| 354 | // static |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 355 | const aura::Window* Shell::GetContainer(const aura::Window* root_window, |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 356 | int container_id) { |
| 357 | return root_window->GetChildById(container_id); |
| 358 | } |
| 359 | |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 360 | // static |
James Cook | 7b7c6a5 | 2018-01-04 23:40:03 | [diff] [blame] | 361 | int Shell::GetOpenSystemModalWindowContainerId() { |
| 362 | // The test boolean is not static to avoid leaking state between tests. |
| 363 | if (Get()->simulate_modal_window_open_for_test_) |
| 364 | return kShellWindowId_SystemModalContainer; |
| 365 | |
| 366 | // Traverse all system modal containers, and find its direct child window |
| 367 | // with "SystemModal" setting, and visible. |
James Cook | 7b7c6a5 | 2018-01-04 23:40:03 | [diff] [blame] | 368 | for (aura::Window* root : Shell::GetAllRootWindows()) { |
Xiyuan Xia | 40b3fb1f | 2018-08-22 22:18:20 | [diff] [blame] | 369 | for (int modal_window_id : kSystemModalContainerIds) { |
James Cook | 7b7c6a5 | 2018-01-04 23:40:03 | [diff] [blame] | 370 | aura::Window* system_modal = root->GetChildById(modal_window_id); |
| 371 | if (!system_modal) |
| 372 | continue; |
| 373 | for (const aura::Window* child : system_modal->children()) { |
| 374 | if (child->GetProperty(aura::client::kModalKey) == |
| 375 | ui::MODAL_TYPE_SYSTEM && |
| 376 | child->layer()->GetTargetVisibility()) { |
| 377 | return modal_window_id; |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | return -1; |
| 383 | } |
| 384 | |
| 385 | // static |
| 386 | bool Shell::IsSystemModalWindowOpen() { |
| 387 | return GetOpenSystemModalWindowContainerId() >= 0; |
| 388 | } |
| 389 | |
| 390 | // static |
Scott Violet | 25848c1 | 2018-12-14 18:29:15 | [diff] [blame] | 391 | bool Shell::IsProxyWindow(aura::Window* window) { |
| 392 | return ws::WindowService::IsProxyWindow(window); |
James Cook | a606697 | 2018-07-31 19:34:07 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | // static |
Steven Bennetts | ca10851 | 2018-05-02 11:05:03 | [diff] [blame] | 396 | void Shell::RegisterLocalStatePrefs(PrefRegistrySimple* registry, |
| 397 | bool for_test) { |
Sammie Quon | 4d7dba6 | 2017-08-03 23:18:17 | [diff] [blame] | 398 | PaletteTray::RegisterLocalStatePrefs(registry); |
Wenzhao Zang | 56c29293 | 2017-08-02 04:58:34 | [diff] [blame] | 399 | WallpaperController::RegisterLocalStatePrefs(registry); |
Sonny Sasaka | 55f69fc | 2017-08-28 21:29:37 | [diff] [blame] | 400 | BluetoothPowerController::RegisterLocalStatePrefs(registry); |
Toni Barzic | d623831 | 2018-03-02 18:26:13 | [diff] [blame] | 401 | DetachableBaseHandler::RegisterPrefs(registry); |
Steven Bennetts | ca10851 | 2018-05-02 11:05:03 | [diff] [blame] | 402 | // Note: DisplayPrefs are registered in chrome in AshShellInit::RegisterPrefs |
| 403 | // (see comment there for details). |
| 404 | if (for_test) |
| 405 | DisplayPrefs::RegisterLocalStatePrefs(registry); |
| 406 | else |
| 407 | DisplayPrefs::RegisterForeignPrefs(registry); |
Wenzhao Zang | 56c29293 | 2017-08-02 04:58:34 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | // static |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 411 | void Shell::RegisterSigninProfilePrefs(PrefRegistrySimple* registry, |
| 412 | bool for_test) { |
| 413 | RegisterProfilePrefs(registry, for_test); |
| 414 | PowerPrefs::RegisterSigninProfilePrefs(registry, for_test); |
| 415 | } |
| 416 | |
| 417 | // static |
| 418 | void Shell::RegisterUserProfilePrefs(PrefRegistrySimple* registry, |
| 419 | bool for_test) { |
| 420 | RegisterProfilePrefs(registry, for_test); |
| 421 | PowerPrefs::RegisterUserProfilePrefs(registry, for_test); |
afakhry | e4fae85 | 2017-05-09 18:49:06 | [diff] [blame] | 422 | } |
| 423 | |
Xiyuan Xia | 3619737 | 2018-04-25 00:45:17 | [diff] [blame] | 424 | void Shell::InitWaylandServer(std::unique_ptr<exo::FileHelper> file_helper) { |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 425 | wayland_server_controller_ = WaylandServerController::CreateIfNecessary( |
| 426 | std::move(file_helper), aura_env_); |
Tetsui Ohkubo | 852abe64 | 2018-10-03 02:52:27 | [diff] [blame] | 427 | if (wayland_server_controller_) { |
| 428 | system_tray_model() |
| 429 | ->virtual_keyboard() |
| 430 | ->SetInputMethodSurfaceManagerObserver( |
| 431 | wayland_server_controller_->arc_input_method_surface_manager()); |
| 432 | } |
Scott Violet | 737fb75 | 2018-04-11 15:35:22 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | void Shell::DestroyWaylandServer() { |
Tetsui Ohkubo | 852abe64 | 2018-10-03 02:52:27 | [diff] [blame] | 436 | if (wayland_server_controller_) { |
| 437 | system_tray_model() |
| 438 | ->virtual_keyboard() |
| 439 | ->RemoveInputMethodSurfaceManagerObserver( |
| 440 | wayland_server_controller_->arc_input_method_surface_manager()); |
| 441 | } |
Scott Violet | 737fb75 | 2018-04-11 15:35:22 | [diff] [blame] | 442 | wayland_server_controller_.reset(); |
| 443 | } |
| 444 | |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 445 | views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 446 | views::Widget* widget) { |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 447 | // Use translucent-style window frames for dialogs. |
Evan Stade | 5f09e657 | 2018-08-10 17:48:15 | [diff] [blame] | 448 | return new NonClientFrameViewAsh(widget); |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 449 | } |
| 450 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 451 | void Shell::SetDisplayWorkAreaInsets(Window* contains, |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 452 | const gfx::Insets& insets) { |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 453 | window_tree_host_manager_->UpdateWorkAreaOfDisplayNearestWindow(contains, |
| 454 | insets); |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 455 | } |
| 456 | |
[email protected] | 58868abf | 2014-01-17 23:45:33 | [diff] [blame] | 457 | void Shell::OnCastingSessionStartedOrStopped(bool started) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 458 | for (auto& observer : shell_observers_) |
ericwilligers | 5eff47d | 2016-10-17 19:19:18 | [diff] [blame] | 459 | observer.OnCastingSessionStartedOrStopped(started); |
[email protected] | 58868abf | 2014-01-17 23:45:33 | [diff] [blame] | 460 | } |
| 461 | |
varkha | c71444e5 | 2017-05-25 22:51:34 | [diff] [blame] | 462 | void Shell::OnRootWindowAdded(aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 463 | for (auto& observer : shell_observers_) |
ericwilligers | 5eff47d | 2016-10-17 19:19:18 | [diff] [blame] | 464 | observer.OnRootWindowAdded(root_window); |
[email protected] | 0e3e7cb | 2014-04-12 05:18:25 | [diff] [blame] | 465 | } |
| 466 | |
Zach Helfinstein | bbb6bad | 2018-05-02 18:21:51 | [diff] [blame] | 467 | void Shell::OnDictationStarted() { |
| 468 | for (auto& observer : shell_observers_) |
| 469 | observer.OnDictationStarted(); |
| 470 | } |
| 471 | |
| 472 | void Shell::OnDictationEnded() { |
| 473 | for (auto& observer : shell_observers_) |
| 474 | observer.OnDictationEnded(); |
| 475 | } |
| 476 | |
Darren Shen | f62db77a | 2018-06-07 06:22:44 | [diff] [blame] | 477 | void Shell::EnableKeyboard() { |
Steven Bennetts | a0ea3094 | 2018-10-11 22:27:51 | [diff] [blame] | 478 | // The keyboard controller is persistent; this will create or recreate the |
| 479 | // keyboard window as necessary. |
| 480 | ash_keyboard_controller_->EnableKeyboard(); |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 481 | } |
| 482 | |
Darren Shen | f62db77a | 2018-06-07 06:22:44 | [diff] [blame] | 483 | void Shell::DisableKeyboard() { |
Steven Bennetts | a0ea3094 | 2018-10-11 22:27:51 | [diff] [blame] | 484 | ash_keyboard_controller_->DisableKeyboard(); |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 485 | } |
| 486 | |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 487 | bool Shell::ShouldSaveDisplaySettings() { |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 488 | return !( |
| 489 | screen_orientation_controller_->ignore_display_configuration_updates() || |
| 490 | resolution_notification_controller_->DoesNotificationTimeout()); |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 491 | } |
[email protected] | da28585 | 2014-05-27 19:53:43 | [diff] [blame] | 492 | |
Ahmed Fakhry | 4bf3f74 | 2018-02-06 17:33:36 | [diff] [blame] | 493 | DockedMagnifierController* Shell::docked_magnifier_controller() { |
Ahmed Fakhry | 4af48e4 | 2018-02-28 17:45:38 | [diff] [blame] | 494 | DCHECK(features::IsDockedMagnifierEnabled()); |
Ahmed Fakhry | 4bf3f74 | 2018-02-06 17:33:36 | [diff] [blame] | 495 | return docked_magnifier_controller_.get(); |
| 496 | } |
| 497 | |
afakhry | 9e0a18b3 | 2017-06-05 19:23:14 | [diff] [blame] | 498 | NightLightController* Shell::night_light_controller() { |
Ahmed Fakhry | b9ace24 | 2018-06-06 18:49:31 | [diff] [blame] | 499 | DCHECK(features::IsNightLightEnabled()); |
afakhry | 9e0a18b3 | 2017-06-05 19:23:14 | [diff] [blame] | 500 | return night_light_controller_.get(); |
| 501 | } |
| 502 | |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 503 | ShelfModel* Shell::shelf_model() { |
| 504 | return shelf_controller_->model(); |
| 505 | } |
| 506 | |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 507 | ::wm::ActivationClient* Shell::activation_client() { |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 508 | return focus_controller_.get(); |
| 509 | } |
| 510 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 511 | void Shell::UpdateShelfVisibility() { |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 512 | for (aura::Window* root : GetAllRootWindows()) |
| 513 | Shelf::ForWindow(root)->UpdateVisibilityState(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 514 | } |
| 515 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 516 | bool Shell::HasPrimaryStatusArea() { |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 517 | return !!GetPrimaryRootWindowController()->GetStatusAreaWidget(); |
[email protected] | 31f19e3 | 2012-10-30 22:31:23 | [diff] [blame] | 518 | } |
| 519 | |
yawano | dc5533b3 | 2017-02-23 11:04:38 | [diff] [blame] | 520 | void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { |
| 521 | window_tree_host_manager_->cursor_window_controller() |
| 522 | ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); |
| 523 | } |
| 524 | |
Weidong Guo | d07448f | 2017-10-18 03:35:18 | [diff] [blame] | 525 | void Shell::UpdateCursorCompositingEnabled() { |
| 526 | SetCursorCompositingEnabled( |
| 527 | window_tree_host_manager_->cursor_window_controller() |
| 528 | ->ShouldEnableCursorCompositing()); |
| 529 | } |
| 530 | |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 531 | void Shell::SetCursorCompositingEnabled(bool enabled) { |
James Cook | f2920df | 2018-09-04 19:55:01 | [diff] [blame] | 532 | CursorWindowController* cursor_window_controller = |
| 533 | window_tree_host_manager_->cursor_window_controller(); |
Weidong Guo | 7dfd148 | 2017-11-08 05:56:28 | [diff] [blame] | 534 | |
James Cook | f2920df | 2018-09-04 19:55:01 | [diff] [blame] | 535 | if (cursor_window_controller->is_cursor_compositing_enabled() == enabled) |
| 536 | return; |
| 537 | cursor_window_controller->SetCursorCompositingEnabled(enabled); |
| 538 | native_cursor_manager_->SetNativeCursorEnabled(!enabled); |
[email protected] | 87ec220 | 2014-02-06 06:24:27 | [diff] [blame] | 539 | } |
[email protected] | 59ccade | 2013-10-17 17:56:40 | [diff] [blame] | 540 | |
[email protected] | f946670 | 2012-09-17 16:35:27 | [diff] [blame] | 541 | void Shell::DoInitialWorkspaceAnimation() { |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 542 | return GetPrimaryRootWindowController() |
| 543 | ->workspace_controller() |
| 544 | ->DoInitialAnimation(); |
[email protected] | f946670 | 2012-09-17 16:35:27 | [diff] [blame] | 545 | } |
| 546 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 547 | bool Shell::IsSplitViewModeActive() const { |
Xiaoqian Dai | bf3771f | 2018-03-13 18:21:46 | [diff] [blame] | 548 | return split_view_controller_.get() && |
| 549 | split_view_controller_->IsSplitViewModeActive(); |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 550 | } |
| 551 | |
James Cook | fa4838e | 2018-08-08 16:30:15 | [diff] [blame] | 552 | void Shell::ShowContextMenu(const gfx::Point& location_in_screen, |
| 553 | ui::MenuSourceType source_type) { |
| 554 | // Bail with no active user session, in the lock screen, or in app/kiosk mode. |
| 555 | if (session_controller_->NumberOfLoggedInUsers() < 1 || |
| 556 | session_controller_->IsScreenLocked() || |
| 557 | session_controller_->IsRunningInAppMode()) { |
| 558 | return; |
| 559 | } |
| 560 | |
| 561 | aura::Window* root = wm::GetRootWindowAt(location_in_screen); |
| 562 | RootWindowController::ForWindow(root)->ShowContextMenu(location_in_screen, |
| 563 | source_type); |
| 564 | } |
| 565 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 566 | void Shell::AddShellObserver(ShellObserver* observer) { |
| 567 | shell_observers_.AddObserver(observer); |
| 568 | } |
| 569 | |
| 570 | void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 571 | shell_observers_.RemoveObserver(observer); |
| 572 | } |
| 573 | |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 574 | void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { |
varkha | 5967963 | 2017-06-01 00:42:05 | [diff] [blame] | 575 | for (auto* root_window_controller : GetAllRootWindowControllers()) |
| 576 | root_window_controller->UpdateAfterLoginStatusChange(status); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 577 | } |
| 578 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 579 | void Shell::NotifyOverviewModeStarting() { |
| 580 | for (auto& observer : shell_observers_) |
| 581 | observer.OnOverviewModeStarting(); |
| 582 | } |
| 583 | |
Sammie Quon | be18606 | 2018-10-26 06:40:34 | [diff] [blame] | 584 | void Shell::NotifyOverviewModeStartingAnimationComplete(bool canceled) { |
| 585 | for (auto& observer : shell_observers_) |
| 586 | observer.OnOverviewModeStartingAnimationComplete(canceled); |
| 587 | } |
| 588 | |
Xiaoqian Dai | fb4698ed | 2018-02-23 20:11:06 | [diff] [blame] | 589 | void Shell::NotifyOverviewModeEnding() { |
| 590 | for (auto& observer : shell_observers_) |
| 591 | observer.OnOverviewModeEnding(); |
| 592 | } |
| 593 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 594 | void Shell::NotifyOverviewModeEnded() { |
| 595 | for (auto& observer : shell_observers_) |
| 596 | observer.OnOverviewModeEnded(); |
| 597 | } |
| 598 | |
Sammie Quon | be18606 | 2018-10-26 06:40:34 | [diff] [blame] | 599 | void Shell::NotifyOverviewModeEndingAnimationComplete(bool canceled) { |
Sammie Quon | 317deb5 | 2018-09-06 16:36:28 | [diff] [blame] | 600 | for (auto& observer : shell_observers_) |
Sammie Quon | be18606 | 2018-10-26 06:40:34 | [diff] [blame] | 601 | observer.OnOverviewModeEndingAnimationComplete(canceled); |
Sammie Quon | 317deb5 | 2018-09-06 16:36:28 | [diff] [blame] | 602 | } |
| 603 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 604 | void Shell::NotifySplitViewModeStarting() { |
| 605 | for (auto& observer : shell_observers_) |
| 606 | observer.OnSplitViewModeStarting(); |
| 607 | } |
| 608 | |
Xiaoqian Dai | bf3771f | 2018-03-13 18:21:46 | [diff] [blame] | 609 | void Shell::NotifySplitViewModeStarted() { |
| 610 | for (auto& observer : shell_observers_) |
| 611 | observer.OnSplitViewModeStarted(); |
| 612 | } |
| 613 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 614 | void Shell::NotifySplitViewModeEnded() { |
| 615 | for (auto& observer : shell_observers_) |
| 616 | observer.OnSplitViewModeEnded(); |
| 617 | } |
| 618 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 619 | void Shell::NotifyFullscreenStateChanged(bool is_fullscreen, |
varkha | c71444e5 | 2017-05-25 22:51:34 | [diff] [blame] | 620 | aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 621 | for (auto& observer : shell_observers_) |
| 622 | observer.OnFullscreenStateChanged(is_fullscreen, root_window); |
| 623 | } |
| 624 | |
varkha | 19d7e6c5 | 2017-05-25 21:15:30 | [diff] [blame] | 625 | void Shell::NotifyPinnedStateChanged(aura::Window* pinned_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 626 | for (auto& observer : shell_observers_) |
| 627 | observer.OnPinnedStateChanged(pinned_window); |
| 628 | } |
| 629 | |
varkha | 6b016b0f | 2017-05-26 16:14:18 | [diff] [blame] | 630 | void Shell::NotifyShelfAlignmentChanged(aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 631 | for (auto& observer : shell_observers_) |
| 632 | observer.OnShelfAlignmentChanged(root_window); |
| 633 | } |
| 634 | |
varkha | 6b016b0f | 2017-05-26 16:14:18 | [diff] [blame] | 635 | void Shell::NotifyShelfAutoHideBehaviorChanged(aura::Window* root_window) { |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 636 | for (auto& observer : shell_observers_) |
| 637 | observer.OnShelfAutoHideBehaviorChanged(root_window); |
| 638 | } |
| 639 | |
jamescook | 518dccbd | 2017-05-18 04:57:07 | [diff] [blame] | 640 | // static |
| 641 | void Shell::SetIsBrowserProcessWithMash() { |
| 642 | g_is_browser_process_with_mash = true; |
| 643 | } |
| 644 | |
muyuanli | d766f2e | 2017-06-26 20:17:19 | [diff] [blame] | 645 | void Shell::NotifyAppListVisibilityChanged(bool visible, |
| 646 | aura::Window* root_window) { |
newcomer | 2febb983 | 2017-06-12 17:00:23 | [diff] [blame] | 647 | for (auto& observer : shell_observers_) |
| 648 | observer.OnAppListVisibilityChanged(visible, root_window); |
| 649 | } |
| 650 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 651 | //////////////////////////////////////////////////////////////////////////////// |
| 652 | // Shell, private: |
| 653 | |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 654 | Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 655 | service_manager::Connector* connector) |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 656 | : owned_aura_env_(::features::IsSingleProcessMash() |
| 657 | ? aura::Env::CreateLocalInstanceForInProcess() |
| 658 | : nullptr), |
| 659 | aura_env_(owned_aura_env_.get() ? owned_aura_env_.get() |
| 660 | : aura::Env::GetInstance()), |
| 661 | ash_display_controller_(std::make_unique<AshDisplayController>()), |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 662 | brightness_control_delegate_( |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 663 | std::make_unique<system::BrightnessControllerChromeos>()), |
| 664 | cast_config_(std::make_unique<CastConfigController>()), |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 665 | connector_(connector), |
Quan Nguyen | af67b64d | 2018-11-29 19:21:48 | [diff] [blame] | 666 | contained_shell_controller_(std::make_unique<ContainedShellController>()), |
James Cook | f539884 | 2018-04-16 20:15:24 | [diff] [blame] | 667 | first_run_helper_(std::make_unique<FirstRunHelper>()), |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 668 | focus_cycler_(std::make_unique<FocusCycler>()), |
| 669 | ime_controller_(std::make_unique<ImeController>()), |
| 670 | immersive_context_(std::make_unique<ImmersiveContextAsh>()), |
sky | 79fa3471 | 2017-03-20 23:46:47 | [diff] [blame] | 671 | keyboard_brightness_control_delegate_( |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 672 | std::make_unique<KeyboardBrightnessController>()), |
Tatsuhisa Yamaguchi | 440e2d2e | 2018-12-05 09:16:31 | [diff] [blame] | 673 | locale_update_controller_(std::make_unique<LocaleUpdateController>()), |
Becca Hughes | 253f1bbf3 | 2018-10-18 18:38:31 | [diff] [blame] | 674 | media_controller_(std::make_unique<MediaController>(connector)), |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 675 | new_window_controller_(std::make_unique<NewWindowController>()), |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 676 | session_controller_(std::make_unique<SessionController>(connector)), |
Vladislav Kaznacheev | 92edf62e | 2017-10-13 22:08:01 | [diff] [blame] | 677 | note_taking_controller_(std::make_unique<NoteTakingController>()), |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 678 | shell_delegate_(std::move(shell_delegate)), |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 679 | shell_state_(std::make_unique<ShellState>()), |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 680 | shutdown_controller_(std::make_unique<ShutdownController>()), |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 681 | system_tray_notifier_(std::make_unique<SystemTrayNotifier>()), |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 682 | vpn_list_(std::make_unique<VpnList>()), |
| 683 | window_cycle_controller_(std::make_unique<WindowCycleController>()), |
Scott Violet | bed23cb | 2018-08-22 19:56:12 | [diff] [blame] | 684 | display_configurator_(std::make_unique<display::DisplayConfigurator>()), |
| 685 | display_output_protection_(std::make_unique<DisplayOutputProtection>( |
| 686 | display_configurator_.get())), |
sadrul | 7a8785e | 2016-02-12 21:54:35 | [diff] [blame] | 687 | native_cursor_manager_(nullptr), |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 688 | weak_factory_(this) { |
Scott Violet | c354dd1 | 2018-10-17 00:12:35 | [diff] [blame] | 689 | // Ash doesn't properly remove pre-target-handlers. |
| 690 | ui::EventHandler::DisableCheckTargets(); |
| 691 | |
Steven Bennetts | 368a1c8 | 2019-01-11 20:45:22 | [diff] [blame] | 692 | AccelerometerReader::GetInstance()->Initialize( |
| 693 | base::CreateSequencedTaskRunnerWithTraits( |
| 694 | {base::MayBlock(), base::TaskPriority::BEST_EFFORT, |
| 695 | base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); |
| 696 | |
Jun Mukai | 5c7b5b4 | 2018-11-30 00:08:50 | [diff] [blame] | 697 | login_screen_controller_ = |
| 698 | std::make_unique<LoginScreenController>(system_tray_notifier_.get()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 699 | display_manager_.reset(ScreenAsh::CreateDisplayManager()); |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 700 | window_tree_host_manager_ = std::make_unique<WindowTreeHostManager>(); |
| 701 | user_metrics_recorder_ = std::make_unique<UserMetricsRecorder>(); |
Steven Bennetts | a0ea3094 | 2018-10-11 22:27:51 | [diff] [blame] | 702 | ash_keyboard_controller_ = |
| 703 | std::make_unique<AshKeyboardController>(session_controller_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 704 | |
Giovanni Ortuño Urquidi | 55aa5d8f | 2018-10-10 05:33:34 | [diff] [blame] | 705 | if (base::FeatureList::IsEnabled(features::kUseBluetoothSystemInAsh)) { |
| 706 | tray_bluetooth_helper_ = |
Giovanni Ortuño Urquidi | c87b6f34 | 2018-10-16 04:44:41 | [diff] [blame] | 707 | std::make_unique<TrayBluetoothHelperExperimental>(connector_); |
Giovanni Ortuño Urquidi | 55aa5d8f | 2018-10-10 05:33:34 | [diff] [blame] | 708 | } else { |
| 709 | tray_bluetooth_helper_ = std::make_unique<TrayBluetoothHelperLegacy>(); |
| 710 | } |
| 711 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 712 | PowerStatus::Initialize(); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 713 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 714 | session_controller_->AddObserver(this); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | Shell::~Shell() { |
| 718 | TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); |
| 719 | |
Scott Violet | 737fb75 | 2018-04-11 15:35:22 | [diff] [blame] | 720 | // Wayland depends upon some ash specific objects. Destroy it early on. |
| 721 | wayland_server_controller_.reset(); |
| 722 | |
Scott Violet | 41562d1c | 2017-06-26 15:15:48 | [diff] [blame] | 723 | user_metrics_recorder_->OnShellShuttingDown(); |
bruthig | c24d11f | 2015-06-09 21:30:03 | [diff] [blame] | 724 | |
Steven Bennetts | 2a9b438 | 2018-04-26 23:41:19 | [diff] [blame] | 725 | cros_display_config_.reset(); |
Steven Bennetts | 9b21fa3 | 2018-04-13 23:45:55 | [diff] [blame] | 726 | display_configuration_observer_.reset(); |
Steven Bennetts | 3688c603 | 2018-04-13 01:14:23 | [diff] [blame] | 727 | display_prefs_.reset(); |
[email protected] | 050e7718 | 2014-03-25 15:29:16 | [diff] [blame] | 728 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 729 | // Remove the focus from any window. This will prevent overhead and side |
| 730 | // effects (e.g. crashes) from changing focus during shutdown. |
| 731 | // See bug crbug.com/134502. |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 732 | aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 733 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 734 | // Please keep in reverse order as in Init() because it's easy to miss one. |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 735 | if (window_modality_controller_) |
| 736 | window_modality_controller_.reset(); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 737 | |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 738 | RemovePreTargetHandler(magnifier_key_scroll_handler_.get()); |
| 739 | magnifier_key_scroll_handler_.reset(); |
| 740 | |
| 741 | RemovePreTargetHandler(speech_feedback_handler_.get()); |
| 742 | speech_feedback_handler_.reset(); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 743 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 744 | RemovePreTargetHandler(overlay_filter_.get()); |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 745 | overlay_filter_.reset(); |
| 746 | |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 747 | RemovePreTargetHandler(accelerator_filter_.get()); |
| 748 | RemovePreTargetHandler(event_transformation_handler_.get()); |
| 749 | RemovePreTargetHandler(toplevel_window_event_handler_.get()); |
| 750 | RemovePostTargetHandler(toplevel_window_event_handler_.get()); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 751 | RemovePreTargetHandler(system_gesture_filter_.get()); |
| 752 | RemovePreTargetHandler(mouse_cursor_filter_.get()); |
hariank | 0dd03dd | 2016-07-14 23:47:33 | [diff] [blame] | 753 | RemovePreTargetHandler(modality_filter_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 754 | RemovePreTargetHandler(tooltip_controller_.get()); |
| 755 | |
Mike Wasserman | efbf340 | 2018-04-26 00:41:32 | [diff] [blame] | 756 | event_rewriter_controller_.reset(); |
| 757 | |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 758 | screen_orientation_controller_.reset(); |
yiyix | a68ade51 | 2016-09-01 17:38:13 | [diff] [blame] | 759 | screen_layout_observer_.reset(); |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 760 | |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 761 | // Destroy the virtual keyboard controller before the tablet mode controller |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 762 | // since the latters destructor triggers events that the former is listening |
| 763 | // to but no longer cares about. |
Steven Bennetts | edb5fa39 | 2018-10-18 17:47:52 | [diff] [blame] | 764 | ash_keyboard_controller_->DestroyVirtualKeyboard(); |
jonross | 0af4521 | 2015-01-13 18:55:46 | [diff] [blame] | 765 | |
James Cook | d2495fe | 2018-03-19 19:53:10 | [diff] [blame] | 766 | // Depends on |tablet_mode_controller_|. |
| 767 | shelf_controller_->Shutdown(); |
| 768 | |
Weidong Guo | 268c799 | 2018-04-13 21:06:07 | [diff] [blame] | 769 | // Destroy |app_list_controller_| early than |tablet_mode_controller_| since |
| 770 | // the former may use the latter before destruction. |
| 771 | app_list_controller_.reset(); |
| 772 | |
David Black | c153e317 | 2018-08-21 18:17:58 | [diff] [blame] | 773 | // Destroy |assistant_controller_| earlier than |tablet_mode_controller_| so |
| 774 | // that the former will destroy the Assistant view hierarchy which has a |
| 775 | // dependency on the latter. |
Muyuan Li | 628f6a6 | 2018-08-15 20:39:58 | [diff] [blame] | 776 | if (chromeos::switches::IsAssistantEnabled()) |
David Black | c153e317 | 2018-08-21 18:17:58 | [diff] [blame] | 777 | assistant_controller_.reset(); |
Muyuan Li | 628f6a6 | 2018-08-15 20:39:58 | [diff] [blame] | 778 | |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 779 | // Destroy tablet mode controller early on since it has some observers which |
[email protected] | 5ed2b64 | 2014-03-04 00:06:57 | [diff] [blame] | 780 | // need to be removed. |
Mitsuru Oshima | 0e9b7a6 | 2017-07-19 18:23:03 | [diff] [blame] | 781 | tablet_mode_controller_.reset(); |
[email protected] | 5ed2b64 | 2014-03-04 00:06:57 | [diff] [blame] | 782 | |
jdufault | 551152e | 2016-01-27 19:48:43 | [diff] [blame] | 783 | // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
| 784 | // layout. |
Darren Shen | f62db77a | 2018-06-07 06:22:44 | [diff] [blame] | 785 | DisableKeyboard(); |
jdufault | 551152e | 2016-01-27 19:48:43 | [diff] [blame] | 786 | |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 787 | toast_manager_.reset(); |
yoshiki | 32f5163 | 2016-03-24 01:24:43 | [diff] [blame] | 788 | |
jamescook | ac672433 | 2017-03-21 02:54:43 | [diff] [blame] | 789 | tray_bluetooth_helper_.reset(); |
James Cook | b50959e2 | 2017-08-10 20:24:38 | [diff] [blame] | 790 | |
| 791 | // Accesses root window containers. |
| 792 | logout_confirmation_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 793 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 794 | // Drag-and-drop must be canceled prior to close all windows. |
James Cook | 1e0f3ff | 2018-03-06 22:52:45 | [diff] [blame] | 795 | for (aura::Window* root : GetAllRootWindows()) |
| 796 | aura::client::SetDragDropClient(root, nullptr); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 797 | drag_drop_controller_.reset(); |
| 798 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 799 | // Controllers who have WindowObserver added must be deleted |
| 800 | // before |window_tree_host_manager_| is deleted. |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 801 | |
Qiang Xu | d77a90c | 2018-02-20 19:43:29 | [diff] [blame] | 802 | persistent_window_controller_.reset(); |
| 803 | |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 804 | // VideoActivityNotifier must be deleted before |video_detector_| is |
| 805 | // deleted because it's observing video activity through |
derat | 83b76139 | 2016-07-11 16:44:44 | [diff] [blame] | 806 | // VideoDetector::Observer interface. |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 807 | video_activity_notifier_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 808 | video_detector_.reset(); |
[email protected] | 0e3e7cb | 2014-04-12 05:18:25 | [diff] [blame] | 809 | high_contrast_controller_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 810 | |
| 811 | shadow_controller_.reset(); |
| 812 | resize_shadow_controller_.reset(); |
| 813 | |
sky | 37f0dd1 | 2016-07-19 18:00:59 | [diff] [blame] | 814 | // Has to happen before ~MruWindowTracker. |
sky | 5b45ed8 | 2017-03-27 02:54:23 | [diff] [blame] | 815 | window_cycle_controller_.reset(); |
| 816 | window_selector_controller_.reset(); |
[email protected] | 8c9d12a | 2013-12-06 18:39:03 | [diff] [blame] | 817 | |
xdai | 7a8867cd | 2017-08-25 23:10:16 | [diff] [blame] | 818 | // |split_view_controller_| needs to be deleted after |
| 819 | // |window_selector_controller_|. |
| 820 | split_view_controller_.reset(); |
| 821 | |
James Cook | 4309713 | 2018-08-18 23:31:54 | [diff] [blame] | 822 | // Stop dispatching events (e.g. synthesized mouse exits from window close). |
| 823 | // https://crbug.com/874156 |
| 824 | for (RootWindowController* rwc : GetAllRootWindowControllers()) |
| 825 | rwc->GetHost()->dispatcher()->Shutdown(); |
| 826 | |
James Cook | ee2daef | 2018-03-10 01:48:10 | [diff] [blame] | 827 | // Close all widgets (including the shelf) and destroy all window containers. |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 828 | CloseAllRootWindowChildWindows(); |
| 829 | |
Jun Mukai | 5c7b5b4 | 2018-11-30 00:08:50 | [diff] [blame] | 830 | login_screen_controller_.reset(); |
Tetsui Ohkubo | 269b579 | 2018-04-26 01:06:32 | [diff] [blame] | 831 | system_notification_controller_.reset(); |
| 832 | // Should be destroyed after Shelf and |system_notification_controller_|. |
| 833 | system_tray_model_.reset(); |
| 834 | |
afakhry | 5815939 | 2015-05-22 02:45:52 | [diff] [blame] | 835 | // MruWindowTracker must be destroyed after all windows have been deleted to |
| 836 | // avoid a possible crash when Shell is destroyed from a non-normal shutdown |
| 837 | // path. (crbug.com/485438). |
sky | 5ab1647 | 2017-03-21 19:35:08 | [diff] [blame] | 838 | mru_window_tracker_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 839 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 840 | // These need a valid Shell instance to clean up properly, so explicitly |
| 841 | // delete them before invalidating the instance. |
| 842 | // Alphabetical. TODO(oshima): sort. |
Katie D | cf8d5593 | 2018-10-24 23:01:22 | [diff] [blame] | 843 | autoclick_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 844 | magnification_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 845 | tooltip_controller_.reset(); |
| 846 | event_client_.reset(); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 847 | toplevel_window_event_handler_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 848 | visibility_controller_.reset(); |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 849 | power_prefs_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 850 | |
Toni Barzic | 85ae39e | 2017-12-07 05:50:18 | [diff] [blame] | 851 | tray_action_.reset(); |
| 852 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 853 | power_button_controller_.reset(); |
| 854 | lock_state_controller_.reset(); |
Toni Barzic | 9d0c82f4 | 2017-12-06 00:53:52 | [diff] [blame] | 855 | backlights_forced_off_setter_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 856 | |
hidehiko | 6821ca4 | 2016-06-18 11:12:23 | [diff] [blame] | 857 | screen_pinning_controller_.reset(); |
| 858 | |
Kyle Horimoto | 9fc84fc2 | 2018-04-27 19:45:15 | [diff] [blame] | 859 | multidevice_notification_presenter_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 860 | resolution_notification_controller_.reset(); |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 861 | screenshot_controller_.reset(); |
[email protected] | 8ab613cf | 2014-05-12 09:39:49 | [diff] [blame] | 862 | mouse_cursor_filter_.reset(); |
hariank | 0dd03dd | 2016-07-14 23:47:33 | [diff] [blame] | 863 | modality_filter_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 864 | |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 865 | touch_transformer_controller_.reset(); |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 866 | laser_pointer_controller_.reset(); |
| 867 | partial_magnification_controller_.reset(); |
Vladislav Kaznacheev | 6d6aaff | 2017-07-22 04:06:32 | [diff] [blame] | 868 | highlighter_controller_.reset(); |
Yue Li | a33960a | 2017-11-01 22:06:07 | [diff] [blame] | 869 | voice_interaction_controller_.reset(); |
David Tseng | 6792dc8 | 2018-05-04 19:18:41 | [diff] [blame] | 870 | key_accessibility_enabler_.reset(); |
warx | 533c8f6 | 2016-04-12 01:19:43 | [diff] [blame] | 871 | |
Tetsui Ohkubo | 01421b3 | 2018-05-30 16:54:59 | [diff] [blame] | 872 | display_speaker_controller_.reset(); |
Tetsui Ohkubo | 54d5022 | 2018-05-10 01:58:11 | [diff] [blame] | 873 | screen_switch_check_controller_.reset(); |
| 874 | |
rjkroege | 2c930540 | 2016-09-07 00:21:45 | [diff] [blame] | 875 | ScreenAsh::CreateScreenForShutdown(); |
stevenjb | 537c5c3f | 2016-01-20 23:38:12 | [diff] [blame] | 876 | display_configuration_controller_.reset(); |
dtseng | 4ae0a88 | 2016-04-15 21:39:27 | [diff] [blame] | 877 | |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 878 | // These members access Shell in their destructors. |
| 879 | wallpaper_controller_.reset(); |
James Cook | ec14495 | 2017-09-01 00:05:16 | [diff] [blame] | 880 | accessibility_controller_.reset(); |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 881 | accessibility_delegate_.reset(); |
Qiang Xu | a959100 | 2018-03-15 22:29:31 | [diff] [blame] | 882 | accessibility_focus_ring_controller_.reset(); |
Qiang Xu | d8e897e | 2018-05-24 20:07:57 | [diff] [blame] | 883 | policy_recommendation_restorer_.reset(); |
Shu Chen | 39277d2 | 2018-12-10 04:22:51 | [diff] [blame] | 884 | ime_controller_.reset(); |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 885 | |
| 886 | // Balances the Install() in Initialize(). |
| 887 | views::FocusManagerFactory::Install(nullptr); |
| 888 | |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 889 | // ShelfWindowWatcher has window observers and a pointer to the shelf model. |
| 890 | shelf_window_watcher_.reset(); |
| 891 | |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 892 | // Removes itself as an observer of |pref_service_|. |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 893 | shelf_controller_.reset(); |
| 894 | |
Ahmed Fakhry | e96051f | 2017-12-12 17:42:17 | [diff] [blame] | 895 | // NightLightController depends on the PrefService as well as the window tree |
| 896 | // host manager, and must be destructed before them. crbug.com/724231. |
| 897 | night_light_controller_ = nullptr; |
Ahmed Fakhry | 4bf3f74 | 2018-02-06 17:33:36 | [diff] [blame] | 898 | // Similarly for DockedMagnifierController. |
| 899 | docked_magnifier_controller_ = nullptr; |
Ahmed Fakhry | e96051f | 2017-12-12 17:42:17 | [diff] [blame] | 900 | |
Scott Violet | b7f4df2 | 2018-05-17 04:43:12 | [diff] [blame] | 901 | // May own windows and other objects that have indirect hooks into |
| 902 | // WindowTreeHostManager. |
| 903 | window_service_owner_.reset(); |
| 904 | |
Xiyuan Xia | 5f1046e | 2018-06-01 16:04:44 | [diff] [blame] | 905 | // Must be released before |focus_controller_|. |
| 906 | ime_focus_handler_.reset(); |
| 907 | |
James Cook | 05b3a3f | 2018-08-07 00:38:55 | [diff] [blame] | 908 | // Stop observing window activation changes before closing all windows. |
| 909 | focus_controller_->RemoveObserver(this); |
| 910 | |
| 911 | // This also deletes all RootWindows. Note that we invoke Shutdown() on |
| 912 | // WindowTreeHostManager before resetting |window_tree_host_manager_|, since |
| 913 | // destruction of its owned RootWindowControllers relies on the value. |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 914 | window_tree_host_manager_->Shutdown(); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 915 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 916 | // Depends on |focus_controller_|, so must be destroyed before. |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 917 | window_tree_host_manager_.reset(); |
Scott Violet | 7dbdaeb | 2018-12-11 22:39:02 | [diff] [blame] | 918 | focus_rules_ = nullptr; |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 919 | focus_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 920 | screen_position_controller_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 921 | |
robert.bradford | ab05249 | 2015-05-06 11:09:56 | [diff] [blame] | 922 | display_color_manager_.reset(); |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 923 | projecting_observer_.reset(); |
| 924 | |
[email protected] | 7bc49bd | 2014-01-22 09:30:34 | [diff] [blame] | 925 | if (display_change_observer_) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 926 | display_configurator_->RemoveObserver(display_change_observer_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 927 | if (display_error_observer_) |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 928 | display_configurator_->RemoveObserver(display_error_observer_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 929 | display_change_observer_.reset(); |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 930 | display_shutdown_observer_.reset(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 931 | |
Steven Bennetts | a0ea3094 | 2018-10-11 22:27:51 | [diff] [blame] | 932 | ash_keyboard_controller_.reset(); |
| 933 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 934 | PowerStatus::Shutdown(); |
James Cook | 934ba81 | 2018-04-20 14:17:35 | [diff] [blame] | 935 | // Depends on SessionController. |
| 936 | power_event_observer_.reset(); |
pneubeck | 8be1f542 | 2014-10-09 16:46:18 | [diff] [blame] | 937 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 938 | session_controller_->RemoveObserver(this); |
Sonny Sasaka | 55f69fc | 2017-08-28 21:29:37 | [diff] [blame] | 939 | // BluetoothPowerController depends on the PrefService and must be destructed |
| 940 | // before it. |
| 941 | bluetooth_power_controller_ = nullptr; |
Qiang Xu | f1400a36 | 2017-09-14 02:28:30 | [diff] [blame] | 942 | // TouchDevicesController depends on the PrefService and must be destructed |
| 943 | // before it. |
| 944 | touch_devices_controller_ = nullptr; |
Toni Barzic | 550419f | 2018-03-08 03:56:21 | [diff] [blame] | 945 | // DetachableBaseNotificationController depends on DetachableBaseHandler, and |
| 946 | // has to be destructed before it. |
| 947 | detachable_base_notification_controller_.reset(); |
Toni Barzic | d623831 | 2018-03-02 18:26:13 | [diff] [blame] | 948 | // DetachableBaseHandler depends on the PrefService and must be destructed |
| 949 | // before it. |
| 950 | detachable_base_handler_.reset(); |
Ahmed Fakhry | e96051f | 2017-12-12 17:42:17 | [diff] [blame] | 951 | |
Becca Hughes | c6a0a06 | 2018-10-25 16:54:13 | [diff] [blame] | 952 | // MediaNotificationController depends on MessageCenter and must be destructed |
| 953 | // before it. |
| 954 | media_notification_controller_.reset(); |
| 955 | |
Evan Stade | 196ec04 | 2018-03-13 19:44:36 | [diff] [blame] | 956 | // Destroys the MessageCenter singleton, so must happen late. |
| 957 | message_center_controller_.reset(); |
| 958 | |
Sam McNally | a853cd8 | 2017-08-30 01:55:10 | [diff] [blame] | 959 | local_state_.reset(); |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 960 | shell_delegate_.reset(); |
sky | 88bd4be6 | 2016-06-09 17:34:41 | [diff] [blame] | 961 | |
Scott Violet | 17a6172 | 2017-06-19 17:54:31 | [diff] [blame] | 962 | for (auto& observer : shell_observers_) |
| 963 | observer.OnShellDestroyed(); |
| 964 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 965 | DCHECK(instance_ == this); |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 966 | instance_ = nullptr; |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 967 | } |
| 968 | |
Scott Violet | ae4c25d | 2018-06-19 15:50:15 | [diff] [blame] | 969 | void Shell::Init( |
| 970 | ui::ContextFactory* context_factory, |
| 971 | ui::ContextFactoryPrivate* context_factory_private, |
| 972 | std::unique_ptr<base::Value> initial_display_prefs, |
Jun Mukai | f235779 | 2018-12-20 19:58:00 | [diff] [blame] | 973 | std::unique_ptr<ws::GpuInterfaceProvider> gpu_interface_provider, |
| 974 | std::unique_ptr<keyboard::KeyboardUIFactory> keyboard_ui_factory) { |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 975 | if (::features::IsSingleProcessMash()) { |
| 976 | // In SingleProcessMash mode ScreenMus is not created, which means Ash needs |
| 977 | // to set the WindowManagerFrameValues. |
| 978 | views::WindowManagerFrameValues frame_values; |
| 979 | frame_values.normal_insets = frame_values.maximized_insets = |
| 980 | NonClientFrameController::GetPreferredClientAreaInsets(); |
| 981 | frame_values.max_title_bar_button_width = |
| 982 | NonClientFrameController::GetMaxTitleBarButtonWidth(); |
| 983 | views::WindowManagerFrameValues::SetInstance(frame_values); |
James Cook | cc2d170 | 2018-12-13 21:20:08 | [diff] [blame] | 984 | |
| 985 | // Accessibility node tree serialization needs to "jump the fence" and |
| 986 | // convert between ash proxy and mus client windows. |
| 987 | views::AXAuraWindowUtils::Set(std::make_unique<AXAshWindowUtils>()); |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 988 | } |
| 989 | |
Evan Stade | 196ec04 | 2018-03-13 19:44:36 | [diff] [blame] | 990 | // This creates the MessageCenter object which is used by some other objects |
| 991 | // initialized here, so it needs to come early. |
| 992 | message_center_controller_ = std::make_unique<MessageCenterController>(); |
| 993 | |
James Cook | bd0b779 | 2017-11-17 03:24:26 | [diff] [blame] | 994 | // These controllers call Shell::Get() in their constructors, so they cannot |
| 995 | // be in the member initialization list. |
Qiang Xu | f1400a36 | 2017-09-14 02:28:30 | [diff] [blame] | 996 | touch_devices_controller_ = std::make_unique<TouchDevicesController>(); |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 997 | bluetooth_power_controller_ = std::make_unique<BluetoothPowerController>(); |
Toni Barzic | d623831 | 2018-03-02 18:26:13 | [diff] [blame] | 998 | detachable_base_handler_ = std::make_unique<DetachableBaseHandler>(this); |
Toni Barzic | 550419f | 2018-03-08 03:56:21 | [diff] [blame] | 999 | detachable_base_notification_controller_ = |
| 1000 | std::make_unique<DetachableBaseNotificationController>( |
| 1001 | detachable_base_handler_.get()); |
Tetsui Ohkubo | 01421b3 | 2018-05-30 16:54:59 | [diff] [blame] | 1002 | display_speaker_controller_ = std::make_unique<DisplaySpeakerController>(); |
Qiang Xu | d8e897e | 2018-05-24 20:07:57 | [diff] [blame] | 1003 | policy_recommendation_restorer_ = |
| 1004 | std::make_unique<PolicyRecommendationRestorer>(); |
Tetsui Ohkubo | 54d5022 | 2018-05-10 01:58:11 | [diff] [blame] | 1005 | screen_switch_check_controller_ = |
| 1006 | std::make_unique<ScreenSwitchCheckController>(); |
Kyle Horimoto | 9fc84fc2 | 2018-04-27 19:45:15 | [diff] [blame] | 1007 | // Connector can be null in tests. |
Kyle Horimoto | 3cdb1d0 | 2018-12-18 00:18:06 | [diff] [blame] | 1008 | if (connector_) { |
Kyle Horimoto | 9fc84fc2 | 2018-04-27 19:45:15 | [diff] [blame] | 1009 | multidevice_notification_presenter_ = |
| 1010 | std::make_unique<MultiDeviceNotificationPresenter>( |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 1011 | message_center::MessageCenter::Get(), connector_); |
Sonny Sasaka | 55f69fc | 2017-08-28 21:29:37 | [diff] [blame] | 1012 | |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1013 | // Connect to local state prefs now, but wait for an active user before |
| 1014 | // connecting to the profile pref service. The login screen has a temporary |
| 1015 | // user profile that is not associated with a real user. |
Taiju Tsuiki | 36c517d | 2017-05-18 06:45:43 | [diff] [blame] | 1016 | auto pref_registry = base::MakeRefCounted<PrefRegistrySimple>(); |
Steven Bennetts | ca10851 | 2018-05-02 11:05:03 | [diff] [blame] | 1017 | RegisterLocalStatePrefs(pref_registry.get(), false); |
tibell | b93c729b | 2017-03-30 00:45:09 | [diff] [blame] | 1018 | prefs::ConnectToPrefService( |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 1019 | connector_, std::move(pref_registry), |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 1020 | base::Bind(&Shell::OnLocalStatePrefServiceInitialized, |
| 1021 | weak_factory_.GetWeakPtr()), |
| 1022 | prefs::mojom::kLocalStateServiceName); |
jonross | c4ba1060 | 2017-04-07 20:51:05 | [diff] [blame] | 1023 | } |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 1024 | |
David Tseng | 562a9c1 | 2018-07-18 03:35:05 | [diff] [blame] | 1025 | tablet_mode_controller_ = std::make_unique<TabletModeController>(); |
| 1026 | |
Qiang Xu | a959100 | 2018-03-15 22:29:31 | [diff] [blame] | 1027 | accessibility_focus_ring_controller_ = |
| 1028 | std::make_unique<AccessibilityFocusRingController>(); |
sky | b073203a | 2017-03-13 16:59:16 | [diff] [blame] | 1029 | accessibility_delegate_.reset(shell_delegate_->CreateAccessibilityDelegate()); |
James Cook | aa6aaad | 2018-08-24 01:00:06 | [diff] [blame] | 1030 | accessibility_controller_ = std::make_unique<AccessibilityController>(); |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1031 | toast_manager_ = std::make_unique<ToastManager>(); |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 1032 | |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 1033 | // Install the custom factory early on so that views::FocusManagers for Tray, |
| 1034 | // Shelf, and WallPaper could be created by the factory. |
| 1035 | views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 1036 | |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1037 | wallpaper_controller_ = std::make_unique<WallpaperController>(); |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 1038 | |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1039 | window_positioner_ = std::make_unique<WindowPositioner>(); |
sky | 984c189 | 2016-04-20 00:00:34 | [diff] [blame] | 1040 | |
James Cook | 79e1ed6 | 2018-09-07 15:40:42 | [diff] [blame] | 1041 | native_cursor_manager_ = new NativeCursorManagerAsh; |
James Cook | 698fc366 | 2018-07-27 16:05:01 | [diff] [blame] | 1042 | cursor_manager_ = |
| 1043 | std::make_unique<CursorManager>(base::WrapUnique(native_cursor_manager_)); |
sky | fee520c | 2016-02-11 19:57:46 | [diff] [blame] | 1044 | |
Steven Bennetts | ca10851 | 2018-05-02 11:05:03 | [diff] [blame] | 1045 | // In CLASSIC mode, |initial_display_prefs| contains the synchronously |
| 1046 | // loaded display pref values. Otherwise |initial_display_prefs| is null and |
| 1047 | // the pref values will be loaded once |local_state_| is available. (Any store |
| 1048 | // requests in the meanwhile will be queued). |
| 1049 | display_prefs_ = |
| 1050 | std::make_unique<DisplayPrefs>(std::move(initial_display_prefs)); |
| 1051 | |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1052 | InitializeDisplayManager(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1053 | |
James Cook | 602164e | 2018-08-07 20:39:42 | [diff] [blame] | 1054 | // This will initialize aura::Env which requires |display_manager_| to |
| 1055 | // be initialized first. |
| 1056 | if (context_factory) |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 1057 | aura_env_->set_context_factory(context_factory); |
| 1058 | if (context_factory_private) |
| 1059 | aura_env_->set_context_factory_private(context_factory_private); |
[email protected] | ecca62b | 2013-10-09 16:18:53 | [diff] [blame] | 1060 | |
Ahmed Fakhry | 4635734 | 2018-04-27 00:46:11 | [diff] [blame] | 1061 | // Night Light depends on the display manager, the display color manager, and |
| 1062 | // aura::Env, so initialize it after all have been initialized. |
Ahmed Fakhry | b9ace24 | 2018-06-06 18:49:31 | [diff] [blame] | 1063 | if (features::IsNightLightEnabled()) |
Ahmed Fakhry | 4635734 | 2018-04-27 00:46:11 | [diff] [blame] | 1064 | night_light_controller_ = std::make_unique<NightLightController>(); |
| 1065 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1066 | // The WindowModalityController needs to be at the front of the input event |
| 1067 | // pretarget handler list to ensure that it processes input events when modal |
| 1068 | // windows are active. |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 1069 | window_modality_controller_ = |
| 1070 | std::make_unique<::wm::WindowModalityController>(this, aura_env_); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1071 | |
Mike Wasserman | efbf340 | 2018-04-26 00:41:32 | [diff] [blame] | 1072 | event_rewriter_controller_ = std::make_unique<EventRewriterController>(); |
| 1073 | |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 1074 | env_filter_ = std::make_unique<::wm::CompoundEventFilter>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1075 | AddPreTargetHandler(env_filter_.get()); |
| 1076 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1077 | // FocusController takes ownership of AshFocusRules. |
Scott Violet | 7dbdaeb | 2018-12-11 22:39:02 | [diff] [blame] | 1078 | focus_rules_ = new wm::AshFocusRules(); |
| 1079 | focus_controller_ = std::make_unique<::wm::FocusController>(focus_rules_); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1080 | focus_controller_->AddObserver(this); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1081 | |
Mitsuru Oshima | e6c3509 | 2018-11-16 20:51:25 | [diff] [blame] | 1082 | window_selector_controller_ = std::make_unique<WindowSelectorController>(); |
| 1083 | |
| 1084 | screen_position_controller_ = std::make_unique<ScreenPositionController>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1085 | |
Scott Violet | 5e50037 | 2018-10-23 20:00:13 | [diff] [blame] | 1086 | // Must be before CreatePrimaryHost(). |
| 1087 | window_service_owner_ = |
| 1088 | std::make_unique<WindowServiceOwner>(std::move(gpu_interface_provider)); |
| 1089 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1090 | window_tree_host_manager_->Start(); |
| 1091 | AshWindowTreeHostInitParams ash_init_params; |
| 1092 | window_tree_host_manager_->CreatePrimaryHost(ash_init_params); |
| 1093 | |
Scott Violet | 3c554ae | 2017-12-13 02:25:41 | [diff] [blame] | 1094 | time_to_first_present_recorder_ = |
| 1095 | std::make_unique<TimeToFirstPresentRecorder>(GetPrimaryRootWindow()); |
| 1096 | |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 1097 | shell_state_->SetRootWindowForNewWindows(GetPrimaryRootWindow()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1098 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1099 | resolution_notification_controller_ = |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1100 | std::make_unique<ResolutionNotificationController>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1101 | |
James Cook | 698fc366 | 2018-07-27 16:05:01 | [diff] [blame] | 1102 | cursor_manager_->SetDisplay( |
| 1103 | display::Screen::GetScreen()->GetPrimaryDisplay()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1104 | |
James Cook | dafb54f | 2018-09-14 16:36:15 | [diff] [blame] | 1105 | accelerator_controller_ = std::make_unique<AcceleratorController>(); |
Xiaohui Chen | d68ffc1 | 2018-08-16 01:56:41 | [diff] [blame] | 1106 | voice_interaction_controller_ = |
| 1107 | std::make_unique<VoiceInteractionController>(); |
Weidong Guo | 268c799 | 2018-04-13 21:06:07 | [diff] [blame] | 1108 | |
| 1109 | // |app_list_controller_| is put after |tablet_mode_controller_| as the former |
| 1110 | // uses the latter in constructor. |
Ken Rockot | 68c021ec | 2018-11-03 08:51:53 | [diff] [blame] | 1111 | app_list_controller_ = std::make_unique<AppListControllerImpl>(); |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1112 | shelf_controller_ = std::make_unique<ShelfController>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1113 | |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 1114 | magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 1115 | AddPreTargetHandler(magnifier_key_scroll_handler_.get()); |
spang | e9b5127 | 2014-12-11 01:20:10 | [diff] [blame] | 1116 | speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler(); |
[email protected] | e4ea5236 | 2014-02-15 03:21:06 | [diff] [blame] | 1117 | AddPreTargetHandler(speech_feedback_handler_.get()); |
[email protected] | 3dff2ef | 2014-02-09 22:50:39 | [diff] [blame] | 1118 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1119 | // The order in which event filters are added is significant. |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1120 | |
derat | 2d4e62d | 2015-01-09 16:09:17 | [diff] [blame] | 1121 | // ui::UserActivityDetector passes events to observers, so let them get |
Michael Wasserman | 0746643 | 2018-04-11 03:56:48 | [diff] [blame] | 1122 | // rewritten first. |
| 1123 | user_activity_detector_.reset(new ui::UserActivityDetector); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1124 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1125 | overlay_filter_.reset(new OverlayEventFilter); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1126 | AddPreTargetHandler(overlay_filter_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1127 | |
[email protected] | 60d677d | 2014-05-30 13:07:02 | [diff] [blame] | 1128 | accelerator_filter_.reset(new ::wm::AcceleratorFilter( |
Scott Violet | f5db250 | 2018-10-05 15:19:39 | [diff] [blame] | 1129 | std::make_unique<PreTargetAcceleratorHandler>(), |
sky | 81a2d79 | 2017-03-17 19:14:39 | [diff] [blame] | 1130 | accelerator_controller_->accelerator_history())); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1131 | AddPreTargetHandler(accelerator_filter_.get()); |
| 1132 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1133 | event_transformation_handler_.reset(new EventTransformationHandler); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1134 | AddPreTargetHandler(event_transformation_handler_.get()); |
| 1135 | |
sky | 11cf8db9 | 2017-04-10 23:38:08 | [diff] [blame] | 1136 | toplevel_window_event_handler_ = |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1137 | std::make_unique<ToplevelWindowEventHandler>(); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 1138 | |
Ryan Cui | eb5b84e3 | 2018-07-19 01:36:02 | [diff] [blame] | 1139 | system_gesture_filter_ = std::make_unique<SystemGestureEventFilter>(); |
| 1140 | AddPreTargetHandler(system_gesture_filter_.get()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1141 | |
[email protected] | 354520b | 2014-06-21 04:31:01 | [diff] [blame] | 1142 | sticky_keys_controller_.reset(new StickyKeysController); |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1143 | screen_pinning_controller_ = std::make_unique<ScreenPinningController>(); |
[email protected] | 354520b | 2014-06-21 04:31:01 | [diff] [blame] | 1144 | |
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 1145 | power_prefs_ = std::make_unique<PowerPrefs>( |
| 1146 | chromeos::PowerPolicyController::Get(), |
| 1147 | chromeos::DBusThreadManager::Get()->GetPowerManagerClient()); |
| 1148 | |
Toni Barzic | 9d0c82f4 | 2017-12-06 00:53:52 | [diff] [blame] | 1149 | backlights_forced_off_setter_ = std::make_unique<BacklightsForcedOffSetter>(); |
| 1150 | |
Toni Barzic | 85ae39e | 2017-12-07 05:50:18 | [diff] [blame] | 1151 | tray_action_ = |
| 1152 | std::make_unique<TrayAction>(backlights_forced_off_setter_.get()); |
| 1153 | |
jamescook | d9f152f | 2016-11-15 00:53:08 | [diff] [blame] | 1154 | lock_state_controller_ = |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1155 | std::make_unique<LockStateController>(shutdown_controller_.get()); |
Toni Barzic | 9d0c82f4 | 2017-12-06 00:53:52 | [diff] [blame] | 1156 | power_button_controller_ = std::make_unique<PowerButtonController>( |
| 1157 | backlights_forced_off_setter_.get()); |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 1158 | // Pass the initial display state to PowerButtonController. |
| 1159 | power_button_controller_->OnDisplayModeChanged( |
[email protected] | bcec7fb6 | 2014-04-08 20:59:09 | [diff] [blame] | 1160 | display_configurator_->cached_displays()); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 1161 | |
James Cook | 93614f0 | 2018-07-11 21:37:35 | [diff] [blame] | 1162 | drag_drop_controller_ = std::make_unique<DragDropController>(); |
Scott Violet | 361833fb | 2017-06-21 22:25:20 | [diff] [blame] | 1163 | |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 1164 | // |screenshot_controller_| needs to be created (and prepended as a |
mukai | 19274bdd | 2015-02-24 22:37:48 | [diff] [blame] | 1165 | // pre-target handler) at this point, because |mouse_cursor_filter_| needs to |
oshima | 5a296e8 | 2016-04-29 01:32:27 | [diff] [blame] | 1166 | // process mouse events prior to screenshot session. |
mukai | 19274bdd | 2015-02-24 22:37:48 | [diff] [blame] | 1167 | // See http://crbug.com/459214 |
James Cook | 5e9d340 | 2017-11-01 00:20:12 | [diff] [blame] | 1168 | screenshot_controller_ = std::make_unique<ScreenshotController>( |
| 1169 | shell_delegate_->CreateScreenshotDelegate()); |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1170 | mouse_cursor_filter_ = std::make_unique<MouseCursorEventFilter>(); |
Katie D | b68a552 | 2018-03-30 18:47:36 | [diff] [blame] | 1171 | AddPreTargetHandler(mouse_cursor_filter_.get(), |
| 1172 | ui::EventTarget::Priority::kAccessibility); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1173 | |
| 1174 | // Create Controllers that may need root window. |
| 1175 | // TODO(oshima): Move as many controllers before creating |
| 1176 | // RootWindowController as possible. |
| 1177 | visibility_controller_.reset(new AshVisibilityController); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1178 | |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 1179 | laser_pointer_controller_.reset(new LaserPointerController()); |
| 1180 | partial_magnification_controller_.reset(new PartialMagnificationController()); |
Vladislav Kaznacheev | 6d6aaff | 2017-07-22 04:06:32 | [diff] [blame] | 1181 | highlighter_controller_.reset(new HighlighterController()); |
sammiequon | 203ae02 | 2016-09-18 17:23:42 | [diff] [blame] | 1182 | |
Qiang Xu | 2657abf | 2018-03-21 18:01:45 | [diff] [blame] | 1183 | magnification_controller_ = std::make_unique<MagnificationController>(); |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1184 | mru_window_tracker_ = std::make_unique<MruWindowTracker>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1185 | |
Katie D | ab4edf57 | 2018-10-12 16:53:55 | [diff] [blame] | 1186 | autoclick_controller_ = std::make_unique<AutoclickController>(); |
[email protected] | 55398d2 | 2013-10-10 19:49:20 | [diff] [blame] | 1187 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1188 | high_contrast_controller_.reset(new HighContrastController); |
Saman Sami | 3fb310d | 2017-11-09 16:51:54 | [diff] [blame] | 1189 | |
Ahmed Fakhry | 4af48e4 | 2018-02-28 17:45:38 | [diff] [blame] | 1190 | if (features::IsDockedMagnifierEnabled()) { |
Ahmed Fakhry | 4bf3f74 | 2018-02-06 17:33:36 | [diff] [blame] | 1191 | docked_magnifier_controller_ = |
| 1192 | std::make_unique<DockedMagnifierController>(); |
| 1193 | } |
| 1194 | |
Saman Sami | a1d88aa | 2018-11-16 22:55:42 | [diff] [blame] | 1195 | video_detector_ = std::make_unique<VideoDetector>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1196 | |
oshima | ebbe6377 | 2015-02-19 18:41:32 | [diff] [blame] | 1197 | tooltip_controller_.reset(new views::corewm::TooltipController( |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 1198 | std::unique_ptr<views::corewm::Tooltip>(new views::corewm::TooltipAura))); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1199 | AddPreTargetHandler(tooltip_controller_.get()); |
| 1200 | |
hariank | 0dd03dd | 2016-07-14 23:47:33 | [diff] [blame] | 1201 | modality_filter_.reset(new SystemModalContainerEventFilter(this)); |
| 1202 | AddPreTargetHandler(modality_filter_.get()); |
| 1203 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1204 | event_client_.reset(new EventClientImpl); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1205 | |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1206 | resize_shadow_controller_.reset(new ResizeShadowController()); |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 1207 | shadow_controller_ = std::make_unique<::wm::ShadowController>( |
| 1208 | focus_controller_.get(), std::make_unique<WmShadowControllerDelegate>(), |
| 1209 | aura_env_); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1210 | |
James Cook | b50959e2 | 2017-08-10 20:24:38 | [diff] [blame] | 1211 | logout_confirmation_controller_ = |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1212 | std::make_unique<LogoutConfirmationController>(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1213 | |
jamescook | ac672433 | 2017-03-21 02:54:43 | [diff] [blame] | 1214 | // May trigger initialization of the Bluetooth adapter. |
| 1215 | tray_bluetooth_helper_->Initialize(); |
| 1216 | |
kylechar | 55f0eaf2 | 2017-01-11 22:57:37 | [diff] [blame] | 1217 | // Create AshTouchTransformController before |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 1218 | // WindowTreeHostManager::InitDisplays() |
kylechar | 55f0eaf2 | 2017-01-11 22:57:37 | [diff] [blame] | 1219 | // since AshTouchTransformController listens on |
oshima | e281892 | 2015-07-28 01:18:52 | [diff] [blame] | 1220 | // WindowTreeHostManager::Observer::OnDisplaysInitialized(). |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1221 | touch_transformer_controller_ = std::make_unique<AshTouchTransformController>( |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1222 | display_configurator_.get(), display_manager_.get(), |
James Cook | 9db56d7 | 2018-08-01 03:21:31 | [diff] [blame] | 1223 | std::make_unique<display::DefaultTouchTransformSetter>()); |
[email protected] | 03122891a | 2014-05-13 23:56:49 | [diff] [blame] | 1224 | |
Tetsui Ohkubo | 269b579 | 2018-04-26 01:06:32 | [diff] [blame] | 1225 | // |system_tray_model_| should be available before |
| 1226 | // |system_notification_controller_| is initialized and Shelf is created by |
| 1227 | // WindowTreeHostManager::InitHosts. |
| 1228 | system_tray_model_ = std::make_unique<SystemTrayModel>(); |
| 1229 | system_notification_controller_ = |
| 1230 | std::make_unique<SystemNotificationController>(); |
| 1231 | |
Jun Mukai | f235779 | 2018-12-20 19:58:00 | [diff] [blame] | 1232 | ash_keyboard_controller_->CreateVirtualKeyboard( |
| 1233 | std::move(keyboard_ui_factory)); |
| 1234 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1235 | window_tree_host_manager_->InitHosts(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1236 | |
Meilin Wang | 3a4ac8e | 2018-09-27 19:03:43 | [diff] [blame] | 1237 | // |assistant_controller_| needs to be created after InitHosts() since its |
| 1238 | // keyboard observer function result has dependency on workspace change. |
| 1239 | assistant_controller_ = chromeos::switches::IsAssistantEnabled() |
| 1240 | ? std::make_unique<AssistantController>() |
| 1241 | : nullptr; |
| 1242 | |
James Cook | 698fc366 | 2018-07-27 16:05:01 | [diff] [blame] | 1243 | cursor_manager_->HideCursor(); // Hide the mouse cursor on startup. |
| 1244 | cursor_manager_->SetCursor(ui::CursorType::kPointer); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1245 | |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1246 | peripheral_battery_notifier_ = std::make_unique<PeripheralBatteryNotifier>(); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1247 | power_event_observer_.reset(new PowerEventObserver()); |
Sarah Hu | 8ce89c33 | 2018-09-24 18:23:14 | [diff] [blame] | 1248 | user_activity_notifier_ = |
| 1249 | std::make_unique<ui::UserActivityPowerManagerNotifier>( |
| 1250 | user_activity_detector_.get(), connector_); |
[email protected] | ded58fd | 2013-10-09 07:56:55 | [diff] [blame] | 1251 | video_activity_notifier_.reset( |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 1252 | new VideoActivityNotifier(video_detector_.get())); |
| 1253 | bluetooth_notification_controller_.reset(new BluetoothNotificationController); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1254 | screen_orientation_controller_ = |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 1255 | std::make_unique<ScreenOrientationController>(); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1256 | screen_layout_observer_.reset(new ScreenLayoutObserver()); |
yiyix | 90cfee2 | 2017-02-16 05:38:18 | [diff] [blame] | 1257 | sms_observer_.reset(new SmsObserver()); |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 1258 | |
xdai | d491376 | 2017-07-06 00:17:22 | [diff] [blame] | 1259 | split_view_controller_.reset(new SplitViewController()); |
| 1260 | |
David Tseng | 6792dc8 | 2018-05-04 19:18:41 | [diff] [blame] | 1261 | key_accessibility_enabler_ = std::make_unique<KeyAccessibilityEnabler>(); |
| 1262 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1263 | // The compositor thread and main message loop have to be running in |
| 1264 | // order to create mirror window. Run it after the main message loop |
| 1265 | // is started. |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 1266 | display_manager_->CreateMirrorWindowAsyncIfAny(); |
bruthig | c24d11f | 2015-06-09 21:30:03 | [diff] [blame] | 1267 | |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 1268 | // |connector_| is null in unit tests. |
Scott Violet | e5c79f5 | 2018-07-31 00:10:17 | [diff] [blame] | 1269 | if (connector_ && |
James Cook | 08ebee4 | 2018-08-07 04:06:42 | [diff] [blame] | 1270 | base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowTaps)) { |
Ken Rockot | a86fa54 | 2018-11-13 21:47:13 | [diff] [blame] | 1271 | // The show taps feature is a separate service. |
James Cook | 08ebee4 | 2018-08-07 04:06:42 | [diff] [blame] | 1272 | // TODO(jamescook): Make this work in ash_shell_with_content. |
James Cook | 1d323b3 | 2019-01-02 19:42:29 | [diff] [blame] | 1273 | tap_visualizer::mojom::TapVisualizerPtr tap_visualizer_ptr; |
| 1274 | connector_->BindInterface(service_manager::ServiceFilter::ByName( |
| 1275 | tap_visualizer::mojom::kServiceName), |
| 1276 | mojo::MakeRequest(&tap_visualizer_ptr)); |
| 1277 | tap_visualizer_ptr->Show(); |
James Cook | 0ba192bf | 2017-12-01 20:53:11 | [diff] [blame] | 1278 | } |
| 1279 | |
James Cook | 7e6a7ae | 2018-08-24 23:00:47 | [diff] [blame] | 1280 | if (!::features::IsMultiProcessMash()) { |
James Cook | c9d6a54 | 2018-07-27 21:00:56 | [diff] [blame] | 1281 | ime_focus_handler_ = std::make_unique<ImeFocusHandler>( |
| 1282 | focus_controller(), window_tree_host_manager_->input_method()); |
Scott Violet | b7f4df2 | 2018-05-17 04:43:12 | [diff] [blame] | 1283 | } |
| 1284 | |
Becca Hughes | c6a0a06 | 2018-10-25 16:54:13 | [diff] [blame] | 1285 | if (base::FeatureList::IsEnabled(features::kMediaSessionNotification)) { |
| 1286 | media_notification_controller_ = |
| 1287 | std::make_unique<MediaNotificationController>(connector_); |
| 1288 | } |
| 1289 | |
sky | 00c813f | 2017-03-08 22:48:55 | [diff] [blame] | 1290 | for (auto& observer : shell_observers_) |
ericwilligers | 5eff47d | 2016-10-17 19:19:18 | [diff] [blame] | 1291 | observer.OnShellInitialized(); |
phweiss | 0bf64c5 | 2015-11-17 12:56:18 | [diff] [blame] | 1292 | |
Scott Violet | 41562d1c | 2017-06-26 15:15:48 | [diff] [blame] | 1293 | user_metrics_recorder_->OnShellInitialized(); |
Toni Barzic | 85c9e080 | 2018-03-30 02:46:01 | [diff] [blame] | 1294 | |
Jeffrey Kardatzke | f108f02 | 2018-04-17 17:52:35 | [diff] [blame] | 1295 | // Initialize the D-Bus thread and services for ash. |
| 1296 | ash_dbus_services_ = std::make_unique<AshDBusServices>(); |
Toni Barzic | 85c9e080 | 2018-03-30 02:46:01 | [diff] [blame] | 1297 | // By this point ash shell should have initialized its D-Bus signal |
| 1298 | // listeners, so emit ash-initialized upstart signal to start Chrome OS tasks |
| 1299 | // that expect that ash is listening to D-Bus signals they emit. For example, |
| 1300 | // hammerd, which handles detachable base state, communicates the base state |
| 1301 | // purely by emitting D-Bus signals, and thus has to be run whenever ash is |
| 1302 | // started so ash (DetachableBaseHandler in particular) gets the proper view |
| 1303 | // of the current detachable base state. |
Jeffrey Kardatzke | f108f02 | 2018-04-17 17:52:35 | [diff] [blame] | 1304 | // TODO(stevenjb): Move this and other D-Bus dependencies to AshDBusServices. |
| 1305 | ash_dbus_services_->EmitAshInitialized(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 1306 | } |
| 1307 | |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1308 | void Shell::InitializeDisplayManager() { |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1309 | bool display_initialized = display_manager_->InitFromCommandLine(); |
| 1310 | |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1311 | display_configuration_controller_ = |
| 1312 | std::make_unique<DisplayConfigurationController>( |
| 1313 | display_manager_.get(), window_tree_host_manager_.get()); |
James Cook | 9db56d7 | 2018-08-01 03:21:31 | [diff] [blame] | 1314 | display_configurator_->Init( |
| 1315 | ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), false); |
Steven Bennetts | 9b21fa3 | 2018-04-13 23:45:55 | [diff] [blame] | 1316 | display_configuration_observer_ = |
| 1317 | std::make_unique<DisplayConfigurationObserver>(); |
| 1318 | |
Steven Bennetts | 2a9b438 | 2018-04-26 23:41:19 | [diff] [blame] | 1319 | cros_display_config_ = std::make_unique<CrosDisplayConfig>(); |
| 1320 | |
Qiang Xu | d77a90c | 2018-02-20 19:43:29 | [diff] [blame] | 1321 | persistent_window_controller_ = |
| 1322 | std::make_unique<PersistentWindowController>(); |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1323 | |
| 1324 | projecting_observer_ = |
| 1325 | std::make_unique<ProjectingObserver>(display_configurator_.get()); |
| 1326 | |
| 1327 | if (!display_initialized) { |
Scott Violet | 97a7b9d | 2018-08-06 22:31:13 | [diff] [blame] | 1328 | if (chromeos::IsRunningAsSystemCompositor()) { |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1329 | display_change_observer_ = |
| 1330 | std::make_unique<display::DisplayChangeObserver>( |
| 1331 | display_configurator_.get(), display_manager_.get()); |
| 1332 | |
| 1333 | display_shutdown_observer_ = std::make_unique<DisplayShutdownObserver>( |
| 1334 | display_configurator_.get()); |
| 1335 | |
| 1336 | // Register |display_change_observer_| first so that the rest of |
| 1337 | // observer gets invoked after the root windows are configured. |
| 1338 | display_configurator_->AddObserver(display_change_observer_.get()); |
| 1339 | display_error_observer_.reset(new DisplayErrorObserver()); |
| 1340 | display_configurator_->AddObserver(display_error_observer_.get()); |
| 1341 | display_configurator_->set_state_controller( |
| 1342 | display_change_observer_.get()); |
| 1343 | display_configurator_->set_mirroring_controller(display_manager_.get()); |
| 1344 | display_configurator_->ForceInitialConfigure(); |
| 1345 | display_initialized = true; |
| 1346 | } |
| 1347 | } |
| 1348 | |
Ahmed Fakhry | 1ad4bd4 | 2018-04-18 19:31:37 | [diff] [blame] | 1349 | display_color_manager_ = std::make_unique<DisplayColorManager>( |
| 1350 | display_configurator_.get(), display::Screen::GetScreen()); |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1351 | |
| 1352 | if (!display_initialized) |
| 1353 | display_manager_->InitDefaultDisplay(); |
| 1354 | |
Scott Violet | 97a7b9d | 2018-08-06 22:31:13 | [diff] [blame] | 1355 | display_manager_->RefreshFontParams(); |
Steven Bennetts | 7683e34 | 2018-01-02 21:29:52 | [diff] [blame] | 1356 | } |
| 1357 | |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame] | 1358 | void Shell::InitRootWindow(aura::Window* root_window) { |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1359 | DCHECK(focus_controller_); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1360 | DCHECK(visibility_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1361 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1362 | aura::client::SetFocusClient(root_window, focus_controller_.get()); |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1363 | ::wm::SetActivationClient(root_window, focus_controller_.get()); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1364 | root_window->AddPreTargetHandler(focus_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1365 | aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
James Cook | 93614f0 | 2018-07-11 21:37:35 | [diff] [blame] | 1366 | aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 1367 | aura::client::SetScreenPositionClient(root_window, |
| 1368 | screen_position_controller_.get()); |
sadrul | 7a8785e | 2016-02-12 21:54:35 | [diff] [blame] | 1369 | aura::client::SetCursorClient(root_window, cursor_manager_.get()); |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1370 | ::wm::SetTooltipClient(root_window, tooltip_controller_.get()); |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 1371 | aura::client::SetEventClient(root_window, event_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1372 | |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1373 | ::wm::SetWindowMoveClient(root_window, toplevel_window_event_handler_.get()); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 1374 | root_window->AddPreTargetHandler(toplevel_window_event_handler_.get()); |
| 1375 | root_window->AddPostTargetHandler(toplevel_window_event_handler_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1376 | } |
| 1377 | |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1378 | void Shell::CloseAllRootWindowChildWindows() { |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 1379 | for (aura::Window* root : GetAllRootWindows()) { |
| 1380 | RootWindowController* controller = RootWindowController::ForWindow(root); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1381 | if (controller) { |
| 1382 | controller->CloseChildWindows(); |
| 1383 | } else { |
msw | 257a6a23 | 2017-06-01 01:46:30 | [diff] [blame] | 1384 | while (!root->children().empty()) { |
| 1385 | aura::Window* child = root->children()[0]; |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 1386 | delete child; |
| 1387 | } |
| 1388 | } |
| 1389 | } |
| 1390 | } |
| 1391 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1392 | bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 1393 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 1394 | for (RootWindowController* controller : controllers) { |
| 1395 | if (controller->CanWindowReceiveEvents(window)) |
[email protected] | 602022b | 2014-03-31 17:07:31 | [diff] [blame] | 1396 | return true; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 1397 | } |
| 1398 | return false; |
| 1399 | } |
| 1400 | |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 1401 | //////////////////////////////////////////////////////////////////////////////// |
| 1402 | // Shell, ui::EventTarget overrides: |
| 1403 | |
[email protected] | 869f635 | 2012-12-06 20:47:17 | [diff] [blame] | 1404 | bool Shell::CanAcceptEvent(const ui::Event& event) { |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 1405 | return true; |
| 1406 | } |
| 1407 | |
| 1408 | ui::EventTarget* Shell::GetParentTarget() { |
Scott Violet | ac41062 | 2018-08-11 18:33:22 | [diff] [blame] | 1409 | return aura_env_; |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 1410 | } |
| 1411 | |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 1412 | std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { |
| 1413 | return std::unique_ptr<ui::EventTargetIterator>(); |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 1414 | } |
| 1415 | |
| 1416 | ui::EventTargeter* Shell::GetEventTargeter() { |
| 1417 | NOTREACHED(); |
achuith | 287b26e | 2015-09-03 17:49:18 | [diff] [blame] | 1418 | return nullptr; |
[email protected] | 3e670aa | 2013-12-02 19:04:32 | [diff] [blame] | 1419 | } |
| 1420 | |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1421 | void Shell::OnWindowActivated( |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 1422 | ::wm::ActivationChangeObserver::ActivationReason reason, |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1423 | aura::Window* gained_active, |
| 1424 | aura::Window* lost_active) { |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 1425 | if (!gained_active) |
| 1426 | return; |
| 1427 | |
| 1428 | shell_state_->SetRootWindowForNewWindows(gained_active->GetRootWindow()); |
sky | 2734438 | 2017-03-08 21:30:32 | [diff] [blame] | 1429 | } |
| 1430 | |
Steven Bennetts | badc309 | 2018-05-24 21:26:01 | [diff] [blame] | 1431 | void Shell::OnFirstSessionStarted() { |
| 1432 | // Enable magnifier scroll keys as there may be no mouse cursor in kiosk mode. |
| 1433 | MagnifierKeyScroller::SetEnabled(session_controller_->IsRunningInAppMode()); |
| 1434 | |
| 1435 | // Enable long press action to toggle spoken feedback with hotrod remote |
| 1436 | // which can't handle shortcuts. |
| 1437 | SpokenFeedbackToggler::SetEnabled(session_controller_->IsRunningInAppMode()); |
| 1438 | } |
| 1439 | |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 1440 | void Shell::OnSessionStateChanged(session_manager::SessionState state) { |
James Cook | eb426b5 | 2018-09-17 16:45:12 | [diff] [blame] | 1441 | const bool is_session_active = state == session_manager::SessionState::ACTIVE; |
Aga Wronska | e195ad2 | 2017-12-20 01:38:11 | [diff] [blame] | 1442 | // Initialize the |shelf_window_watcher_| when a session becomes active. |
| 1443 | // Shelf itself is initialized in RootWindowController. |
James Cook | eb426b5 | 2018-09-17 16:45:12 | [diff] [blame] | 1444 | if (is_session_active && !shelf_window_watcher_) |
| 1445 | shelf_window_watcher_ = std::make_unique<ShelfWindowWatcher>(shelf_model()); |
| 1446 | |
| 1447 | // Disable drag-and-drop during OOBE and GAIA login screens by only enabling |
| 1448 | // the controller when the session is active. https://crbug.com/464118 |
| 1449 | drag_drop_controller_->set_enabled(is_session_active); |
Quan Nguyen | af67b64d | 2018-11-29 19:21:48 | [diff] [blame] | 1450 | |
| 1451 | if (base::FeatureList::IsEnabled(features::kContainedShell) && |
| 1452 | is_session_active) { |
| 1453 | contained_shell_controller_->LaunchContainedShell(); |
| 1454 | } |
xiyuan | 233f4e7 | 2017-04-06 06:59:56 | [diff] [blame] | 1455 | } |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 1456 | |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 1457 | void Shell::OnLoginStatusChanged(LoginStatus login_status) { |
xiyuan | 233f4e7 | 2017-04-06 06:59:56 | [diff] [blame] | 1458 | UpdateAfterLoginStatusChange(login_status); |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 1459 | } |
| 1460 | |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 1461 | void Shell::OnLockStateChanged(bool locked) { |
xiyuan | 7ebbf7f | 2017-04-10 16:49:10 | [diff] [blame] | 1462 | #ifndef NDEBUG |
| 1463 | // Make sure that there is no system modal in Lock layer when unlocked. |
| 1464 | if (!locked) { |
| 1465 | aura::Window::Windows containers = wm::GetContainersFromAllRootWindows( |
| 1466 | kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow()); |
| 1467 | for (aura::Window* container : containers) |
| 1468 | DCHECK(container->children().empty()); |
| 1469 | } |
| 1470 | #endif |
| 1471 | } |
| 1472 | |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 1473 | void Shell::OnLocalStatePrefServiceInitialized( |
| 1474 | std::unique_ptr<::PrefService> pref_service) { |
Sam McNally | a853cd8 | 2017-08-30 01:55:10 | [diff] [blame] | 1475 | DCHECK(!local_state_); |
James Cook | 8532dbc | 2017-07-31 21:54:51 | [diff] [blame] | 1476 | // |pref_service| is null if can't connect to Chrome (as happens when |
Scott Violet | 8ff9c30 | 2018-02-22 22:28:35 | [diff] [blame] | 1477 | // running mash outside of chrome --enable-features=Mash and chrome isn't |
| 1478 | // built). |
Sam McNally | a853cd8 | 2017-08-30 01:55:10 | [diff] [blame] | 1479 | if (!pref_service) |
| 1480 | return; |
| 1481 | |
| 1482 | local_state_ = std::move(pref_service); |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame] | 1483 | |
| 1484 | for (auto& observer : shell_observers_) |
Sam McNally | a853cd8 | 2017-08-30 01:55:10 | [diff] [blame] | 1485 | observer.OnLocalStatePrefServiceInitialized(local_state_.get()); |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 1486 | } |
| 1487 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 1488 | } // namespace ash |