blob: 5c49f6b8bbcd5a4746ca3a6165668f9621e2aa3a [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)f2477e02013-11-28 11:55:43 +000012#include "ash/periodic_metrics_recorder.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000013#include "ash/shelf/shelf_types.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000014#include "ash/system/user/login_status.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000015#include "ash/wm/system_modal_container_event_filter_delegate.h"
16#include "base/basictypes.h"
17#include "base/compiler_specific.h"
18#include "base/gtest_prod_util.h"
19#include "base/memory/scoped_ptr.h"
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +000020#include "base/memory/weak_ptr.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000021#include "base/observer_list.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000022#include "ui/aura/client/activation_change_observer.h"
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +000023#include "ui/aura/window.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010024#include "ui/base/ui_base_types.h"
Torne (Richard Coles)d0247b12013-09-19 22:36:51 +010025#include "ui/events/event_target.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000026#include "ui/gfx/insets.h"
27#include "ui/gfx/screen.h"
28#include "ui/gfx/size.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000029#include "ui/views/corewm/cursor_manager.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000030
31class CommandLine;
32
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +010033namespace app_list {
34class AppListView;
35}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000036namespace aura {
37class EventFilter;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000038class RootWindow;
39class Window;
40namespace client {
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000041class ActivationClient;
42class FocusClient;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000043class UserActionClient;
44}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000045}
46namespace chromeos {
47class OutputConfigurator;
48}
Torne (Richard Coles)58218062012-11-14 11:43:16 +000049
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)1e9bf3e2013-10-31 11:16:26 +000079class AccessibilityDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000080class AshNativeCursorManager;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +010081class AutoclickController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000082class CapsLockDelegate;
83class DesktopBackgroundController;
84class DisplayController;
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +010085class FirstRunHelper;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000086class HighContrastController;
87class Launcher;
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +000088class ShelfDelegate;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +000089class LockStateController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000090class MagnificationController;
Torne (Richard Coles)0f1bc082013-11-06 12:27:47 +000091class MediaDelegate;
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)1e9bf3e2013-10-31 11:16:26 +000094class NewWindowDelegate;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000095class PartialMagnificationController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000096class PowerButtonController;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000097class RootWindowHostFactory;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000098class ScreenAsh;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010099class SessionStateDelegate;
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +0000100class ShelfItemDelegateManager;
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000101class ShelfModel;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000102class ShellDelegate;
103class ShellObserver;
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000104class StickyKeys;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000105class 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)a3f6a492013-12-18 16:25:09 +0000139class ShelfWindowWatcher;
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:
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000167 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.
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000210 static aura::Window::Windows GetAllRootWindows();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000211
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
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000273 // Called after the logged-in user's profile is ready.
274 void OnLoginUserProfilePrepared();
275
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000276 // Called when the login status changes.
277 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
278 void UpdateAfterLoginStatusChange(user::LoginStatus status);
279
280 // Called when the application is exiting.
281 void OnAppTerminating();
282
283 // Called when the screen is locked (after the lock window is visible) or
284 // unlocked.
285 void OnLockStateChanged(bool locked);
286
287 // Initializes |launcher_|. Does nothing if it's already initialized.
288 void CreateLauncher();
289
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000290 // Creates virtual keyboard. Deletes the old virtual keyboard if it's already
291 // exist.
292 void CreateKeyboard();
293
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100294 // Show shelf view if it was created hidden (before session has started).
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000295 void ShowLauncher();
296
297 // Adds/removes observer.
298 void AddShellObserver(ShellObserver* observer);
299 void RemoveShellObserver(ShellObserver* observer);
300
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100301 keyboard::KeyboardController* keyboard_controller() {
302 return keyboard_controller_.get();
303 }
304
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000305 AcceleratorController* accelerator_controller() {
306 return accelerator_controller_.get();
307 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000308
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000309 internal::DisplayManager* display_manager() {
310 return display_manager_.get();
311 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100312 views::corewm::InputMethodEventFilter* input_method_filter() {
313 return input_method_filter_.get();
314 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000315 views::corewm::CompoundEventFilter* env_filter() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000316 return env_filter_.get();
317 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000318 views::corewm::TooltipController* tooltip_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000319 return tooltip_controller_.get();
320 }
321 internal::EventRewriterEventFilter* event_rewriter_filter() {
322 return event_rewriter_filter_.get();
323 }
324 internal::OverlayEventFilter* overlay_filter() {
325 return overlay_filter_.get();
326 }
327 DesktopBackgroundController* desktop_background_controller() {
328 return desktop_background_controller_.get();
329 }
330 PowerButtonController* power_button_controller() {
331 return power_button_controller_.get();
332 }
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100333 LockStateController* lock_state_controller() {
334 return lock_state_controller_.get();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000335 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100336 MruWindowTracker* mru_window_tracker() {
337 return mru_window_tracker_.get();
338 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000339 UserActivityDetector* user_activity_detector() {
340 return user_activity_detector_.get();
341 }
342 VideoDetector* video_detector() {
343 return video_detector_.get();
344 }
345 WindowCycleController* window_cycle_controller() {
346 return window_cycle_controller_.get();
347 }
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100348 WindowSelectorController* window_selector_controller() {
349 return window_selector_controller_.get();
350 }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000351 internal::FocusCycler* focus_cycler() {
352 return focus_cycler_.get();
353 }
354 DisplayController* display_controller() {
355 return display_controller_.get();
356 }
357 internal::MouseCursorEventFilter* mouse_cursor_filter() {
358 return mouse_cursor_filter_.get();
359 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000360 internal::EventTransformationHandler* event_transformation_handler() {
361 return event_transformation_handler_.get();
362 }
363 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000364
365 ShellDelegate* delegate() { return delegate_.get(); }
366
367 UserWallpaperDelegate* user_wallpaper_delegate() {
368 return user_wallpaper_delegate_.get();
369 }
370
371 CapsLockDelegate* caps_lock_delegate() {
372 return caps_lock_delegate_.get();
373 }
374
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100375 SessionStateDelegate* session_state_delegate() {
376 return session_state_delegate_.get();
377 }
378
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000379 AccessibilityDelegate* accessibility_delegate() {
380 return accessibility_delegate_.get();
381 }
382
383 NewWindowDelegate* new_window_delegate() {
384 return new_window_delegate_.get();
385 }
386
Torne (Richard Coles)0f1bc082013-11-06 12:27:47 +0000387 MediaDelegate* media_delegate() {
388 return media_delegate_.get();
389 }
390
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000391 HighContrastController* high_contrast_controller() {
392 return high_contrast_controller_.get();
393 }
394
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000395 MagnificationController* magnification_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000396 return magnification_controller_.get();
397 }
398
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000399 PartialMagnificationController* partial_magnification_controller() {
400 return partial_magnification_controller_.get();
401 }
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100402
403 AutoclickController* autoclick_controller() {
404 return autoclick_controller_.get();
405 }
406
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000407 aura::client::ActivationClient* activation_client() {
408 return activation_client_;
409 }
410
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +0000411 ShelfItemDelegateManager* shelf_item_delegate_manager() {
412 return shelf_item_delegate_manager_.get();
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +0100413 }
414
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000415 ScreenAsh* screen() { return screen_; }
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000416
417 // Force the shelf to query for it's current visibility state.
418 void UpdateShelfVisibility();
419
420 // TODO(oshima): Define an interface to access shelf/launcher
421 // state, or just use Launcher.
422
423 // Sets/gets the shelf auto-hide behavior on |root_window|.
424 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000425 aura::Window* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000426 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000427 aura::Window* root_window) const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000428
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000429 // Sets/gets shelf's alignment on |root_window|.
430 void SetShelfAlignment(ShelfAlignment alignment,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000431 aura::Window* root_window);
432 ShelfAlignment GetShelfAlignment(aura::Window* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000433
434 // Dims or undims the screen.
435 void SetDimming(bool should_dim);
436
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100437 // Notifies |observers_| when entering or exiting fullscreen mode in
438 // |root_window|.
439 void NotifyFullscreenStateChange(bool is_fullscreen,
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000440 aura::Window* root_window);
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100441
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000442 // Creates a modal background (a partially-opaque fullscreen window)
443 // on all displays for |window|.
444 void CreateModalBackground(aura::Window* window);
445
446 // Called when a modal window is removed. It will activate
447 // another modal window if any, or remove modal screens
448 // on all displays.
449 void OnModalWindowRemoved(aura::Window* removed);
450
451 // Returns WebNotificationTray on the primary root window.
452 WebNotificationTray* GetWebNotificationTray();
453
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000454 // Does the primary display have status area?
455 bool HasPrimaryStatusArea();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000456
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000457 // Returns the system tray on primary display.
458 SystemTray* GetPrimarySystemTray();
459
460 SystemTrayDelegate* system_tray_delegate() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000461 return system_tray_delegate_.get();
462 }
463
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000464 SystemTrayNotifier* system_tray_notifier() {
465 return system_tray_notifier_.get();
466 }
467
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000468 static void set_initially_hide_cursor(bool hide) {
469 initially_hide_cursor_ = hide;
470 }
471
472 internal::ResizeShadowController* resize_shadow_controller() {
473 return resize_shadow_controller_.get();
474 }
475
476 // Made available for tests.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000477 views::corewm::ShadowController* shadow_controller() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000478 return shadow_controller_.get();
479 }
480
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000481 // Starts the animation that occurs on first login.
482 void DoInitialWorkspaceAnimation();
483
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100484#if defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000485 // TODO(oshima): Move these objects to DisplayController.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000486 chromeos::OutputConfigurator* output_configurator() {
487 return output_configurator_.get();
488 }
489 internal::OutputConfiguratorAnimation* output_configurator_animation() {
490 return output_configurator_animation_.get();
491 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000492 internal::DisplayErrorObserver* display_error_observer() {
493 return display_error_observer_.get();
494 }
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100495#endif // defined(OS_CHROMEOS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000496
Ben Murdochba5b9a62013-08-12 14:20:17 +0100497 internal::ResolutionNotificationController*
498 resolution_notification_controller() {
499 return resolution_notification_controller_.get();
500 }
501
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000502 RootWindowHostFactory* root_window_host_factory() {
503 return root_window_host_factory_.get();
504 }
505
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000506 ShelfModel* shelf_model() {
507 return shelf_model_.get();
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000508 }
509
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100510 WindowPositioner* window_positioner() {
511 return window_positioner_.get();
512 }
513
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000514 // Returns the launcher delegate, creating if necesary.
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +0000515 ShelfDelegate* GetShelfDelegate();
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000516
Ben Murdocheb525c52013-07-10 11:40:50 +0100517 void SetTouchHudProjectionEnabled(bool enabled);
518
519 bool is_touch_hud_projection_enabled() const {
520 return is_touch_hud_projection_enabled_;
521 }
522
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100523#if defined(OS_CHROMEOS)
524 // Creates instance of FirstRunHelper. Caller is responsible for deleting
525 // returned object.
526 ash::FirstRunHelper* CreateFirstRunHelper();
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000527
528 StickyKeys* sticky_keys() {
529 return sticky_keys_.get();
530 }
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100531#endif // defined(OS_CHROMEOS)
532
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000533 private:
534 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
535 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
536 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
537 friend class internal::RootWindowController;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100538 friend class internal::ScopedTargetRootWindow;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000539 friend class test::ShellTestApi;
540 friend class shell::WindowWatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000541
542 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
543
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100544 // Takes ownership of |delegate|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000545 explicit Shell(ShellDelegate* delegate);
546 virtual ~Shell();
547
548 void Init();
549
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000550 // Initializes virtual keyboard controller.
551 void InitKeyboard();
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100552
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +0100553 // Initializes the root window so that it can host browser windows.
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000554 void InitRootWindow(aura::Window* root_window);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000555
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000556 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
557 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
558
559 // Overridden from ui::EventTarget:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000560 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000561 virtual EventTarget* GetParentTarget() OVERRIDE;
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +0000562 virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const OVERRIDE;
563 virtual ui::EventTargeter* GetEventTargeter() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000564 virtual void OnEvent(ui::Event* event) OVERRIDE;
565
566 // Overridden from aura::client::ActivationChangeObserver:
567 virtual void OnWindowActivated(aura::Window* gained_active,
568 aura::Window* lost_active) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000569
570 static Shell* instance_;
571
572 // If set before the Shell is initialized, the mouse cursor will be hidden
573 // when the screen is initially created.
574 static bool initially_hide_cursor_;
575
576 ScreenAsh* screen_;
577
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100578 // When no explicit target display/RootWindow is given, new windows are
579 // created on |scoped_target_root_window_| , unless NULL in
580 // which case they are created on |target_root_window_|.
581 // |target_root_window_| never becomes NULL during the session.
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000582 aura::Window* target_root_window_;
583 aura::Window* scoped_target_root_window_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000584
585 // The CompoundEventFilter owned by aura::Env object.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000586 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000587
588 std::vector<WindowAndBoundsPair> to_restore_;
589
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000590 scoped_ptr<PeriodicMetricsRecorder> periodic_metrics_recorder_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100591 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000592 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000593 scoped_ptr<AcceleratorController> accelerator_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000594 scoped_ptr<ShellDelegate> delegate_;
595 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000596 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000597 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
598 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100599 scoped_ptr<SessionStateDelegate> session_state_delegate_;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000600 scoped_ptr<AccessibilityDelegate> accessibility_delegate_;
601 scoped_ptr<NewWindowDelegate> new_window_delegate_;
Torne (Richard Coles)0f1bc082013-11-06 12:27:47 +0000602 scoped_ptr<MediaDelegate> media_delegate_;
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +0000603 scoped_ptr<ShelfDelegate> shelf_delegate_;
604 scoped_ptr<ShelfItemDelegateManager> shelf_item_delegate_manager_;
605 scoped_ptr<internal::ShelfWindowWatcher> shelf_window_watcher_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000606
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000607 scoped_ptr<ShelfModel> shelf_model_;
608 scoped_ptr<WindowPositioner> window_positioner_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000609
610 scoped_ptr<internal::AppListController> app_list_controller_;
611
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000612 scoped_ptr<internal::DragDropController> drag_drop_controller_;
613 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000614 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
615 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
616 scoped_ptr<views::corewm::WindowModalityController>
617 window_modality_controller_;
618 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000619 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
620 scoped_ptr<PowerButtonController> power_button_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100621 scoped_ptr<LockStateController> lock_state_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100622 scoped_ptr<MruWindowTracker> mru_window_tracker_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000623 scoped_ptr<UserActivityDetector> user_activity_detector_;
624 scoped_ptr<VideoDetector> video_detector_;
625 scoped_ptr<WindowCycleController> window_cycle_controller_;
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100626 scoped_ptr<WindowSelectorController> window_selector_controller_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000627 scoped_ptr<internal::FocusCycler> focus_cycler_;
628 scoped_ptr<DisplayController> display_controller_;
629 scoped_ptr<HighContrastController> high_contrast_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000630 scoped_ptr<MagnificationController> magnification_controller_;
631 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100632 scoped_ptr<AutoclickController> autoclick_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000633 scoped_ptr<aura::client::FocusClient> focus_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000634 scoped_ptr<aura::client::UserActionClient> user_action_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000635 aura::client::ActivationClient* activation_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000636 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
637 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
638 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
639 scoped_ptr<internal::EventClientImpl> event_client_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000640 scoped_ptr<internal::EventTransformationHandler>
641 event_transformation_handler_;
642 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000643
644 // An event filter that rewrites or drops an event.
645 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
646
647 // An event filter that pre-handles key events while the partial
648 // screenshot UI or the keyboard overlay is active.
649 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
650
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100651 // An event filter for logging keyboard-related metrics.
652 scoped_ptr<internal::KeyboardUMAEventFilter> keyboard_metrics_filter_;
653
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000654 // An event filter which handles system level gestures
655 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
656
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000657 // An event filter that pre-handles global accelerators.
658 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000659
660 // An event filter that pre-handles all key events to send them to an IME.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000661 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000662
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000663 scoped_ptr<internal::DisplayManager> display_manager_;
Torne (Richard Coles)1e9bf3e2013-10-31 11:16:26 +0000664 scoped_ptr<base::WeakPtrFactory<internal::DisplayManager> >
665 weak_display_manager_factory_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000666
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +0100667 scoped_ptr<internal::LocaleNotificationController>
668 locale_notification_controller_;
669
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100670#if defined(OS_CHROMEOS)
671 scoped_ptr<internal::PowerEventObserver> power_event_observer_;
672 scoped_ptr<internal::UserActivityNotifier> user_activity_notifier_;
673 scoped_ptr<internal::VideoActivityNotifier> video_activity_notifier_;
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +0000674 scoped_ptr<StickyKeys> sticky_keys_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100675#if defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000676 // Controls video output device state.
677 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
678 scoped_ptr<internal::OutputConfiguratorAnimation>
679 output_configurator_animation_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000680 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
681
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +0100682 // Listens for output changes and updates the display manager.
683 scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +0100684#endif // defined(USE_X11)
685#endif // defined(OS_CHROMEOS)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000686
Ben Murdochba5b9a62013-08-12 14:20:17 +0100687 scoped_ptr<internal::ResolutionNotificationController>
688 resolution_notification_controller_;
689
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000690 // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
691 // pointer to vend to test code.
692 AshNativeCursorManager* native_cursor_manager_;
693 views::corewm::CursorManager cursor_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000694
695 ObserverList<ShellObserver> observers_;
696
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000697 // For testing only: simulate that a modal window is open
698 bool simulate_modal_window_open_for_testing_;
699
Ben Murdocheb525c52013-07-10 11:40:50 +0100700 bool is_touch_hud_projection_enabled_;
701
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000702 DISALLOW_COPY_AND_ASSIGN(Shell);
703};
704
705} // namespace ash
706
707#endif // ASH_SHELL_H_