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