blob: fa54faa81839841fafda3b96742b96063468c9ea [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)0f1bc082013-11-06 12:27:47 +000095class MediaDelegate;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010096class MruWindowTracker;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000097class NestedDispatcherController;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +000098class NewWindowDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000099class PartialMagnificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000100class PowerButtonController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000101class RootWindowHostFactory;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000102class ScreenAsh;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100103class SessionStateDelegate;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000104class ShellDelegate;
105class ShellObserver;
106class SystemTray;
107class SystemTrayDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000108class SystemTrayNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000109class UserActivityDetector;
110class UserWallpaperDelegate;
111class VideoDetector;
112class WebNotificationTray;
113class WindowCycleController;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100114class WindowPositioner;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100115class WindowSelectorController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000116
117namespace internal {
118class AcceleratorFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000119class AppListController;
120class CaptureController;
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100121class DisplayChangeObserver;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000122class DisplayErrorObserver;
123class DisplayManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000124class DragDropController;
125class EventClientImpl;
126class EventRewriterEventFilter;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000127class EventTransformationHandler;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000128class FocusCycler;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100129class KeyboardUMAEventFilter;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100130class LocaleNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000131class MouseCursorEventFilter;
132class OutputConfiguratorAnimation;
133class OverlayEventFilter;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100134class PowerEventObserver;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000135class ResizeShadowController;
Ben Murdochba5b9a62013-08-12 14:20:17 +0100136class ResolutionNotificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000137class RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100138class ScopedTargetRootWindow;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000139class ScreenPositionController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000140class SlowAnimationEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000141class StatusAreaWidget;
142class SystemGestureEventFilter;
143class SystemModalContainerEventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000144class TouchObserverHUD;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100145class UserActivityNotifier;
146class VideoActivityNotifier;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000147}
148
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000149namespace shell {
150class WindowWatcher;
151}
152
153namespace test {
154class ShellTestApi;
155}
156
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000157// Shell is a singleton object that presents the Shell API and implements the
158// RootWindow's delegate interface.
159//
160// Upon creation, the Shell sets itself as the RootWindow's delegate, which
161// takes ownership of the Shell.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000162class ASH_EXPORT Shell
163 : public internal::SystemModalContainerEventFilterDelegate,
164 public ui::EventTarget,
165 public aura::client::ActivationChangeObserver {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000166 public:
167 typedef std::vector<aura::RootWindow*> RootWindowList;
168 typedef std::vector<internal::RootWindowController*> RootWindowControllerList;
169
170 enum Direction {
171 FORWARD,
172 BACKWARD
173 };
174
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000175 // A shell must be explicitly created so that it can call |Init()| with the
176 // delegate set. |delegate| can be NULL (if not required for initialization).
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100177 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000178 static Shell* CreateInstance(ShellDelegate* delegate);
179
180 // Should never be called before |CreateInstance()|.
181 static Shell* GetInstance();
182
183 // Returns true if the ash shell has been instantiated.
184 static bool HasInstance();
185
186 static void DeleteInstance();
187
188 // Returns the root window controller for the primary root window.
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 internal::RootWindowController* GetPrimaryRootWindowController();
191
192 // Returns all root window controllers.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000193 // TODO(oshima): move this to |RootWindowController|
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000194 static RootWindowControllerList GetAllRootWindowControllers();
195
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000196 // Returns the primary root Window. The primary root Window is the one that
197 // has a launcher.
198 static aura::Window* GetPrimaryRootWindow();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000199
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000200 // Returns a root Window when used as a target when creating a new window.
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100201 // The root window of the active window is used in most cases, but can
202 // be overridden by using ScopedTargetRootWindow().
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000203 // If you want to get the root Window of the active window, just use
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100204 // |wm::GetActiveWindow()->GetRootWindow()|.
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000205 static aura::Window* GetTargetRootWindow();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000206
207 // Returns the global Screen object that's always active in ash.
208 static gfx::Screen* GetScreen();
209
210 // Returns all root windows.
211 static RootWindowList GetAllRootWindows();
212
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000213 static aura::Window* GetContainer(aura::Window* root_window,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000214 int container_id);
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000215 static const aura::Window* GetContainer(const aura::Window* root_window,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000216 int container_id);
217
218 // Returns the list of containers that match |container_id| in
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000219 // all root windows. If |priority_root| is given, the container
220 // in the |priority_root| will be inserted at the top of the list.
221 static std::vector<aura::Window*> GetContainersFromAllRootWindows(
222 int container_id,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000223 aura::Window* priority_root);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000224
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000225 void set_target_root_window(aura::Window* target_root_window) {
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100226 target_root_window_ = target_root_window;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000227 }
228
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000229 // Shows the context menu for the background and launcher at
230 // |location_in_screen| (in screen coordinates).
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100231 void ShowContextMenu(const gfx::Point& location_in_screen,
232 ui::MenuSourceType source_type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000233
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000234 // Toggles the app list. |window| specifies in which display the app
235 // list should be shown. If this is NULL, the active root window
236 // will be used.
237 void ToggleAppList(aura::Window* anchor);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000238
239 // Returns app list target visibility.
240 bool GetAppListTargetVisibility() const;
241
242 // Returns app list window or NULL if it is not visible.
243 aura::Window* GetAppListWindow();
244
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100245 // Returns app list view or NULL if it is not visible.
246 app_list::AppListView* GetAppListView();
247
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000248 // Returns true if a system-modal dialog window is currently open.
249 bool IsSystemModalWindowOpen() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000250
251 // For testing only: set simulation that a modal window is open
252 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
253 simulate_modal_window_open_for_testing_ = modal_window_open;
254 }
255
256 // Creates a default views::NonClientFrameView for use by windows in the
257 // Ash environment.
258 views::NonClientFrameView* CreateDefaultNonClientFrameView(
259 views::Widget* widget);
260
261 // Rotates focus through containers that can receive focus.
262 void RotateFocus(Direction direction);
263
264 // Sets the work area insets of the display that contains |window|,
265 // this notifies observers too.
266 // TODO(sky): this no longer really replicates what happens and is unreliable.
267 // Remove this.
268 void SetDisplayWorkAreaInsets(aura::Window* window,
269 const gfx::Insets& insets);
270
271 // Called when the user logs in.
272 void OnLoginStateChanged(user::LoginStatus status);
273
274 // Called when the login status changes.
275 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
276 void UpdateAfterLoginStatusChange(user::LoginStatus status);
277
278 // Called when the application is exiting.
279 void OnAppTerminating();
280
281 // Called when the screen is locked (after the lock window is visible) or
282 // unlocked.
283 void OnLockStateChanged(bool locked);
284
285 // Initializes |launcher_|. Does nothing if it's already initialized.
286 void CreateLauncher();
287
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100288 // Show shelf view if it was created hidden (before session has started).
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000289 void ShowLauncher();
290
291 // Adds/removes observer.
292 void AddShellObserver(ShellObserver* observer);
293 void RemoveShellObserver(ShellObserver* observer);
294
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100295 keyboard::KeyboardController* keyboard_controller() {
296 return keyboard_controller_.get();
297 }
298
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000299 AcceleratorController* accelerator_controller() {
300 return accelerator_controller_.get();
301 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000302
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000303 internal::DisplayManager* display_manager() {
304 return display_manager_.get();
305 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100306 views::corewm::InputMethodEventFilter* input_method_filter() {
307 return input_method_filter_.get();
308 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000309 views::corewm::CompoundEventFilter* env_filter() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000310 return env_filter_.get();
311 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000312 views::corewm::TooltipController* tooltip_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000313 return tooltip_controller_.get();
314 }
315 internal::EventRewriterEventFilter* event_rewriter_filter() {
316 return event_rewriter_filter_.get();
317 }
318 internal::OverlayEventFilter* overlay_filter() {
319 return overlay_filter_.get();
320 }
321 DesktopBackgroundController* desktop_background_controller() {
322 return desktop_background_controller_.get();
323 }
324 PowerButtonController* power_button_controller() {
325 return power_button_controller_.get();
326 }
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100327 LockStateController* lock_state_controller() {
328 return lock_state_controller_.get();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000329 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100330 MruWindowTracker* mru_window_tracker() {
331 return mru_window_tracker_.get();
332 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000333 UserActivityDetector* user_activity_detector() {
334 return user_activity_detector_.get();
335 }
336 VideoDetector* video_detector() {
337 return video_detector_.get();
338 }
339 WindowCycleController* window_cycle_controller() {
340 return window_cycle_controller_.get();
341 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100342 WindowSelectorController* window_selector_controller() {
343 return window_selector_controller_.get();
344 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000345 internal::FocusCycler* focus_cycler() {
346 return focus_cycler_.get();
347 }
348 DisplayController* display_controller() {
349 return display_controller_.get();
350 }
351 internal::MouseCursorEventFilter* mouse_cursor_filter() {
352 return mouse_cursor_filter_.get();
353 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000354 internal::EventTransformationHandler* event_transformation_handler() {
355 return event_transformation_handler_.get();
356 }
357 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000358
359 ShellDelegate* delegate() { return delegate_.get(); }
360
361 UserWallpaperDelegate* user_wallpaper_delegate() {
362 return user_wallpaper_delegate_.get();
363 }
364
365 CapsLockDelegate* caps_lock_delegate() {
366 return caps_lock_delegate_.get();
367 }
368
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100369 SessionStateDelegate* session_state_delegate() {
370 return session_state_delegate_.get();
371 }
372
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000373 AccessibilityDelegate* accessibility_delegate() {
374 return accessibility_delegate_.get();
375 }
376
377 NewWindowDelegate* new_window_delegate() {
378 return new_window_delegate_.get();
379 }
380
Torne (Richard Coles)0f1bc082013-11-06 12:27:47 +0000381 MediaDelegate* media_delegate() {
382 return media_delegate_.get();
383 }
384
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000385 HighContrastController* high_contrast_controller() {
386 return high_contrast_controller_.get();
387 }
388
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000389 MagnificationController* magnification_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000390 return magnification_controller_.get();
391 }
392
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000393 PartialMagnificationController* partial_magnification_controller() {
394 return partial_magnification_controller_.get();
395 }
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100396
397 AutoclickController* autoclick_controller() {
398 return autoclick_controller_.get();
399 }
400
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000401 aura::client::ActivationClient* activation_client() {
402 return activation_client_;
403 }
404
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100405 LauncherItemDelegateManager* launcher_item_delegate_manager() {
406 return launcher_item_delegate_manager_.get();
407 }
408
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000409 ScreenAsh* screen() { return screen_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000410
411 // Force the shelf to query for it's current visibility state.
412 void UpdateShelfVisibility();
413
414 // TODO(oshima): Define an interface to access shelf/launcher
415 // state, or just use Launcher.
416
417 // Sets/gets the shelf auto-hide behavior on |root_window|.
418 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000419 aura::Window* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000420 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000421 aura::Window* root_window) const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000422
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000423 // Sets/gets shelf's alignment on |root_window|.
424 void SetShelfAlignment(ShelfAlignment alignment,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000425 aura::Window* root_window);
426 ShelfAlignment GetShelfAlignment(aura::Window* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000427
428 // Dims or undims the screen.
429 void SetDimming(bool should_dim);
430
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100431 // Notifies |observers_| when entering or exiting fullscreen mode in
432 // |root_window|.
433 void NotifyFullscreenStateChange(bool is_fullscreen,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000434 aura::Window* root_window);
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100435
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000436 // Creates a modal background (a partially-opaque fullscreen window)
437 // on all displays for |window|.
438 void CreateModalBackground(aura::Window* window);
439
440 // Called when a modal window is removed. It will activate
441 // another modal window if any, or remove modal screens
442 // on all displays.
443 void OnModalWindowRemoved(aura::Window* removed);
444
445 // Returns WebNotificationTray on the primary root window.
446 WebNotificationTray* GetWebNotificationTray();
447
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000448 // Does the primary display have status area?
449 bool HasPrimaryStatusArea();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000450
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000451 // Returns the system tray on primary display.
452 SystemTray* GetPrimarySystemTray();
453
454 SystemTrayDelegate* system_tray_delegate() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000455 return system_tray_delegate_.get();
456 }
457
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000458 SystemTrayNotifier* system_tray_notifier() {
459 return system_tray_notifier_.get();
460 }
461
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000462 static void set_initially_hide_cursor(bool hide) {
463 initially_hide_cursor_ = hide;
464 }
465
466 internal::ResizeShadowController* resize_shadow_controller() {
467 return resize_shadow_controller_.get();
468 }
469
470 // Made available for tests.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000471 views::corewm::ShadowController* shadow_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000472 return shadow_controller_.get();
473 }
474
475 content::BrowserContext* browser_context() { return browser_context_; }
476 void set_browser_context(content::BrowserContext* browser_context) {
477 browser_context_ = browser_context;
478 }
479
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000480 // Starts the animation that occurs on first login.
481 void DoInitialWorkspaceAnimation();
482
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100483#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000484 // TODO(oshima): Move these objects to DisplayController.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000485 chromeos::OutputConfigurator* output_configurator() {
486 return output_configurator_.get();
487 }
488 internal::OutputConfiguratorAnimation* output_configurator_animation() {
489 return output_configurator_animation_.get();
490 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000491 internal::DisplayErrorObserver* display_error_observer() {
492 return display_error_observer_.get();
493 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100494#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000495
Ben Murdochba5b9a62013-08-12 14:20:17 +0100496 internal::ResolutionNotificationController*
497 resolution_notification_controller() {
498 return resolution_notification_controller_.get();
499 }
500
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000501 RootWindowHostFactory* root_window_host_factory() {
502 return root_window_host_factory_.get();
503 }
504
505 LauncherModel* launcher_model() {
506 return launcher_model_.get();
507 }
508
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100509 WindowPositioner* window_positioner() {
510 return window_positioner_.get();
511 }
512
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000513 // Returns the launcher delegate, creating if necesary.
514 LauncherDelegate* GetLauncherDelegate();
515
Ben Murdocheb525c52013-07-10 11:40:50 +0100516 void SetTouchHudProjectionEnabled(bool enabled);
517
518 bool is_touch_hud_projection_enabled() const {
519 return is_touch_hud_projection_enabled_;
520 }
521
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100522#if defined(OS_CHROMEOS)
523 // Creates instance of FirstRunHelper. Caller is responsible for deleting
524 // returned object.
525 ash::FirstRunHelper* CreateFirstRunHelper();
526#endif // defined(OS_CHROMEOS)
527
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000528 private:
529 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
530 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
531 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
532 friend class internal::RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100533 friend class internal::ScopedTargetRootWindow;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000534 friend class test::ShellTestApi;
535 friend class shell::WindowWatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000536
537 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
538
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100539 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000540 explicit Shell(ShellDelegate* delegate);
541 virtual ~Shell();
542
543 void Init();
544
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100545 // Initializes virtual keyboard controller and attaches it to |root|.
546 void InitKeyboard(internal::RootWindowController* root);
547
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100548 // Initializes the root window so that it can host browser windows.
549 void InitRootWindow(aura::RootWindow* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000550
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000551 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
552 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
553
554 // Overridden from ui::EventTarget:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000555 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000556 virtual EventTarget* GetParentTarget() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000557 virtual void OnEvent(ui::Event* event) OVERRIDE;
558
559 // Overridden from aura::client::ActivationChangeObserver:
560 virtual void OnWindowActivated(aura::Window* gained_active,
561 aura::Window* lost_active) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000562
563 static Shell* instance_;
564
565 // If set before the Shell is initialized, the mouse cursor will be hidden
566 // when the screen is initially created.
567 static bool initially_hide_cursor_;
568
569 ScreenAsh* screen_;
570
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100571 // When no explicit target display/RootWindow is given, new windows are
572 // created on |scoped_target_root_window_| , unless NULL in
573 // which case they are created on |target_root_window_|.
574 // |target_root_window_| never becomes NULL during the session.
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000575 aura::Window* target_root_window_;
576 aura::Window* scoped_target_root_window_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000577
578 // The CompoundEventFilter owned by aura::Env object.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000579 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000580
581 std::vector<WindowAndBoundsPair> to_restore_;
582
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100583 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000584 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000585 scoped_ptr<AcceleratorController> accelerator_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000586 scoped_ptr<ShellDelegate> delegate_;
587 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000588 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000589 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
590 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100591 scoped_ptr<SessionStateDelegate> session_state_delegate_;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000592 scoped_ptr<AccessibilityDelegate> accessibility_delegate_;
593 scoped_ptr<NewWindowDelegate> new_window_delegate_;
Torne (Richard Coles)0f1bc082013-11-06 12:27:47 +0000594 scoped_ptr<MediaDelegate> media_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000595 scoped_ptr<LauncherDelegate> launcher_delegate_;
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100596 scoped_ptr<LauncherItemDelegateManager> launcher_item_delegate_manager_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000597
598 scoped_ptr<LauncherModel> launcher_model_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100599 scoped_ptr<ash::WindowPositioner> window_positioner_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000600
601 scoped_ptr<internal::AppListController> app_list_controller_;
602
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000603 scoped_ptr<internal::DragDropController> drag_drop_controller_;
604 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000605 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
606 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
607 scoped_ptr<views::corewm::WindowModalityController>
608 window_modality_controller_;
609 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000610 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
611 scoped_ptr<PowerButtonController> power_button_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100612 scoped_ptr<LockStateController> lock_state_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100613 scoped_ptr<MruWindowTracker> mru_window_tracker_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000614 scoped_ptr<UserActivityDetector> user_activity_detector_;
615 scoped_ptr<VideoDetector> video_detector_;
616 scoped_ptr<WindowCycleController> window_cycle_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100617 scoped_ptr<WindowSelectorController> window_selector_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000618 scoped_ptr<internal::FocusCycler> focus_cycler_;
619 scoped_ptr<DisplayController> display_controller_;
620 scoped_ptr<HighContrastController> high_contrast_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000621 scoped_ptr<MagnificationController> magnification_controller_;
622 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100623 scoped_ptr<AutoclickController> autoclick_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000624 scoped_ptr<aura::client::FocusClient> focus_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000625 scoped_ptr<aura::client::UserActionClient> user_action_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000626 aura::client::ActivationClient* activation_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000627 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
628 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
629 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
630 scoped_ptr<internal::EventClientImpl> event_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000631 scoped_ptr<internal::EventTransformationHandler>
632 event_transformation_handler_;
633 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000634
635 // An event filter that rewrites or drops an event.
636 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
637
638 // An event filter that pre-handles key events while the partial
639 // screenshot UI or the keyboard overlay is active.
640 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
641
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100642 // An event filter for logging keyboard-related metrics.
643 scoped_ptr<internal::KeyboardUMAEventFilter> keyboard_metrics_filter_;
644
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000645 // An event filter which handles system level gestures
646 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
647
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000648 // An event filter that pre-handles global accelerators.
649 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000650
651 // An event filter that pre-handles all key events to send them to an IME.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000652 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000653
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000654 scoped_ptr<internal::DisplayManager> display_manager_;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000655 scoped_ptr<base::WeakPtrFactory<internal::DisplayManager> >
656 weak_display_manager_factory_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000657
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100658 scoped_ptr<internal::LocaleNotificationController>
659 locale_notification_controller_;
660
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100661#if defined(OS_CHROMEOS)
662 scoped_ptr<internal::PowerEventObserver> power_event_observer_;
663 scoped_ptr<internal::UserActivityNotifier> user_activity_notifier_;
664 scoped_ptr<internal::VideoActivityNotifier> video_activity_notifier_;
665#if defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000666 // Controls video output device state.
667 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
668 scoped_ptr<internal::OutputConfiguratorAnimation>
669 output_configurator_animation_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000670 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
671
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100672 // Listens for output changes and updates the display manager.
673 scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100674#endif // defined(USE_X11)
675#endif // defined(OS_CHROMEOS)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000676
Ben Murdochba5b9a62013-08-12 14:20:17 +0100677 scoped_ptr<internal::ResolutionNotificationController>
678 resolution_notification_controller_;
679
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000680 // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
681 // pointer to vend to test code.
682 AshNativeCursorManager* native_cursor_manager_;
683 views::corewm::CursorManager cursor_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000684
685 ObserverList<ShellObserver> observers_;
686
687 // Used by ash/shell.
688 content::BrowserContext* browser_context_;
689
690 // For testing only: simulate that a modal window is open
691 bool simulate_modal_window_open_for_testing_;
692
Ben Murdocheb525c52013-07-10 11:40:50 +0100693 bool is_touch_hud_projection_enabled_;
694
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000695 DISALLOW_COPY_AND_ASSIGN(Shell);
696};
697
698} // namespace ash
699
700#endif // ASH_SHELL_H_