Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: ash/wm_shell.h

Issue 2734733002: Revert "chromeos: Move files in //ash/common to //ash, part 3" (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm_layout_manager.h ('k') | ash/wm_shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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
5 #ifndef ASH_WM_SHELL_H_
6 #define ASH_WM_SHELL_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <vector>
12
13 #include "ash/ash_export.h"
14 #include "ash/metrics/gesture_action_type.h"
15 #include "ash/metrics/user_metrics_action.h"
16 #include "ash/session/session_state_observer.h"
17 #include "ash/wm/lock_state_observer.h"
18 #include "base/observer_list.h"
19 #include "components/ui_devtools/devtools_server.h"
20 #include "ui/base/ui_base_types.h"
21 #include "ui/compositor/layer_type.h"
22 #include "ui/wm/public/activation_change_observer.h"
23 #include "ui/wm/public/window_types.h"
24
25 namespace app_list {
26 class AppList;
27 }
28
29 namespace base {
30 class SequencedWorkerPool;
31 }
32
33 namespace display {
34 class Display;
35 class ManagedDisplayInfo;
36 }
37
38 namespace gfx {
39 class Insets;
40 class Point;
41 }
42
43 namespace preferences {
44 class PrefClientStore;
45 }
46
47 namespace views {
48 class PointerWatcher;
49 enum class PointerWatcherEventTypes;
50 }
51
52 namespace ash {
53 class AcceleratorController;
54 class AccessibilityDelegate;
55 class BrightnessControlDelegate;
56 class CastConfigController;
57 class FocusCycler;
58 class ImmersiveContextAsh;
59 class ImmersiveFullscreenController;
60 class KeyEventWatcher;
61 class KeyboardBrightnessControlDelegate;
62 class KeyboardUI;
63 class LocaleNotificationController;
64 class LogoutConfirmationController;
65 class MaximizeModeController;
66 class MediaController;
67 class MruWindowTracker;
68 class NewWindowController;
69 class PaletteDelegate;
70 class RootWindowController;
71 class ScopedDisableInternalMouseAndKeyboard;
72 class SessionController;
73 class SessionStateDelegate;
74 class ShelfController;
75 class ShelfDelegate;
76 class ShelfModel;
77 class ShelfWindowWatcher;
78 class ShellDelegate;
79 struct ShellInitParams;
80 class ShellObserver;
81 class ShutdownController;
82 class SystemTrayDelegate;
83 class SystemTrayController;
84 class SystemTrayNotifier;
85 class ToastManager;
86 class VpnList;
87 class WallpaperController;
88 class WallpaperDelegate;
89 class WindowCycleController;
90 class WindowCycleEventFilter;
91 class WindowResizer;
92 class WindowSelectorController;
93 class WmActivationObserver;
94 class WmDisplayObserver;
95 class WmWindow;
96 class WorkspaceEventHandler;
97
98 enum class LoginStatus;
99 enum class TaskSwitchSource;
100
101 namespace wm {
102 class MaximizeModeEventHandler;
103 class WindowState;
104 }
105
106 // Similar to ash::Shell. Eventually the two will be merged.
107 class ASH_EXPORT WmShell : public SessionStateObserver,
108 public aura::client::ActivationChangeObserver {
109 public:
110 ~WmShell() override;
111
112 // This is necessary for a handful of places that is difficult to plumb
113 // through context.
114 static void Set(WmShell* instance);
115 static WmShell* Get();
116 static bool HasInstance() { return instance_ != nullptr; }
117
118 virtual void Initialize(const scoped_refptr<base::SequencedWorkerPool>& pool);
119 virtual void Shutdown();
120
121 ShellDelegate* delegate() { return delegate_.get(); }
122
123 AcceleratorController* accelerator_controller() {
124 return accelerator_controller_.get();
125 }
126
127 AccessibilityDelegate* accessibility_delegate() {
128 return accessibility_delegate_.get();
129 }
130
131 app_list::AppList* app_list() { return app_list_.get(); }
132
133 BrightnessControlDelegate* brightness_control_delegate() {
134 return brightness_control_delegate_.get();
135 }
136
137 CastConfigController* cast_config() { return cast_config_.get(); }
138
139 FocusCycler* focus_cycler() { return focus_cycler_.get(); }
140
141 KeyboardBrightnessControlDelegate* keyboard_brightness_control_delegate() {
142 return keyboard_brightness_control_delegate_.get();
143 }
144
145 KeyboardUI* keyboard_ui() { return keyboard_ui_.get(); }
146
147 LocaleNotificationController* locale_notification_controller() {
148 return locale_notification_controller_.get();
149 }
150
151 LogoutConfirmationController* logout_confirmation_controller() {
152 return logout_confirmation_controller_.get();
153 }
154
155 MaximizeModeController* maximize_mode_controller() {
156 return maximize_mode_controller_.get();
157 }
158
159 MruWindowTracker* mru_window_tracker() { return mru_window_tracker_.get(); }
160
161 MediaController* media_controller() { return media_controller_.get(); }
162
163 NewWindowController* new_window_controller() {
164 return new_window_controller_.get();
165 }
166
167 // NOTE: Prefer ScopedRootWindowForNewWindows when setting temporarily.
168 void set_root_window_for_new_windows(WmWindow* root) {
169 root_window_for_new_windows_ = root;
170 }
171
172 PaletteDelegate* palette_delegate() { return palette_delegate_.get(); }
173
174 preferences::PrefClientStore* pref_store() { return pref_store_.get(); }
175
176 SessionController* session_controller() { return session_controller_.get(); }
177
178 ShelfController* shelf_controller() { return shelf_controller_.get(); }
179
180 ShelfDelegate* shelf_delegate() { return shelf_delegate_.get(); }
181
182 ShelfModel* shelf_model();
183
184 ShutdownController* shutdown_controller() {
185 return shutdown_controller_.get();
186 }
187
188 SystemTrayController* system_tray_controller() {
189 return system_tray_controller_.get();
190 }
191
192 SystemTrayNotifier* system_tray_notifier() {
193 return system_tray_notifier_.get();
194 }
195
196 SystemTrayDelegate* system_tray_delegate() {
197 return system_tray_delegate_.get();
198 }
199
200 ToastManager* toast_manager() { return toast_manager_.get(); }
201
202 VpnList* vpn_list() { return vpn_list_.get(); }
203
204 WallpaperController* wallpaper_controller() {
205 return wallpaper_controller_.get();
206 }
207
208 WallpaperDelegate* wallpaper_delegate() { return wallpaper_delegate_.get(); }
209
210 WindowCycleController* window_cycle_controller() {
211 return window_cycle_controller_.get();
212 }
213
214 WindowSelectorController* window_selector_controller() {
215 return window_selector_controller_.get();
216 }
217
218 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool() {
219 return blocking_pool_;
220 }
221
222 // Returns true when ash is running as a service_manager::Service.
223 virtual bool IsRunningInMash() const = 0;
224
225 virtual WmWindow* NewWindow(ui::wm::WindowType window_type,
226 ui::LayerType layer_type) = 0;
227
228 virtual WmWindow* GetFocusedWindow() = 0;
229 virtual WmWindow* GetActiveWindow() = 0;
230
231 virtual WmWindow* GetCaptureWindow() = 0;
232
233 // Convenience for GetPrimaryRootWindow()->GetRootWindowController().
234 RootWindowController* GetPrimaryRootWindowController();
235
236 virtual WmWindow* GetPrimaryRootWindow() = 0;
237
238 // Returns the root window for the specified display.
239 virtual WmWindow* GetRootWindowForDisplayId(int64_t display_id) = 0;
240
241 // Returns the root window that newly created windows should be added to.
242 // Value can be temporarily overridden using ScopedRootWindowForNewWindows.
243 // NOTE: this returns the root, newly created window should be added to the
244 // appropriate container in the returned window.
245 WmWindow* GetRootWindowForNewWindows();
246
247 // Retuns the display info associated with |display_id|.
248 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
249 virtual const display::ManagedDisplayInfo& GetDisplayInfo(
250 int64_t display_id) const = 0;
251
252 // Matches that of DisplayManager::IsActiveDisplayId().
253 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
254 virtual bool IsActiveDisplayId(int64_t display_id) const = 0;
255
256 // Returns true if the desktop is in unified mode and there are no mirroring
257 // displays.
258 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
259 virtual bool IsInUnifiedMode() const = 0;
260
261 // Returns true if the desktop is in unified mode.
262 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
263 virtual bool IsInUnifiedModeIgnoreMirroring() const = 0;
264
265 // Returns the first display; this is the first display listed by hardware,
266 // which corresponds to internal displays on devices with integrated displays.
267 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
268 virtual display::Display GetFirstDisplay() const = 0;
269
270 // Returns true if the first window shown on first run should be
271 // unconditionally maximized, overriding the heuristic that normally chooses
272 // the window size.
273 virtual bool IsForceMaximizeOnFirstRun() = 0;
274
275 // Sets work area insets of the display containing |window|, pings observers.
276 virtual void SetDisplayWorkAreaInsets(WmWindow* window,
277 const gfx::Insets& insets) = 0;
278
279 // Returns true if a system-modal dialog window is currently open.
280 bool IsSystemModalWindowOpen();
281
282 // Creates a modal background (a partially-opaque fullscreen window) on all
283 // displays for |window|.
284 void CreateModalBackground(WmWindow* window);
285
286 // Called when a modal window is removed. It will activate another modal
287 // window if any, or remove modal screens on all displays.
288 void OnModalWindowRemoved(WmWindow* removed);
289
290 // For testing only: set simulation that a modal window is open
291 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
292 simulate_modal_window_open_for_testing_ = modal_window_open;
293 }
294
295 // Shows the app list on the active root window.
296 void ShowAppList();
297
298 // Dismisses the app list.
299 void DismissAppList();
300
301 // Shows the app list if it's not visible. Dismisses it otherwise.
302 void ToggleAppList();
303
304 // Returns app list actual visibility. This might differ from
305 // GetAppListTargetVisibility() when hiding animation is still in flight.
306 bool IsApplistVisible() const;
307
308 // Returns app list target visibility.
309 bool GetAppListTargetVisibility() const;
310
311 // Returns true if a window is currently pinned.
312 virtual bool IsPinned() = 0;
313
314 // Sets/Unsets the |window| to as a pinned window. If this is called with a
315 // window with WINDOW_STATE_TYPE_PINNED state, then this sets the |window|
316 // as a pinned window. Otherwise, this unsets it.
317 // For setting, a caller needs to guarantee that no windows are set
318 // as pinned window. For unsetting, a caller needs to guarantee that the
319 // |window| is the one which is currently set as a pinned window via previous
320 // this function invocation.
321 virtual void SetPinnedWindow(WmWindow* window) = 0;
322
323 // See aura::client::CursorClient for details on these.
324 virtual void LockCursor() = 0;
325 virtual void UnlockCursor() = 0;
326 virtual bool IsMouseEventsEnabled() = 0;
327
328 virtual std::vector<WmWindow*> GetAllRootWindows() = 0;
329
330 virtual void RecordGestureAction(GestureActionType action) = 0;
331 virtual void RecordUserMetricsAction(UserMetricsAction action) = 0;
332 virtual void RecordTaskSwitchMetric(TaskSwitchSource source) = 0;
333
334 // Shows the context menu for the wallpaper or shelf at |location_in_screen|.
335 void ShowContextMenu(const gfx::Point& location_in_screen,
336 ui::MenuSourceType source_type);
337
338 // Returns a WindowResizer to handle dragging. |next_window_resizer| is
339 // the next WindowResizer in the WindowResizer chain. This may return
340 // |next_window_resizer|.
341 virtual std::unique_ptr<WindowResizer> CreateDragWindowResizer(
342 std::unique_ptr<WindowResizer> next_window_resizer,
343 wm::WindowState* window_state) = 0;
344
345 virtual std::unique_ptr<WindowCycleEventFilter>
346 CreateWindowCycleEventFilter() = 0;
347
348 virtual std::unique_ptr<wm::MaximizeModeEventHandler>
349 CreateMaximizeModeEventHandler() = 0;
350
351 virtual std::unique_ptr<WorkspaceEventHandler> CreateWorkspaceEventHandler(
352 WmWindow* workspace_window) = 0;
353
354 virtual std::unique_ptr<ScopedDisableInternalMouseAndKeyboard>
355 CreateScopedDisableInternalMouseAndKeyboard() = 0;
356
357 virtual std::unique_ptr<ImmersiveFullscreenController>
358 CreateImmersiveFullscreenController() = 0;
359
360 virtual std::unique_ptr<KeyEventWatcher> CreateKeyEventWatcher() = 0;
361
362 // Creates the ShelfView for each display and populates it with items.
363 // Called after the user session is active and profile is available.
364 void CreateShelfView();
365
366 void CreateShelfDelegate();
367
368 // Called after maximize mode has started, windows might still animate though.
369 void OnMaximizeModeStarted();
370
371 // Called after maximize mode is about to end.
372 void OnMaximizeModeEnding();
373
374 // Called after maximize mode has ended, windows might still be returning to
375 // their original position.
376 void OnMaximizeModeEnded();
377
378 // Called when the overview mode is about to be started (before the windows
379 // get re-arranged).
380 virtual void OnOverviewModeStarting() = 0;
381
382 // Called after overview mode has ended.
383 virtual void OnOverviewModeEnded() = 0;
384
385 // Called when the login status changes.
386 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
387 void UpdateAfterLoginStatusChange(LoginStatus status);
388
389 // Notify observers that fullscreen mode has changed for |root_window|.
390 void NotifyFullscreenStateChanged(bool is_fullscreen, WmWindow* root_window);
391
392 // Notify observers that |pinned_window| changed its pinned window state.
393 void NotifyPinnedStateChanged(WmWindow* pinned_window);
394
395 // Notify observers that the virtual keyboard has been activated/deactivated.
396 void NotifyVirtualKeyboardActivated(bool activated);
397
398 // Notify observers that the shelf was created for |root_window|.
399 // TODO(jamescook): Move to Shelf.
400 void NotifyShelfCreatedForRootWindow(WmWindow* root_window);
401
402 // Notify observers that |root_window|'s shelf changed auto-hide alignment.
403 // TODO(jamescook): Move to Shelf.
404 void NotifyShelfAlignmentChanged(WmWindow* root_window);
405
406 // Notify observers that |root_window|'s shelf changed auto-hide behavior.
407 // TODO(jamescook): Move to Shelf.
408 void NotifyShelfAutoHideBehaviorChanged(WmWindow* root_window);
409
410 virtual SessionStateDelegate* GetSessionStateDelegate() = 0;
411
412 void AddActivationObserver(WmActivationObserver* observer);
413 void RemoveActivationObserver(WmActivationObserver* observer);
414
415 virtual void AddDisplayObserver(WmDisplayObserver* observer) = 0;
416 virtual void RemoveDisplayObserver(WmDisplayObserver* observer) = 0;
417
418 void AddShellObserver(ShellObserver* observer);
419 void RemoveShellObserver(ShellObserver* observer);
420
421 // If |events| is PointerWatcherEventTypes::MOVES,
422 // PointerWatcher::OnPointerEventObserved() is called for pointer move events.
423 // If |events| is PointerWatcherEventTypes::DRAGS,
424 // PointerWatcher::OnPointerEventObserved() is called for pointer drag events.
425 // Requesting pointer moves or drags may incur a performance hit and should be
426 // avoided if possible.
427 virtual void AddPointerWatcher(views::PointerWatcher* watcher,
428 views::PointerWatcherEventTypes events) = 0;
429 virtual void RemovePointerWatcher(views::PointerWatcher* watcher) = 0;
430
431 // TODO: Move these back to LockStateController when that has been moved.
432 void OnLockStateEvent(LockStateObserver::EventType event);
433 void AddLockStateObserver(LockStateObserver* observer);
434 void RemoveLockStateObserver(LockStateObserver* observer);
435
436 void SetShelfDelegateForTesting(std::unique_ptr<ShelfDelegate> test_delegate);
437 void SetPaletteDelegateForTesting(
438 std::unique_ptr<PaletteDelegate> palette_delegate);
439
440 // True if any touch points are down.
441 virtual bool IsTouchDown() = 0;
442
443 // TODO(jamescook): Remove this when VirtualKeyboardController has been moved.
444 virtual void ToggleIgnoreExternalKeyboard() = 0;
445
446 // Enable or disable the laser pointer.
447 virtual void SetLaserPointerEnabled(bool enabled) = 0;
448
449 // Enable or disable the partial magnifier.
450 virtual void SetPartialMagnifierEnabled(bool enabled) = 0;
451
452 virtual void CreatePointerWatcherAdapter() = 0;
453
454 protected:
455 explicit WmShell(std::unique_ptr<ShellDelegate> shell_delegate);
456
457 // Called during startup to create the primary WindowTreeHost and
458 // the corresponding RootWindowController.
459 virtual void CreatePrimaryHost() = 0;
460 virtual void InitHosts(const ShellInitParams& init_params) = 0;
461
462 base::ObserverList<ShellObserver>* shell_observers() {
463 return &shell_observers_;
464 }
465
466 void SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui);
467
468 // Helpers to set (and initialize) or destroy various delegates.
469 // TODO(msw|jamescook): Remove these once ShellDelegate, etc. are ported.
470 void SetSystemTrayDelegate(std::unique_ptr<SystemTrayDelegate> delegate);
471 void DeleteSystemTrayDelegate();
472
473 void DeleteWindowCycleController();
474
475 void DeleteWindowSelectorController();
476
477 void CreateMaximizeModeController();
478 void DeleteMaximizeModeController();
479
480 void CreateMruWindowTracker();
481 void DeleteMruWindowTracker();
482
483 void DeleteToastManager();
484
485 void SetAcceleratorController(
486 std::unique_ptr<AcceleratorController> accelerator_controller);
487
488 // SessionStateObserver:
489 void SessionStateChanged(session_manager::SessionState state) override;
490
491 private:
492 friend class AcceleratorControllerTest;
493 friend class ScopedRootWindowForNewWindows;
494 friend class Shell;
495 friend class WmShellTestApi;
496
497 // aura::client::ActivationChangeObserver:
498 void OnWindowActivated(ActivationReason reason,
499 aura::Window* gained_active,
500 aura::Window* lost_active) override;
501 void OnAttemptToReactivateWindow(aura::Window* request_active,
502 aura::Window* actual_active) override;
503
504 static WmShell* instance_;
505
506 base::ObserverList<ShellObserver> shell_observers_;
507 std::unique_ptr<ShellDelegate> delegate_;
508
509 scoped_refptr<preferences::PrefClientStore> pref_store_;
510
511 std::unique_ptr<AcceleratorController> accelerator_controller_;
512 std::unique_ptr<AccessibilityDelegate> accessibility_delegate_;
513 std::unique_ptr<app_list::AppList> app_list_;
514 std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate_;
515 std::unique_ptr<CastConfigController> cast_config_;
516 std::unique_ptr<FocusCycler> focus_cycler_;
517 std::unique_ptr<ImmersiveContextAsh> immersive_context_;
518 std::unique_ptr<KeyboardBrightnessControlDelegate>
519 keyboard_brightness_control_delegate_;
520 std::unique_ptr<KeyboardUI> keyboard_ui_;
521 std::unique_ptr<LocaleNotificationController> locale_notification_controller_;
522 std::unique_ptr<LogoutConfirmationController> logout_confirmation_controller_;
523 std::unique_ptr<MaximizeModeController> maximize_mode_controller_;
524 std::unique_ptr<MediaController> media_controller_;
525 std::unique_ptr<MruWindowTracker> mru_window_tracker_;
526 std::unique_ptr<NewWindowController> new_window_controller_;
527 std::unique_ptr<PaletteDelegate> palette_delegate_;
528 std::unique_ptr<SessionController> session_controller_;
529 std::unique_ptr<ShelfController> shelf_controller_;
530 std::unique_ptr<ShelfDelegate> shelf_delegate_;
531 std::unique_ptr<ShelfWindowWatcher> shelf_window_watcher_;
532 std::unique_ptr<ShutdownController> shutdown_controller_;
533 std::unique_ptr<SystemTrayController> system_tray_controller_;
534 std::unique_ptr<SystemTrayNotifier> system_tray_notifier_;
535 std::unique_ptr<SystemTrayDelegate> system_tray_delegate_;
536 std::unique_ptr<ToastManager> toast_manager_;
537 std::unique_ptr<VpnList> vpn_list_;
538 std::unique_ptr<WallpaperController> wallpaper_controller_;
539 std::unique_ptr<WallpaperDelegate> wallpaper_delegate_;
540 std::unique_ptr<WindowCycleController> window_cycle_controller_;
541 std::unique_ptr<WindowSelectorController> window_selector_controller_;
542 std::unique_ptr<ui::devtools::UiDevToolsServer> devtools_server_;
543
544 base::ObserverList<LockStateObserver> lock_state_observers_;
545
546 // See comment for GetRootWindowForNewWindows().
547 WmWindow* root_window_for_new_windows_ = nullptr;
548 WmWindow* scoped_root_window_for_new_windows_ = nullptr;
549
550 bool simulate_modal_window_open_for_testing_ = false;
551
552 bool added_activation_observer_ = false;
553 base::ObserverList<WmActivationObserver> activation_observers_;
554
555 scoped_refptr<base::SequencedWorkerPool> blocking_pool_;
556 };
557
558 } // namespace ash
559
560 #endif // ASH_WM_SHELL_H_
OLDNEW
« no previous file with comments | « ash/wm_layout_manager.h ('k') | ash/wm_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698