android webview envsetup: Set android_ndk_root and android_sdk_version to dummy values.
[chromium-blink-merge.git] / ash / root_window_controller.h
blobaa1ec2bc5a0b27692a69123bb258557a64f8a465
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.
5 #ifndef ASH_ROOT_WINDOW_CONTROLLER_H_
6 #define ASH_ROOT_WINDOW_CONTROLLER_H_
8 #include <map>
10 #include "ash/ash_export.h"
11 #include "ash/shelf/shelf_types.h"
12 #include "ash/shell_observer.h"
13 #include "ash/system/user/login_status.h"
14 #include "base/basictypes.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "ui/aura/root_window.h"
17 #include "ui/aura/window.h"
18 #include "ui/base/ui_base_types.h"
20 class SkBitmap;
22 namespace aura {
23 class EventFilter;
24 class Window;
27 namespace gfx {
28 class Point;
31 namespace views {
32 class Widget;
34 namespace corewm {
35 class InputMethodEventFilter;
36 class RootWindowEventFilter;
37 class ScopedCaptureClient;
41 namespace keyboard {
42 class KeyboardController;
45 namespace ui {
46 class EventHandler;
49 namespace ash {
50 class ShelfWidget;
51 class StackingController;
52 class SystemTray;
54 namespace internal {
56 class AlwaysOnTopController;
57 class AnimatingDesktopController;
58 class DesktopBackgroundWidgetController;
59 class DockedWindowLayoutManager;
60 class PanelLayoutManager;
61 class RootWindowLayoutManager;
62 class ScreenDimmer;
63 class ShelfLayoutManager;
64 class StatusAreaWidget;
65 class SystemBackgroundController;
66 class SystemModalContainerLayoutManager;
67 class TouchHudDebug;
68 class TouchHudProjection;
69 class WorkspaceController;
71 #if defined(OS_CHROMEOS)
72 class BootSplashScreen;
73 #endif
75 // This class maintains the per root window state for ash. This class
76 // owns the root window and other dependent objects that should be
77 // deleted upon the deletion of the root window. This object is
78 // indirectly owned and deleted by |DisplayController|.
79 // The RootWindowController for particular root window is stored in
80 // its property (RootWindowSettings) and can be obtained using
81 // |GetRootWindowController(aura::RootWindow*)| function.
82 class ASH_EXPORT RootWindowController : public ShellObserver {
83 public:
85 // Creates and Initialize the RootWindowController for primary display.
86 static void CreateForPrimaryDisplay(aura::RootWindow* root_window);
88 // Creates and Initialize the RootWindowController for secondary displays.
89 static void CreateForSecondaryDisplay(aura::RootWindow* root_window);
91 // Creates and Initialize the RootWindowController for virtual
92 // keyboard displays.
93 static void CreateForVirtualKeyboardDisplay(aura::RootWindow* root_window);
95 // Returns a RootWindowController that has a shelf for given
96 // |window|. This returns the RootWindowController for the |window|'s
97 // root window when multiple shelf mode is enabled, or the primary
98 // RootWindowController otherwise.
99 static RootWindowController* ForShelf(aura::Window* window);
101 // Returns a RootWindowController of the window's root window.
102 static RootWindowController* ForWindow(const aura::Window* window);
104 // Returns the RootWindowController of the target root window.
105 static internal::RootWindowController* ForTargetRootWindow();
107 // Returns container which contains a given |window|.
108 static aura::Window* GetContainerForWindow(aura::Window* window);
110 virtual ~RootWindowController();
112 aura::Window* root_window() { return dispatcher()->window(); }
113 aura::WindowEventDispatcher* dispatcher() { return root_window_.get(); }
115 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
117 WorkspaceController* workspace_controller() {
118 return workspace_controller_.get();
121 AlwaysOnTopController* always_on_top_controller() {
122 return always_on_top_controller_.get();
125 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
127 // Access the shelf associated with this root window controller,
128 // NULL if no such shelf exists.
129 ShelfWidget* shelf() { return shelf_.get(); }
131 // Get touch HUDs associated with this root window controller.
132 TouchHudDebug* touch_hud_debug() const {
133 return touch_hud_debug_;
135 TouchHudProjection* touch_hud_projection() const {
136 return touch_hud_projection_;
139 // Set touch HUDs for this root window controller. The root window controller
140 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
141 // the widget showing a HUD is being destroyed (e.g. because of detaching a
142 // display), the HUD deletes itself.
143 void set_touch_hud_debug(TouchHudDebug* hud) {
144 touch_hud_debug_ = hud;
146 void set_touch_hud_projection(TouchHudProjection* hud) {
147 touch_hud_projection_ = hud;
150 DesktopBackgroundWidgetController* wallpaper_controller() {
151 return wallpaper_controller_.get();
153 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
154 AnimatingDesktopController* animating_wallpaper_controller() {
155 return animating_wallpaper_controller_.get();
157 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
159 // Access the shelf layout manager associated with this root
160 // window controller, NULL if no such shelf exists.
161 ShelfLayoutManager* GetShelfLayoutManager();
163 // Returns the system tray on this root window. Note that
164 // calling this on the root window that doesn't have a shelf will
165 // lead to a crash.
166 SystemTray* GetSystemTray();
168 // Shows context menu at the |location_in_screen|. This uses
169 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
170 void ShowContextMenu(const gfx::Point& location_in_screen,
171 ui::MenuSourceType source_type);
173 // Returns the layout-manager for the appropriate modal-container. If the
174 // window is inside the lockscreen modal container, then the layout manager
175 // for that is returned. Otherwise the layout manager for the default modal
176 // container is returned.
177 // If no window is specified (i.e. |window| is NULL), then the lockscreen
178 // modal container is used if the screen is currently locked. Otherwise, the
179 // default modal container is used.
180 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
181 aura::Window* window);
183 aura::Window* GetContainer(int container_id);
184 const aura::Window* GetContainer(int container_id) const;
186 // Show shelf view if it was created hidden (before session has started).
187 void ShowShelf();
189 // Called when the shelf associated with this root window is created.
190 void OnShelfCreated();
192 // Called when the login status changes after login (such as lock/unlock).
193 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
194 void UpdateAfterLoginStatusChange(user::LoginStatus status);
196 // Called when the brightness/grayscale animation from white to the login
197 // desktop background image has started. Starts |boot_splash_screen_|'s
198 // hiding animation (if the screen is non-NULL).
199 void HandleInitialDesktopBackgroundAnimationStarted();
201 // Called when the wallpaper ainmation is finished. Updates |background_|
202 // to be black and drops |boot_splash_screen_| and moves the wallpaper
203 // controller into the root window controller. |widget| holds the wallpaper
204 // image, or NULL if the background is a solid color.
205 void OnWallpaperAnimationFinished(views::Widget* widget);
207 // Deletes associated objects and clears the state, but doesn't delete
208 // the root window yet. This is used to delete a secondary displays'
209 // root window safely when the display disconnect signal is received,
210 // which may come while we're in the nested message loop.
211 void Shutdown();
213 // Deletes all child windows and performs necessary cleanup.
214 void CloseChildWindows();
216 // Moves child windows to |dest|.
217 void MoveWindowsTo(aura::Window* dest);
219 // Force the shelf to query for it's current visibility state.
220 void UpdateShelfVisibility();
222 // Initialize touch HUDs if necessary.
223 void InitTouchHuds();
225 // Returns the topmost window or one of its transient parents, if any of them
226 // are in fullscreen mode.
227 const aura::Window* GetWindowForFullscreenMode() const;
229 // Activate virtual keyboard on current root window controller.
230 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
232 // Deactivate virtual keyboard on current root window controller.
233 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
235 private:
236 explicit RootWindowController(aura::RootWindow* root_window);
237 enum RootWindowType {
238 PRIMARY,
239 SECONDARY,
240 VIRTUAL_KEYBOARD
243 // Initializes the RootWindowController. |is_primary| is true if
244 // the controller is for primary display. |first_run_after_boot| is
245 // set to true only for primary root window after boot.
246 void Init(RootWindowType root_window_type, bool first_run_after_boot);
248 void InitLayoutManagers();
250 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
251 // |is_first_run_after_boot| determines the background's initial color.
252 void CreateSystemBackground(bool is_first_run_after_boot);
254 // Creates each of the special window containers that holds windows of various
255 // types in the shell UI.
256 void CreateContainersInRootWindow(aura::Window* root_window);
258 // Enables projection touch HUD.
259 void EnableTouchHudProjection();
261 // Disables projection touch HUD.
262 void DisableTouchHudProjection();
264 // Overridden from ShellObserver.
265 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
266 virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE;
268 scoped_ptr<aura::RootWindow> root_window_;
269 RootWindowLayoutManager* root_window_layout_;
271 scoped_ptr<StackingController> stacking_controller_;
273 // The shelf for managing the shelf and the status widget.
274 scoped_ptr<ShelfWidget> shelf_;
276 // An invisible/empty window used as a event target for
277 // |MouseCursorEventFilter| before a user logs in.
278 // (crbug.com/266987)
279 // Its container is |LockScreenBackgroundContainer| and
280 // this must be deleted before the container is deleted.
281 scoped_ptr<aura::Window> mouse_event_target_;
283 // Manages layout of docked windows. Owned by DockedContainer.
284 DockedWindowLayoutManager* docked_layout_manager_;
286 // Manages layout of panels. Owned by PanelContainer.
287 PanelLayoutManager* panel_layout_manager_;
289 scoped_ptr<SystemBackgroundController> system_background_;
290 #if defined(OS_CHROMEOS)
291 scoped_ptr<BootSplashScreen> boot_splash_screen_;
292 #endif
294 scoped_ptr<ScreenDimmer> screen_dimmer_;
295 scoped_ptr<WorkspaceController> workspace_controller_;
296 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
298 // Heads-up displays for touch events. These HUDs are not owned by the root
299 // window controller and manage their own lifetimes.
300 TouchHudDebug* touch_hud_debug_;
301 TouchHudProjection* touch_hud_projection_;
303 // Handles double clicks on the panel window header.
304 scoped_ptr<ui::EventHandler> panel_container_handler_;
306 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
307 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
308 scoped_ptr<views::corewm::ScopedCaptureClient> capture_client_;
310 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
314 // Gets the RootWindowController for |root_window|.
315 ASH_EXPORT RootWindowController* GetRootWindowController(
316 const aura::Window* root_window);
318 } // namespace internal
319 } // ash
321 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_