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