blob: 5c49f6b8bbcd5a4746ca3a6165668f9621e2aa3a [file] [log] [blame]
[email protected]e0d22e82012-01-04 00:46:571// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]87b0d82e2011-10-07 21:02:592// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]b65bdda2011-12-23 23:35:315#ifndef ASH_SHELL_H_
6#define ASH_SHELL_H_
[email protected]87b0d82e2011-10-07 21:02:597
[email protected]cac10fc62011-10-07 23:22:568#include <utility>
9#include <vector>
10
[email protected]b65bdda2011-12-23 23:35:3111#include "ash/ash_export.h"
[email protected]5dacbb92013-11-19 03:58:5612#include "ash/periodic_metrics_recorder.h"
[email protected]478c6c32013-03-09 02:50:5813#include "ash/shelf/shelf_types.h"
[email protected]82d3954ae2012-04-20 09:02:2214#include "ash/system/user/login_status.h"
[email protected]c0ce80e2012-10-05 23:28:2715#include "ash/wm/system_modal_container_event_filter_delegate.h"
[email protected]87b0d82e2011-10-07 21:02:5916#include "base/basictypes.h"
[email protected]c45fdc72012-02-22 22:59:1217#include "base/compiler_specific.h"
[email protected]b0639282011-12-22 21:12:2718#include "base/gtest_prod_util.h"
[email protected]2b99f8c2011-10-11 19:42:2419#include "base/memory/scoped_ptr.h"
[email protected]6f67df52013-10-29 01:07:1520#include "base/memory/weak_ptr.h"
[email protected]1a2145b2012-03-13 21:09:1721#include "base/observer_list.h"
[email protected]1ae361652012-12-12 22:39:5122#include "ui/aura/client/activation_change_observer.h"
[email protected]c9390bd2013-11-08 20:33:1323#include "ui/aura/window.h"
[email protected]940fb1c2013-06-18 16:54:2824#include "ui/base/ui_base_types.h"
[email protected]86ccbd42013-09-18 18:11:5425#include "ui/events/event_target.h"
[email protected]2eb6b892012-05-31 13:28:2126#include "ui/gfx/insets.h"
[email protected]ffabb1e2012-10-12 19:51:1727#include "ui/gfx/screen.h"
[email protected]9ec0f452012-05-31 15:58:5328#include "ui/gfx/size.h"
[email protected]c0ff0342013-02-27 00:41:2929#include "ui/views/corewm/cursor_manager.h"
[email protected]87b0d82e2011-10-07 21:02:5930
[email protected]b0639282011-12-22 21:12:2731class CommandLine;
32
[email protected]59ccade2013-10-17 17:56:4033namespace app_list {
34class AppListView;
35}
[email protected]87b0d82e2011-10-07 21:02:5936namespace aura {
[email protected]e29014c2011-11-16 18:25:5137class EventFilter;
[email protected]35304ce2011-12-14 23:21:0138class RootWindow;
[email protected]87b0d82e2011-10-07 21:02:5939class Window;
[email protected]c28853612012-05-31 22:43:4440namespace client {
[email protected]39718b52012-12-03 17:24:5641class ActivationClient;
[email protected]8cfb6722012-11-28 03:28:4642class FocusClient;
[email protected]c28853612012-05-31 22:43:4443class UserActionClient;
44}
[email protected]87b0d82e2011-10-07 21:02:5945}
[email protected]70b3e7d52012-06-02 22:12:2546namespace chromeos {
47class OutputConfigurator;
48}
[email protected]fa4a45832012-04-12 21:32:4849
[email protected]2b99f8c2011-10-11 19:42:2450namespace gfx {
[email protected]9ec0f452012-05-31 15:58:5351class ImageSkia;
[email protected]b5f30602012-01-30 15:16:5752class Point;
[email protected]cac10fc62011-10-07 23:22:5653class Rect;
54}
[email protected]b6ba05d902013-10-04 21:38:4555
56namespace keyboard {
57class KeyboardController;
58}
59
[email protected]a8bd1cb2012-02-17 23:05:5460namespace ui {
61class Layer;
62}
[email protected]57b8bb352012-01-11 05:11:4663namespace views {
64class NonClientFrameView;
65class Widget;
[email protected]4a59e4e2012-11-12 21:15:4066namespace corewm {
67class CompoundEventFilter;
68class InputMethodEventFilter;
[email protected]86f2b5e2012-11-14 20:37:0069class ShadowController;
[email protected]a1b7a822013-02-23 19:08:0470class TooltipController;
[email protected]b5756e22012-11-30 01:32:0271class VisibilityController;
[email protected]0c2dc012012-12-02 00:00:2372class WindowModalityController;
[email protected]4a59e4e2012-11-12 21:15:4073}
[email protected]57b8bb352012-01-11 05:11:4674}
[email protected]87b0d82e2011-10-07 21:02:5975
[email protected]55f593352011-12-24 05:42:4676namespace ash {
[email protected]87b0d82e2011-10-07 21:02:5977
[email protected]2f744282011-12-23 22:40:5278class AcceleratorController;
[email protected]f3ab6eff52013-10-24 03:29:3879class AccessibilityDelegate;
[email protected]c0ff0342013-02-27 00:41:2980class AshNativeCursorManager;
[email protected]55398d22013-10-10 19:49:2081class AutoclickController;
[email protected]f4c92b382012-08-28 00:59:5982class CapsLockDelegate;
[email protected]e70cf0ed2012-03-15 16:24:4783class DesktopBackgroundController;
[email protected]edbfb8d2012-09-03 08:33:4384class DisplayController;
[email protected]59ccade2013-10-17 17:56:4085class FirstRunHelper;
[email protected]f48075d2012-05-24 11:06:5186class HighContrastController;
[email protected]671a2ae2011-10-13 21:53:2387class Launcher;
[email protected]8b57e942013-12-09 19:39:2088class ShelfDelegate;
[email protected]47686c42013-10-25 01:49:1789class LockStateController;
[email protected]77f7c132012-11-15 06:52:5490class MagnificationController;
[email protected]efc897f72013-11-01 11:43:0791class MediaDelegate;
[email protected]66c5c4112013-07-31 07:10:5992class MruWindowTracker;
[email protected]8f80db0f2012-02-07 14:44:5393class NestedDispatcherController;
[email protected]47686c42013-10-25 01:49:1794class NewWindowDelegate;
[email protected]77f7c132012-11-15 06:52:5495class PartialMagnificationController;
[email protected]e0d22e82012-01-04 00:46:5796class PowerButtonController;
[email protected]8520ebd22013-11-20 01:41:5197class RootWindowHostFactory;
[email protected]1a2145b2012-03-13 21:09:1798class ScreenAsh;
[email protected]fcb123d2013-04-17 15:58:4999class SessionStateDelegate;
[email protected]c25ff502013-12-04 13:52:48100class ShelfItemDelegateManager;
[email protected]64936bf2013-11-14 19:48:36101class ShelfModel;
[email protected]2b99f8c2011-10-11 19:42:24102class ShellDelegate;
[email protected]1a2145b2012-03-13 21:09:17103class ShellObserver;
[email protected]f94c6aa2013-11-08 01:18:54104class StickyKeys;
[email protected]bfb411312012-02-27 20:59:27105class SystemTray;
[email protected]51ed5992012-11-07 10:14:39106class SystemTrayDelegate;
[email protected]83b2b84c2012-11-14 01:11:00107class SystemTrayNotifier;
[email protected]c16b9422012-06-06 21:51:11108class UserActivityDetector;
[email protected]10b22612012-03-22 17:07:55109class UserWallpaperDelegate;
[email protected]6aa614a2012-01-19 22:13:38110class VideoDetector;
[email protected]88d71122012-10-18 07:11:01111class WebNotificationTray;
[email protected]40c4cbb2012-01-10 23:26:07112class WindowCycleController;
[email protected]e9a71312013-10-04 03:20:01113class WindowPositioner;
[email protected]d24ce2c2013-08-01 15:14:19114class WindowSelectorController;
[email protected]60fa9bba2011-10-28 21:21:51115
116namespace internal {
[email protected]2f744282011-12-23 22:40:52117class AcceleratorFilter;
[email protected]0039db92012-05-09 04:11:45118class AppListController;
[email protected]60a978b72012-06-08 00:29:18119class CaptureController;
[email protected]c1234a42013-08-20 09:35:40120class DisplayChangeObserver;
[email protected]18b21b2e2013-03-01 20:56:23121class DisplayErrorObserver;
[email protected]6bdf7952012-11-14 10:10:58122class DisplayManager;
[email protected]084b6bb2011-11-17 05:18:16123class DragDropController;
[email protected]e67291f12012-10-10 05:52:38124class EventClientImpl;
[email protected]b9d224c2012-07-13 01:09:03125class EventRewriterEventFilter;
[email protected]682990f2013-01-10 06:49:11126class EventTransformationHandler;
[email protected]3d29912a2012-02-07 07:41:51127class FocusCycler;
[email protected]7a80cdd2013-09-26 09:20:53128class KeyboardUMAEventFilter;
[email protected]a9a40462013-07-31 06:22:56129class LocaleNotificationController;
[email protected]78d96302012-06-22 00:58:07130class MouseCursorEventFilter;
[email protected]196e9452012-08-01 06:42:51131class OutputConfiguratorAnimation;
[email protected]9ae32df2012-07-26 03:25:18132class OverlayEventFilter;
[email protected]51625052013-10-10 01:40:16133class PowerEventObserver;
[email protected]e4a181cc2012-03-17 02:20:57134class ResizeShadowController;
[email protected]6ef71d72013-08-10 18:13:44135class ResolutionNotificationController;
[email protected]d90b8392012-06-13 09:34:56136class RootWindowController;
[email protected]b42910f2013-08-01 11:45:29137class ScopedTargetRootWindow;
[email protected]8d625fb2012-07-18 16:40:06138class ScreenPositionController;
[email protected]055a56d2013-12-06 12:13:36139class ShelfWindowWatcher;
[email protected]9861f1752012-06-01 07:16:14140class SlowAnimationEventFilter;
[email protected]6d6546e2012-05-30 23:12:02141class StatusAreaWidget;
[email protected]9ae32df2012-07-26 03:25:18142class SystemGestureEventFilter;
[email protected]c0ce80e2012-10-05 23:28:27143class SystemModalContainerEventFilter;
[email protected]73074742012-05-17 01:44:41144class TouchObserverHUD;
[email protected]ded58fd2013-10-09 07:56:55145class UserActivityNotifier;
146class VideoActivityNotifier;
[email protected]60fa9bba2011-10-28 21:21:51147}
[email protected]2b99f8c2011-10-11 19:42:24148
[email protected]0af58042012-12-13 03:21:35149namespace shell {
150class WindowWatcher;
151}
152
[email protected]0c68e892012-12-08 16:54:53153namespace test {
154class ShellTestApi;
155}
156
[email protected]87b0d82e2011-10-07 21:02:59157// Shell is a singleton object that presents the Shell API and implements the
[email protected]99f07e02011-12-07 00:02:59158// RootWindow's delegate interface.
[email protected]b0079a92012-01-25 20:13:38159//
160// Upon creation, the Shell sets itself as the RootWindow's delegate, which
161// takes ownership of the Shell.
[email protected]1ae361652012-12-12 22:39:51162class ASH_EXPORT Shell
163 : public internal::SystemModalContainerEventFilterDelegate,
164 public ui::EventTarget,
165 public aura::client::ActivationChangeObserver {
[email protected]87b0d82e2011-10-07 21:02:59166 public:
[email protected]be65be362012-06-15 07:38:23167 typedef std::vector<internal::RootWindowController*> RootWindowControllerList;
168
[email protected]3d29912a2012-02-07 07:41:51169 enum Direction {
170 FORWARD,
171 BACKWARD
172 };
173
[email protected]3266c2b92011-11-14 00:06:08174 // 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).
[email protected]09464c72013-04-26 07:31:28176 // Takes ownership of |delegate|.
[email protected]3266c2b92011-11-14 00:06:08177 static Shell* CreateInstance(ShellDelegate* delegate);
178
179 // Should never be called before |CreateInstance()|.
[email protected]cac10fc62011-10-07 23:22:56180 static Shell* GetInstance();
[email protected]3266c2b92011-11-14 00:06:08181
[email protected]b3b7bcd2012-03-06 19:35:45182 // Returns true if the ash shell has been instantiated.
183 static bool HasInstance();
184
[email protected]ef589af2011-12-03 01:07:15185 static void DeleteInstance();
[email protected]cac10fc62011-10-07 23:22:56186
[email protected]d90b8392012-06-13 09:34:56187 // Returns the root window controller for the primary root window.
[email protected]a0afeb12012-12-10 22:57:09188 // TODO(oshima): move this to |RootWindowController|
[email protected]d90b8392012-06-13 09:34:56189 static internal::RootWindowController* GetPrimaryRootWindowController();
190
[email protected]cf1c70e2012-08-30 01:13:02191 // Returns all root window controllers.
[email protected]a0afeb12012-12-10 22:57:09192 // TODO(oshima): move this to |RootWindowController|
[email protected]be65be362012-06-15 07:38:23193 static RootWindowControllerList GetAllRootWindowControllers();
194
[email protected]bf9cdb362013-10-25 19:22:45195 // Returns the primary root Window. The primary root Window is the one that
196 // has a launcher.
197 static aura::Window* GetPrimaryRootWindow();
[email protected]e73bd7802012-02-17 20:10:34198
[email protected]bf9cdb362013-10-25 19:22:45199 // Returns a root Window when used as a target when creating a new window.
[email protected]b42910f2013-08-01 11:45:29200 // The root window of the active window is used in most cases, but can
201 // be overridden by using ScopedTargetRootWindow().
[email protected]bf9cdb362013-10-25 19:22:45202 // If you want to get the root Window of the active window, just use
[email protected]b42910f2013-08-01 11:45:29203 // |wm::GetActiveWindow()->GetRootWindow()|.
[email protected]bf9cdb362013-10-25 19:22:45204 static aura::Window* GetTargetRootWindow();
[email protected]a857dbe2012-05-30 22:10:14205
[email protected]ffabb1e2012-10-12 19:51:17206 // Returns the global Screen object that's always active in ash.
207 static gfx::Screen* GetScreen();
208
[email protected]cf1c70e2012-08-30 01:13:02209 // Returns all root windows.
[email protected]c9390bd2013-11-08 20:33:13210 static aura::Window::Windows GetAllRootWindows();
[email protected]be65be362012-06-15 07:38:23211
[email protected]bf9cdb362013-10-25 19:22:45212 static aura::Window* GetContainer(aura::Window* root_window,
[email protected]7b0f7502012-06-11 00:12:39213 int container_id);
[email protected]bf9cdb362013-10-25 19:22:45214 static const aura::Window* GetContainer(const aura::Window* root_window,
[email protected]e67291f12012-10-10 05:52:38215 int container_id);
[email protected]7b0f7502012-06-11 00:12:39216
217 // Returns the list of containers that match |container_id| in
[email protected]429433f2012-12-28 20:14:46218 // 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,
[email protected]bf9cdb362013-10-25 19:22:45222 aura::Window* priority_root);
[email protected]7b0f7502012-06-11 00:12:39223
[email protected]bf9cdb362013-10-25 19:22:45224 void set_target_root_window(aura::Window* target_root_window) {
[email protected]b42910f2013-08-01 11:45:29225 target_root_window_ = target_root_window;
[email protected]a857dbe2012-05-30 22:10:14226 }
227
[email protected]cb054f972012-10-11 20:27:28228 // Shows the context menu for the background and launcher at
[email protected]431552c2012-10-23 00:38:33229 // |location_in_screen| (in screen coordinates).
[email protected]940fb1c2013-06-18 16:54:28230 void ShowContextMenu(const gfx::Point& location_in_screen,
231 ui::MenuSourceType source_type);
[email protected]cac10fc62011-10-07 23:22:56232
[email protected]b913a3a2012-12-11 13:07:19233 // 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);
[email protected]ae4987d2011-11-21 22:52:44237
[email protected]7510d1082012-03-30 21:58:34238 // Returns app list target visibility.
239 bool GetAppListTargetVisibility() const;
240
[email protected]1e51a9d2012-04-09 23:31:11241 // Returns app list window or NULL if it is not visible.
242 aura::Window* GetAppListWindow();
243
[email protected]59ccade2013-10-17 17:56:40244 // Returns app list view or NULL if it is not visible.
245 app_list::AppListView* GetAppListView();
246
[email protected]dc09739372012-11-15 20:17:39247 // Returns true if a system-modal dialog window is currently open.
248 bool IsSystemModalWindowOpen() const;
[email protected]40c4cbb2012-01-10 23:26:07249
[email protected]852a55d2012-10-17 13:30:30250 // 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
[email protected]57b8bb352012-01-11 05:11:46255 // Creates a default views::NonClientFrameView for use by windows in the
256 // Ash environment.
257 views::NonClientFrameView* CreateDefaultNonClientFrameView(
258 views::Widget* widget);
259
[email protected]d9456cb2012-03-21 16:41:04260 // Rotates focus through containers that can receive focus.
[email protected]3d29912a2012-02-07 07:41:51261 void RotateFocus(Direction direction);
262
[email protected]2e236a52012-06-27 22:21:47263 // Sets the work area insets of the display that contains |window|,
[email protected]8a45c972012-03-14 18:22:44264 // this notifies observers too.
[email protected]27f6af62012-03-21 05:34:40265 // TODO(sky): this no longer really replicates what happens and is unreliable.
266 // Remove this.
[email protected]2e236a52012-06-27 22:21:47267 void SetDisplayWorkAreaInsets(aura::Window* window,
[email protected]8a45c972012-03-14 18:22:44268 const gfx::Insets& insets);
[email protected]1a2145b2012-03-13 21:09:17269
[email protected]82d3954ae2012-04-20 09:02:22270 // Called when the user logs in.
271 void OnLoginStateChanged(user::LoginStatus status);
272
[email protected]51f438112013-11-18 19:32:50273 // Called after the logged-in user's profile is ready.
274 void OnLoginUserProfilePrepared();
275
[email protected]88d71122012-10-18 07:11:01276 // Called when the login status changes.
277 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
278 void UpdateAfterLoginStatusChange(user::LoginStatus status);
279
[email protected]82d3954ae2012-04-20 09:02:22280 // 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
[email protected]d9456cb2012-03-21 16:41:04287 // Initializes |launcher_|. Does nothing if it's already initialized.
288 void CreateLauncher();
289
[email protected]51f438112013-11-18 19:32:50290 // Creates virtual keyboard. Deletes the old virtual keyboard if it's already
291 // exist.
292 void CreateKeyboard();
293
[email protected]99c5ed82013-10-18 01:30:04294 // Show shelf view if it was created hidden (before session has started).
[email protected]7e1df2f62012-07-19 19:17:18295 void ShowLauncher();
296
[email protected]d9456cb2012-03-21 16:41:04297 // Adds/removes observer.
[email protected]1a2145b2012-03-13 21:09:17298 void AddShellObserver(ShellObserver* observer);
299 void RemoveShellObserver(ShellObserver* observer);
300
[email protected]b6ba05d902013-10-04 21:38:45301 keyboard::KeyboardController* keyboard_controller() {
302 return keyboard_controller_.get();
303 }
304
[email protected]2f744282011-12-23 22:40:52305 AcceleratorController* accelerator_controller() {
[email protected]745816be2011-11-22 05:08:30306 return accelerator_controller_.get();
307 }
[email protected]6e9f6aa2012-02-09 04:16:20308
[email protected]6bdf7952012-11-14 10:10:58309 internal::DisplayManager* display_manager() {
310 return display_manager_.get();
311 }
[email protected]f1d5c3a2013-04-23 17:42:56312 views::corewm::InputMethodEventFilter* input_method_filter() {
313 return input_method_filter_.get();
314 }
[email protected]4a59e4e2012-11-12 21:15:40315 views::corewm::CompoundEventFilter* env_filter() {
[email protected]492533b32012-09-21 19:06:14316 return env_filter_.get();
[email protected]627a62f2012-02-14 22:59:14317 }
[email protected]a1b7a822013-02-23 19:08:04318 views::corewm::TooltipController* tooltip_controller() {
[email protected]862deef2011-12-15 22:07:33319 return tooltip_controller_.get();
[email protected]4a229e902011-12-01 21:21:11320 }
[email protected]b9d224c2012-07-13 01:09:03321 internal::EventRewriterEventFilter* event_rewriter_filter() {
322 return event_rewriter_filter_.get();
[email protected]42f06f92012-03-27 00:57:57323 }
[email protected]9ae32df2012-07-26 03:25:18324 internal::OverlayEventFilter* overlay_filter() {
325 return overlay_filter_.get();
[email protected]0b0b0742012-02-16 13:23:45326 }
[email protected]e70cf0ed2012-03-15 16:24:47327 DesktopBackgroundController* desktop_background_controller() {
328 return desktop_background_controller_.get();
329 }
[email protected]e0d22e82012-01-04 00:46:57330 PowerButtonController* power_button_controller() {
331 return power_button_controller_.get();
332 }
[email protected]ab4f8c92013-05-30 19:07:47333 LockStateController* lock_state_controller() {
334 return lock_state_controller_.get();
[email protected]222f40c2012-10-18 08:58:13335 }
[email protected]66c5c4112013-07-31 07:10:59336 MruWindowTracker* mru_window_tracker() {
337 return mru_window_tracker_.get();
338 }
[email protected]c16b9422012-06-06 21:51:11339 UserActivityDetector* user_activity_detector() {
340 return user_activity_detector_.get();
341 }
[email protected]6aa614a2012-01-19 22:13:38342 VideoDetector* video_detector() {
343 return video_detector_.get();
344 }
[email protected]40c4cbb2012-01-10 23:26:07345 WindowCycleController* window_cycle_controller() {
346 return window_cycle_controller_.get();
347 }
[email protected]d24ce2c2013-08-01 15:14:19348 WindowSelectorController* window_selector_controller() {
349 return window_selector_controller_.get();
350 }
[email protected]2d511542012-03-07 09:13:34351 internal::FocusCycler* focus_cycler() {
352 return focus_cycler_.get();
353 }
[email protected]edbfb8d2012-09-03 08:33:43354 DisplayController* display_controller() {
[email protected]2e236a52012-06-27 22:21:47355 return display_controller_.get();
[email protected]3e1cdd312012-06-07 03:48:41356 }
[email protected]8b7ba87b2012-09-01 00:40:40357 internal::MouseCursorEventFilter* mouse_cursor_filter() {
358 return mouse_cursor_filter_.get();
359 }
[email protected]682990f2013-01-10 06:49:11360 internal::EventTransformationHandler* event_transformation_handler() {
361 return event_transformation_handler_.get();
362 }
[email protected]c0ff0342013-02-27 00:41:29363 views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; }
[email protected]4a229e902011-12-01 21:21:11364
[email protected]3266c2b92011-11-14 00:06:08365 ShellDelegate* delegate() { return delegate_.get(); }
[email protected]aa54218b2012-06-12 16:51:42366
[email protected]10b22612012-03-22 17:07:55367 UserWallpaperDelegate* user_wallpaper_delegate() {
368 return user_wallpaper_delegate_.get();
369 }
[email protected]35304ce2011-12-14 23:21:01370
[email protected]f4c92b382012-08-28 00:59:59371 CapsLockDelegate* caps_lock_delegate() {
372 return caps_lock_delegate_.get();
373 }
374
[email protected]fcb123d2013-04-17 15:58:49375 SessionStateDelegate* session_state_delegate() {
376 return session_state_delegate_.get();
377 }
378
[email protected]f3ab6eff52013-10-24 03:29:38379 AccessibilityDelegate* accessibility_delegate() {
380 return accessibility_delegate_.get();
381 }
382
[email protected]47686c42013-10-25 01:49:17383 NewWindowDelegate* new_window_delegate() {
384 return new_window_delegate_.get();
385 }
386
[email protected]efc897f72013-11-01 11:43:07387 MediaDelegate* media_delegate() {
388 return media_delegate_.get();
389 }
390
[email protected]f48075d2012-05-24 11:06:51391 HighContrastController* high_contrast_controller() {
392 return high_contrast_controller_.get();
393 }
394
[email protected]77f7c132012-11-15 06:52:54395 MagnificationController* magnification_controller() {
[email protected]c1c670172012-04-26 04:20:26396 return magnification_controller_.get();
397 }
[email protected]f48075d2012-05-24 11:06:51398
[email protected]77f7c132012-11-15 06:52:54399 PartialMagnificationController* partial_magnification_controller() {
400 return partial_magnification_controller_.get();
401 }
[email protected]55398d22013-10-10 19:49:20402
403 AutoclickController* autoclick_controller() {
404 return autoclick_controller_.get();
405 }
406
[email protected]d219a192012-12-14 00:08:18407 aura::client::ActivationClient* activation_client() {
408 return activation_client_;
409 }
[email protected]77f7c132012-11-15 06:52:54410
[email protected]c25ff502013-12-04 13:52:48411 ShelfItemDelegateManager* shelf_item_delegate_manager() {
412 return shelf_item_delegate_manager_.get();
[email protected]cc29ba12013-08-28 05:22:34413 }
414
[email protected]6bdf7952012-11-14 10:10:58415 ScreenAsh* screen() { return screen_; }
[email protected]1a2145b2012-03-13 21:09:17416
[email protected]c758fbf2012-03-25 22:53:59417 // Force the shelf to query for it's current visibility state.
418 void UpdateShelfVisibility();
419
[email protected]431552c2012-10-23 00:38:33420 // TODO(oshima): Define an interface to access shelf/launcher
421 // state, or just use Launcher.
[email protected]c758fbf2012-03-25 22:53:59422
[email protected]431552c2012-10-23 00:38:33423 // Sets/gets the shelf auto-hide behavior on |root_window|.
424 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
[email protected]bf9cdb362013-10-25 19:22:45425 aura::Window* root_window);
[email protected]431552c2012-10-23 00:38:33426 ShelfAutoHideBehavior GetShelfAutoHideBehavior(
[email protected]bf9cdb362013-10-25 19:22:45427 aura::Window* root_window) const;
[email protected]431552c2012-10-23 00:38:33428
[email protected]431552c2012-10-23 00:38:33429 // Sets/gets shelf's alignment on |root_window|.
430 void SetShelfAlignment(ShelfAlignment alignment,
[email protected]bf9cdb362013-10-25 19:22:45431 aura::Window* root_window);
432 ShelfAlignment GetShelfAlignment(aura::Window* root_window);
[email protected]55444502012-05-10 15:43:53433
[email protected]d90b8392012-06-13 09:34:56434 // Dims or undims the screen.
435 void SetDimming(bool should_dim);
436
[email protected]375069e2013-10-04 13:54:31437 // Notifies |observers_| when entering or exiting fullscreen mode in
438 // |root_window|.
439 void NotifyFullscreenStateChange(bool is_fullscreen,
[email protected]bf9cdb362013-10-25 19:22:45440 aura::Window* root_window);
[email protected]375069e2013-10-04 13:54:31441
[email protected]090c4f12012-10-29 18:56:42442 // Creates a modal background (a partially-opaque fullscreen window)
443 // on all displays for |window|.
444 void CreateModalBackground(aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27445
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
[email protected]88d71122012-10-18 07:11:01451 // Returns WebNotificationTray on the primary root window.
452 WebNotificationTray* GetWebNotificationTray();
[email protected]6d6546e2012-05-30 23:12:02453
[email protected]a0afeb12012-12-10 22:57:09454 // Does the primary display have status area?
455 bool HasPrimaryStatusArea();
456
457 // Returns the system tray on primary display.
458 SystemTray* GetPrimarySystemTray();
[email protected]bfb411312012-02-27 20:59:27459
[email protected]945f9cae2012-12-12 09:54:29460 SystemTrayDelegate* system_tray_delegate() {
[email protected]51ed5992012-11-07 10:14:39461 return system_tray_delegate_.get();
462 }
463
[email protected]83b2b84c2012-11-14 01:11:00464 SystemTrayNotifier* system_tray_notifier() {
465 return system_tray_notifier_.get();
466 }
467
[email protected]9488d4d2012-02-29 18:32:37468 static void set_initially_hide_cursor(bool hide) {
469 initially_hide_cursor_ = hide;
470 }
471
[email protected]e4a181cc2012-03-17 02:20:57472 internal::ResizeShadowController* resize_shadow_controller() {
473 return resize_shadow_controller_.get();
474 }
475
[email protected]a54e65b2011-11-21 22:03:34476 // Made available for tests.
[email protected]86f2b5e2012-11-14 20:37:00477 views::corewm::ShadowController* shadow_controller() {
[email protected]a54e65b2011-11-21 22:03:34478 return shadow_controller_.get();
479 }
480
[email protected]f9466702012-09-17 16:35:27481 // Starts the animation that occurs on first login.
482 void DoInitialWorkspaceAnimation();
483
[email protected]117542c2013-04-30 20:27:21484#if defined(OS_CHROMEOS) && defined(USE_X11)
[email protected]945ece962013-03-21 06:42:39485 // TODO(oshima): Move these objects to DisplayController.
[email protected]70b3e7d52012-06-02 22:12:25486 chromeos::OutputConfigurator* output_configurator() {
487 return output_configurator_.get();
488 }
[email protected]196e9452012-08-01 06:42:51489 internal::OutputConfiguratorAnimation* output_configurator_animation() {
490 return output_configurator_animation_.get();
491 }
[email protected]18b21b2e2013-03-01 20:56:23492 internal::DisplayErrorObserver* display_error_observer() {
493 return display_error_observer_.get();
494 }
[email protected]117542c2013-04-30 20:27:21495#endif // defined(OS_CHROMEOS) && defined(USE_X11)
[email protected]70b3e7d52012-06-02 22:12:25496
[email protected]6ef71d72013-08-10 18:13:44497 internal::ResolutionNotificationController*
498 resolution_notification_controller() {
499 return resolution_notification_controller_.get();
500 }
501
[email protected]8520ebd22013-11-20 01:41:51502 RootWindowHostFactory* root_window_host_factory() {
[email protected]8393aa62013-01-23 19:40:10503 return root_window_host_factory_.get();
504 }
505
[email protected]64936bf2013-11-14 19:48:36506 ShelfModel* shelf_model() {
507 return shelf_model_.get();
[email protected]478c6c32013-03-09 02:50:58508 }
509
[email protected]e9a71312013-10-04 03:20:01510 WindowPositioner* window_positioner() {
511 return window_positioner_.get();
512 }
513
[email protected]478c6c32013-03-09 02:50:58514 // Returns the launcher delegate, creating if necesary.
[email protected]8b57e942013-12-09 19:39:20515 ShelfDelegate* GetShelfDelegate();
[email protected]478c6c32013-03-09 02:50:58516
[email protected]2b8a9bb2013-07-01 22:43:40517 void SetTouchHudProjectionEnabled(bool enabled);
518
519 bool is_touch_hud_projection_enabled() const {
520 return is_touch_hud_projection_enabled_;
521 }
522
[email protected]59ccade2013-10-17 17:56:40523#if defined(OS_CHROMEOS)
524 // Creates instance of FirstRunHelper. Caller is responsible for deleting
525 // returned object.
526 ash::FirstRunHelper* CreateFirstRunHelper();
[email protected]f94c6aa2013-11-08 01:18:54527
528 StickyKeys* sticky_keys() {
529 return sticky_keys_.get();
530 }
[email protected]59ccade2013-10-17 17:56:40531#endif // defined(OS_CHROMEOS)
532
[email protected]2b4cd302012-02-24 20:21:13533 private:
[email protected]c39be8f2012-06-15 22:58:36534 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
[email protected]1aad3322012-06-06 06:37:09535 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
536 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
[email protected]d90b8392012-06-13 09:34:56537 friend class internal::RootWindowController;
[email protected]b42910f2013-08-01 11:45:29538 friend class internal::ScopedTargetRootWindow;
[email protected]0c68e892012-12-08 16:54:53539 friend class test::ShellTestApi;
[email protected]0af58042012-12-13 03:21:35540 friend class shell::WindowWatcher;
[email protected]ad0c8722012-03-02 20:17:45541
[email protected]cac10fc62011-10-07 23:22:56542 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
543
[email protected]09464c72013-04-26 07:31:28544 // Takes ownership of |delegate|.
[email protected]3266c2b92011-11-14 00:06:08545 explicit Shell(ShellDelegate* delegate);
546 virtual ~Shell();
547
548 void Init();
[email protected]b0639282011-12-22 21:12:27549
[email protected]51f438112013-11-18 19:32:50550 // Initializes virtual keyboard controller.
551 void InitKeyboard();
[email protected]b6ba05d902013-10-04 21:38:45552
[email protected]a273d33a2013-10-17 12:41:21553 // Initializes the root window so that it can host browser windows.
[email protected]41baaed2013-11-09 04:18:26554 void InitRootWindow(aura::Window* root_window);
[email protected]d90b8392012-06-13 09:34:56555
[email protected]c0ce80e2012-10-05 23:28:27556 // ash::internal::SystemModalContainerEventFilterDelegate overrides:
557 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE;
558
[email protected]5097e692012-10-30 22:08:41559 // Overridden from ui::EventTarget:
[email protected]869f6352012-12-06 20:47:17560 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
[email protected]5097e692012-10-30 22:08:41561 virtual EventTarget* GetParentTarget() OVERRIDE;
[email protected]3e670aa2013-12-02 19:04:32562 virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const OVERRIDE;
563 virtual ui::EventTargeter* GetEventTargeter() OVERRIDE;
[email protected]049cf34b2012-12-07 17:15:48564 virtual void OnEvent(ui::Event* event) OVERRIDE;
[email protected]5097e692012-10-30 22:08:41565
[email protected]1ae361652012-12-12 22:39:51566 // Overridden from aura::client::ActivationChangeObserver:
567 virtual void OnWindowActivated(aura::Window* gained_active,
568 aura::Window* lost_active) OVERRIDE;
569
[email protected]cac10fc62011-10-07 23:22:56570 static Shell* instance_;
571
[email protected]9488d4d2012-02-29 18:32:37572 // 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
[email protected]b0a8faa2012-10-19 03:22:22576 ScreenAsh* screen_;
[email protected]58482fa2012-03-02 14:57:39577
[email protected]b42910f2013-08-01 11:45:29578 // 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.
[email protected]bf9cdb362013-10-25 19:22:45582 aura::Window* target_root_window_;
583 aura::Window* scoped_target_root_window_;
[email protected]a857dbe2012-05-30 22:10:14584
[email protected]1aad3322012-06-06 06:37:09585 // The CompoundEventFilter owned by aura::Env object.
[email protected]4a59e4e2012-11-12 21:15:40586 scoped_ptr<views::corewm::CompoundEventFilter> env_filter_;
[email protected]627a62f2012-02-14 22:59:14587
[email protected]cac10fc62011-10-07 23:22:56588 std::vector<WindowAndBoundsPair> to_restore_;
589
[email protected]5dacbb92013-11-19 03:58:56590 scoped_ptr<PeriodicMetricsRecorder> periodic_metrics_recorder_;
[email protected]b6ba05d902013-10-04 21:38:45591 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
[email protected]8f80db0f2012-02-07 14:44:53592 scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_;
[email protected]2f744282011-12-23 22:40:52593 scoped_ptr<AcceleratorController> accelerator_controller_;
[email protected]2b99f8c2011-10-11 19:42:24594 scoped_ptr<ShellDelegate> delegate_;
[email protected]51ed5992012-11-07 10:14:39595 scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
[email protected]83b2b84c2012-11-14 01:11:00596 scoped_ptr<SystemTrayNotifier> system_tray_notifier_;
[email protected]10b22612012-03-22 17:07:55597 scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
[email protected]f4c92b382012-08-28 00:59:59598 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
[email protected]fcb123d2013-04-17 15:58:49599 scoped_ptr<SessionStateDelegate> session_state_delegate_;
[email protected]f3ab6eff52013-10-24 03:29:38600 scoped_ptr<AccessibilityDelegate> accessibility_delegate_;
[email protected]47686c42013-10-25 01:49:17601 scoped_ptr<NewWindowDelegate> new_window_delegate_;
[email protected]efc897f72013-11-01 11:43:07602 scoped_ptr<MediaDelegate> media_delegate_;
[email protected]8b57e942013-12-09 19:39:20603 scoped_ptr<ShelfDelegate> shelf_delegate_;
[email protected]c25ff502013-12-04 13:52:48604 scoped_ptr<ShelfItemDelegateManager> shelf_item_delegate_manager_;
[email protected]055a56d2013-12-06 12:13:36605 scoped_ptr<internal::ShelfWindowWatcher> shelf_window_watcher_;
[email protected]b913a3a2012-12-11 13:07:19606
[email protected]64936bf2013-11-14 19:48:36607 scoped_ptr<ShelfModel> shelf_model_;
608 scoped_ptr<WindowPositioner> window_positioner_;
[email protected]2b99f8c2011-10-11 19:42:24609
[email protected]0039db92012-05-09 04:11:45610 scoped_ptr<internal::AppListController> app_list_controller_;
[email protected]ae4987d2011-11-21 22:52:44611
[email protected]084b6bb2011-11-17 05:18:16612 scoped_ptr<internal::DragDropController> drag_drop_controller_;
[email protected]e4a181cc2012-03-17 02:20:57613 scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
[email protected]86f2b5e2012-11-14 20:37:00614 scoped_ptr<views::corewm::ShadowController> shadow_controller_;
[email protected]b5756e22012-11-30 01:32:02615 scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
[email protected]0c2dc012012-12-02 00:00:23616 scoped_ptr<views::corewm::WindowModalityController>
617 window_modality_controller_;
[email protected]a1b7a822013-02-23 19:08:04618 scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
[email protected]e70cf0ed2012-03-15 16:24:47619 scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
[email protected]e0d22e82012-01-04 00:46:57620 scoped_ptr<PowerButtonController> power_button_controller_;
[email protected]ab4f8c92013-05-30 19:07:47621 scoped_ptr<LockStateController> lock_state_controller_;
[email protected]66c5c4112013-07-31 07:10:59622 scoped_ptr<MruWindowTracker> mru_window_tracker_;
[email protected]c16b9422012-06-06 21:51:11623 scoped_ptr<UserActivityDetector> user_activity_detector_;
[email protected]6aa614a2012-01-19 22:13:38624 scoped_ptr<VideoDetector> video_detector_;
[email protected]40c4cbb2012-01-10 23:26:07625 scoped_ptr<WindowCycleController> window_cycle_controller_;
[email protected]d24ce2c2013-08-01 15:14:19626 scoped_ptr<WindowSelectorController> window_selector_controller_;
[email protected]3d29912a2012-02-07 07:41:51627 scoped_ptr<internal::FocusCycler> focus_cycler_;
[email protected]edbfb8d2012-09-03 08:33:43628 scoped_ptr<DisplayController> display_controller_;
[email protected]f48075d2012-05-24 11:06:51629 scoped_ptr<HighContrastController> high_contrast_controller_;
[email protected]77f7c132012-11-15 06:52:54630 scoped_ptr<MagnificationController> magnification_controller_;
631 scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
[email protected]55398d22013-10-10 19:49:20632 scoped_ptr<AutoclickController> autoclick_controller_;
[email protected]8cfb6722012-11-28 03:28:46633 scoped_ptr<aura::client::FocusClient> focus_client_;
[email protected]c28853612012-05-31 22:43:44634 scoped_ptr<aura::client::UserActionClient> user_action_client_;
[email protected]39718b52012-12-03 17:24:56635 aura::client::ActivationClient* activation_client_;
[email protected]78d96302012-06-22 00:58:07636 scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_;
[email protected]8d625fb2012-07-18 16:40:06637 scoped_ptr<internal::ScreenPositionController> screen_position_controller_;
[email protected]c0ce80e2012-10-05 23:28:27638 scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_;
[email protected]e67291f12012-10-10 05:52:38639 scoped_ptr<internal::EventClientImpl> event_client_;
[email protected]682990f2013-01-10 06:49:11640 scoped_ptr<internal::EventTransformationHandler>
641 event_transformation_handler_;
[email protected]8520ebd22013-11-20 01:41:51642 scoped_ptr<RootWindowHostFactory> root_window_host_factory_;
[email protected]ae18b9112011-11-07 16:59:13643
[email protected]b9d224c2012-07-13 01:09:03644 // An event filter that rewrites or drops an event.
645 scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_;
[email protected]6e9f6aa2012-02-09 04:16:20646
[email protected]0b0b0742012-02-16 13:23:45647 // An event filter that pre-handles key events while the partial
[email protected]a1584a712012-07-30 21:02:26648 // screenshot UI or the keyboard overlay is active.
[email protected]9ae32df2012-07-26 03:25:18649 scoped_ptr<internal::OverlayEventFilter> overlay_filter_;
[email protected]0b0b0742012-02-16 13:23:45650
[email protected]7a80cdd2013-09-26 09:20:53651 // An event filter for logging keyboard-related metrics.
652 scoped_ptr<internal::KeyboardUMAEventFilter> keyboard_metrics_filter_;
653
[email protected]435b212e2012-04-05 19:43:37654 // An event filter which handles system level gestures
655 scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_;
656
[email protected]745816be2011-11-22 05:08:30657 // An event filter that pre-handles global accelerators.
[email protected]2f744282011-12-23 22:40:52658 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_;
[email protected]745816be2011-11-22 05:08:30659
[email protected]42f06f92012-03-27 00:57:57660 // An event filter that pre-handles all key events to send them to an IME.
[email protected]4a59e4e2012-11-12 21:15:40661 scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_;
[email protected]42f06f92012-03-27 00:57:57662
[email protected]6bdf7952012-11-14 10:10:58663 scoped_ptr<internal::DisplayManager> display_manager_;
[email protected]6f67df52013-10-29 01:07:15664 scoped_ptr<base::WeakPtrFactory<internal::DisplayManager> >
665 weak_display_manager_factory_;
[email protected]6bdf7952012-11-14 10:10:58666
[email protected]a9a40462013-07-31 06:22:56667 scoped_ptr<internal::LocaleNotificationController>
668 locale_notification_controller_;
669
[email protected]ded58fd2013-10-09 07:56:55670#if defined(OS_CHROMEOS)
[email protected]51625052013-10-10 01:40:16671 scoped_ptr<internal::PowerEventObserver> power_event_observer_;
[email protected]ded58fd2013-10-09 07:56:55672 scoped_ptr<internal::UserActivityNotifier> user_activity_notifier_;
673 scoped_ptr<internal::VideoActivityNotifier> video_activity_notifier_;
[email protected]f94c6aa2013-11-08 01:18:54674 scoped_ptr<StickyKeys> sticky_keys_;
[email protected]ded58fd2013-10-09 07:56:55675#if defined(USE_X11)
[email protected]70b3e7d52012-06-02 22:12:25676 // Controls video output device state.
677 scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
[email protected]196e9452012-08-01 06:42:51678 scoped_ptr<internal::OutputConfiguratorAnimation>
679 output_configurator_animation_;
[email protected]18b21b2e2013-03-01 20:56:23680 scoped_ptr<internal::DisplayErrorObserver> display_error_observer_;
[email protected]6bdf7952012-11-14 10:10:58681
[email protected]c1234a42013-08-20 09:35:40682 // Listens for output changes and updates the display manager.
683 scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
[email protected]ded58fd2013-10-09 07:56:55684#endif // defined(USE_X11)
685#endif // defined(OS_CHROMEOS)
[email protected]70b3e7d52012-06-02 22:12:25686
[email protected]6ef71d72013-08-10 18:13:44687 scoped_ptr<internal::ResolutionNotificationController>
688 resolution_notification_controller_;
689
[email protected]c0ff0342013-02-27 00:41:29690 // |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_;
[email protected]4b8003c2012-07-26 00:54:19694
[email protected]1a2145b2012-03-13 21:09:17695 ObserverList<ShellObserver> observers_;
696
[email protected]852a55d2012-10-17 13:30:30697 // For testing only: simulate that a modal window is open
698 bool simulate_modal_window_open_for_testing_;
699
[email protected]2b8a9bb2013-07-01 22:43:40700 bool is_touch_hud_projection_enabled_;
701
[email protected]87b0d82e2011-10-07 21:02:59702 DISALLOW_COPY_AND_ASSIGN(Shell);
703};
704
[email protected]55f593352011-12-24 05:42:46705} // namespace ash
[email protected]87b0d82e2011-10-07 21:02:59706
[email protected]b65bdda2011-12-23 23:35:31707#endif // ASH_SHELL_H_