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