Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1 | // 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) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 12 | #include "ash/shelf/shelf_types.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 13 | #include "ash/system/user/login_status.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 14 | #include "ash/wm/system_modal_container_event_filter_delegate.h" |
| 15 | #include "base/basictypes.h" |
| 16 | #include "base/compiler_specific.h" |
| 17 | #include "base/gtest_prod_util.h" |
| 18 | #include "base/memory/scoped_ptr.h" |
| 19 | #include "base/observer_list.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 20 | #include "ui/aura/client/activation_change_observer.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 21 | #include "ui/base/events/event_target.h" |
| 22 | #include "ui/gfx/insets.h" |
| 23 | #include "ui/gfx/screen.h" |
| 24 | #include "ui/gfx/size.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 25 | #include "ui/views/corewm/cursor_manager.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 26 | |
| 27 | class CommandLine; |
| 28 | |
| 29 | namespace aura { |
| 30 | class EventFilter; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 31 | class RootWindow; |
| 32 | class Window; |
| 33 | namespace client { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 34 | class ActivationClient; |
| 35 | class FocusClient; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 36 | class UserActionClient; |
| 37 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 38 | } |
| 39 | namespace chromeos { |
| 40 | class OutputConfigurator; |
| 41 | } |
| 42 | namespace content { |
| 43 | class BrowserContext; |
| 44 | } |
| 45 | |
| 46 | namespace gfx { |
| 47 | class ImageSkia; |
| 48 | class Point; |
| 49 | class Rect; |
| 50 | } |
| 51 | namespace ui { |
| 52 | class Layer; |
| 53 | } |
| 54 | namespace views { |
| 55 | class NonClientFrameView; |
| 56 | class Widget; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 57 | namespace corewm { |
| 58 | class CompoundEventFilter; |
| 59 | class InputMethodEventFilter; |
| 60 | class ShadowController; |
| 61 | class TooltipController; |
| 62 | class VisibilityController; |
| 63 | class WindowModalityController; |
| 64 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | namespace ash { |
| 68 | |
| 69 | class AcceleratorController; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 70 | class AshNativeCursorManager; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 71 | class CapsLockDelegate; |
| 72 | class DesktopBackgroundController; |
| 73 | class DisplayController; |
| 74 | class HighContrastController; |
| 75 | class Launcher; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 76 | class LauncherDelegate; |
| 77 | class LauncherModel; |
| 78 | class MagnificationController; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 79 | class NestedDispatcherController; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 80 | class PartialMagnificationController; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 81 | class PowerButtonController; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 82 | class RootWindowHostFactory; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 83 | class ScreenAsh; |
| 84 | class SessionStateController; |
| 85 | class ShellDelegate; |
| 86 | class ShellObserver; |
| 87 | class SystemTray; |
| 88 | class SystemTrayDelegate; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 89 | class SystemTrayNotifier; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 90 | class UserActivityDetector; |
| 91 | class UserWallpaperDelegate; |
| 92 | class VideoDetector; |
| 93 | class WebNotificationTray; |
| 94 | class WindowCycleController; |
| 95 | |
| 96 | namespace internal { |
| 97 | class AcceleratorFilter; |
| 98 | class ActivationController; |
| 99 | class AppListController; |
| 100 | class CaptureController; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 101 | class DisplayChangeObserverX11; |
| 102 | class DisplayErrorObserver; |
| 103 | class DisplayManager; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 104 | class DragDropController; |
| 105 | class EventClientImpl; |
| 106 | class EventRewriterEventFilter; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 107 | class EventTransformationHandler; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 108 | class FocusCycler; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 109 | class MouseCursorEventFilter; |
| 110 | class OutputConfiguratorAnimation; |
| 111 | class OverlayEventFilter; |
| 112 | class ResizeShadowController; |
| 113 | class RootWindowController; |
| 114 | class RootWindowLayoutManager; |
| 115 | class ScreenPositionController; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 116 | class SlowAnimationEventFilter; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 117 | class StatusAreaWidget; |
| 118 | class SystemGestureEventFilter; |
| 119 | class SystemModalContainerEventFilter; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 120 | class TouchObserverHUD; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 121 | class WorkspaceController; |
| 122 | } |
| 123 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 124 | namespace shell { |
| 125 | class WindowWatcher; |
| 126 | } |
| 127 | |
| 128 | namespace test { |
| 129 | class ShellTestApi; |
| 130 | } |
| 131 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 132 | // Shell is a singleton object that presents the Shell API and implements the |
| 133 | // RootWindow's delegate interface. |
| 134 | // |
| 135 | // Upon creation, the Shell sets itself as the RootWindow's delegate, which |
| 136 | // takes ownership of the Shell. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 137 | class ASH_EXPORT Shell |
| 138 | : public internal::SystemModalContainerEventFilterDelegate, |
| 139 | public ui::EventTarget, |
| 140 | public aura::client::ActivationChangeObserver { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 141 | public: |
| 142 | typedef std::vector<aura::RootWindow*> RootWindowList; |
| 143 | typedef std::vector<internal::RootWindowController*> RootWindowControllerList; |
| 144 | |
| 145 | enum Direction { |
| 146 | FORWARD, |
| 147 | BACKWARD |
| 148 | }; |
| 149 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 150 | // A shell must be explicitly created so that it can call |Init()| with the |
| 151 | // delegate set. |delegate| can be NULL (if not required for initialization). |
| 152 | static Shell* CreateInstance(ShellDelegate* delegate); |
| 153 | |
| 154 | // Should never be called before |CreateInstance()|. |
| 155 | static Shell* GetInstance(); |
| 156 | |
| 157 | // Returns true if the ash shell has been instantiated. |
| 158 | static bool HasInstance(); |
| 159 | |
| 160 | static void DeleteInstance(); |
| 161 | |
| 162 | // Returns the root window controller for the primary root window. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 163 | // TODO(oshima): move this to |RootWindowController| |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 164 | static internal::RootWindowController* GetPrimaryRootWindowController(); |
| 165 | |
| 166 | // Returns all root window controllers. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 167 | // TODO(oshima): move this to |RootWindowController| |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 168 | static RootWindowControllerList GetAllRootWindowControllers(); |
| 169 | |
| 170 | // Returns the primary RootWindow. The primary RootWindow is the one |
| 171 | // that has a launcher. |
| 172 | static aura::RootWindow* GetPrimaryRootWindow(); |
| 173 | |
| 174 | // Returns the active RootWindow. The active RootWindow is the one that |
| 175 | // contains the current active window as a decendant child. The active |
| 176 | // RootWindow remains the same even when the active window becomes NULL, |
| 177 | // until the another window who has a different root window becomes active. |
| 178 | static aura::RootWindow* GetActiveRootWindow(); |
| 179 | |
| 180 | // Returns the global Screen object that's always active in ash. |
| 181 | static gfx::Screen* GetScreen(); |
| 182 | |
| 183 | // Returns all root windows. |
| 184 | static RootWindowList GetAllRootWindows(); |
| 185 | |
| 186 | static aura::Window* GetContainer(aura::RootWindow* root_window, |
| 187 | int container_id); |
| 188 | static const aura::Window* GetContainer(const aura::RootWindow* root_window, |
| 189 | int container_id); |
| 190 | |
| 191 | // Returns the list of containers that match |container_id| in |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 192 | // all root windows. If |priority_root| is given, the container |
| 193 | // in the |priority_root| will be inserted at the top of the list. |
| 194 | static std::vector<aura::Window*> GetContainersFromAllRootWindows( |
| 195 | int container_id, |
| 196 | aura::RootWindow* priority_root); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 197 | |
| 198 | // True if "launcher per display" feature is enabled. |
| 199 | static bool IsLauncherPerDisplayEnabled(); |
| 200 | |
| 201 | void set_active_root_window(aura::RootWindow* active_root_window) { |
| 202 | active_root_window_ = active_root_window; |
| 203 | } |
| 204 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 205 | // Shows the context menu for the background and launcher at |
| 206 | // |location_in_screen| (in screen coordinates). |
| 207 | void ShowContextMenu(const gfx::Point& location_in_screen); |
| 208 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 209 | // Toggles the app list. |window| specifies in which display the app |
| 210 | // list should be shown. If this is NULL, the active root window |
| 211 | // will be used. |
| 212 | void ToggleAppList(aura::Window* anchor); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 213 | |
| 214 | // Returns app list target visibility. |
| 215 | bool GetAppListTargetVisibility() const; |
| 216 | |
| 217 | // Returns app list window or NULL if it is not visible. |
| 218 | aura::Window* GetAppListWindow(); |
| 219 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 220 | // Returns true if a user is logged in whose session can be locked (i.e. the |
| 221 | // user has a password with which to unlock the session). |
| 222 | bool CanLockScreen(); |
| 223 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 224 | // Returns true if the screen is locked. |
| 225 | bool IsScreenLocked() const; |
| 226 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 227 | // Returns true if a system-modal dialog window is currently open. |
| 228 | bool IsSystemModalWindowOpen() const; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 229 | |
| 230 | // For testing only: set simulation that a modal window is open |
| 231 | void SimulateModalWindowOpenForTesting(bool modal_window_open) { |
| 232 | simulate_modal_window_open_for_testing_ = modal_window_open; |
| 233 | } |
| 234 | |
| 235 | // Creates a default views::NonClientFrameView for use by windows in the |
| 236 | // Ash environment. |
| 237 | views::NonClientFrameView* CreateDefaultNonClientFrameView( |
| 238 | views::Widget* widget); |
| 239 | |
| 240 | // Rotates focus through containers that can receive focus. |
| 241 | void RotateFocus(Direction direction); |
| 242 | |
| 243 | // Sets the work area insets of the display that contains |window|, |
| 244 | // this notifies observers too. |
| 245 | // TODO(sky): this no longer really replicates what happens and is unreliable. |
| 246 | // Remove this. |
| 247 | void SetDisplayWorkAreaInsets(aura::Window* window, |
| 248 | const gfx::Insets& insets); |
| 249 | |
| 250 | // Called when the user logs in. |
| 251 | void OnLoginStateChanged(user::LoginStatus status); |
| 252 | |
| 253 | // Called when the login status changes. |
| 254 | // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. |
| 255 | void UpdateAfterLoginStatusChange(user::LoginStatus status); |
| 256 | |
| 257 | // Called when the application is exiting. |
| 258 | void OnAppTerminating(); |
| 259 | |
| 260 | // Called when the screen is locked (after the lock window is visible) or |
| 261 | // unlocked. |
| 262 | void OnLockStateChanged(bool locked); |
| 263 | |
| 264 | // Initializes |launcher_|. Does nothing if it's already initialized. |
| 265 | void CreateLauncher(); |
| 266 | |
| 267 | // Show launcher view if it was created hidden (before session has started). |
| 268 | void ShowLauncher(); |
| 269 | |
| 270 | // Adds/removes observer. |
| 271 | void AddShellObserver(ShellObserver* observer); |
| 272 | void RemoveShellObserver(ShellObserver* observer); |
| 273 | |
| 274 | #if !defined(OS_MACOSX) |
| 275 | AcceleratorController* accelerator_controller() { |
| 276 | return accelerator_controller_.get(); |
| 277 | } |
| 278 | #endif // !defined(OS_MACOSX) |
| 279 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 280 | internal::DisplayManager* display_manager() { |
| 281 | return display_manager_.get(); |
| 282 | } |
| 283 | views::corewm::CompoundEventFilter* env_filter() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 284 | return env_filter_.get(); |
| 285 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 286 | views::corewm::TooltipController* tooltip_controller() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 287 | return tooltip_controller_.get(); |
| 288 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 289 | internal::TouchObserverHUD* touch_observer_hud() { |
| 290 | return touch_observer_hud_.get(); |
| 291 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 292 | internal::EventRewriterEventFilter* event_rewriter_filter() { |
| 293 | return event_rewriter_filter_.get(); |
| 294 | } |
| 295 | internal::OverlayEventFilter* overlay_filter() { |
| 296 | return overlay_filter_.get(); |
| 297 | } |
| 298 | DesktopBackgroundController* desktop_background_controller() { |
| 299 | return desktop_background_controller_.get(); |
| 300 | } |
| 301 | PowerButtonController* power_button_controller() { |
| 302 | return power_button_controller_.get(); |
| 303 | } |
| 304 | SessionStateController* session_state_controller() { |
| 305 | return session_state_controller_.get(); |
| 306 | } |
| 307 | UserActivityDetector* user_activity_detector() { |
| 308 | return user_activity_detector_.get(); |
| 309 | } |
| 310 | VideoDetector* video_detector() { |
| 311 | return video_detector_.get(); |
| 312 | } |
| 313 | WindowCycleController* window_cycle_controller() { |
| 314 | return window_cycle_controller_.get(); |
| 315 | } |
| 316 | internal::FocusCycler* focus_cycler() { |
| 317 | return focus_cycler_.get(); |
| 318 | } |
| 319 | DisplayController* display_controller() { |
| 320 | return display_controller_.get(); |
| 321 | } |
| 322 | internal::MouseCursorEventFilter* mouse_cursor_filter() { |
| 323 | return mouse_cursor_filter_.get(); |
| 324 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 325 | internal::EventTransformationHandler* event_transformation_handler() { |
| 326 | return event_transformation_handler_.get(); |
| 327 | } |
| 328 | views::corewm::CursorManager* cursor_manager() { return &cursor_manager_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 329 | |
| 330 | ShellDelegate* delegate() { return delegate_.get(); } |
| 331 | |
| 332 | UserWallpaperDelegate* user_wallpaper_delegate() { |
| 333 | return user_wallpaper_delegate_.get(); |
| 334 | } |
| 335 | |
| 336 | CapsLockDelegate* caps_lock_delegate() { |
| 337 | return caps_lock_delegate_.get(); |
| 338 | } |
| 339 | |
| 340 | HighContrastController* high_contrast_controller() { |
| 341 | return high_contrast_controller_.get(); |
| 342 | } |
| 343 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 344 | MagnificationController* magnification_controller() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 345 | return magnification_controller_.get(); |
| 346 | } |
| 347 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 348 | PartialMagnificationController* partial_magnification_controller() { |
| 349 | return partial_magnification_controller_.get(); |
| 350 | } |
| 351 | aura::client::ActivationClient* activation_client() { |
| 352 | return activation_client_; |
| 353 | } |
| 354 | |
| 355 | ScreenAsh* screen() { return screen_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 356 | |
| 357 | // Force the shelf to query for it's current visibility state. |
| 358 | void UpdateShelfVisibility(); |
| 359 | |
| 360 | // TODO(oshima): Define an interface to access shelf/launcher |
| 361 | // state, or just use Launcher. |
| 362 | |
| 363 | // Sets/gets the shelf auto-hide behavior on |root_window|. |
| 364 | void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, |
| 365 | aura::RootWindow* root_window); |
| 366 | ShelfAutoHideBehavior GetShelfAutoHideBehavior( |
| 367 | aura::RootWindow* root_window) const; |
| 368 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 369 | // Sets/gets shelf's alignment on |root_window|. |
| 370 | void SetShelfAlignment(ShelfAlignment alignment, |
| 371 | aura::RootWindow* root_window); |
| 372 | ShelfAlignment GetShelfAlignment(aura::RootWindow* root_window); |
| 373 | |
| 374 | // Dims or undims the screen. |
| 375 | void SetDimming(bool should_dim); |
| 376 | |
| 377 | // Creates a modal background (a partially-opaque fullscreen window) |
| 378 | // on all displays for |window|. |
| 379 | void CreateModalBackground(aura::Window* window); |
| 380 | |
| 381 | // Called when a modal window is removed. It will activate |
| 382 | // another modal window if any, or remove modal screens |
| 383 | // on all displays. |
| 384 | void OnModalWindowRemoved(aura::Window* removed); |
| 385 | |
| 386 | // Returns WebNotificationTray on the primary root window. |
| 387 | WebNotificationTray* GetWebNotificationTray(); |
| 388 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 389 | // Does the primary display have status area? |
| 390 | bool HasPrimaryStatusArea(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 391 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 392 | // Returns the system tray on primary display. |
| 393 | SystemTray* GetPrimarySystemTray(); |
| 394 | |
| 395 | SystemTrayDelegate* system_tray_delegate() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 396 | return system_tray_delegate_.get(); |
| 397 | } |
| 398 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 399 | SystemTrayNotifier* system_tray_notifier() { |
| 400 | return system_tray_notifier_.get(); |
| 401 | } |
| 402 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 403 | static void set_initially_hide_cursor(bool hide) { |
| 404 | initially_hide_cursor_ = hide; |
| 405 | } |
| 406 | |
| 407 | internal::ResizeShadowController* resize_shadow_controller() { |
| 408 | return resize_shadow_controller_.get(); |
| 409 | } |
| 410 | |
| 411 | // Made available for tests. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 412 | views::corewm::ShadowController* shadow_controller() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 413 | return shadow_controller_.get(); |
| 414 | } |
| 415 | |
| 416 | content::BrowserContext* browser_context() { return browser_context_; } |
| 417 | void set_browser_context(content::BrowserContext* browser_context) { |
| 418 | browser_context_ = browser_context; |
| 419 | } |
| 420 | |
| 421 | // Initializes the root window to be used for a secondary display. |
| 422 | void InitRootWindowForSecondaryDisplay(aura::RootWindow* root); |
| 423 | |
| 424 | // Starts the animation that occurs on first login. |
| 425 | void DoInitialWorkspaceAnimation(); |
| 426 | |
| 427 | #if defined(OS_CHROMEOS) |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 428 | // TODO(oshima): Move these objects to DisplayController. |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 429 | chromeos::OutputConfigurator* output_configurator() { |
| 430 | return output_configurator_.get(); |
| 431 | } |
| 432 | internal::OutputConfiguratorAnimation* output_configurator_animation() { |
| 433 | return output_configurator_animation_.get(); |
| 434 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 435 | internal::DisplayErrorObserver* display_error_observer() { |
| 436 | return display_error_observer_.get(); |
| 437 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 438 | #endif // defined(OS_CHROMEOS) |
| 439 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 440 | RootWindowHostFactory* root_window_host_factory() { |
| 441 | return root_window_host_factory_.get(); |
| 442 | } |
| 443 | |
| 444 | LauncherModel* launcher_model() { |
| 445 | return launcher_model_.get(); |
| 446 | } |
| 447 | |
| 448 | // Returns the launcher delegate, creating if necesary. |
| 449 | LauncherDelegate* GetLauncherDelegate(); |
| 450 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 451 | private: |
| 452 | FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor); |
| 453 | FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors); |
| 454 | FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate); |
| 455 | friend class internal::RootWindowController; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 456 | friend class test::ShellTestApi; |
| 457 | friend class shell::WindowWatcher; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 458 | |
| 459 | typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; |
| 460 | |
| 461 | explicit Shell(ShellDelegate* delegate); |
| 462 | virtual ~Shell(); |
| 463 | |
| 464 | void Init(); |
| 465 | |
| 466 | // Initializes the root window and root window controller so that it |
| 467 | // can host browser windows. |
| 468 | void InitRootWindowController(internal::RootWindowController* root); |
| 469 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 470 | // ash::internal::SystemModalContainerEventFilterDelegate overrides: |
| 471 | virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE; |
| 472 | |
| 473 | // Overridden from ui::EventTarget: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 474 | virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 475 | virtual EventTarget* GetParentTarget() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 476 | virtual void OnEvent(ui::Event* event) OVERRIDE; |
| 477 | |
| 478 | // Overridden from aura::client::ActivationChangeObserver: |
| 479 | virtual void OnWindowActivated(aura::Window* gained_active, |
| 480 | aura::Window* lost_active) OVERRIDE; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 481 | |
| 482 | static Shell* instance_; |
| 483 | |
| 484 | // If set before the Shell is initialized, the mouse cursor will be hidden |
| 485 | // when the screen is initially created. |
| 486 | static bool initially_hide_cursor_; |
| 487 | |
| 488 | ScreenAsh* screen_; |
| 489 | |
| 490 | // Active root window. Never becomes NULL during the session. |
| 491 | aura::RootWindow* active_root_window_; |
| 492 | |
| 493 | // The CompoundEventFilter owned by aura::Env object. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 494 | scoped_ptr<views::corewm::CompoundEventFilter> env_filter_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 495 | |
| 496 | std::vector<WindowAndBoundsPair> to_restore_; |
| 497 | |
| 498 | #if !defined(OS_MACOSX) |
| 499 | scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_; |
| 500 | |
| 501 | scoped_ptr<AcceleratorController> accelerator_controller_; |
| 502 | #endif // !defined(OS_MACOSX) |
| 503 | |
| 504 | scoped_ptr<ShellDelegate> delegate_; |
| 505 | scoped_ptr<SystemTrayDelegate> system_tray_delegate_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 506 | scoped_ptr<SystemTrayNotifier> system_tray_notifier_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 507 | scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_; |
| 508 | scoped_ptr<CapsLockDelegate> caps_lock_delegate_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 509 | scoped_ptr<LauncherDelegate> launcher_delegate_; |
| 510 | |
| 511 | scoped_ptr<LauncherModel> launcher_model_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 512 | |
| 513 | scoped_ptr<internal::AppListController> app_list_controller_; |
| 514 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 515 | scoped_ptr<internal::ActivationController> activation_controller_; |
| 516 | scoped_ptr<internal::CaptureController> capture_controller_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 517 | scoped_ptr<internal::DragDropController> drag_drop_controller_; |
| 518 | scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 519 | scoped_ptr<views::corewm::ShadowController> shadow_controller_; |
| 520 | scoped_ptr<views::corewm::VisibilityController> visibility_controller_; |
| 521 | scoped_ptr<views::corewm::WindowModalityController> |
| 522 | window_modality_controller_; |
| 523 | scoped_ptr<views::corewm::TooltipController> tooltip_controller_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 524 | scoped_ptr<DesktopBackgroundController> desktop_background_controller_; |
| 525 | scoped_ptr<PowerButtonController> power_button_controller_; |
| 526 | scoped_ptr<SessionStateController> session_state_controller_; |
| 527 | scoped_ptr<UserActivityDetector> user_activity_detector_; |
| 528 | scoped_ptr<VideoDetector> video_detector_; |
| 529 | scoped_ptr<WindowCycleController> window_cycle_controller_; |
| 530 | scoped_ptr<internal::FocusCycler> focus_cycler_; |
| 531 | scoped_ptr<DisplayController> display_controller_; |
| 532 | scoped_ptr<HighContrastController> high_contrast_controller_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 533 | scoped_ptr<MagnificationController> magnification_controller_; |
| 534 | scoped_ptr<PartialMagnificationController> partial_magnification_controller_; |
| 535 | scoped_ptr<aura::client::FocusClient> focus_client_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 536 | scoped_ptr<aura::client::UserActionClient> user_action_client_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 537 | aura::client::ActivationClient* activation_client_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 538 | scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_; |
| 539 | scoped_ptr<internal::ScreenPositionController> screen_position_controller_; |
| 540 | scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_; |
| 541 | scoped_ptr<internal::EventClientImpl> event_client_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 542 | scoped_ptr<internal::EventTransformationHandler> |
| 543 | event_transformation_handler_; |
| 544 | scoped_ptr<RootWindowHostFactory> root_window_host_factory_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 545 | |
| 546 | // An event filter that rewrites or drops an event. |
| 547 | scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_; |
| 548 | |
| 549 | // An event filter that pre-handles key events while the partial |
| 550 | // screenshot UI or the keyboard overlay is active. |
| 551 | scoped_ptr<internal::OverlayEventFilter> overlay_filter_; |
| 552 | |
| 553 | // An event filter which handles system level gestures |
| 554 | scoped_ptr<internal::SystemGestureEventFilter> system_gesture_filter_; |
| 555 | |
| 556 | #if !defined(OS_MACOSX) |
| 557 | // An event filter that pre-handles global accelerators. |
| 558 | scoped_ptr<internal::AcceleratorFilter> accelerator_filter_; |
| 559 | #endif |
| 560 | |
| 561 | // An event filter that pre-handles all key events to send them to an IME. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 562 | scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 563 | |
| 564 | // An event filter that silently keeps track of all touch events and controls |
| 565 | // a heads-up display. This is enabled only if --ash-touch-hud flag is used. |
| 566 | scoped_ptr<internal::TouchObserverHUD> touch_observer_hud_; |
| 567 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 568 | scoped_ptr<internal::DisplayManager> display_manager_; |
| 569 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 570 | #if defined(OS_CHROMEOS) |
| 571 | // Controls video output device state. |
| 572 | scoped_ptr<chromeos::OutputConfigurator> output_configurator_; |
| 573 | scoped_ptr<internal::OutputConfiguratorAnimation> |
| 574 | output_configurator_animation_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 575 | scoped_ptr<internal::DisplayErrorObserver> display_error_observer_; |
| 576 | |
| 577 | // Receives output change events and udpates the display manager. |
| 578 | scoped_ptr<internal::DisplayChangeObserverX11> display_change_observer_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 579 | #endif // defined(OS_CHROMEOS) |
| 580 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame^] | 581 | // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a |
| 582 | // pointer to vend to test code. |
| 583 | AshNativeCursorManager* native_cursor_manager_; |
| 584 | views::corewm::CursorManager cursor_manager_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 585 | |
| 586 | ObserverList<ShellObserver> observers_; |
| 587 | |
| 588 | // Used by ash/shell. |
| 589 | content::BrowserContext* browser_context_; |
| 590 | |
| 591 | // For testing only: simulate that a modal window is open |
| 592 | bool simulate_modal_window_open_for_testing_; |
| 593 | |
| 594 | DISALLOW_COPY_AND_ASSIGN(Shell); |
| 595 | }; |
| 596 | |
| 597 | } // namespace ash |
| 598 | |
| 599 | #endif // ASH_SHELL_H_ |