blob: 34b31ebb256bf673a59d6a30ebd2a33828ff0c3c [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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
5#ifndef ASH_SHELL_H_
6#define ASH_SHELL_H_
7
8#include <utility>
9#include <vector>
10
11#include "ash/ash_export.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000012#include "ash/shelf/shelf_types.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000013#include "ash/system/user/login_status.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000014#include "ash/wm/system_modal_container_event_filter_delegate.h"
15#include "base/basictypes.h"
16#include "base/compiler_specific.h"
17#include "base/gtest_prod_util.h"
18#include "base/memory/scoped_ptr.h"
19#include "base/observer_list.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000020#include "ui/aura/client/activation_change_observer.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010021#include "ui/base/ui_base_types.h"
Torne (Richard Coles)d0247b12013-09-19 22:36:51 +010022#include "ui/events/event_target.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000023#include "ui/gfx/insets.h"
24#include "ui/gfx/screen.h"
25#include "ui/gfx/size.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000026#include "ui/views/corewm/cursor_manager.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000027
28class CommandLine;
29
30namespace aura {
31class EventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000032class RootWindow;
33class Window;
34namespace client {
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000035class ActivationClient;
36class FocusClient;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000037class UserActionClient;
38}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000039}
40namespace chromeos {
41class OutputConfigurator;
42}
43namespace content {
44class BrowserContext;
45}
46
47namespace gfx {
48class ImageSkia;
49class Point;
50class Rect;
51}
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010052
53namespace keyboard {
54class KeyboardController;
55}
56
Torne (Richard Coles)58218062012-11-14 11:43:16 +000057namespace ui {
58class Layer;
59}
60namespace views {
61class NonClientFrameView;
62class Widget;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000063namespace corewm {
64class CompoundEventFilter;
65class InputMethodEventFilter;
66class ShadowController;
67class TooltipController;
68class VisibilityController;
69class WindowModalityController;
70}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000071}
72
73namespace ash {
74
75class AcceleratorController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000076class AshNativeCursorManager;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010077class AutoclickController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000078class CapsLockDelegate;
79class DesktopBackgroundController;
80class DisplayController;
81class HighContrastController;
82class Launcher;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000083class LauncherDelegate;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010084class LauncherItemDelegate;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +010085class LauncherItemDelegateManager;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000086class LauncherModel;
87class MagnificationController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010088class MruWindowTracker;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000089class NestedDispatcherController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000090class PartialMagnificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000091class PowerButtonController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000092class RootWindowHostFactory;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000093class ScreenAsh;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010094class LockStateController;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010095class SessionStateDelegate;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000096class ShellDelegate;
97class ShellObserver;
98class SystemTray;
99class SystemTrayDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000100class SystemTrayNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000101class UserActivityDetector;
102class UserWallpaperDelegate;
103class VideoDetector;
104class WebNotificationTray;
105class WindowCycleController;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100106class WindowPositioner;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100107class WindowSelectorController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000108
109namespace internal {
110class AcceleratorFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000111class AppListController;
112class CaptureController;
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100113class DisplayChangeObserver;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000114class DisplayErrorObserver;
115class DisplayManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000116class DragDropController;
117class EventClientImpl;
118class EventRewriterEventFilter;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000119class EventTransformationHandler;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000120class FocusCycler;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100121class KeyboardUMAEventFilter;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100122class LocaleNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000123class MouseCursorEventFilter;
124class OutputConfiguratorAnimation;
125class OverlayEventFilter;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100126class PowerEventObserver;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000127class ResizeShadowController;
Ben Murdochba5b9a62013-08-12 14:20:17 +0100128class ResolutionNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000129class RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100130class ScopedTargetRootWindow;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000131class ScreenPositionController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000132class SlowAnimationEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000133class StatusAreaWidget;
134class SystemGestureEventFilter;
135class SystemModalContainerEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000136class TouchObserverHUD;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100137class UserActivityNotifier;
138class VideoActivityNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000139}
140
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000141namespace shell {
142class WindowWatcher;
143}
144
145namespace test {
146class ShellTestApi;
147}
148
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000149// Shell is a singleton object that presents the Shell API and implements the
150// RootWindow's delegate interface.
151//
152// Upon creation, the Shell sets itself as the RootWindow's delegate, which
153// takes ownership of the Shell.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000154class ASH_EXPORT Shell
155 : public internal::SystemModalContainerEventFilterDelegate,
156 public ui::EventTarget,
157 public aura::client::ActivationChangeObserver {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000158 public:
159 typedef std::vector<aura::RootWindow*> RootWindowList;
160 typedef std::vector<internal::RootWindowController*> RootWindowControllerList;
161
162 enum Direction {
163 FORWARD,
164 BACKWARD
165 };
166
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000167 // A shell must be explicitly created so that it can call |Init()| with the
168 // delegate set. |delegate| can be NULL (if not required for initialization).
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100169 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000170 static Shell* CreateInstance(ShellDelegate* delegate);
171
172 // Should never be called before |CreateInstance()|.
173 static Shell* GetInstance();
174
175 // Returns true if the ash shell has been instantiated.
176 static bool HasInstance();
177
178 static void DeleteInstance();
179
180 // Returns the root window controller for the primary root window.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000181 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000182 static internal::RootWindowController* GetPrimaryRootWindowController();
183
184 // Returns all root window controllers.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000185 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000186 static RootWindowControllerList GetAllRootWindowControllers();
187
188 // Returns the primary RootWindow. The primary RootWindow is the one
189 // that has a launcher.
190 static aura::RootWindow* GetPrimaryRootWindow();
191
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100192 // Returns a RootWindow when used as a target when creating a new window.
193 // The root window of the active window is used in most cases, but can
194 // be overridden by using ScopedTargetRootWindow().
195 // If you want to get a RootWindow of the active window, just use
196 // |wm::GetActiveWindow()->GetRootWindow()|.
Torne (Richard Coles)d0247b12013-09-19 22:36:51 +0100197 static aura::RootWindow* GetTargetRootWindow();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000198
199 // Returns the global Screen object that's always active in ash.
200 static gfx::Screen* GetScreen();
201
202 // Returns all root windows.
203 static RootWindowList GetAllRootWindows();
204
205 static aura::Window* GetContainer(aura::RootWindow* root_window,
206 int container_id);
207 static const aura::Window* GetContainer(const aura::RootWindow* root_window,
208 int container_id);
209
210 // Returns the list of containers that match |container_id| in
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000211 // all root windows. If |priority_root| is given, the container
212 // in the |priority_root| will be inserted at the top of the list.
213 static std::vector<aura::Window*> GetContainersFromAllRootWindows(
214 int container_id,
215 aura::RootWindow* priority_root);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000216
Torne (Richard Coles)d0247b12013-09-19 22:36:51 +0100217 void set_target_root_window(aura::RootWindow* target_root_window) {
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100218 target_root_window_ = target_root_window;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000219 }
220
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000221 // Shows the context menu for the background and launcher at
222 // |location_in_screen| (in screen coordinates).
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100223 void ShowContextMenu(const gfx::Point& location_in_screen,
224 ui::MenuSourceType source_type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000225
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000226 // Toggles the app list. |window| specifies in which display the app
227 // list should be shown. If this is NULL, the active root window
228 // will be used.
229 void ToggleAppList(aura::Window* anchor);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000230
231 // Returns app list target visibility.
232 bool GetAppListTargetVisibility() const;
233
234 // Returns app list window or NULL if it is not visible.
235 aura::Window* GetAppListWindow();
236
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000237 // Returns true if a system-modal dialog window is currently open.
238 bool IsSystemModalWindowOpen() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000239
240 // For testing only: set simulation that a modal window is open
241 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
242 simulate_modal_window_open_for_testing_ = modal_window_open;
243 }
244
245 // Creates a default views::NonClientFrameView for use by windows in the
246 // Ash environment.
247 views::NonClientFrameView* CreateDefaultNonClientFrameView(
248 views::Widget* widget);
249
250 // Rotates focus through containers that can receive focus.
251 void RotateFocus(Direction direction);
252
253 // Sets the work area insets of the display that contains |window|,
254 // this notifies observers too.
255 // TODO(sky): this no longer really replicates what happens and is unreliable.
256 // Remove this.
257 void SetDisplayWorkAreaInsets(aura::Window* window,
258 const gfx::Insets& insets);
259
260 // Called when the user logs in.
261 void OnLoginStateChanged(user::LoginStatus status);
262
263 // Called when the login status changes.
264 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
265 void UpdateAfterLoginStatusChange(user::LoginStatus status);
266
267 // Called when the application is exiting.
268 void OnAppTerminating();
269
270 // Called when the screen is locked (after the lock window is visible) or
271 // unlocked.
272 void OnLockStateChanged(bool locked);
273
274 // Initializes |launcher_|. Does nothing if it's already initialized.
275 void CreateLauncher();
276
277 // Show launcher view if it was created hidden (before session has started).
278 void ShowLauncher();
279
280 // Adds/removes observer.
281 void AddShellObserver(ShellObserver* observer);
282 void RemoveShellObserver(ShellObserver* observer);
283
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100284 keyboard::KeyboardController* keyboard_controller() {
285 return keyboard_controller_.get();
286 }
287
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000288 AcceleratorController* accelerator_controller() {
289 return accelerator_controller_.get();
290 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000291
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000292 internal::DisplayManager* display_manager() {
293 return display_manager_.get();
294 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100295 views::corewm::InputMethodEventFilter* input_method_filter() {
296 return input_method_filter_.get();
297 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000298 views::corewm::CompoundEventFilter* env_filter() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000299 return env_filter_.get();
300 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000301 views::corewm::TooltipController* tooltip_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000302 return tooltip_controller_.get();
303 }
304 internal::EventRewriterEventFilter* event_rewriter_filter() {
305 return event_rewriter_filter_.get();
306 }
307 internal::OverlayEventFilter* overlay_filter() {
308 return overlay_filter_.get();
309 }
310 DesktopBackgroundController* desktop_background_controller() {
311 return desktop_background_controller_.get();
312 }
313 PowerButtonController* power_button_controller() {
314 return power_button_controller_.get();
315 }
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100316 LockStateController* lock_state_controller() {
317 return lock_state_controller_.get();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000318 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100319 MruWindowTracker* mru_window_tracker() {
320 return mru_window_tracker_.get();
321 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000322 UserActivityDetector* user_activity_detector() {
323 return user_activity_detector_.get();
324 }
325 VideoDetector* video_detector() {
326 return video_detector_.get();
327 }
328 WindowCycleController* window_cycle_controller() {
329 return window_cycle_controller_.get();
330 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100331 WindowSelectorController* window_selector_controller() {
332 return window_selector_controller_.get();
333 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000334 internal::FocusCycler* focus_cycler() {
335 return focus_cycler_.get();
336 }
337 DisplayController* display_controller() {
338 return display_controller_.get();
339 }
340 internal::MouseCursorEventFilter* mouse_cursor_filter() {
341 return mouse_cursor_filter_.get();
342 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000343 internal::EventTransformationHandler* event_transformation_handler() {
344 return event_transformation_handler_.get();
345 }
346 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000347
348 ShellDelegate* delegate() { return delegate_.get(); }
349
350 UserWallpaperDelegate* user_wallpaper_delegate() {
351 return user_wallpaper_delegate_.get();
352 }
353
354 CapsLockDelegate* caps_lock_delegate() {
355 return caps_lock_delegate_.get();
356 }
357
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100358 SessionStateDelegate* session_state_delegate() {
359 return session_state_delegate_.get();
360 }
361
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000362 HighContrastController* high_contrast_controller() {
363 return high_contrast_controller_.get();
364 }
365
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000366 MagnificationController* magnification_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000367 return magnification_controller_.get();
368 }
369
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000370 PartialMagnificationController* partial_magnification_controller() {
371 return partial_magnification_controller_.get();
372 }
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100373
374 AutoclickController* autoclick_controller() {
375 return autoclick_controller_.get();
376 }
377
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000378 aura::client::ActivationClient* activation_client() {
379 return activation_client_;
380 }
381
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100382 LauncherItemDelegateManager* launcher_item_delegate_manager() {
383 return launcher_item_delegate_manager_.get();
384 }
385
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000386 ScreenAsh* screen() { return screen_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000387
388 // Force the shelf to query for it's current visibility state.
389 void UpdateShelfVisibility();
390
391 // TODO(oshima): Define an interface to access shelf/launcher
392 // state, or just use Launcher.
393
394 // Sets/gets the shelf auto-hide behavior on |root_window|.
395 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
396 aura::RootWindow* root_window);
397 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
398 aura::RootWindow* root_window) const;
399
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000400 // Sets/gets shelf's alignment on |root_window|.
401 void SetShelfAlignment(ShelfAlignment alignment,
402 aura::RootWindow* root_window);
403 ShelfAlignment GetShelfAlignment(aura::RootWindow* root_window);
404
405 // Dims or undims the screen.
406 void SetDimming(bool should_dim);
407
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100408 // Notifies |observers_| when entering or exiting fullscreen mode in
409 // |root_window|.
410 void NotifyFullscreenStateChange(bool is_fullscreen,
411 aura::RootWindow* root_window);
412
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000413 // Creates a modal background (a partially-opaque fullscreen window)
414 // on all displays for |window|.
415 void CreateModalBackground(aura::Window* window);
416
417 // Called when a modal window is removed. It will activate
418 // another modal window if any, or remove modal screens
419 // on all displays.
420 void OnModalWindowRemoved(aura::Window* removed);
421
422 // Returns WebNotificationTray on the primary root window.
423 WebNotificationTray* GetWebNotificationTray();
424
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000425 // Does the primary display have status area?
426 bool HasPrimaryStatusArea();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000427
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000428 // Returns the system tray on primary display.
429 SystemTray* GetPrimarySystemTray();
430
431 SystemTrayDelegate* system_tray_delegate() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000432 return system_tray_delegate_.get();
433 }
434
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000435 SystemTrayNotifier* system_tray_notifier() {
436 return system_tray_notifier_.get();
437 }
438
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000439 static void set_initially_hide_cursor(bool hide) {
440 initially_hide_cursor_ = hide;
441 }
442
443 internal::ResizeShadowController* resize_shadow_controller() {
444 return resize_shadow_controller_.get();
445 }
446
447 // Made available for tests.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000448 views::corewm::ShadowController* shadow_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000449 return shadow_controller_.get();
450 }
451
452 content::BrowserContext* browser_context() { return browser_context_; }
453 void set_browser_context(content::BrowserContext* browser_context) {
454 browser_context_ = browser_context;
455 }
456
457 // Initializes the root window to be used for a secondary display.
458 void InitRootWindowForSecondaryDisplay(aura::RootWindow* root);
459
460 // Starts the animation that occurs on first login.
461 void DoInitialWorkspaceAnimation();
462
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100463#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000464 // TODO(oshima): Move these objects to DisplayController.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000465 chromeos::OutputConfigurator* output_configurator() {
466 return output_configurator_.get();
467 }
468 internal::OutputConfiguratorAnimation* output_configurator_animation() {
469 return output_configurator_animation_.get();
470 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000471 internal::DisplayErrorObserver* display_error_observer() {
472 return display_error_observer_.get();
473 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100474#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000475
Ben Murdochba5b9a62013-08-12 14:20:17 +0100476 internal::ResolutionNotificationController*
477 resolution_notification_controller() {
478 return resolution_notification_controller_.get();
479 }
480
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000481 RootWindowHostFactory* root_window_host_factory() {
482 return root_window_host_factory_.get();
483 }
484
485 LauncherModel* launcher_model() {
486 return launcher_model_.get();
487 }
488
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100489 WindowPositioner* window_positioner() {
490 return window_positioner_.get();
491 }
492
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000493 // Returns the launcher delegate, creating if necesary.
494 LauncherDelegate* GetLauncherDelegate();
495
Ben Murdocheb525c52013-07-10 11:40:50 +0100496 void SetTouchHudProjectionEnabled(bool enabled);
497
498 bool is_touch_hud_projection_enabled() const {
499 return is_touch_hud_projection_enabled_;
500 }
501
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000502 private:
503 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
504 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
505 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
506 friend class internal::RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100507 friend class internal::ScopedTargetRootWindow;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000508 friend class test::ShellTestApi;
509 friend class shell::WindowWatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000510
511 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
512
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100513 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000514 explicit Shell(ShellDelegate* delegate);
515 virtual ~Shell();
516
517 void Init();
518
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100519 // Initializes virtual keyboard controller and attaches it to |root|.
520 void InitKeyboard(internal::RootWindowController* root);
521
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000522 // Initializes the root window and root window controller so that it
Ben Murdocheb525c52013-07-10 11:40:50 +0100523 // can host browser windows. |first_run_after_boot| is true for the
524 // primary display only first time after boot.
525 void InitRootWindowController(internal::RootWindowController* root,
526 bool first_run_after_boot);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000527
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000528 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
529 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
530
531 // Overridden from ui::EventTarget:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000532 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000533 virtual EventTarget* GetParentTarget() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000534 virtual void OnEvent(ui::Event* event) OVERRIDE;
535
536 // Overridden from aura::client::ActivationChangeObserver:
537 virtual void OnWindowActivated(aura::Window* gained_active,
538 aura::Window* lost_active) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000539
540 static Shell* instance_;
541
542 // If set before the Shell is initialized, the mouse cursor will be hidden
543 // when the screen is initially created.
544 static bool initially_hide_cursor_;
545
546 ScreenAsh* screen_;
547
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100548 // When no explicit target display/RootWindow is given, new windows are
549 // created on |scoped_target_root_window_| , unless NULL in
550 // which case they are created on |target_root_window_|.
551 // |target_root_window_| never becomes NULL during the session.
552 aura::RootWindow* target_root_window_;
553 aura::RootWindow* scoped_target_root_window_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000554
555 // The CompoundEventFilter owned by aura::Env object.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000556 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000557
558 std::vector<WindowAndBoundsPair> to_restore_;
559
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100560 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000561 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000562 scoped_ptr<AcceleratorController> accelerator_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000563 scoped_ptr<ShellDelegate> delegate_;
564 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000565 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000566 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
567 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100568 scoped_ptr<SessionStateDelegate> session_state_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000569 scoped_ptr<LauncherDelegate> launcher_delegate_;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100570 scoped_ptr<LauncherItemDelegateManager> launcher_item_delegate_manager_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000571
572 scoped_ptr<LauncherModel> launcher_model_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100573 scoped_ptr<ash::WindowPositioner> window_positioner_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000574
575 scoped_ptr<internal::AppListController> app_list_controller_;
576
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000577 scoped_ptr<internal::DragDropController> drag_drop_controller_;
578 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000579 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
580 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
581 scoped_ptr<views::corewm::WindowModalityController>
582 window_modality_controller_;
583 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000584 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
585 scoped_ptr<PowerButtonController> power_button_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100586 scoped_ptr<LockStateController> lock_state_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100587 scoped_ptr<MruWindowTracker> mru_window_tracker_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000588 scoped_ptr<UserActivityDetector> user_activity_detector_;
589 scoped_ptr<VideoDetector> video_detector_;
590 scoped_ptr<WindowCycleController> window_cycle_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100591 scoped_ptr<WindowSelectorController> window_selector_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000592 scoped_ptr<internal::FocusCycler> focus_cycler_;
593 scoped_ptr<DisplayController> display_controller_;
594 scoped_ptr<HighContrastController> high_contrast_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000595 scoped_ptr<MagnificationController> magnification_controller_;
596 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100597 scoped_ptr<AutoclickController> autoclick_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000598 scoped_ptr<aura::client::FocusClient> focus_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000599 scoped_ptr<aura::client::UserActionClient> user_action_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000600 aura::client::ActivationClient* activation_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000601 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
602 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
603 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
604 scoped_ptr<internal::EventClientImpl> event_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000605 scoped_ptr<internal::EventTransformationHandler>
606 event_transformation_handler_;
607 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000608
609 // An event filter that rewrites or drops an event.
610 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
611
612 // An event filter that pre-handles key events while the partial
613 // screenshot UI or the keyboard overlay is active.
614 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
615
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100616 // An event filter for logging keyboard-related metrics.
617 scoped_ptr<internal::KeyboardUMAEventFilter> keyboard_metrics_filter_;
618
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000619 // An event filter which handles system level gestures
620 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
621
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000622 // An event filter that pre-handles global accelerators.
623 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000624
625 // An event filter that pre-handles all key events to send them to an IME.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000626 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000627
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000628 scoped_ptr<internal::DisplayManager> display_manager_;
629
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100630 scoped_ptr<internal::LocaleNotificationController>
631 locale_notification_controller_;
632
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100633#if defined(OS_CHROMEOS)
634 scoped_ptr<internal::PowerEventObserver> power_event_observer_;
635 scoped_ptr<internal::UserActivityNotifier> user_activity_notifier_;
636 scoped_ptr<internal::VideoActivityNotifier> video_activity_notifier_;
637#if defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000638 // Controls video output device state.
639 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
640 scoped_ptr<internal::OutputConfiguratorAnimation>
641 output_configurator_animation_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000642 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
643
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100644 // Listens for output changes and updates the display manager.
645 scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100646#endif // defined(USE_X11)
647#endif // defined(OS_CHROMEOS)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000648
Ben Murdochba5b9a62013-08-12 14:20:17 +0100649 scoped_ptr<internal::ResolutionNotificationController>
650 resolution_notification_controller_;
651
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000652 // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
653 // pointer to vend to test code.
654 AshNativeCursorManager* native_cursor_manager_;
655 views::corewm::CursorManager cursor_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000656
657 ObserverList<ShellObserver> observers_;
658
659 // Used by ash/shell.
660 content::BrowserContext* browser_context_;
661
662 // For testing only: simulate that a modal window is open
663 bool simulate_modal_window_open_for_testing_;
664
Ben Murdocheb525c52013-07-10 11:40:50 +0100665 bool is_touch_hud_projection_enabled_;
666
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000667 DISALLOW_COPY_AND_ASSIGN(Shell);
668};
669
670} // namespace ash
671
672#endif // ASH_SHELL_H_