blob: af884f40fd5e700777b0dbf18ae9f4a698ed07cf [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
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +010030namespace app_list {
31class AppListView;
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}
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010055
56namespace keyboard {
57class KeyboardController;
58}
59
Torne (Richard Coles)58218062012-11-14 11:43:16 +000060namespace ui {
61class Layer;
62}
63namespace views {
64class NonClientFrameView;
65class Widget;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000066namespace corewm {
67class CompoundEventFilter;
68class InputMethodEventFilter;
69class ShadowController;
70class TooltipController;
71class VisibilityController;
72class WindowModalityController;
73}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000074}
75
76namespace ash {
77
78class AcceleratorController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000079class AshNativeCursorManager;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010080class AutoclickController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000081class CapsLockDelegate;
82class DesktopBackgroundController;
83class DisplayController;
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +010084class FirstRunHelper;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000085class HighContrastController;
86class Launcher;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000087class LauncherDelegate;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010088class LauncherItemDelegate;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +010089class LauncherItemDelegateManager;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000090class LauncherModel;
91class MagnificationController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010092class MruWindowTracker;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000093class NestedDispatcherController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000094class PartialMagnificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000095class PowerButtonController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000096class RootWindowHostFactory;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000097class ScreenAsh;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010098class LockStateController;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010099class SessionStateDelegate;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000100class ShellDelegate;
101class ShellObserver;
102class SystemTray;
103class SystemTrayDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000104class SystemTrayNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000105class UserActivityDetector;
106class UserWallpaperDelegate;
107class VideoDetector;
108class WebNotificationTray;
109class WindowCycleController;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100110class WindowPositioner;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100111class WindowSelectorController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000112
113namespace internal {
114class AcceleratorFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000115class AppListController;
116class CaptureController;
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100117class DisplayChangeObserver;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000118class DisplayErrorObserver;
119class DisplayManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000120class DragDropController;
121class EventClientImpl;
122class EventRewriterEventFilter;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000123class EventTransformationHandler;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000124class FocusCycler;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100125class KeyboardUMAEventFilter;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100126class LocaleNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000127class MouseCursorEventFilter;
128class OutputConfiguratorAnimation;
129class OverlayEventFilter;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100130class PowerEventObserver;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000131class ResizeShadowController;
Ben Murdochba5b9a62013-08-12 14:20:17 +0100132class ResolutionNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000133class RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100134class ScopedTargetRootWindow;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000135class ScreenPositionController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000136class SlowAnimationEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000137class StatusAreaWidget;
138class SystemGestureEventFilter;
139class SystemModalContainerEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000140class TouchObserverHUD;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100141class UserActivityNotifier;
142class VideoActivityNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000143}
144
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000145namespace shell {
146class WindowWatcher;
147}
148
149namespace test {
150class ShellTestApi;
151}
152
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000153// Shell is a singleton object that presents the Shell API and implements the
154// RootWindow's delegate interface.
155//
156// Upon creation, the Shell sets itself as the RootWindow's delegate, which
157// takes ownership of the Shell.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000158class ASH_EXPORT Shell
159 : public internal::SystemModalContainerEventFilterDelegate,
160 public ui::EventTarget,
161 public aura::client::ActivationChangeObserver {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000162 public:
163 typedef std::vector<aura::RootWindow*> RootWindowList;
164 typedef std::vector<internal::RootWindowController*> RootWindowControllerList;
165
166 enum Direction {
167 FORWARD,
168 BACKWARD
169 };
170
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000171 // A shell must be explicitly created so that it can call |Init()| with the
172 // delegate set. |delegate| can be NULL (if not required for initialization).
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100173 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000174 static Shell* CreateInstance(ShellDelegate* delegate);
175
176 // Should never be called before |CreateInstance()|.
177 static Shell* GetInstance();
178
179 // Returns true if the ash shell has been instantiated.
180 static bool HasInstance();
181
182 static void DeleteInstance();
183
184 // Returns the root window controller for the primary root window.
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 internal::RootWindowController* GetPrimaryRootWindowController();
187
188 // Returns all root window controllers.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000189 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000190 static RootWindowControllerList GetAllRootWindowControllers();
191
192 // Returns the primary RootWindow. The primary RootWindow is the one
193 // that has a launcher.
194 static aura::RootWindow* GetPrimaryRootWindow();
195
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100196 // Returns a RootWindow when used as a target when creating a new window.
197 // The root window of the active window is used in most cases, but can
198 // be overridden by using ScopedTargetRootWindow().
199 // If you want to get a RootWindow of the active window, just use
200 // |wm::GetActiveWindow()->GetRootWindow()|.
Torne (Richard Coles)d0247b12013-09-19 22:36:51 +0100201 static aura::RootWindow* GetTargetRootWindow();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000202
203 // Returns the global Screen object that's always active in ash.
204 static gfx::Screen* GetScreen();
205
206 // Returns all root windows.
207 static RootWindowList GetAllRootWindows();
208
209 static aura::Window* GetContainer(aura::RootWindow* root_window,
210 int container_id);
211 static const aura::Window* GetContainer(const aura::RootWindow* root_window,
212 int container_id);
213
214 // Returns the list of containers that match |container_id| in
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000215 // all root windows. If |priority_root| is given, the container
216 // in the |priority_root| will be inserted at the top of the list.
217 static std::vector<aura::Window*> GetContainersFromAllRootWindows(
218 int container_id,
219 aura::RootWindow* priority_root);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000220
Torne (Richard Coles)d0247b12013-09-19 22:36:51 +0100221 void set_target_root_window(aura::RootWindow* target_root_window) {
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100222 target_root_window_ = target_root_window;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000223 }
224
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000225 // Shows the context menu for the background and launcher at
226 // |location_in_screen| (in screen coordinates).
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100227 void ShowContextMenu(const gfx::Point& location_in_screen,
228 ui::MenuSourceType source_type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000229
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000230 // Toggles the app list. |window| specifies in which display the app
231 // list should be shown. If this is NULL, the active root window
232 // will be used.
233 void ToggleAppList(aura::Window* anchor);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000234
235 // Returns app list target visibility.
236 bool GetAppListTargetVisibility() const;
237
238 // Returns app list window or NULL if it is not visible.
239 aura::Window* GetAppListWindow();
240
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100241 // Returns app list view or NULL if it is not visible.
242 app_list::AppListView* GetAppListView();
243
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000244 // Returns true if a system-modal dialog window is currently open.
245 bool IsSystemModalWindowOpen() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000246
247 // For testing only: set simulation that a modal window is open
248 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
249 simulate_modal_window_open_for_testing_ = modal_window_open;
250 }
251
252 // Creates a default views::NonClientFrameView for use by windows in the
253 // Ash environment.
254 views::NonClientFrameView* CreateDefaultNonClientFrameView(
255 views::Widget* widget);
256
257 // Rotates focus through containers that can receive focus.
258 void RotateFocus(Direction direction);
259
260 // Sets the work area insets of the display that contains |window|,
261 // this notifies observers too.
262 // TODO(sky): this no longer really replicates what happens and is unreliable.
263 // Remove this.
264 void SetDisplayWorkAreaInsets(aura::Window* window,
265 const gfx::Insets& insets);
266
267 // Called when the user logs in.
268 void OnLoginStateChanged(user::LoginStatus status);
269
270 // Called when the login status changes.
271 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
272 void UpdateAfterLoginStatusChange(user::LoginStatus status);
273
274 // Called when the application is exiting.
275 void OnAppTerminating();
276
277 // Called when the screen is locked (after the lock window is visible) or
278 // unlocked.
279 void OnLockStateChanged(bool locked);
280
281 // Initializes |launcher_|. Does nothing if it's already initialized.
282 void CreateLauncher();
283
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100284 // Show shelf view if it was created hidden (before session has started).
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000285 void ShowLauncher();
286
287 // Adds/removes observer.
288 void AddShellObserver(ShellObserver* observer);
289 void RemoveShellObserver(ShellObserver* observer);
290
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100291 keyboard::KeyboardController* keyboard_controller() {
292 return keyboard_controller_.get();
293 }
294
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000295 AcceleratorController* accelerator_controller() {
296 return accelerator_controller_.get();
297 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000298
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000299 internal::DisplayManager* display_manager() {
300 return display_manager_.get();
301 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100302 views::corewm::InputMethodEventFilter* input_method_filter() {
303 return input_method_filter_.get();
304 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000305 views::corewm::CompoundEventFilter* env_filter() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000306 return env_filter_.get();
307 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000308 views::corewm::TooltipController* tooltip_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000309 return tooltip_controller_.get();
310 }
311 internal::EventRewriterEventFilter* event_rewriter_filter() {
312 return event_rewriter_filter_.get();
313 }
314 internal::OverlayEventFilter* overlay_filter() {
315 return overlay_filter_.get();
316 }
317 DesktopBackgroundController* desktop_background_controller() {
318 return desktop_background_controller_.get();
319 }
320 PowerButtonController* power_button_controller() {
321 return power_button_controller_.get();
322 }
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100323 LockStateController* lock_state_controller() {
324 return lock_state_controller_.get();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000325 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100326 MruWindowTracker* mru_window_tracker() {
327 return mru_window_tracker_.get();
328 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000329 UserActivityDetector* user_activity_detector() {
330 return user_activity_detector_.get();
331 }
332 VideoDetector* video_detector() {
333 return video_detector_.get();
334 }
335 WindowCycleController* window_cycle_controller() {
336 return window_cycle_controller_.get();
337 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100338 WindowSelectorController* window_selector_controller() {
339 return window_selector_controller_.get();
340 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000341 internal::FocusCycler* focus_cycler() {
342 return focus_cycler_.get();
343 }
344 DisplayController* display_controller() {
345 return display_controller_.get();
346 }
347 internal::MouseCursorEventFilter* mouse_cursor_filter() {
348 return mouse_cursor_filter_.get();
349 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000350 internal::EventTransformationHandler* event_transformation_handler() {
351 return event_transformation_handler_.get();
352 }
353 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000354
355 ShellDelegate* delegate() { return delegate_.get(); }
356
357 UserWallpaperDelegate* user_wallpaper_delegate() {
358 return user_wallpaper_delegate_.get();
359 }
360
361 CapsLockDelegate* caps_lock_delegate() {
362 return caps_lock_delegate_.get();
363 }
364
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100365 SessionStateDelegate* session_state_delegate() {
366 return session_state_delegate_.get();
367 }
368
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000369 HighContrastController* high_contrast_controller() {
370 return high_contrast_controller_.get();
371 }
372
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000373 MagnificationController* magnification_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000374 return magnification_controller_.get();
375 }
376
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000377 PartialMagnificationController* partial_magnification_controller() {
378 return partial_magnification_controller_.get();
379 }
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100380
381 AutoclickController* autoclick_controller() {
382 return autoclick_controller_.get();
383 }
384
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000385 aura::client::ActivationClient* activation_client() {
386 return activation_client_;
387 }
388
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100389 LauncherItemDelegateManager* launcher_item_delegate_manager() {
390 return launcher_item_delegate_manager_.get();
391 }
392
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000393 ScreenAsh* screen() { return screen_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000394
395 // Force the shelf to query for it's current visibility state.
396 void UpdateShelfVisibility();
397
398 // TODO(oshima): Define an interface to access shelf/launcher
399 // state, or just use Launcher.
400
401 // Sets/gets the shelf auto-hide behavior on |root_window|.
402 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
403 aura::RootWindow* root_window);
404 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
405 aura::RootWindow* root_window) const;
406
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000407 // Sets/gets shelf's alignment on |root_window|.
408 void SetShelfAlignment(ShelfAlignment alignment,
409 aura::RootWindow* root_window);
410 ShelfAlignment GetShelfAlignment(aura::RootWindow* root_window);
411
412 // Dims or undims the screen.
413 void SetDimming(bool should_dim);
414
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100415 // Notifies |observers_| when entering or exiting fullscreen mode in
416 // |root_window|.
417 void NotifyFullscreenStateChange(bool is_fullscreen,
418 aura::RootWindow* root_window);
419
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000420 // Creates a modal background (a partially-opaque fullscreen window)
421 // on all displays for |window|.
422 void CreateModalBackground(aura::Window* window);
423
424 // Called when a modal window is removed. It will activate
425 // another modal window if any, or remove modal screens
426 // on all displays.
427 void OnModalWindowRemoved(aura::Window* removed);
428
429 // Returns WebNotificationTray on the primary root window.
430 WebNotificationTray* GetWebNotificationTray();
431
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000432 // Does the primary display have status area?
433 bool HasPrimaryStatusArea();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000434
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000435 // Returns the system tray on primary display.
436 SystemTray* GetPrimarySystemTray();
437
438 SystemTrayDelegate* system_tray_delegate() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000439 return system_tray_delegate_.get();
440 }
441
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000442 SystemTrayNotifier* system_tray_notifier() {
443 return system_tray_notifier_.get();
444 }
445
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000446 static void set_initially_hide_cursor(bool hide) {
447 initially_hide_cursor_ = hide;
448 }
449
450 internal::ResizeShadowController* resize_shadow_controller() {
451 return resize_shadow_controller_.get();
452 }
453
454 // Made available for tests.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000455 views::corewm::ShadowController* shadow_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000456 return shadow_controller_.get();
457 }
458
459 content::BrowserContext* browser_context() { return browser_context_; }
460 void set_browser_context(content::BrowserContext* browser_context) {
461 browser_context_ = browser_context;
462 }
463
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000464 // Starts the animation that occurs on first login.
465 void DoInitialWorkspaceAnimation();
466
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100467#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000468 // TODO(oshima): Move these objects to DisplayController.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000469 chromeos::OutputConfigurator* output_configurator() {
470 return output_configurator_.get();
471 }
472 internal::OutputConfiguratorAnimation* output_configurator_animation() {
473 return output_configurator_animation_.get();
474 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000475 internal::DisplayErrorObserver* display_error_observer() {
476 return display_error_observer_.get();
477 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100478#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000479
Ben Murdochba5b9a62013-08-12 14:20:17 +0100480 internal::ResolutionNotificationController*
481 resolution_notification_controller() {
482 return resolution_notification_controller_.get();
483 }
484
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000485 RootWindowHostFactory* root_window_host_factory() {
486 return root_window_host_factory_.get();
487 }
488
489 LauncherModel* launcher_model() {
490 return launcher_model_.get();
491 }
492
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100493 WindowPositioner* window_positioner() {
494 return window_positioner_.get();
495 }
496
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000497 // Returns the launcher delegate, creating if necesary.
498 LauncherDelegate* GetLauncherDelegate();
499
Ben Murdocheb525c52013-07-10 11:40:50 +0100500 void SetTouchHudProjectionEnabled(bool enabled);
501
502 bool is_touch_hud_projection_enabled() const {
503 return is_touch_hud_projection_enabled_;
504 }
505
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100506#if defined(OS_CHROMEOS)
507 // Creates instance of FirstRunHelper. Caller is responsible for deleting
508 // returned object.
509 ash::FirstRunHelper* CreateFirstRunHelper();
510#endif // defined(OS_CHROMEOS)
511
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000512 private:
513 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
514 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
515 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
516 friend class internal::RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100517 friend class internal::ScopedTargetRootWindow;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000518 friend class test::ShellTestApi;
519 friend class shell::WindowWatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000520
521 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
522
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100523 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000524 explicit Shell(ShellDelegate* delegate);
525 virtual ~Shell();
526
527 void Init();
528
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100529 // Initializes virtual keyboard controller and attaches it to |root|.
530 void InitKeyboard(internal::RootWindowController* root);
531
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100532 // Initializes the root window so that it can host browser windows.
533 void InitRootWindow(aura::RootWindow* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000534
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000535 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
536 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
537
538 // Overridden from ui::EventTarget:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000539 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000540 virtual EventTarget* GetParentTarget() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000541 virtual void OnEvent(ui::Event* event) OVERRIDE;
542
543 // Overridden from aura::client::ActivationChangeObserver:
544 virtual void OnWindowActivated(aura::Window* gained_active,
545 aura::Window* lost_active) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000546
547 static Shell* instance_;
548
549 // If set before the Shell is initialized, the mouse cursor will be hidden
550 // when the screen is initially created.
551 static bool initially_hide_cursor_;
552
553 ScreenAsh* screen_;
554
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100555 // When no explicit target display/RootWindow is given, new windows are
556 // created on |scoped_target_root_window_| , unless NULL in
557 // which case they are created on |target_root_window_|.
558 // |target_root_window_| never becomes NULL during the session.
559 aura::RootWindow* target_root_window_;
560 aura::RootWindow* scoped_target_root_window_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000561
562 // The CompoundEventFilter owned by aura::Env object.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000563 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000564
565 std::vector<WindowAndBoundsPair> to_restore_;
566
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100567 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000568 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000569 scoped_ptr<AcceleratorController> accelerator_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000570 scoped_ptr<ShellDelegate> delegate_;
571 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000572 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000573 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
574 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100575 scoped_ptr<SessionStateDelegate> session_state_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000576 scoped_ptr<LauncherDelegate> launcher_delegate_;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100577 scoped_ptr<LauncherItemDelegateManager> launcher_item_delegate_manager_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000578
579 scoped_ptr<LauncherModel> launcher_model_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100580 scoped_ptr<ash::WindowPositioner> window_positioner_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000581
582 scoped_ptr<internal::AppListController> app_list_controller_;
583
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000584 scoped_ptr<internal::DragDropController> drag_drop_controller_;
585 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000586 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
587 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
588 scoped_ptr<views::corewm::WindowModalityController>
589 window_modality_controller_;
590 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000591 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
592 scoped_ptr<PowerButtonController> power_button_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100593 scoped_ptr<LockStateController> lock_state_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100594 scoped_ptr<MruWindowTracker> mru_window_tracker_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000595 scoped_ptr<UserActivityDetector> user_activity_detector_;
596 scoped_ptr<VideoDetector> video_detector_;
597 scoped_ptr<WindowCycleController> window_cycle_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100598 scoped_ptr<WindowSelectorController> window_selector_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000599 scoped_ptr<internal::FocusCycler> focus_cycler_;
600 scoped_ptr<DisplayController> display_controller_;
601 scoped_ptr<HighContrastController> high_contrast_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000602 scoped_ptr<MagnificationController> magnification_controller_;
603 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100604 scoped_ptr<AutoclickController> autoclick_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000605 scoped_ptr<aura::client::FocusClient> focus_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000606 scoped_ptr<aura::client::UserActionClient> user_action_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000607 aura::client::ActivationClient* activation_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000608 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
609 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
610 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
611 scoped_ptr<internal::EventClientImpl> event_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000612 scoped_ptr<internal::EventTransformationHandler>
613 event_transformation_handler_;
614 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000615
616 // An event filter that rewrites or drops an event.
617 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
618
619 // An event filter that pre-handles key events while the partial
620 // screenshot UI or the keyboard overlay is active.
621 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
622
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100623 // An event filter for logging keyboard-related metrics.
624 scoped_ptr<internal::KeyboardUMAEventFilter> keyboard_metrics_filter_;
625
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000626 // An event filter which handles system level gestures
627 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
628
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000629 // An event filter that pre-handles global accelerators.
630 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000631
632 // An event filter that pre-handles all key events to send them to an IME.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000633 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000634
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000635 scoped_ptr<internal::DisplayManager> display_manager_;
636
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100637 scoped_ptr<internal::LocaleNotificationController>
638 locale_notification_controller_;
639
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100640#if defined(OS_CHROMEOS)
641 scoped_ptr<internal::PowerEventObserver> power_event_observer_;
642 scoped_ptr<internal::UserActivityNotifier> user_activity_notifier_;
643 scoped_ptr<internal::VideoActivityNotifier> video_activity_notifier_;
644#if defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000645 // Controls video output device state.
646 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
647 scoped_ptr<internal::OutputConfiguratorAnimation>
648 output_configurator_animation_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000649 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
650
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100651 // Listens for output changes and updates the display manager.
652 scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100653#endif // defined(USE_X11)
654#endif // defined(OS_CHROMEOS)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000655
Ben Murdochba5b9a62013-08-12 14:20:17 +0100656 scoped_ptr<internal::ResolutionNotificationController>
657 resolution_notification_controller_;
658
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000659 // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
660 // pointer to vend to test code.
661 AshNativeCursorManager* native_cursor_manager_;
662 views::corewm::CursorManager cursor_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000663
664 ObserverList<ShellObserver> observers_;
665
666 // Used by ash/shell.
667 content::BrowserContext* browser_context_;
668
669 // For testing only: simulate that a modal window is open
670 bool simulate_modal_window_open_for_testing_;
671
Ben Murdocheb525c52013-07-10 11:40:50 +0100672 bool is_touch_hud_projection_enabled_;
673
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000674 DISALLOW_COPY_AND_ASSIGN(Shell);
675};
676
677} // namespace ash
678
679#endif // ASH_SHELL_H_