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