blob: 62379acd06aebdf01ca5cf0c590760ce59ca0171 [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"
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +000019#include "base/memory/weak_ptr.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000020#include "base/observer_list.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000021#include "ui/aura/client/activation_change_observer.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010022#include "ui/base/ui_base_types.h"
Torne (Richard Coles)d0247b12013-09-19 22:36:51 +010023#include "ui/events/event_target.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000024#include "ui/gfx/insets.h"
25#include "ui/gfx/screen.h"
26#include "ui/gfx/size.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000027#include "ui/views/corewm/cursor_manager.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000028
29class CommandLine;
30
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +010031namespace app_list {
32class AppListView;
33}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000034namespace aura {
35class EventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000036class RootWindow;
37class Window;
38namespace client {
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000039class ActivationClient;
40class FocusClient;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000041class UserActionClient;
42}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000043}
44namespace chromeos {
45class OutputConfigurator;
46}
47namespace content {
48class BrowserContext;
49}
50
51namespace gfx {
52class ImageSkia;
53class Point;
54class Rect;
55}
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010056
57namespace keyboard {
58class KeyboardController;
59}
60
Torne (Richard Coles)58218062012-11-14 11:43:16 +000061namespace ui {
62class Layer;
63}
64namespace views {
65class NonClientFrameView;
66class Widget;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000067namespace corewm {
68class CompoundEventFilter;
69class InputMethodEventFilter;
70class ShadowController;
71class TooltipController;
72class VisibilityController;
73class WindowModalityController;
74}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000075}
76
77namespace ash {
78
79class AcceleratorController;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +000080class AccessibilityDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000081class AshNativeCursorManager;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010082class AutoclickController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000083class CapsLockDelegate;
84class DesktopBackgroundController;
85class DisplayController;
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +010086class FirstRunHelper;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000087class HighContrastController;
88class Launcher;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000089class LauncherDelegate;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010090class LauncherItemDelegate;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +010091class LauncherItemDelegateManager;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000092class LauncherModel;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +000093class LockStateController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000094class MagnificationController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010095class MruWindowTracker;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000096class NestedDispatcherController;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +000097class NewWindowDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000098class PartialMagnificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000099class PowerButtonController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000100class RootWindowHostFactory;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000101class ScreenAsh;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100102class SessionStateDelegate;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000103class ShellDelegate;
104class ShellObserver;
105class SystemTray;
106class SystemTrayDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000107class SystemTrayNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000108class UserActivityDetector;
109class UserWallpaperDelegate;
110class VideoDetector;
111class WebNotificationTray;
112class WindowCycleController;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100113class WindowPositioner;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100114class WindowSelectorController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000115
116namespace internal {
117class AcceleratorFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000118class AppListController;
119class CaptureController;
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100120class DisplayChangeObserver;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000121class DisplayErrorObserver;
122class DisplayManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000123class DragDropController;
124class EventClientImpl;
125class EventRewriterEventFilter;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000126class EventTransformationHandler;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000127class FocusCycler;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100128class KeyboardUMAEventFilter;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100129class LocaleNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000130class MouseCursorEventFilter;
131class OutputConfiguratorAnimation;
132class OverlayEventFilter;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100133class PowerEventObserver;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000134class ResizeShadowController;
Ben Murdochba5b9a62013-08-12 14:20:17 +0100135class ResolutionNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000136class RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100137class ScopedTargetRootWindow;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000138class ScreenPositionController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000139class SlowAnimationEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000140class StatusAreaWidget;
141class SystemGestureEventFilter;
142class SystemModalContainerEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000143class TouchObserverHUD;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100144class UserActivityNotifier;
145class VideoActivityNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000146}
147
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000148namespace shell {
149class WindowWatcher;
150}
151
152namespace test {
153class ShellTestApi;
154}
155
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000156// Shell is a singleton object that presents the Shell API and implements the
157// RootWindow's delegate interface.
158//
159// Upon creation, the Shell sets itself as the RootWindow's delegate, which
160// takes ownership of the Shell.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000161class ASH_EXPORT Shell
162 : public internal::SystemModalContainerEventFilterDelegate,
163 public ui::EventTarget,
164 public aura::client::ActivationChangeObserver {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000165 public:
166 typedef std::vector<aura::RootWindow*> RootWindowList;
167 typedef std::vector<internal::RootWindowController*> RootWindowControllerList;
168
169 enum Direction {
170 FORWARD,
171 BACKWARD
172 };
173
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000174 // A shell must be explicitly created so that it can call |Init()| with the
175 // delegate set. |delegate| can be NULL (if not required for initialization).
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100176 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000177 static Shell* CreateInstance(ShellDelegate* delegate);
178
179 // Should never be called before |CreateInstance()|.
180 static Shell* GetInstance();
181
182 // Returns true if the ash shell has been instantiated.
183 static bool HasInstance();
184
185 static void DeleteInstance();
186
187 // Returns the root window controller for the primary root window.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000188 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000189 static internal::RootWindowController* GetPrimaryRootWindowController();
190
191 // Returns all root window controllers.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000192 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000193 static RootWindowControllerList GetAllRootWindowControllers();
194
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000195 // Returns the primary root Window. The primary root Window is the one that
196 // has a launcher.
197 static aura::Window* GetPrimaryRootWindow();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000198
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000199 // Returns a root Window when used as a target when creating a new window.
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100200 // The root window of the active window is used in most cases, but can
201 // be overridden by using ScopedTargetRootWindow().
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000202 // If you want to get the root Window of the active window, just use
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100203 // |wm::GetActiveWindow()->GetRootWindow()|.
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000204 static aura::Window* GetTargetRootWindow();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000205
206 // Returns the global Screen object that's always active in ash.
207 static gfx::Screen* GetScreen();
208
209 // Returns all root windows.
210 static RootWindowList GetAllRootWindows();
211
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000212 static aura::Window* GetContainer(aura::Window* root_window,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000213 int container_id);
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000214 static const aura::Window* GetContainer(const aura::Window* root_window,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000215 int container_id);
216
217 // Returns the list of containers that match |container_id| in
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000218 // all root windows. If |priority_root| is given, the container
219 // in the |priority_root| will be inserted at the top of the list.
220 static std::vector<aura::Window*> GetContainersFromAllRootWindows(
221 int container_id,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000222 aura::Window* priority_root);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000223
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000224 void set_target_root_window(aura::Window* target_root_window) {
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100225 target_root_window_ = target_root_window;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000226 }
227
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000228 // Shows the context menu for the background and launcher at
229 // |location_in_screen| (in screen coordinates).
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100230 void ShowContextMenu(const gfx::Point& location_in_screen,
231 ui::MenuSourceType source_type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000232
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000233 // Toggles the app list. |window| specifies in which display the app
234 // list should be shown. If this is NULL, the active root window
235 // will be used.
236 void ToggleAppList(aura::Window* anchor);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000237
238 // Returns app list target visibility.
239 bool GetAppListTargetVisibility() const;
240
241 // Returns app list window or NULL if it is not visible.
242 aura::Window* GetAppListWindow();
243
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100244 // Returns app list view or NULL if it is not visible.
245 app_list::AppListView* GetAppListView();
246
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000247 // Returns true if a system-modal dialog window is currently open.
248 bool IsSystemModalWindowOpen() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000249
250 // For testing only: set simulation that a modal window is open
251 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
252 simulate_modal_window_open_for_testing_ = modal_window_open;
253 }
254
255 // Creates a default views::NonClientFrameView for use by windows in the
256 // Ash environment.
257 views::NonClientFrameView* CreateDefaultNonClientFrameView(
258 views::Widget* widget);
259
260 // Rotates focus through containers that can receive focus.
261 void RotateFocus(Direction direction);
262
263 // Sets the work area insets of the display that contains |window|,
264 // this notifies observers too.
265 // TODO(sky): this no longer really replicates what happens and is unreliable.
266 // Remove this.
267 void SetDisplayWorkAreaInsets(aura::Window* window,
268 const gfx::Insets& insets);
269
270 // Called when the user logs in.
271 void OnLoginStateChanged(user::LoginStatus status);
272
273 // Called when the login status changes.
274 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
275 void UpdateAfterLoginStatusChange(user::LoginStatus status);
276
277 // Called when the application is exiting.
278 void OnAppTerminating();
279
280 // Called when the screen is locked (after the lock window is visible) or
281 // unlocked.
282 void OnLockStateChanged(bool locked);
283
284 // Initializes |launcher_|. Does nothing if it's already initialized.
285 void CreateLauncher();
286
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100287 // Show shelf view if it was created hidden (before session has started).
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000288 void ShowLauncher();
289
290 // Adds/removes observer.
291 void AddShellObserver(ShellObserver* observer);
292 void RemoveShellObserver(ShellObserver* observer);
293
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100294 keyboard::KeyboardController* keyboard_controller() {
295 return keyboard_controller_.get();
296 }
297
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000298 AcceleratorController* accelerator_controller() {
299 return accelerator_controller_.get();
300 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000301
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000302 internal::DisplayManager* display_manager() {
303 return display_manager_.get();
304 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100305 views::corewm::InputMethodEventFilter* input_method_filter() {
306 return input_method_filter_.get();
307 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000308 views::corewm::CompoundEventFilter* env_filter() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000309 return env_filter_.get();
310 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000311 views::corewm::TooltipController* tooltip_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000312 return tooltip_controller_.get();
313 }
314 internal::EventRewriterEventFilter* event_rewriter_filter() {
315 return event_rewriter_filter_.get();
316 }
317 internal::OverlayEventFilter* overlay_filter() {
318 return overlay_filter_.get();
319 }
320 DesktopBackgroundController* desktop_background_controller() {
321 return desktop_background_controller_.get();
322 }
323 PowerButtonController* power_button_controller() {
324 return power_button_controller_.get();
325 }
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100326 LockStateController* lock_state_controller() {
327 return lock_state_controller_.get();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000328 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100329 MruWindowTracker* mru_window_tracker() {
330 return mru_window_tracker_.get();
331 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000332 UserActivityDetector* user_activity_detector() {
333 return user_activity_detector_.get();
334 }
335 VideoDetector* video_detector() {
336 return video_detector_.get();
337 }
338 WindowCycleController* window_cycle_controller() {
339 return window_cycle_controller_.get();
340 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100341 WindowSelectorController* window_selector_controller() {
342 return window_selector_controller_.get();
343 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000344 internal::FocusCycler* focus_cycler() {
345 return focus_cycler_.get();
346 }
347 DisplayController* display_controller() {
348 return display_controller_.get();
349 }
350 internal::MouseCursorEventFilter* mouse_cursor_filter() {
351 return mouse_cursor_filter_.get();
352 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000353 internal::EventTransformationHandler* event_transformation_handler() {
354 return event_transformation_handler_.get();
355 }
356 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000357
358 ShellDelegate* delegate() { return delegate_.get(); }
359
360 UserWallpaperDelegate* user_wallpaper_delegate() {
361 return user_wallpaper_delegate_.get();
362 }
363
364 CapsLockDelegate* caps_lock_delegate() {
365 return caps_lock_delegate_.get();
366 }
367
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100368 SessionStateDelegate* session_state_delegate() {
369 return session_state_delegate_.get();
370 }
371
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000372 AccessibilityDelegate* accessibility_delegate() {
373 return accessibility_delegate_.get();
374 }
375
376 NewWindowDelegate* new_window_delegate() {
377 return new_window_delegate_.get();
378 }
379
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000380 HighContrastController* high_contrast_controller() {
381 return high_contrast_controller_.get();
382 }
383
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000384 MagnificationController* magnification_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000385 return magnification_controller_.get();
386 }
387
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000388 PartialMagnificationController* partial_magnification_controller() {
389 return partial_magnification_controller_.get();
390 }
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100391
392 AutoclickController* autoclick_controller() {
393 return autoclick_controller_.get();
394 }
395
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000396 aura::client::ActivationClient* activation_client() {
397 return activation_client_;
398 }
399
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100400 LauncherItemDelegateManager* launcher_item_delegate_manager() {
401 return launcher_item_delegate_manager_.get();
402 }
403
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000404 ScreenAsh* screen() { return screen_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000405
406 // Force the shelf to query for it's current visibility state.
407 void UpdateShelfVisibility();
408
409 // TODO(oshima): Define an interface to access shelf/launcher
410 // state, or just use Launcher.
411
412 // Sets/gets the shelf auto-hide behavior on |root_window|.
413 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000414 aura::Window* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000415 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000416 aura::Window* root_window) const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000417
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000418 // Sets/gets shelf's alignment on |root_window|.
419 void SetShelfAlignment(ShelfAlignment alignment,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000420 aura::Window* root_window);
421 ShelfAlignment GetShelfAlignment(aura::Window* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000422
423 // Dims or undims the screen.
424 void SetDimming(bool should_dim);
425
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100426 // Notifies |observers_| when entering or exiting fullscreen mode in
427 // |root_window|.
428 void NotifyFullscreenStateChange(bool is_fullscreen,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000429 aura::Window* root_window);
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100430
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000431 // Creates a modal background (a partially-opaque fullscreen window)
432 // on all displays for |window|.
433 void CreateModalBackground(aura::Window* window);
434
435 // Called when a modal window is removed. It will activate
436 // another modal window if any, or remove modal screens
437 // on all displays.
438 void OnModalWindowRemoved(aura::Window* removed);
439
440 // Returns WebNotificationTray on the primary root window.
441 WebNotificationTray* GetWebNotificationTray();
442
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000443 // Does the primary display have status area?
444 bool HasPrimaryStatusArea();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000445
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000446 // Returns the system tray on primary display.
447 SystemTray* GetPrimarySystemTray();
448
449 SystemTrayDelegate* system_tray_delegate() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000450 return system_tray_delegate_.get();
451 }
452
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000453 SystemTrayNotifier* system_tray_notifier() {
454 return system_tray_notifier_.get();
455 }
456
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000457 static void set_initially_hide_cursor(bool hide) {
458 initially_hide_cursor_ = hide;
459 }
460
461 internal::ResizeShadowController* resize_shadow_controller() {
462 return resize_shadow_controller_.get();
463 }
464
465 // Made available for tests.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000466 views::corewm::ShadowController* shadow_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000467 return shadow_controller_.get();
468 }
469
470 content::BrowserContext* browser_context() { return browser_context_; }
471 void set_browser_context(content::BrowserContext* browser_context) {
472 browser_context_ = browser_context;
473 }
474
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000475 // Starts the animation that occurs on first login.
476 void DoInitialWorkspaceAnimation();
477
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100478#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000479 // TODO(oshima): Move these objects to DisplayController.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000480 chromeos::OutputConfigurator* output_configurator() {
481 return output_configurator_.get();
482 }
483 internal::OutputConfiguratorAnimation* output_configurator_animation() {
484 return output_configurator_animation_.get();
485 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000486 internal::DisplayErrorObserver* display_error_observer() {
487 return display_error_observer_.get();
488 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100489#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000490
Ben Murdochba5b9a62013-08-12 14:20:17 +0100491 internal::ResolutionNotificationController*
492 resolution_notification_controller() {
493 return resolution_notification_controller_.get();
494 }
495
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000496 RootWindowHostFactory* root_window_host_factory() {
497 return root_window_host_factory_.get();
498 }
499
500 LauncherModel* launcher_model() {
501 return launcher_model_.get();
502 }
503
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100504 WindowPositioner* window_positioner() {
505 return window_positioner_.get();
506 }
507
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000508 // Returns the launcher delegate, creating if necesary.
509 LauncherDelegate* GetLauncherDelegate();
510
Ben Murdocheb525c52013-07-10 11:40:50 +0100511 void SetTouchHudProjectionEnabled(bool enabled);
512
513 bool is_touch_hud_projection_enabled() const {
514 return is_touch_hud_projection_enabled_;
515 }
516
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100517#if defined(OS_CHROMEOS)
518 // Creates instance of FirstRunHelper. Caller is responsible for deleting
519 // returned object.
520 ash::FirstRunHelper* CreateFirstRunHelper();
521#endif // defined(OS_CHROMEOS)
522
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000523 private:
524 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
525 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
526 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
527 friend class internal::RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100528 friend class internal::ScopedTargetRootWindow;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000529 friend class test::ShellTestApi;
530 friend class shell::WindowWatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000531
532 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
533
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100534 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000535 explicit Shell(ShellDelegate* delegate);
536 virtual ~Shell();
537
538 void Init();
539
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100540 // Initializes virtual keyboard controller and attaches it to |root|.
541 void InitKeyboard(internal::RootWindowController* root);
542
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100543 // Initializes the root window so that it can host browser windows.
544 void InitRootWindow(aura::RootWindow* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000545
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000546 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
547 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
548
549 // Overridden from ui::EventTarget:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000550 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000551 virtual EventTarget* GetParentTarget() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000552 virtual void OnEvent(ui::Event* event) OVERRIDE;
553
554 // Overridden from aura::client::ActivationChangeObserver:
555 virtual void OnWindowActivated(aura::Window* gained_active,
556 aura::Window* lost_active) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000557
558 static Shell* instance_;
559
560 // If set before the Shell is initialized, the mouse cursor will be hidden
561 // when the screen is initially created.
562 static bool initially_hide_cursor_;
563
564 ScreenAsh* screen_;
565
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100566 // When no explicit target display/RootWindow is given, new windows are
567 // created on |scoped_target_root_window_| , unless NULL in
568 // which case they are created on |target_root_window_|.
569 // |target_root_window_| never becomes NULL during the session.
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000570 aura::Window* target_root_window_;
571 aura::Window* scoped_target_root_window_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000572
573 // The CompoundEventFilter owned by aura::Env object.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000574 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000575
576 std::vector<WindowAndBoundsPair> to_restore_;
577
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100578 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000579 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000580 scoped_ptr<AcceleratorController> accelerator_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000581 scoped_ptr<ShellDelegate> delegate_;
582 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000583 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000584 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
585 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100586 scoped_ptr<SessionStateDelegate> session_state_delegate_;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000587 scoped_ptr<AccessibilityDelegate> accessibility_delegate_;
588 scoped_ptr<NewWindowDelegate> new_window_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000589 scoped_ptr<LauncherDelegate> launcher_delegate_;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100590 scoped_ptr<LauncherItemDelegateManager> launcher_item_delegate_manager_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000591
592 scoped_ptr<LauncherModel> launcher_model_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100593 scoped_ptr<ash::WindowPositioner> window_positioner_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000594
595 scoped_ptr<internal::AppListController> app_list_controller_;
596
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000597 scoped_ptr<internal::DragDropController> drag_drop_controller_;
598 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000599 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
600 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
601 scoped_ptr<views::corewm::WindowModalityController>
602 window_modality_controller_;
603 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000604 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
605 scoped_ptr<PowerButtonController> power_button_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100606 scoped_ptr<LockStateController> lock_state_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100607 scoped_ptr<MruWindowTracker> mru_window_tracker_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000608 scoped_ptr<UserActivityDetector> user_activity_detector_;
609 scoped_ptr<VideoDetector> video_detector_;
610 scoped_ptr<WindowCycleController> window_cycle_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100611 scoped_ptr<WindowSelectorController> window_selector_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000612 scoped_ptr<internal::FocusCycler> focus_cycler_;
613 scoped_ptr<DisplayController> display_controller_;
614 scoped_ptr<HighContrastController> high_contrast_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000615 scoped_ptr<MagnificationController> magnification_controller_;
616 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100617 scoped_ptr<AutoclickController> autoclick_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000618 scoped_ptr<aura::client::FocusClient> focus_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000619 scoped_ptr<aura::client::UserActionClient> user_action_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000620 aura::client::ActivationClient* activation_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000621 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
622 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
623 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
624 scoped_ptr<internal::EventClientImpl> event_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000625 scoped_ptr<internal::EventTransformationHandler>
626 event_transformation_handler_;
627 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000628
629 // An event filter that rewrites or drops an event.
630 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
631
632 // An event filter that pre-handles key events while the partial
633 // screenshot UI or the keyboard overlay is active.
634 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
635
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100636 // An event filter for logging keyboard-related metrics.
637 scoped_ptr<internal::KeyboardUMAEventFilter> keyboard_metrics_filter_;
638
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000639 // An event filter which handles system level gestures
640 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
641
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000642 // An event filter that pre-handles global accelerators.
643 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000644
645 // An event filter that pre-handles all key events to send them to an IME.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000646 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000647
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000648 scoped_ptr<internal::DisplayManager> display_manager_;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000649 scoped_ptr<base::WeakPtrFactory<internal::DisplayManager> >
650 weak_display_manager_factory_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000651
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100652 scoped_ptr<internal::LocaleNotificationController>
653 locale_notification_controller_;
654
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100655#if defined(OS_CHROMEOS)
656 scoped_ptr<internal::PowerEventObserver> power_event_observer_;
657 scoped_ptr<internal::UserActivityNotifier> user_activity_notifier_;
658 scoped_ptr<internal::VideoActivityNotifier> video_activity_notifier_;
659#if defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000660 // Controls video output device state.
661 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
662 scoped_ptr<internal::OutputConfiguratorAnimation>
663 output_configurator_animation_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000664 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
665
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100666 // Listens for output changes and updates the display manager.
667 scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100668#endif // defined(USE_X11)
669#endif // defined(OS_CHROMEOS)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000670
Ben Murdochba5b9a62013-08-12 14:20:17 +0100671 scoped_ptr<internal::ResolutionNotificationController>
672 resolution_notification_controller_;
673
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000674 // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
675 // pointer to vend to test code.
676 AshNativeCursorManager* native_cursor_manager_;
677 views::corewm::CursorManager cursor_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000678
679 ObserverList<ShellObserver> observers_;
680
681 // Used by ash/shell.
682 content::BrowserContext* browser_context_;
683
684 // For testing only: simulate that a modal window is open
685 bool simulate_modal_window_open_for_testing_;
686
Ben Murdocheb525c52013-07-10 11:40:50 +0100687 bool is_touch_hud_projection_enabled_;
688
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000689 DISALLOW_COPY_AND_ASSIGN(Shell);
690};
691
692} // namespace ash
693
694#endif // ASH_SHELL_H_