shell.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_SHELL_H_
  5. #define ASH_SHELL_H_
  6. #include <memory>
  7. #include <utility>
  8. #include <vector>
  9. #include "ash/ash_export.h"
  10. #include "ash/constants/ash_features.h"
  11. #include "ash/in_session_auth/in_session_auth_dialog_controller_impl.h"
  12. #include "ash/public/cpp/session/session_observer.h"
  13. #include "ash/public/cpp/shelf_types.h"
  14. #include "ash/wm/system_modal_container_event_filter_delegate.h"
  15. #include "base/gtest_prod_util.h"
  16. #include "base/memory/weak_ptr.h"
  17. #include "base/observer_list.h"
  18. #include "ui/aura/window.h"
  19. #include "ui/base/ui_base_types.h"
  20. #include "ui/display/screen.h"
  21. #include "ui/events/event_target.h"
  22. #include "ui/wm/core/cursor_manager.h"
  23. #include "ui/wm/public/activation_change_observer.h"
  24. class PrefService;
  25. namespace aura {
  26. class RootWindow;
  27. class Window;
  28. } // namespace aura
  29. namespace chromeos {
  30. class ImmersiveContext;
  31. class SnapController;
  32. } // namespace chromeos
  33. namespace dbus {
  34. class Bus;
  35. }
  36. namespace display {
  37. class DisplayChangeObserver;
  38. class DisplayConfigurator;
  39. class DisplayManager;
  40. } // namespace display
  41. namespace gfx {
  42. class Point;
  43. } // namespace gfx
  44. namespace keyboard {
  45. class KeyboardUIFactory;
  46. }
  47. namespace ui {
  48. class ContextFactory;
  49. class UserActivityDetector;
  50. class UserActivityPowerManagerNotifier;
  51. } // namespace ui
  52. namespace views {
  53. class NonClientFrameView;
  54. class Widget;
  55. namespace corewm {
  56. class TooltipController;
  57. }
  58. } // namespace views
  59. namespace wm {
  60. class AcceleratorFilter;
  61. class ActivationClient;
  62. class CompoundEventFilter;
  63. class FocusController;
  64. class ShadowController;
  65. class VisibilityController;
  66. class WindowModalityController;
  67. } // namespace wm
  68. namespace ash {
  69. class AcceleratorControllerImpl;
  70. class AccessibilityControllerImpl;
  71. class AccessibilityDelegate;
  72. class AccessibilityFocusRingControllerImpl;
  73. class AdaptiveChargingController;
  74. class AmbientController;
  75. class AppListControllerImpl;
  76. class AppListFeatureUsageMetrics;
  77. class AshColorProvider;
  78. class AshDBusServices;
  79. class AshFocusRules;
  80. class AshTouchTransformController;
  81. class AssistantControllerImpl;
  82. class AutoclickController;
  83. class AutozoomControllerImpl;
  84. class BackGestureEventHandler;
  85. class BacklightsForcedOffSetter;
  86. class BluetoothDeviceStatusUiHandler;
  87. class BluetoothNotificationController;
  88. class BluetoothPowerController;
  89. class BrightnessControlDelegate;
  90. class CalendarController;
  91. class CaptureModeController;
  92. class ControlVHistogramRecorder;
  93. class CrosDisplayConfig;
  94. class DarkLightModeControllerImpl;
  95. class DesksController;
  96. class DetachableBaseHandler;
  97. class DetachableBaseNotificationController;
  98. class DisplayAlignmentController;
  99. class DisplayColorManager;
  100. class NativeCursorManagerAsh;
  101. class DisplayConfigurationController;
  102. class DisplayConfigurationObserver;
  103. class DisplayErrorObserver;
  104. class DisplayHighlightController;
  105. class DisplayPrefs;
  106. class DisplayShutdownObserver;
  107. class DisplaySpeakerController;
  108. class DockedMagnifierController;
  109. class DragDropController;
  110. class EventClientImpl;
  111. class EventRewriterControllerImpl;
  112. class EventTransformationHandler;
  113. class WindowRestoreController;
  114. class FirmwareUpdateNotificationController;
  115. class FloatController;
  116. class FocusCycler;
  117. class FrameThrottlingController;
  118. class FullscreenMagnifierController;
  119. class GeolocationController;
  120. class GlanceablesController;
  121. class HighContrastController;
  122. class HighlighterController;
  123. class HoldingSpaceController;
  124. class HumanPresenceOrientationController;
  125. class ImeControllerImpl;
  126. class WebAuthNDialogControllerImpl;
  127. class KeyAccessibilityEnabler;
  128. class KeyboardBacklightColorController;
  129. class KeyboardBrightnessControlDelegate;
  130. class KeyboardControllerImpl;
  131. class LaserPointerController;
  132. class LocaleUpdateControllerImpl;
  133. class LockStateController;
  134. class LogoutConfirmationController;
  135. class LoginScreenController;
  136. class LoginUnlockThroughputRecorder;
  137. class MediaNotificationProviderImpl;
  138. class TabClusterUIController;
  139. class TabletModeController;
  140. class MediaControllerImpl;
  141. class MessageCenterAshImpl;
  142. class MessageCenterController;
  143. class MouseCursorEventFilter;
  144. class MruWindowTracker;
  145. class MultiDeviceNotificationPresenter;
  146. class MultitaskMenuNudgeController;
  147. class NearbyShareControllerImpl;
  148. class DesksTemplatesDelegate;
  149. class NearbyShareDelegate;
  150. class NightLightControllerImpl;
  151. class OcclusionTrackerPauser;
  152. class OverlayEventFilter;
  153. class OverviewController;
  154. class ParentAccessController;
  155. class PartialMagnifierController;
  156. class PciePeripheralNotificationController;
  157. class UsbPeripheralNotificationController;
  158. class PeripheralBatteryListener;
  159. class PeripheralBatteryNotifier;
  160. class PersistentDesksBarController;
  161. class PersistentWindowController;
  162. class PolicyRecommendationRestorer;
  163. class PowerButtonController;
  164. class PowerEventObserver;
  165. class PowerPrefs;
  166. class PrivacyHubController;
  167. class PrivacyScreenController;
  168. class ProjectingObserver;
  169. class ProjectorControllerImpl;
  170. class RgbKeyboardManager;
  171. class RefreshRateThrottleController;
  172. class ResizeShadowController;
  173. class ResolutionNotificationController;
  174. class RootWindowController;
  175. class ScreenLayoutObserver;
  176. class ScreenOrientationController;
  177. class ScreenPinningController;
  178. class ScreenPositionController;
  179. class ScreenSwitchCheckController;
  180. class SessionControllerImpl;
  181. class FeatureDiscoveryDurationReporterImpl;
  182. class ShelfConfig;
  183. class ShelfController;
  184. class ShelfWindowWatcher;
  185. class ShellDelegate;
  186. struct ShellInitParams;
  187. class ShellObserver;
  188. class ShutdownControllerImpl;
  189. class SmsObserver;
  190. class SnoopingProtectionController;
  191. class StickyKeysController;
  192. class SystemGestureEventFilter;
  193. class SystemModalContainerEventFilter;
  194. class SystemNotificationController;
  195. class SystemTrayModel;
  196. class SystemTrayNotifier;
  197. class ToastManagerImpl;
  198. class ToplevelWindowEventHandler;
  199. class ClipboardHistoryControllerImpl;
  200. class TouchDevicesController;
  201. class TrayAction;
  202. class TrayBluetoothHelper;
  203. class UserMetricsRecorder;
  204. class VideoActivityNotifier;
  205. class VideoDetector;
  206. class WallpaperControllerImpl;
  207. class WindowCycleController;
  208. class WindowPositioner;
  209. class WindowTreeHostManager;
  210. class ArcInputMethodBoundsTracker;
  211. class MultiCaptureServiceClient;
  212. enum class LoginStatus;
  213. namespace diagnostics {
  214. class DiagnosticsLogController;
  215. } // namespace diagnostics
  216. namespace quick_pair {
  217. class Mediator;
  218. } // namespace quick_pair
  219. // Shell is a singleton object that presents the Shell API and implements the
  220. // RootWindow's delegate interface.
  221. //
  222. // Upon creation, the Shell sets itself as the RootWindow's delegate, which
  223. // takes ownership of the Shell.
  224. class ASH_EXPORT Shell : public SessionObserver,
  225. public SystemModalContainerEventFilterDelegate,
  226. public ui::EventTarget,
  227. public ::wm::ActivationChangeObserver {
  228. public:
  229. typedef std::vector<RootWindowController*> RootWindowControllerList;
  230. Shell(const Shell&) = delete;
  231. Shell& operator=(const Shell&) = delete;
  232. // Creates the single Shell instance.
  233. static Shell* CreateInstance(ShellInitParams init_params);
  234. // Should never be called before |CreateInstance()|.
  235. static Shell* Get();
  236. // Returns true if the ash shell has been instantiated.
  237. static bool HasInstance();
  238. static void DeleteInstance();
  239. // Returns the root window controller for the primary root window.
  240. // TODO(oshima): move this to |RootWindowController|
  241. static RootWindowController* GetPrimaryRootWindowController();
  242. // Returns the RootWindowController for the given display id. If there
  243. // is no display for |display_id|, null is returned.
  244. static RootWindowController* GetRootWindowControllerWithDisplayId(
  245. int64_t display_id);
  246. // Returns the root Window for the given display id. If there is no display
  247. // for |display_id| null is returned.
  248. static aura::Window* GetRootWindowForDisplayId(int64_t display_id);
  249. // Returns all root window controllers.
  250. // TODO(oshima): move this to |RootWindowController|
  251. static RootWindowControllerList GetAllRootWindowControllers();
  252. // Returns the primary root Window. The primary root Window is the one that
  253. // has a launcher.
  254. static aura::Window* GetPrimaryRootWindow();
  255. // Sets the root window that newly created windows should be added to.
  256. static void SetRootWindowForNewWindows(aura::Window* root);
  257. // Returns the root window that newly created windows should be added to.
  258. // Value can be temporarily overridden using
  259. // display::ScopedDisplayForNewWindows. NOTE: this returns the root, newly
  260. // created window should be added to the appropriate container in the returned
  261. // window.
  262. static aura::Window* GetRootWindowForNewWindows();
  263. // Returns all root windows.
  264. static aura::Window::Windows GetAllRootWindows();
  265. static aura::Window* GetContainer(aura::Window* root_window,
  266. int container_id);
  267. static const aura::Window* GetContainer(const aura::Window* root_window,
  268. int container_id);
  269. // If a system-modal dialog window is currently open, returns the ID of the
  270. // system modal window container that contains the window.
  271. // If no system-modal dialogs are open it returns -1.
  272. static int GetOpenSystemModalWindowContainerId();
  273. // Returns true if a system-modal dialog window is currently open.
  274. static bool IsSystemModalWindowOpen();
  275. // Track/Untrack InputMethod bounds.
  276. void TrackInputMethodBounds(ArcInputMethodBoundsTracker* tracker);
  277. void UntrackTrackInputMethodBounds(ArcInputMethodBoundsTracker* tracker);
  278. // Creates a default views::NonClientFrameView for use by windows in the
  279. // Ash environment.
  280. std::unique_ptr<views::NonClientFrameView> CreateDefaultNonClientFrameView(
  281. views::Widget* widget);
  282. // Called when a casting session is started or stopped.
  283. void OnCastingSessionStartedOrStopped(bool started);
  284. // Called when a root window is created.
  285. void OnRootWindowAdded(aura::Window* root_window);
  286. // Called when a root window is about to shutdown.
  287. void OnRootWindowWillShutdown(aura::Window* root_window);
  288. // Called when dictation is activated.
  289. void OnDictationStarted();
  290. // Called when dictation is ended.
  291. void OnDictationEnded();
  292. // Returns whether the device is currently in tablet mode. If the tablet
  293. // mode controller isn't available, we assume the device is not in
  294. // tablet mode.
  295. bool IsInTabletMode() const;
  296. // Tests if TabletModeWindowManager is not enabled, and if
  297. // TabletModeController is not currently setting a display rotation. Or if
  298. // the |resolution_notification_controller_| is not showing its confirmation
  299. // dialog. If true then changes to display settings can be saved.
  300. bool ShouldSaveDisplaySettings();
  301. AcceleratorControllerImpl* accelerator_controller() {
  302. return accelerator_controller_.get();
  303. }
  304. AccessibilityControllerImpl* accessibility_controller() {
  305. return accessibility_controller_.get();
  306. }
  307. AccessibilityDelegate* accessibility_delegate() {
  308. return accessibility_delegate_.get();
  309. }
  310. AccessibilityFocusRingControllerImpl* accessibility_focus_ring_controller() {
  311. return accessibility_focus_ring_controller_.get();
  312. }
  313. ::wm::ActivationClient* activation_client();
  314. AppListControllerImpl* app_list_controller() {
  315. return app_list_controller_.get();
  316. }
  317. AdaptiveChargingController* adaptive_charging_controller() {
  318. return adaptive_charging_controller_.get();
  319. }
  320. AmbientController* ambient_controller() { return ambient_controller_.get(); }
  321. AssistantControllerImpl* assistant_controller() {
  322. return assistant_controller_.get();
  323. }
  324. AutoclickController* autoclick_controller() {
  325. return autoclick_controller_.get();
  326. }
  327. AutozoomControllerImpl* autozoom_controller() {
  328. return autozoom_controller_.get();
  329. }
  330. BacklightsForcedOffSetter* backlights_forced_off_setter() {
  331. return backlights_forced_off_setter_.get();
  332. }
  333. BluetoothPowerController* bluetooth_power_controller() {
  334. DCHECK(!ash::features::IsBluetoothRevampEnabled());
  335. return bluetooth_power_controller_.get();
  336. }
  337. BrightnessControlDelegate* brightness_control_delegate() {
  338. return brightness_control_delegate_.get();
  339. }
  340. CalendarController* calendar_controller() {
  341. return calendar_controller_.get();
  342. }
  343. CrosDisplayConfig* cros_display_config() {
  344. return cros_display_config_.get();
  345. }
  346. ::wm::CursorManager* cursor_manager() { return cursor_manager_.get(); }
  347. DarkLightModeControllerImpl* dark_light_mode_controller() {
  348. return dark_light_mode_controller_.get();
  349. }
  350. DesksController* desks_controller() { return desks_controller_.get(); }
  351. PersistentDesksBarController* persistent_desks_bar_controller() {
  352. return persistent_desks_bar_controller_.get();
  353. }
  354. DesksTemplatesDelegate* desks_templates_delegate() {
  355. return desks_templates_delegate_.get();
  356. }
  357. DetachableBaseHandler* detachable_base_handler() {
  358. return detachable_base_handler_.get();
  359. }
  360. display::DisplayManager* display_manager() { return display_manager_.get(); }
  361. DisplayPrefs* display_prefs() { return display_prefs_.get(); }
  362. DisplayConfigurationController* display_configuration_controller() {
  363. return display_configuration_controller_.get();
  364. }
  365. RefreshRateThrottleController* refresh_rate_throttle_controller() {
  366. return refresh_rate_throttle_controller_.get();
  367. }
  368. DisplayAlignmentController* display_alignment_controller() {
  369. return display_alignment_controller_.get();
  370. }
  371. display::DisplayConfigurator* display_configurator();
  372. DisplayColorManager* display_color_manager() {
  373. return display_color_manager_.get();
  374. }
  375. DisplayErrorObserver* display_error_observer() {
  376. return display_error_observer_.get();
  377. }
  378. ProjectingObserver* projecting_observer() {
  379. return projecting_observer_.get();
  380. }
  381. DisplayHighlightController* display_highlight_controller() {
  382. return display_highlight_controller_.get();
  383. }
  384. DockedMagnifierController* docked_magnifier_controller() {
  385. return docked_magnifier_controller_.get();
  386. }
  387. ::wm::CompoundEventFilter* env_filter() { return env_filter_.get(); }
  388. EventRewriterControllerImpl* event_rewriter_controller() {
  389. return event_rewriter_controller_.get();
  390. }
  391. EventClientImpl* event_client() { return event_client_.get(); }
  392. EventTransformationHandler* event_transformation_handler() {
  393. return event_transformation_handler_.get();
  394. }
  395. FirmwareUpdateNotificationController*
  396. firmware_update_notification_controller() {
  397. return firmware_update_notification_controller_.get();
  398. }
  399. FloatController* float_controller() { return float_controller_.get(); }
  400. ::wm::FocusController* focus_controller() { return focus_controller_.get(); }
  401. AshFocusRules* focus_rules() { return focus_rules_; }
  402. FocusCycler* focus_cycler() { return focus_cycler_.get(); }
  403. FullscreenMagnifierController* fullscreen_magnifier_controller() {
  404. return fullscreen_magnifier_controller_.get();
  405. }
  406. GeolocationController* geolocation_controller() {
  407. return geolocation_controller_.get();
  408. }
  409. GlanceablesController* glanceables_controller() {
  410. return glanceables_controller_.get();
  411. }
  412. HighlighterController* highlighter_controller() {
  413. return highlighter_controller_.get();
  414. }
  415. HighContrastController* high_contrast_controller() {
  416. return high_contrast_controller_.get();
  417. }
  418. HumanPresenceOrientationController* human_presence_orientation_controller() {
  419. return human_presence_orientation_controller_.get();
  420. }
  421. ImeControllerImpl* ime_controller() { return ime_controller_.get(); }
  422. WebAuthNDialogControllerImpl* webauthn_dialog_controller() {
  423. return webauthn_dialog_controller_.get();
  424. }
  425. InSessionAuthDialogControllerImpl* in_session_auth_dialog_controller() {
  426. return in_session_auth_dialog_controller_.get();
  427. }
  428. KeyAccessibilityEnabler* key_accessibility_enabler() {
  429. return key_accessibility_enabler_.get();
  430. }
  431. KeyboardBacklightColorController* keyboard_backlight_color_controller() {
  432. return keyboard_backlight_color_controller_.get();
  433. }
  434. KeyboardBrightnessControlDelegate* keyboard_brightness_control_delegate() {
  435. return keyboard_brightness_control_delegate_.get();
  436. }
  437. KeyboardControllerImpl* keyboard_controller() {
  438. return keyboard_controller_.get();
  439. }
  440. LaserPointerController* laser_pointer_controller() {
  441. return laser_pointer_controller_.get();
  442. }
  443. LocaleUpdateControllerImpl* locale_update_controller() {
  444. return locale_update_controller_.get();
  445. }
  446. LoginScreenController* login_screen_controller() {
  447. return login_screen_controller_.get();
  448. }
  449. LockStateController* lock_state_controller() {
  450. return lock_state_controller_.get();
  451. }
  452. LogoutConfirmationController* logout_confirmation_controller() {
  453. return logout_confirmation_controller_.get();
  454. }
  455. MediaControllerImpl* media_controller() { return media_controller_.get(); }
  456. MediaNotificationProviderImpl* media_notification_provider() {
  457. return media_notification_provider_.get();
  458. }
  459. MessageCenterAshImpl* message_center_ash_impl() {
  460. return message_center_ash_impl_.get();
  461. }
  462. MessageCenterController* message_center_controller() {
  463. return message_center_controller_.get();
  464. }
  465. MouseCursorEventFilter* mouse_cursor_filter() {
  466. return mouse_cursor_filter_.get();
  467. }
  468. MruWindowTracker* mru_window_tracker() { return mru_window_tracker_.get(); }
  469. MultitaskMenuNudgeController* multitask_menu_nudge_controller() {
  470. return multitask_menu_nudge_controller_.get();
  471. }
  472. NearbyShareControllerImpl* nearby_share_controller() {
  473. return nearby_share_controller_.get();
  474. }
  475. NearbyShareDelegate* nearby_share_delegate() {
  476. return nearby_share_delegate_.get();
  477. }
  478. NightLightControllerImpl* night_light_controller() {
  479. return night_light_controller_.get();
  480. }
  481. OverlayEventFilter* overlay_filter() { return overlay_filter_.get(); }
  482. ParentAccessController* parent_access_controller() {
  483. return parent_access_controller_.get();
  484. }
  485. PartialMagnifierController* partial_magnifier_controller() {
  486. return partial_magnifier_controller_.get();
  487. }
  488. PeripheralBatteryListener* peripheral_battery_listener() {
  489. return peripheral_battery_listener_.get();
  490. }
  491. PolicyRecommendationRestorer* policy_recommendation_restorer() {
  492. return policy_recommendation_restorer_.get();
  493. }
  494. PowerButtonController* power_button_controller() {
  495. return power_button_controller_.get();
  496. }
  497. PowerEventObserver* power_event_observer() {
  498. return power_event_observer_.get();
  499. }
  500. PrivacyHubController* privacy_hub_controller() {
  501. return privacy_hub_controller_.get();
  502. }
  503. PrivacyScreenController* privacy_screen_controller() {
  504. return privacy_screen_controller_.get();
  505. }
  506. quick_pair::Mediator* quick_pair_mediator() {
  507. return quick_pair_mediator_.get();
  508. }
  509. MultiCaptureServiceClient* multi_capture_service_client() {
  510. return multi_capture_service_client_.get();
  511. }
  512. ResizeShadowController* resize_shadow_controller() {
  513. return resize_shadow_controller_.get();
  514. }
  515. ResolutionNotificationController* resolution_notification_controller() {
  516. return resolution_notification_controller_.get();
  517. }
  518. RgbKeyboardManager* rgb_keyboard_manager() {
  519. return rgb_keyboard_manager_.get();
  520. }
  521. ScreenLayoutObserver* screen_layout_observer() {
  522. return screen_layout_observer_.get();
  523. }
  524. ScreenOrientationController* screen_orientation_controller() {
  525. return screen_orientation_controller_.get();
  526. }
  527. ScreenPinningController* screen_pinning_controller() {
  528. return screen_pinning_controller_.get();
  529. }
  530. ScreenSwitchCheckController* screen_switch_check_controller() {
  531. return screen_switch_check_controller_.get();
  532. }
  533. SessionControllerImpl* session_controller() {
  534. return session_controller_.get();
  535. }
  536. FeatureDiscoveryDurationReporterImpl* feature_discover_reporter() {
  537. return feature_discover_reporter_.get();
  538. }
  539. ::wm::ShadowController* shadow_controller() {
  540. return shadow_controller_.get();
  541. }
  542. ShelfConfig* shelf_config() { return shelf_config_.get(); }
  543. ShelfController* shelf_controller() { return shelf_controller_.get(); }
  544. ShellDelegate* shell_delegate() { return shell_delegate_.get(); }
  545. ShutdownControllerImpl* shutdown_controller() {
  546. return shutdown_controller_.get();
  547. }
  548. SnoopingProtectionController* snooping_protection_controller() {
  549. return snooping_protection_controller_.get();
  550. }
  551. StickyKeysController* sticky_keys_controller() {
  552. return sticky_keys_controller_.get();
  553. }
  554. SystemNotificationController* system_notification_controller() {
  555. return system_notification_controller_.get();
  556. }
  557. SystemTrayModel* system_tray_model() { return system_tray_model_.get(); }
  558. SystemTrayNotifier* system_tray_notifier() {
  559. return system_tray_notifier_.get();
  560. }
  561. TabClusterUIController* tab_cluster_ui_controller() const {
  562. return tab_cluster_ui_controller_.get();
  563. }
  564. TabletModeController* tablet_mode_controller() const {
  565. return tablet_mode_controller_.get();
  566. }
  567. ToastManagerImpl* toast_manager() { return toast_manager_.get(); }
  568. views::corewm::TooltipController* tooltip_controller() {
  569. return tooltip_controller_.get();
  570. }
  571. ClipboardHistoryControllerImpl* clipboard_history_controller() {
  572. return clipboard_history_controller_.get();
  573. }
  574. TouchDevicesController* touch_devices_controller() {
  575. return touch_devices_controller_.get();
  576. }
  577. AshTouchTransformController* touch_transformer_controller() {
  578. return touch_transformer_controller_.get();
  579. }
  580. TrayAction* tray_action() { return tray_action_.get(); }
  581. // Will return |nullptr| when the |kBluetoothRevamp| feature flag is enabled.
  582. TrayBluetoothHelper* tray_bluetooth_helper() {
  583. return tray_bluetooth_helper_.get();
  584. }
  585. UserMetricsRecorder* metrics() { return user_metrics_recorder_.get(); }
  586. VideoDetector* video_detector() { return video_detector_.get(); }
  587. WallpaperControllerImpl* wallpaper_controller() {
  588. return wallpaper_controller_.get();
  589. }
  590. WindowCycleController* window_cycle_controller() {
  591. return window_cycle_controller_.get();
  592. }
  593. WindowPositioner* window_positioner() { return window_positioner_.get(); }
  594. OverviewController* overview_controller() {
  595. return overview_controller_.get();
  596. }
  597. WindowTreeHostManager* window_tree_host_manager() {
  598. return window_tree_host_manager_.get();
  599. }
  600. BackGestureEventHandler* back_gesture_event_handler() {
  601. return back_gesture_event_handler_.get();
  602. }
  603. ui::EventHandler* shell_tab_handler() { return shell_tab_handler_.get(); }
  604. ToplevelWindowEventHandler* toplevel_window_event_handler() {
  605. return toplevel_window_event_handler_.get();
  606. }
  607. AshColorProvider* ash_color_provider() { return ash_color_provider_.get(); }
  608. PrefService* local_state() { return local_state_; }
  609. FrameThrottlingController* frame_throttling_controller() {
  610. return frame_throttling_controller_.get();
  611. }
  612. ProjectorControllerImpl* projector_controller() {
  613. return projector_controller_.get();
  614. }
  615. PciePeripheralNotificationController*
  616. pcie_peripheral_notification_controller() {
  617. return pcie_peripheral_notification_controller_.get();
  618. }
  619. UsbPeripheralNotificationController*
  620. usb_peripheral_notification_controller() {
  621. return usb_peripheral_notification_controller_.get();
  622. }
  623. OcclusionTrackerPauser* occlusion_tracker_pauser() {
  624. return occlusion_tracker_pauser_.get();
  625. }
  626. // Does the primary display have status area?
  627. bool HasPrimaryStatusArea();
  628. // Starts the animation that occurs on first login.
  629. void DoInitialWorkspaceAnimation();
  630. void SetLargeCursorSizeInDip(int large_cursor_size_in_dip);
  631. // Sets a custom color for the cursor.
  632. void SetCursorColor(SkColor cursor_color);
  633. // Updates cursor compositing on/off. Native cursor is disabled when cursor
  634. // compositing is enabled, and vice versa.
  635. void UpdateCursorCompositingEnabled();
  636. // Force setting compositing on/off without checking dependency.
  637. void SetCursorCompositingEnabled(bool enabled);
  638. // Shows the context menu for the wallpaper or shelf at |location_in_screen|.
  639. void ShowContextMenu(const gfx::Point& location_in_screen,
  640. ui::MenuSourceType source_type);
  641. void AddShellObserver(ShellObserver* observer);
  642. void RemoveShellObserver(ShellObserver* observer);
  643. // Disables event dispatch during shutdown so that Window events no longer
  644. // propagate as they are being closed/destroyed.
  645. void ShutdownEventDispatch();
  646. // Called when the login status changes.
  647. // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
  648. void UpdateAfterLoginStatusChange(LoginStatus status);
  649. // Notifies observers that fullscreen mode has changed for |container|.
  650. // |container| is always the active desk container.
  651. void NotifyFullscreenStateChanged(bool is_fullscreen,
  652. aura::Window* container);
  653. // Notifies observers that |pinned_window| changed its pinned window state.
  654. void NotifyPinnedStateChanged(aura::Window* pinned_window);
  655. // Notifies observers that |root_window|'s user work area insets have changed.
  656. // This notification is not fired when shelf bounds changed.
  657. void NotifyUserWorkAreaInsetsChanged(aura::Window* root_window);
  658. // Notifies observers that |root_window|'s shelf changed alignment.
  659. // TODO(jamescook): Move to Shelf.
  660. void NotifyShelfAlignmentChanged(aura::Window* root_window,
  661. ShelfAlignment old_alignment);
  662. private:
  663. FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
  664. FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
  665. FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
  666. friend class AcceleratorControllerTest;
  667. friend class AshTestHelper;
  668. friend class RootWindowController;
  669. friend class ShellTestApi;
  670. friend class SmsObserverTest;
  671. explicit Shell(std::unique_ptr<ShellDelegate> shell_delegate);
  672. ~Shell() override;
  673. void Init(ui::ContextFactory* context_factory,
  674. PrefService* local_state,
  675. std::unique_ptr<keyboard::KeyboardUIFactory> keyboard_ui_factory,
  676. scoped_refptr<dbus::Bus> dbus_bus);
  677. // Initializes the display manager and related components.
  678. void InitializeDisplayManager();
  679. // Initializes the root window so that it can host browser windows.
  680. void InitRootWindow(aura::Window* root_window);
  681. // Destroys all child windows including widgets across all roots.
  682. void CloseAllRootWindowChildWindows();
  683. // SystemModalContainerEventFilterDelegate:
  684. bool CanWindowReceiveEvents(aura::Window* window) override;
  685. // Overridden from ui::EventTarget:
  686. bool CanAcceptEvent(const ui::Event& event) override;
  687. EventTarget* GetParentTarget() override;
  688. std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override;
  689. ui::EventTargeter* GetEventTargeter() override;
  690. // wm::ActivationChangeObserver:
  691. void OnWindowActivated(ActivationReason reason,
  692. aura::Window* gained_active,
  693. aura::Window* lost_active) override;
  694. // SessionObserver:
  695. void OnFirstSessionStarted() override;
  696. void OnSessionStateChanged(session_manager::SessionState state) override;
  697. void OnLoginStatusChanged(LoginStatus login_status) override;
  698. void OnLockStateChanged(bool locked) override;
  699. static Shell* instance_;
  700. // The CompoundEventFilter owned by aura::Env object.
  701. std::unique_ptr<::wm::CompoundEventFilter> env_filter_;
  702. std::unique_ptr<EventRewriterControllerImpl> event_rewriter_controller_;
  703. std::unique_ptr<UserMetricsRecorder> user_metrics_recorder_;
  704. std::unique_ptr<WindowPositioner> window_positioner_;
  705. std::unique_ptr<AcceleratorControllerImpl> accelerator_controller_;
  706. std::unique_ptr<AccessibilityControllerImpl> accessibility_controller_;
  707. std::unique_ptr<AccessibilityDelegate> accessibility_delegate_;
  708. std::unique_ptr<AccessibilityFocusRingControllerImpl>
  709. accessibility_focus_ring_controller_;
  710. std::unique_ptr<AdaptiveChargingController> adaptive_charging_controller_;
  711. std::unique_ptr<AmbientController> ambient_controller_;
  712. std::unique_ptr<AppListControllerImpl> app_list_controller_;
  713. std::unique_ptr<AppListFeatureUsageMetrics> app_list_feature_usage_metrics_;
  714. // May be null in tests or when running on linux-chromeos.
  715. scoped_refptr<dbus::Bus> dbus_bus_;
  716. std::unique_ptr<AshDBusServices> ash_dbus_services_;
  717. std::unique_ptr<AssistantControllerImpl> assistant_controller_;
  718. std::unique_ptr<AutozoomControllerImpl> autozoom_controller_;
  719. std::unique_ptr<BacklightsForcedOffSetter> backlights_forced_off_setter_;
  720. std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate_;
  721. std::unique_ptr<CalendarController> calendar_controller_;
  722. std::unique_ptr<CrosDisplayConfig> cros_display_config_;
  723. std::unique_ptr<DarkLightModeControllerImpl> dark_light_mode_controller_;
  724. std::unique_ptr<DesksController> desks_controller_;
  725. std::unique_ptr<DesksTemplatesDelegate> desks_templates_delegate_;
  726. std::unique_ptr<DetachableBaseHandler> detachable_base_handler_;
  727. std::unique_ptr<DetachableBaseNotificationController>
  728. detachable_base_notification_controller_;
  729. std::unique_ptr<diagnostics::DiagnosticsLogController>
  730. diagnostics_log_controller_;
  731. std::unique_ptr<DisplayHighlightController> display_highlight_controller_;
  732. std::unique_ptr<DisplaySpeakerController> display_speaker_controller_;
  733. std::unique_ptr<DragDropController> drag_drop_controller_;
  734. std::unique_ptr<FirmwareUpdateNotificationController>
  735. firmware_update_notification_controller_;
  736. std::unique_ptr<FocusCycler> focus_cycler_;
  737. std::unique_ptr<FloatController> float_controller_;
  738. std::unique_ptr<GeolocationController> geolocation_controller_;
  739. std::unique_ptr<GlanceablesController> glanceables_controller_;
  740. std::unique_ptr<HoldingSpaceController> holding_space_controller_;
  741. std::unique_ptr<PowerPrefs> power_prefs_;
  742. std::unique_ptr<SnoopingProtectionController> snooping_protection_controller_;
  743. std::unique_ptr<HumanPresenceOrientationController>
  744. human_presence_orientation_controller_;
  745. std::unique_ptr<ImeControllerImpl> ime_controller_;
  746. std::unique_ptr<chromeos::ImmersiveContext> immersive_context_;
  747. std::unique_ptr<WebAuthNDialogControllerImpl> webauthn_dialog_controller_;
  748. std::unique_ptr<KeyboardBacklightColorController>
  749. keyboard_backlight_color_controller_;
  750. std::unique_ptr<InSessionAuthDialogControllerImpl>
  751. in_session_auth_dialog_controller_;
  752. std::unique_ptr<KeyboardBrightnessControlDelegate>
  753. keyboard_brightness_control_delegate_;
  754. std::unique_ptr<LocaleUpdateControllerImpl> locale_update_controller_;
  755. std::unique_ptr<LoginScreenController> login_screen_controller_;
  756. std::unique_ptr<LogoutConfirmationController> logout_confirmation_controller_;
  757. std::unique_ptr<TabClusterUIController> tab_cluster_ui_controller_;
  758. std::unique_ptr<TabletModeController> tablet_mode_controller_;
  759. std::unique_ptr<MessageCenterAshImpl> message_center_ash_impl_;
  760. std::unique_ptr<MediaControllerImpl> media_controller_;
  761. std::unique_ptr<MediaNotificationProviderImpl> media_notification_provider_;
  762. std::unique_ptr<MruWindowTracker> mru_window_tracker_;
  763. std::unique_ptr<MultiDeviceNotificationPresenter>
  764. multidevice_notification_presenter_;
  765. std::unique_ptr<MultitaskMenuNudgeController>
  766. multitask_menu_nudge_controller_;
  767. std::unique_ptr<NearbyShareControllerImpl> nearby_share_controller_;
  768. std::unique_ptr<NearbyShareDelegate> nearby_share_delegate_;
  769. std::unique_ptr<ParentAccessController> parent_access_controller_;
  770. std::unique_ptr<PciePeripheralNotificationController>
  771. pcie_peripheral_notification_controller_;
  772. std::unique_ptr<PrivacyHubController> privacy_hub_controller_;
  773. std::unique_ptr<UsbPeripheralNotificationController>
  774. usb_peripheral_notification_controller_;
  775. std::unique_ptr<PersistentDesksBarController>
  776. persistent_desks_bar_controller_;
  777. std::unique_ptr<RgbKeyboardManager> rgb_keyboard_manager_;
  778. std::unique_ptr<ResizeShadowController> resize_shadow_controller_;
  779. std::unique_ptr<SessionControllerImpl> session_controller_;
  780. std::unique_ptr<FeatureDiscoveryDurationReporterImpl>
  781. feature_discover_reporter_;
  782. std::unique_ptr<AshColorProvider> ash_color_provider_;
  783. std::unique_ptr<NightLightControllerImpl> night_light_controller_;
  784. std::unique_ptr<PrivacyScreenController> privacy_screen_controller_;
  785. std::unique_ptr<PolicyRecommendationRestorer> policy_recommendation_restorer_;
  786. std::unique_ptr<ScreenSwitchCheckController> screen_switch_check_controller_;
  787. std::unique_ptr<ShelfConfig> shelf_config_;
  788. std::unique_ptr<ShelfController> shelf_controller_;
  789. std::unique_ptr<ShelfWindowWatcher> shelf_window_watcher_;
  790. std::unique_ptr<ShellDelegate> shell_delegate_;
  791. std::unique_ptr<CaptureModeController> capture_mode_controller_;
  792. std::unique_ptr<ControlVHistogramRecorder> control_v_histogram_recorder_;
  793. std::unique_ptr<ShutdownControllerImpl> shutdown_controller_;
  794. std::unique_ptr<SystemNotificationController> system_notification_controller_;
  795. std::unique_ptr<SystemTrayModel> system_tray_model_;
  796. std::unique_ptr<SystemTrayNotifier> system_tray_notifier_;
  797. std::unique_ptr<ToastManagerImpl> toast_manager_;
  798. std::unique_ptr<ClipboardHistoryControllerImpl> clipboard_history_controller_;
  799. std::unique_ptr<TouchDevicesController> touch_devices_controller_;
  800. std::unique_ptr<TrayAction> tray_action_;
  801. std::unique_ptr<WallpaperControllerImpl> wallpaper_controller_;
  802. std::unique_ptr<WindowCycleController> window_cycle_controller_;
  803. std::unique_ptr<WindowRestoreController> window_restore_controller_;
  804. std::unique_ptr<OverviewController> overview_controller_;
  805. // Owned by |focus_controller_|.
  806. AshFocusRules* focus_rules_ = nullptr;
  807. std::unique_ptr<::wm::ShadowController> shadow_controller_;
  808. std::unique_ptr<::wm::VisibilityController> visibility_controller_;
  809. std::unique_ptr<::wm::WindowModalityController> window_modality_controller_;
  810. PrefService* local_state_ = nullptr;
  811. std::unique_ptr<views::corewm::TooltipController> tooltip_controller_;
  812. std::unique_ptr<PowerButtonController> power_button_controller_;
  813. std::unique_ptr<LockStateController> lock_state_controller_;
  814. std::unique_ptr<ui::UserActivityDetector> user_activity_detector_;
  815. std::unique_ptr<VideoDetector> video_detector_;
  816. std::unique_ptr<WindowTreeHostManager> window_tree_host_manager_;
  817. std::unique_ptr<PersistentWindowController> persistent_window_controller_;
  818. std::unique_ptr<HighContrastController> high_contrast_controller_;
  819. std::unique_ptr<FullscreenMagnifierController>
  820. fullscreen_magnifier_controller_;
  821. std::unique_ptr<AutoclickController> autoclick_controller_;
  822. std::unique_ptr<::wm::FocusController> focus_controller_;
  823. std::unique_ptr<MouseCursorEventFilter> mouse_cursor_filter_;
  824. std::unique_ptr<ScreenPositionController> screen_position_controller_;
  825. std::unique_ptr<SystemModalContainerEventFilter> modality_filter_;
  826. std::unique_ptr<EventClientImpl> event_client_;
  827. std::unique_ptr<EventTransformationHandler> event_transformation_handler_;
  828. // An event filter that pre-handles key events while the partial
  829. // screenshot UI or the keyboard overlay is active.
  830. std::unique_ptr<OverlayEventFilter> overlay_filter_;
  831. // An event filter which handles swiping back from left side of the window.
  832. std::unique_ptr<BackGestureEventHandler> back_gesture_event_handler_;
  833. // An event filter which redirects focus when tab is pressed on a RootWindow
  834. // with no active windows.
  835. std::unique_ptr<ui::EventHandler> shell_tab_handler_;
  836. // An event filter which handles moving and resizing windows.
  837. std::unique_ptr<ToplevelWindowEventHandler> toplevel_window_event_handler_;
  838. // An event filter which handles system level gestures
  839. std::unique_ptr<SystemGestureEventFilter> system_gesture_filter_;
  840. // An event filter that pre-handles global accelerators.
  841. std::unique_ptr<::wm::AcceleratorFilter> accelerator_filter_;
  842. std::unique_ptr<display::DisplayManager> display_manager_;
  843. std::unique_ptr<DisplayPrefs> display_prefs_;
  844. std::unique_ptr<DisplayConfigurationController>
  845. display_configuration_controller_;
  846. std::unique_ptr<DisplayConfigurationObserver> display_configuration_observer_;
  847. std::unique_ptr<RefreshRateThrottleController>
  848. refresh_rate_throttle_controller_;
  849. std::unique_ptr<ScreenPinningController> screen_pinning_controller_;
  850. std::unique_ptr<PeripheralBatteryListener> peripheral_battery_listener_;
  851. std::unique_ptr<PeripheralBatteryNotifier> peripheral_battery_notifier_;
  852. std::unique_ptr<PowerEventObserver> power_event_observer_;
  853. std::unique_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
  854. std::unique_ptr<VideoActivityNotifier> video_activity_notifier_;
  855. std::unique_ptr<StickyKeysController> sticky_keys_controller_;
  856. std::unique_ptr<ResolutionNotificationController>
  857. resolution_notification_controller_;
  858. std::unique_ptr<BluetoothNotificationController>
  859. bluetooth_notification_controller_;
  860. std::unique_ptr<BluetoothDeviceStatusUiHandler>
  861. bluetooth_device_status_ui_handler_;
  862. std::unique_ptr<BluetoothPowerController> bluetooth_power_controller_;
  863. // Will be |nullptr| when the |kBluetoothRevamp| feature flag is enabled.
  864. std::unique_ptr<TrayBluetoothHelper> tray_bluetooth_helper_;
  865. std::unique_ptr<KeyboardControllerImpl> keyboard_controller_;
  866. std::unique_ptr<DisplayAlignmentController> display_alignment_controller_;
  867. std::unique_ptr<DisplayColorManager> display_color_manager_;
  868. std::unique_ptr<DisplayErrorObserver> display_error_observer_;
  869. std::unique_ptr<ProjectingObserver> projecting_observer_;
  870. // Listens for output changes and updates the display manager.
  871. std::unique_ptr<display::DisplayChangeObserver> display_change_observer_;
  872. // Listens for shutdown and updates DisplayConfigurator.
  873. std::unique_ptr<DisplayShutdownObserver> display_shutdown_observer_;
  874. // Listens for new sms messages and shows notifications.
  875. std::unique_ptr<SmsObserver> sms_observer_;
  876. // Implements content::ScreenOrientationController for Chrome OS.
  877. std::unique_ptr<ScreenOrientationController> screen_orientation_controller_;
  878. std::unique_ptr<ScreenLayoutObserver> screen_layout_observer_;
  879. std::unique_ptr<AshTouchTransformController> touch_transformer_controller_;
  880. std::unique_ptr<ui::EventHandler> magnifier_key_scroll_handler_;
  881. std::unique_ptr<ui::EventHandler> speech_feedback_handler_;
  882. std::unique_ptr<LaserPointerController> laser_pointer_controller_;
  883. std::unique_ptr<PartialMagnifierController> partial_magnifier_controller_;
  884. std::unique_ptr<HighlighterController> highlighter_controller_;
  885. std::unique_ptr<DockedMagnifierController> docked_magnifier_controller_;
  886. std::unique_ptr<chromeos::SnapController> snap_controller_;
  887. // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
  888. // pointer to vend to test code.
  889. NativeCursorManagerAsh* native_cursor_manager_;
  890. // Cursor may be hidden on certain key events in Chrome OS, whereas we never
  891. // hide the cursor on Windows.
  892. std::unique_ptr<::wm::CursorManager> cursor_manager_;
  893. // Enables spoken feedback accessibility based on a press and hold of both
  894. // volume keys.
  895. std::unique_ptr<KeyAccessibilityEnabler> key_accessibility_enabler_;
  896. std::unique_ptr<FrameThrottlingController> frame_throttling_controller_;
  897. std::unique_ptr<ProjectorControllerImpl> projector_controller_;
  898. // For testing only: simulate that a modal window is open
  899. bool simulate_modal_window_open_for_test_ = false;
  900. std::unique_ptr<MessageCenterController> message_center_controller_;
  901. std::unique_ptr<LoginUnlockThroughputRecorder>
  902. login_unlock_throughput_recorder_;
  903. std::unique_ptr<OcclusionTrackerPauser> occlusion_tracker_pauser_;
  904. std::unique_ptr<MultiCaptureServiceClient> multi_capture_service_client_;
  905. std::unique_ptr<quick_pair::Mediator> quick_pair_mediator_;
  906. base::ObserverList<ShellObserver>::Unchecked shell_observers_;
  907. base::WeakPtrFactory<Shell> weak_factory_{this};
  908. };
  909. } // namespace ash
  910. #endif // ASH_SHELL_H_