blob: 718d1f839d3396ec08c96e42418b8b702ad041f1 [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
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}
52namespace ui {
53class Layer;
54}
55namespace views {
56class NonClientFrameView;
57class Widget;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000058namespace corewm {
59class CompoundEventFilter;
60class InputMethodEventFilter;
61class ShadowController;
62class TooltipController;
63class VisibilityController;
64class WindowModalityController;
65}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000066}
67
68namespace ash {
69
70class AcceleratorController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000071class AshNativeCursorManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000072class CapsLockDelegate;
73class DesktopBackgroundController;
74class DisplayController;
75class HighContrastController;
76class Launcher;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000077class LauncherDelegate;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +010078class LauncherItemDelegateManager;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000079class LauncherModel;
80class MagnificationController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010081class MruWindowTracker;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000082class NestedDispatcherController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000083class PartialMagnificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000084class PowerButtonController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000085class RootWindowHostFactory;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000086class ScreenAsh;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010087class LockStateController;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010088class SessionStateDelegate;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000089class ShellDelegate;
90class ShellObserver;
91class SystemTray;
92class SystemTrayDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000093class SystemTrayNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000094class UserActivityDetector;
95class UserWallpaperDelegate;
96class VideoDetector;
97class WebNotificationTray;
98class WindowCycleController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010099class WindowSelectorController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000100
101namespace internal {
102class AcceleratorFilter;
103class ActivationController;
104class AppListController;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100105class AppListLauncherItemDelegate;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000106class CaptureController;
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100107class DisplayChangeObserver;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000108class DisplayErrorObserver;
109class DisplayManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000110class DragDropController;
111class EventClientImpl;
112class EventRewriterEventFilter;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000113class EventTransformationHandler;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000114class FocusCycler;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100115class LocaleNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000116class MouseCursorEventFilter;
117class OutputConfiguratorAnimation;
118class OverlayEventFilter;
119class ResizeShadowController;
Ben Murdochba5b9a62013-08-12 14:20:17 +0100120class ResolutionNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000121class 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
227 // Returns app list target visibility.
228 bool GetAppListTargetVisibility() const;
229
230 // Returns app list window or NULL if it is not visible.
231 aura::Window* GetAppListWindow();
232
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000233 // Returns true if a system-modal dialog window is currently open.
234 bool IsSystemModalWindowOpen() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000235
236 // For testing only: set simulation that a modal window is open
237 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
238 simulate_modal_window_open_for_testing_ = modal_window_open;
239 }
240
241 // Creates a default views::NonClientFrameView for use by windows in the
242 // Ash environment.
243 views::NonClientFrameView* CreateDefaultNonClientFrameView(
244 views::Widget* widget);
245
246 // Rotates focus through containers that can receive focus.
247 void RotateFocus(Direction direction);
248
249 // Sets the work area insets of the display that contains |window|,
250 // this notifies observers too.
251 // TODO(sky): this no longer really replicates what happens and is unreliable.
252 // Remove this.
253 void SetDisplayWorkAreaInsets(aura::Window* window,
254 const gfx::Insets& insets);
255
256 // Called when the user logs in.
257 void OnLoginStateChanged(user::LoginStatus status);
258
259 // Called when the login status changes.
260 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
261 void UpdateAfterLoginStatusChange(user::LoginStatus status);
262
263 // Called when the application is exiting.
264 void OnAppTerminating();
265
266 // Called when the screen is locked (after the lock window is visible) or
267 // unlocked.
268 void OnLockStateChanged(bool locked);
269
270 // Initializes |launcher_|. Does nothing if it's already initialized.
271 void CreateLauncher();
272
273 // Show launcher view if it was created hidden (before session has started).
274 void ShowLauncher();
275
276 // Adds/removes observer.
277 void AddShellObserver(ShellObserver* observer);
278 void RemoveShellObserver(ShellObserver* observer);
279
280#if !defined(OS_MACOSX)
281 AcceleratorController* accelerator_controller() {
282 return accelerator_controller_.get();
283 }
284#endif // !defined(OS_MACOSX)
285
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000286 internal::DisplayManager* display_manager() {
287 return display_manager_.get();
288 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100289 views::corewm::InputMethodEventFilter* input_method_filter() {
290 return input_method_filter_.get();
291 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000292 views::corewm::CompoundEventFilter* env_filter() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000293 return env_filter_.get();
294 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000295 views::corewm::TooltipController* tooltip_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000296 return tooltip_controller_.get();
297 }
298 internal::EventRewriterEventFilter* event_rewriter_filter() {
299 return event_rewriter_filter_.get();
300 }
301 internal::OverlayEventFilter* overlay_filter() {
302 return overlay_filter_.get();
303 }
304 DesktopBackgroundController* desktop_background_controller() {
305 return desktop_background_controller_.get();
306 }
307 PowerButtonController* power_button_controller() {
308 return power_button_controller_.get();
309 }
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100310 LockStateController* lock_state_controller() {
311 return lock_state_controller_.get();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000312 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100313 MruWindowTracker* mru_window_tracker() {
314 return mru_window_tracker_.get();
315 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000316 UserActivityDetector* user_activity_detector() {
317 return user_activity_detector_.get();
318 }
319 VideoDetector* video_detector() {
320 return video_detector_.get();
321 }
322 WindowCycleController* window_cycle_controller() {
323 return window_cycle_controller_.get();
324 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100325 WindowSelectorController* window_selector_controller() {
326 return window_selector_controller_.get();
327 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000328 internal::FocusCycler* focus_cycler() {
329 return focus_cycler_.get();
330 }
331 DisplayController* display_controller() {
332 return display_controller_.get();
333 }
334 internal::MouseCursorEventFilter* mouse_cursor_filter() {
335 return mouse_cursor_filter_.get();
336 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000337 internal::EventTransformationHandler* event_transformation_handler() {
338 return event_transformation_handler_.get();
339 }
340 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000341
342 ShellDelegate* delegate() { return delegate_.get(); }
343
344 UserWallpaperDelegate* user_wallpaper_delegate() {
345 return user_wallpaper_delegate_.get();
346 }
347
348 CapsLockDelegate* caps_lock_delegate() {
349 return caps_lock_delegate_.get();
350 }
351
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100352 SessionStateDelegate* session_state_delegate() {
353 return session_state_delegate_.get();
354 }
355
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000356 HighContrastController* high_contrast_controller() {
357 return high_contrast_controller_.get();
358 }
359
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000360 MagnificationController* magnification_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000361 return magnification_controller_.get();
362 }
363
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000364 PartialMagnificationController* partial_magnification_controller() {
365 return partial_magnification_controller_.get();
366 }
367 aura::client::ActivationClient* activation_client() {
368 return activation_client_;
369 }
370
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100371 LauncherItemDelegateManager* launcher_item_delegate_manager() {
372 return launcher_item_delegate_manager_.get();
373 }
374
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000375 ScreenAsh* screen() { return screen_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000376
377 // Force the shelf to query for it's current visibility state.
378 void UpdateShelfVisibility();
379
380 // TODO(oshima): Define an interface to access shelf/launcher
381 // state, or just use Launcher.
382
383 // Sets/gets the shelf auto-hide behavior on |root_window|.
384 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
385 aura::RootWindow* root_window);
386 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
387 aura::RootWindow* root_window) const;
388
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000389 // Sets/gets shelf's alignment on |root_window|.
390 void SetShelfAlignment(ShelfAlignment alignment,
391 aura::RootWindow* root_window);
392 ShelfAlignment GetShelfAlignment(aura::RootWindow* root_window);
393
394 // Dims or undims the screen.
395 void SetDimming(bool should_dim);
396
397 // Creates a modal background (a partially-opaque fullscreen window)
398 // on all displays for |window|.
399 void CreateModalBackground(aura::Window* window);
400
401 // Called when a modal window is removed. It will activate
402 // another modal window if any, or remove modal screens
403 // on all displays.
404 void OnModalWindowRemoved(aura::Window* removed);
405
406 // Returns WebNotificationTray on the primary root window.
407 WebNotificationTray* GetWebNotificationTray();
408
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000409 // Does the primary display have status area?
410 bool HasPrimaryStatusArea();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000411
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000412 // Returns the system tray on primary display.
413 SystemTray* GetPrimarySystemTray();
414
415 SystemTrayDelegate* system_tray_delegate() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000416 return system_tray_delegate_.get();
417 }
418
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000419 SystemTrayNotifier* system_tray_notifier() {
420 return system_tray_notifier_.get();
421 }
422
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000423 static void set_initially_hide_cursor(bool hide) {
424 initially_hide_cursor_ = hide;
425 }
426
427 internal::ResizeShadowController* resize_shadow_controller() {
428 return resize_shadow_controller_.get();
429 }
430
431 // Made available for tests.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000432 views::corewm::ShadowController* shadow_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000433 return shadow_controller_.get();
434 }
435
436 content::BrowserContext* browser_context() { return browser_context_; }
437 void set_browser_context(content::BrowserContext* browser_context) {
438 browser_context_ = browser_context;
439 }
440
441 // Initializes the root window to be used for a secondary display.
442 void InitRootWindowForSecondaryDisplay(aura::RootWindow* root);
443
444 // Starts the animation that occurs on first login.
445 void DoInitialWorkspaceAnimation();
446
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100447#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000448 // TODO(oshima): Move these objects to DisplayController.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000449 chromeos::OutputConfigurator* output_configurator() {
450 return output_configurator_.get();
451 }
452 internal::OutputConfiguratorAnimation* output_configurator_animation() {
453 return output_configurator_animation_.get();
454 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000455 internal::DisplayErrorObserver* display_error_observer() {
456 return display_error_observer_.get();
457 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100458#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000459
Ben Murdochba5b9a62013-08-12 14:20:17 +0100460 internal::ResolutionNotificationController*
461 resolution_notification_controller() {
462 return resolution_notification_controller_.get();
463 }
464
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000465 RootWindowHostFactory* root_window_host_factory() {
466 return root_window_host_factory_.get();
467 }
468
469 LauncherModel* launcher_model() {
470 return launcher_model_.get();
471 }
472
473 // Returns the launcher delegate, creating if necesary.
474 LauncherDelegate* GetLauncherDelegate();
475
Ben Murdocheb525c52013-07-10 11:40:50 +0100476 void SetTouchHudProjectionEnabled(bool enabled);
477
478 bool is_touch_hud_projection_enabled() const {
479 return is_touch_hud_projection_enabled_;
480 }
481
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000482 private:
483 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
484 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
485 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
486 friend class internal::RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100487 friend class internal::ScopedTargetRootWindow;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000488 friend class test::ShellTestApi;
489 friend class shell::WindowWatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000490
491 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
492
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100493 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000494 explicit Shell(ShellDelegate* delegate);
495 virtual ~Shell();
496
497 void Init();
498
499 // Initializes the root window and root window controller so that it
Ben Murdocheb525c52013-07-10 11:40:50 +0100500 // can host browser windows. |first_run_after_boot| is true for the
501 // primary display only first time after boot.
502 void InitRootWindowController(internal::RootWindowController* root,
503 bool first_run_after_boot);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000504
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000505 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
506 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
507
508 // Overridden from ui::EventTarget:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000509 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000510 virtual EventTarget* GetParentTarget() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000511 virtual void OnEvent(ui::Event* event) OVERRIDE;
512
513 // Overridden from aura::client::ActivationChangeObserver:
514 virtual void OnWindowActivated(aura::Window* gained_active,
515 aura::Window* lost_active) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000516
517 static Shell* instance_;
518
519 // If set before the Shell is initialized, the mouse cursor will be hidden
520 // when the screen is initially created.
521 static bool initially_hide_cursor_;
522
523 ScreenAsh* screen_;
524
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100525 // When no explicit target display/RootWindow is given, new windows are
526 // created on |scoped_target_root_window_| , unless NULL in
527 // which case they are created on |target_root_window_|.
528 // |target_root_window_| never becomes NULL during the session.
529 aura::RootWindow* target_root_window_;
530 aura::RootWindow* scoped_target_root_window_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000531
532 // The CompoundEventFilter owned by aura::Env object.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000533 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000534
535 std::vector<WindowAndBoundsPair> to_restore_;
536
537#if !defined(OS_MACOSX)
538 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
539
540 scoped_ptr<AcceleratorController> accelerator_controller_;
541#endif // !defined(OS_MACOSX)
542
543 scoped_ptr<ShellDelegate> delegate_;
544 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000545 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000546 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
547 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100548 scoped_ptr<SessionStateDelegate> session_state_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000549 scoped_ptr<LauncherDelegate> launcher_delegate_;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100550 scoped_ptr<LauncherItemDelegateManager> launcher_item_delegate_manager_;
551 scoped_ptr<internal::AppListLauncherItemDelegate>
552 app_list_launcher_item_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000553
554 scoped_ptr<LauncherModel> launcher_model_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000555
556 scoped_ptr<internal::AppListController> app_list_controller_;
557
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000558 scoped_ptr<internal::ActivationController> activation_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000559 scoped_ptr<internal::DragDropController> drag_drop_controller_;
560 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000561 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
562 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
563 scoped_ptr<views::corewm::WindowModalityController>
564 window_modality_controller_;
565 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000566 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
567 scoped_ptr<PowerButtonController> power_button_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100568 scoped_ptr<LockStateController> lock_state_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100569 scoped_ptr<MruWindowTracker> mru_window_tracker_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000570 scoped_ptr<UserActivityDetector> user_activity_detector_;
571 scoped_ptr<VideoDetector> video_detector_;
572 scoped_ptr<WindowCycleController> window_cycle_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100573 scoped_ptr<WindowSelectorController> window_selector_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000574 scoped_ptr<internal::FocusCycler> focus_cycler_;
575 scoped_ptr<DisplayController> display_controller_;
576 scoped_ptr<HighContrastController> high_contrast_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000577 scoped_ptr<MagnificationController> magnification_controller_;
578 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
579 scoped_ptr<aura::client::FocusClient> focus_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000580 scoped_ptr<aura::client::UserActionClient> user_action_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000581 aura::client::ActivationClient* activation_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000582 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
583 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
584 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
585 scoped_ptr<internal::EventClientImpl> event_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000586 scoped_ptr<internal::EventTransformationHandler>
587 event_transformation_handler_;
588 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000589
590 // An event filter that rewrites or drops an event.
591 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
592
593 // An event filter that pre-handles key events while the partial
594 // screenshot UI or the keyboard overlay is active.
595 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
596
597 // An event filter which handles system level gestures
598 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
599
600#if !defined(OS_MACOSX)
601 // An event filter that pre-handles global accelerators.
602 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
603#endif
604
605 // An event filter that pre-handles all key events to send them to an IME.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000606 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000607
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000608 scoped_ptr<internal::DisplayManager> display_manager_;
609
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100610 scoped_ptr<internal::LocaleNotificationController>
611 locale_notification_controller_;
612
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100613#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000614 // Controls video output device state.
615 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
616 scoped_ptr<internal::OutputConfiguratorAnimation>
617 output_configurator_animation_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000618 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
619
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100620 // Listens for output changes and updates the display manager.
621 scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100622#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000623
Ben Murdochba5b9a62013-08-12 14:20:17 +0100624 scoped_ptr<internal::ResolutionNotificationController>
625 resolution_notification_controller_;
626
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000627 // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
628 // pointer to vend to test code.
629 AshNativeCursorManager* native_cursor_manager_;
630 views::corewm::CursorManager cursor_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000631
632 ObserverList<ShellObserver> observers_;
633
634 // Used by ash/shell.
635 content::BrowserContext* browser_context_;
636
637 // For testing only: simulate that a modal window is open
638 bool simulate_modal_window_open_for_testing_;
639
Ben Murdocheb525c52013-07-10 11:40:50 +0100640 bool is_touch_hud_projection_enabled_;
641
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000642 DISALLOW_COPY_AND_ASSIGN(Shell);
643};
644
645} // namespace ash
646
647#endif // ASH_SHELL_H_