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