blob: 237a1a88666f0ed9273883558034094ab5a40b88 [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)58218062012-11-14 11:43:16 +000021#include "ui/base/events/event_target.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010022#include "ui/base/ui_base_types.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
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010030namespace app_list {
31class ApplicationDragAndDropHost;
32}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000033namespace aura {
34class EventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000035class RootWindow;
36class Window;
37namespace client {
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000038class ActivationClient;
39class FocusClient;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000040class UserActionClient;
41}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000042}
43namespace chromeos {
44class OutputConfigurator;
45}
46namespace content {
47class BrowserContext;
48}
49
50namespace gfx {
51class ImageSkia;
52class Point;
53class Rect;
54}
55namespace ui {
56class Layer;
57}
58namespace views {
59class NonClientFrameView;
60class Widget;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000061namespace corewm {
62class CompoundEventFilter;
63class InputMethodEventFilter;
64class ShadowController;
65class TooltipController;
66class VisibilityController;
67class WindowModalityController;
68}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000069}
70
71namespace ash {
72
73class AcceleratorController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000074class AshNativeCursorManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000075class CapsLockDelegate;
76class DesktopBackgroundController;
77class DisplayController;
78class HighContrastController;
79class Launcher;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000080class LauncherDelegate;
81class LauncherModel;
82class MagnificationController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010083class MruWindowTracker;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000084class NestedDispatcherController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000085class PartialMagnificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000086class PowerButtonController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000087class RootWindowHostFactory;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000088class ScreenAsh;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010089class LockStateController;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010090class SessionStateDelegate;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000091class ShellDelegate;
92class ShellObserver;
93class SystemTray;
94class SystemTrayDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000095class SystemTrayNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000096class UserActivityDetector;
97class UserWallpaperDelegate;
98class VideoDetector;
99class WebNotificationTray;
100class WindowCycleController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100101class WindowSelectorController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000102
103namespace internal {
104class AcceleratorFilter;
105class ActivationController;
106class AppListController;
107class CaptureController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000108class DisplayChangeObserverX11;
109class DisplayErrorObserver;
110class DisplayManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000111class DragDropController;
112class EventClientImpl;
113class EventRewriterEventFilter;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000114class EventTransformationHandler;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000115class FocusCycler;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100116class LocaleNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000117class MouseCursorEventFilter;
118class OutputConfiguratorAnimation;
119class OverlayEventFilter;
120class ResizeShadowController;
121class RootWindowController;
122class RootWindowLayoutManager;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100123class ScopedTargetRootWindow;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000124class ScreenPositionController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000125class SlowAnimationEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000126class StatusAreaWidget;
127class SystemGestureEventFilter;
128class SystemModalContainerEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000129class TouchObserverHUD;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000130}
131
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000132namespace shell {
133class WindowWatcher;
134}
135
136namespace test {
137class ShellTestApi;
138}
139
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000140// Shell is a singleton object that presents the Shell API and implements the
141// RootWindow's delegate interface.
142//
143// Upon creation, the Shell sets itself as the RootWindow's delegate, which
144// takes ownership of the Shell.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000145class ASH_EXPORT Shell
146 : public internal::SystemModalContainerEventFilterDelegate,
147 public ui::EventTarget,
148 public aura::client::ActivationChangeObserver {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000149 public:
150 typedef std::vector<aura::RootWindow*> RootWindowList;
151 typedef std::vector<internal::RootWindowController*> RootWindowControllerList;
152
153 enum Direction {
154 FORWARD,
155 BACKWARD
156 };
157
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000158 // A shell must be explicitly created so that it can call |Init()| with the
159 // delegate set. |delegate| can be NULL (if not required for initialization).
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100160 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000161 static Shell* CreateInstance(ShellDelegate* delegate);
162
163 // Should never be called before |CreateInstance()|.
164 static Shell* GetInstance();
165
166 // Returns true if the ash shell has been instantiated.
167 static bool HasInstance();
168
169 static void DeleteInstance();
170
171 // Returns the root window controller for the primary root window.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000172 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000173 static internal::RootWindowController* GetPrimaryRootWindowController();
174
175 // Returns all root window controllers.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000176 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000177 static RootWindowControllerList GetAllRootWindowControllers();
178
179 // Returns the primary RootWindow. The primary RootWindow is the one
180 // that has a launcher.
181 static aura::RootWindow* GetPrimaryRootWindow();
182
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100183 // Returns a RootWindow when used as a target when creating a new window.
184 // The root window of the active window is used in most cases, but can
185 // be overridden by using ScopedTargetRootWindow().
186 // If you want to get a RootWindow of the active window, just use
187 // |wm::GetActiveWindow()->GetRootWindow()|.
188 // TODO(oshima): Rename to GetTargetRootWindow() crbug.com/266378.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000189 static aura::RootWindow* GetActiveRootWindow();
190
191 // Returns the global Screen object that's always active in ash.
192 static gfx::Screen* GetScreen();
193
194 // Returns all root windows.
195 static RootWindowList GetAllRootWindows();
196
197 static aura::Window* GetContainer(aura::RootWindow* root_window,
198 int container_id);
199 static const aura::Window* GetContainer(const aura::RootWindow* root_window,
200 int container_id);
201
202 // Returns the list of containers that match |container_id| in
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000203 // all root windows. If |priority_root| is given, the container
204 // in the |priority_root| will be inserted at the top of the list.
205 static std::vector<aura::Window*> GetContainersFromAllRootWindows(
206 int container_id,
207 aura::RootWindow* priority_root);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000208
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100209 // True if an experimental maximize mode is enabled which forces browser and
210 // application windows to be maximized only.
211 static bool IsForcedMaximizeMode();
212
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100213 void set_active_root_window(aura::RootWindow* target_root_window) {
214 target_root_window_ = target_root_window;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000215 }
216
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000217 // Shows the context menu for the background and launcher at
218 // |location_in_screen| (in screen coordinates).
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100219 void ShowContextMenu(const gfx::Point& location_in_screen,
220 ui::MenuSourceType source_type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000221
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000222 // Toggles the app list. |window| specifies in which display the app
223 // list should be shown. If this is NULL, the active root window
224 // will be used.
225 void ToggleAppList(aura::Window* anchor);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000226
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +0100227 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
228 // operations outside the application list.
229 void SetDragAndDropHostOfCurrentAppList(
230 app_list::ApplicationDragAndDropHost* drag_and_drop_host);
231
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000232 // Returns app list target visibility.
233 bool GetAppListTargetVisibility() const;
234
235 // Returns app list window or NULL if it is not visible.
236 aura::Window* GetAppListWindow();
237
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000238 // Returns true if a system-modal dialog window is currently open.
239 bool IsSystemModalWindowOpen() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000240
241 // For testing only: set simulation that a modal window is open
242 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
243 simulate_modal_window_open_for_testing_ = modal_window_open;
244 }
245
246 // Creates a default views::NonClientFrameView for use by windows in the
247 // Ash environment.
248 views::NonClientFrameView* CreateDefaultNonClientFrameView(
249 views::Widget* widget);
250
251 // Rotates focus through containers that can receive focus.
252 void RotateFocus(Direction direction);
253
254 // Sets the work area insets of the display that contains |window|,
255 // this notifies observers too.
256 // TODO(sky): this no longer really replicates what happens and is unreliable.
257 // Remove this.
258 void SetDisplayWorkAreaInsets(aura::Window* window,
259 const gfx::Insets& insets);
260
261 // Called when the user logs in.
262 void OnLoginStateChanged(user::LoginStatus status);
263
264 // Called when the login status changes.
265 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
266 void UpdateAfterLoginStatusChange(user::LoginStatus status);
267
268 // Called when the application is exiting.
269 void OnAppTerminating();
270
271 // Called when the screen is locked (after the lock window is visible) or
272 // unlocked.
273 void OnLockStateChanged(bool locked);
274
275 // Initializes |launcher_|. Does nothing if it's already initialized.
276 void CreateLauncher();
277
278 // Show launcher view if it was created hidden (before session has started).
279 void ShowLauncher();
280
281 // Adds/removes observer.
282 void AddShellObserver(ShellObserver* observer);
283 void RemoveShellObserver(ShellObserver* observer);
284
285#if !defined(OS_MACOSX)
286 AcceleratorController* accelerator_controller() {
287 return accelerator_controller_.get();
288 }
289#endif // !defined(OS_MACOSX)
290
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000291 internal::DisplayManager* display_manager() {
292 return display_manager_.get();
293 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100294 views::corewm::InputMethodEventFilter* input_method_filter() {
295 return input_method_filter_.get();
296 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000297 views::corewm::CompoundEventFilter* env_filter() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000298 return env_filter_.get();
299 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000300 views::corewm::TooltipController* tooltip_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000301 return tooltip_controller_.get();
302 }
303 internal::EventRewriterEventFilter* event_rewriter_filter() {
304 return event_rewriter_filter_.get();
305 }
306 internal::OverlayEventFilter* overlay_filter() {
307 return overlay_filter_.get();
308 }
309 DesktopBackgroundController* desktop_background_controller() {
310 return desktop_background_controller_.get();
311 }
312 PowerButtonController* power_button_controller() {
313 return power_button_controller_.get();
314 }
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100315 LockStateController* lock_state_controller() {
316 return lock_state_controller_.get();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000317 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100318 MruWindowTracker* mru_window_tracker() {
319 return mru_window_tracker_.get();
320 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000321 UserActivityDetector* user_activity_detector() {
322 return user_activity_detector_.get();
323 }
324 VideoDetector* video_detector() {
325 return video_detector_.get();
326 }
327 WindowCycleController* window_cycle_controller() {
328 return window_cycle_controller_.get();
329 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100330 WindowSelectorController* window_selector_controller() {
331 return window_selector_controller_.get();
332 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000333 internal::FocusCycler* focus_cycler() {
334 return focus_cycler_.get();
335 }
336 DisplayController* display_controller() {
337 return display_controller_.get();
338 }
339 internal::MouseCursorEventFilter* mouse_cursor_filter() {
340 return mouse_cursor_filter_.get();
341 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000342 internal::EventTransformationHandler* event_transformation_handler() {
343 return event_transformation_handler_.get();
344 }
345 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000346
347 ShellDelegate* delegate() { return delegate_.get(); }
348
349 UserWallpaperDelegate* user_wallpaper_delegate() {
350 return user_wallpaper_delegate_.get();
351 }
352
353 CapsLockDelegate* caps_lock_delegate() {
354 return caps_lock_delegate_.get();
355 }
356
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100357 SessionStateDelegate* session_state_delegate() {
358 return session_state_delegate_.get();
359 }
360
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000361 HighContrastController* high_contrast_controller() {
362 return high_contrast_controller_.get();
363 }
364
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000365 MagnificationController* magnification_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000366 return magnification_controller_.get();
367 }
368
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000369 PartialMagnificationController* partial_magnification_controller() {
370 return partial_magnification_controller_.get();
371 }
372 aura::client::ActivationClient* activation_client() {
373 return activation_client_;
374 }
375
376 ScreenAsh* screen() { return screen_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000377
378 // Force the shelf to query for it's current visibility state.
379 void UpdateShelfVisibility();
380
381 // TODO(oshima): Define an interface to access shelf/launcher
382 // state, or just use Launcher.
383
384 // Sets/gets the shelf auto-hide behavior on |root_window|.
385 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
386 aura::RootWindow* root_window);
387 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
388 aura::RootWindow* root_window) const;
389
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000390 // Sets/gets shelf's alignment on |root_window|.
391 void SetShelfAlignment(ShelfAlignment alignment,
392 aura::RootWindow* root_window);
393 ShelfAlignment GetShelfAlignment(aura::RootWindow* root_window);
394
395 // Dims or undims the screen.
396 void SetDimming(bool should_dim);
397
398 // Creates a modal background (a partially-opaque fullscreen window)
399 // on all displays for |window|.
400 void CreateModalBackground(aura::Window* window);
401
402 // Called when a modal window is removed. It will activate
403 // another modal window if any, or remove modal screens
404 // on all displays.
405 void OnModalWindowRemoved(aura::Window* removed);
406
407 // Returns WebNotificationTray on the primary root window.
408 WebNotificationTray* GetWebNotificationTray();
409
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000410 // Does the primary display have status area?
411 bool HasPrimaryStatusArea();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000412
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000413 // Returns the system tray on primary display.
414 SystemTray* GetPrimarySystemTray();
415
416 SystemTrayDelegate* system_tray_delegate() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000417 return system_tray_delegate_.get();
418 }
419
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000420 SystemTrayNotifier* system_tray_notifier() {
421 return system_tray_notifier_.get();
422 }
423
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000424 static void set_initially_hide_cursor(bool hide) {
425 initially_hide_cursor_ = hide;
426 }
427
428 internal::ResizeShadowController* resize_shadow_controller() {
429 return resize_shadow_controller_.get();
430 }
431
432 // Made available for tests.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000433 views::corewm::ShadowController* shadow_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000434 return shadow_controller_.get();
435 }
436
437 content::BrowserContext* browser_context() { return browser_context_; }
438 void set_browser_context(content::BrowserContext* browser_context) {
439 browser_context_ = browser_context;
440 }
441
442 // Initializes the root window to be used for a secondary display.
443 void InitRootWindowForSecondaryDisplay(aura::RootWindow* root);
444
445 // Starts the animation that occurs on first login.
446 void DoInitialWorkspaceAnimation();
447
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100448#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000449 // TODO(oshima): Move these objects to DisplayController.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000450 chromeos::OutputConfigurator* output_configurator() {
451 return output_configurator_.get();
452 }
453 internal::OutputConfiguratorAnimation* output_configurator_animation() {
454 return output_configurator_animation_.get();
455 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000456 internal::DisplayErrorObserver* display_error_observer() {
457 return display_error_observer_.get();
458 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100459#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000460
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000461 RootWindowHostFactory* root_window_host_factory() {
462 return root_window_host_factory_.get();
463 }
464
465 LauncherModel* launcher_model() {
466 return launcher_model_.get();
467 }
468
469 // Returns the launcher delegate, creating if necesary.
470 LauncherDelegate* GetLauncherDelegate();
471
Ben Murdocheb525c52013-07-10 11:40:50 +0100472 void SetTouchHudProjectionEnabled(bool enabled);
473
474 bool is_touch_hud_projection_enabled() const {
475 return is_touch_hud_projection_enabled_;
476 }
477
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000478 private:
479 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
480 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
481 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
482 friend class internal::RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100483 friend class internal::ScopedTargetRootWindow;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000484 friend class test::ShellTestApi;
485 friend class shell::WindowWatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000486
487 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
488
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100489 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000490 explicit Shell(ShellDelegate* delegate);
491 virtual ~Shell();
492
493 void Init();
494
495 // Initializes the root window and root window controller so that it
Ben Murdocheb525c52013-07-10 11:40:50 +0100496 // can host browser windows. |first_run_after_boot| is true for the
497 // primary display only first time after boot.
498 void InitRootWindowController(internal::RootWindowController* root,
499 bool first_run_after_boot);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000500
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000501 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
502 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
503
504 // Overridden from ui::EventTarget:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000505 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000506 virtual EventTarget* GetParentTarget() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000507 virtual void OnEvent(ui::Event* event) OVERRIDE;
508
509 // Overridden from aura::client::ActivationChangeObserver:
510 virtual void OnWindowActivated(aura::Window* gained_active,
511 aura::Window* lost_active) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000512
513 static Shell* instance_;
514
515 // If set before the Shell is initialized, the mouse cursor will be hidden
516 // when the screen is initially created.
517 static bool initially_hide_cursor_;
518
519 ScreenAsh* screen_;
520
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100521 // When no explicit target display/RootWindow is given, new windows are
522 // created on |scoped_target_root_window_| , unless NULL in
523 // which case they are created on |target_root_window_|.
524 // |target_root_window_| never becomes NULL during the session.
525 aura::RootWindow* target_root_window_;
526 aura::RootWindow* scoped_target_root_window_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000527
528 // The CompoundEventFilter owned by aura::Env object.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000529 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000530
531 std::vector<WindowAndBoundsPair> to_restore_;
532
533#if !defined(OS_MACOSX)
534 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
535
536 scoped_ptr<AcceleratorController> accelerator_controller_;
537#endif // !defined(OS_MACOSX)
538
539 scoped_ptr<ShellDelegate> delegate_;
540 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000541 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000542 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
543 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100544 scoped_ptr<SessionStateDelegate> session_state_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000545 scoped_ptr<LauncherDelegate> launcher_delegate_;
546
547 scoped_ptr<LauncherModel> launcher_model_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000548
549 scoped_ptr<internal::AppListController> app_list_controller_;
550
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000551 scoped_ptr<internal::ActivationController> activation_controller_;
552 scoped_ptr<internal::CaptureController> capture_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000553 scoped_ptr<internal::DragDropController> drag_drop_controller_;
554 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000555 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
556 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
557 scoped_ptr<views::corewm::WindowModalityController>
558 window_modality_controller_;
559 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000560 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
561 scoped_ptr<PowerButtonController> power_button_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100562 scoped_ptr<LockStateController> lock_state_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100563 scoped_ptr<MruWindowTracker> mru_window_tracker_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000564 scoped_ptr<UserActivityDetector> user_activity_detector_;
565 scoped_ptr<VideoDetector> video_detector_;
566 scoped_ptr<WindowCycleController> window_cycle_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100567 scoped_ptr<WindowSelectorController> window_selector_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000568 scoped_ptr<internal::FocusCycler> focus_cycler_;
569 scoped_ptr<DisplayController> display_controller_;
570 scoped_ptr<HighContrastController> high_contrast_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000571 scoped_ptr<MagnificationController> magnification_controller_;
572 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
573 scoped_ptr<aura::client::FocusClient> focus_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000574 scoped_ptr<aura::client::UserActionClient> user_action_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000575 aura::client::ActivationClient* activation_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000576 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
577 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
578 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
579 scoped_ptr<internal::EventClientImpl> event_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000580 scoped_ptr<internal::EventTransformationHandler>
581 event_transformation_handler_;
582 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000583
584 // An event filter that rewrites or drops an event.
585 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
586
587 // An event filter that pre-handles key events while the partial
588 // screenshot UI or the keyboard overlay is active.
589 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
590
591 // An event filter which handles system level gestures
592 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
593
594#if !defined(OS_MACOSX)
595 // An event filter that pre-handles global accelerators.
596 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
597#endif
598
599 // An event filter that pre-handles all key events to send them to an IME.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000600 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000601
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000602 scoped_ptr<internal::DisplayManager> display_manager_;
603
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100604 scoped_ptr<internal::LocaleNotificationController>
605 locale_notification_controller_;
606
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100607#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000608 // Controls video output device state.
609 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
610 scoped_ptr<internal::OutputConfiguratorAnimation>
611 output_configurator_animation_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000612 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
613
614 // Receives output change events and udpates the display manager.
615 scoped_ptr<internal::DisplayChangeObserverX11> display_change_observer_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100616#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000617
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000618 // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
619 // pointer to vend to test code.
620 AshNativeCursorManager* native_cursor_manager_;
621 views::corewm::CursorManager cursor_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000622
623 ObserverList<ShellObserver> observers_;
624
625 // Used by ash/shell.
626 content::BrowserContext* browser_context_;
627
628 // For testing only: simulate that a modal window is open
629 bool simulate_modal_window_open_for_testing_;
630
Ben Murdocheb525c52013-07-10 11:40:50 +0100631 bool is_touch_hud_projection_enabled_;
632
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000633 DISALLOW_COPY_AND_ASSIGN(Shell);
634};
635
636} // namespace ash
637
638#endif // ASH_SHELL_H_