blob: 92185a6a63ea562a710909c986e80f1c80074848 [file] [log] [blame]
[email protected]d90b8392012-06-13 09:34:561// 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_ROOT_WINDOW_CONTROLLER_H_
6#define ASH_ROOT_WINDOW_CONTROLLER_H_
[email protected]d90b8392012-06-13 09:34:567
[email protected]c0ce80e2012-10-05 23:28:278#include "ash/ash_export.h"
[email protected]ef80e4302012-12-04 19:37:319#include "ash/shelf_types.h"
[email protected]16059276d2012-10-22 18:59:5010#include "ash/system/user/login_status.h"
[email protected]d90b8392012-06-13 09:34:5611#include "base/basictypes.h"
12#include "base/memory/scoped_ptr.h"
13
14class SkBitmap;
15
16namespace aura {
17class EventFilter;
18class RootWindow;
19class Window;
[email protected]4a59e4e2012-11-12 21:15:4020}
21
22namespace gfx {
23class Point;
24}
25
26namespace views {
27namespace corewm {
[email protected]d90b8392012-06-13 09:34:5628class InputMethodEventFilter;
29class RootWindowEventFilter;
[email protected]4a59e4e2012-11-12 21:15:4030}
31}
[email protected]d90b8392012-06-13 09:34:5632
33namespace ash {
[email protected]e74aaf0a2012-10-12 18:42:2834class Launcher;
[email protected]a0afeb12012-12-10 22:57:0935class SystemTray;
[email protected]a4cd6d32012-09-12 03:42:1336class ToplevelWindowEventHandler;
[email protected]e74aaf0a2012-10-12 18:42:2837
[email protected]d90b8392012-06-13 09:34:5638namespace internal {
39
[email protected]bca9a7e2012-11-10 06:25:4940class BootSplashScreen;
[email protected]e74aaf0a2012-10-12 18:42:2841class PanelLayoutManager;
[email protected]d90b8392012-06-13 09:34:5642class RootWindowLayoutManager;
43class ScreenDimmer;
[email protected]e74aaf0a2012-10-12 18:42:2844class ShelfLayoutManager;
45class StatusAreaWidget;
46class SystemBackgroundController;
[email protected]c0ce80e2012-10-05 23:28:2747class SystemModalContainerLayoutManager;
[email protected]d90b8392012-06-13 09:34:5648class WorkspaceController;
49
50// This class maintains the per root window state for ash. This class
51// owns the root window and other dependent objects that should be
52// deleted upon the deletion of the root window. The RootWindowController
53// for particular root window is stored as a property and can be obtained
54// using |GetRootWindowController(aura::RootWindow*)| function.
[email protected]c0ce80e2012-10-05 23:28:2755class ASH_EXPORT RootWindowController {
[email protected]d90b8392012-06-13 09:34:5656 public:
57 explicit RootWindowController(aura::RootWindow* root_window);
58 ~RootWindowController();
59
[email protected]88d71122012-10-18 07:11:0160 // Returns a RootWindowController that has a launcher for given
61 // |window|. This returns the RootWindowController for the |window|'s
62 // root window when multiple launcher mode is enabled, or the primary
63 // RootWindowController otherwise.
64 static RootWindowController* ForLauncher(aura::Window* window);
65
[email protected]a0afeb12012-12-10 22:57:0966 // Returns a RootWindowController of the window's root window.
67 static RootWindowController* ForWindow(aura::Window* window);
68
69 // Returns the RootWindowController of the active root window.
70 static internal::RootWindowController* ForActiveRootWindow();
71
[email protected]e74aaf0a2012-10-12 18:42:2872 aura::RootWindow* root_window() { return root_window_.get(); }
[email protected]d90b8392012-06-13 09:34:5673
[email protected]e74aaf0a2012-10-12 18:42:2874 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:5675
[email protected]c0ce80e2012-10-05 23:28:2776 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:5677 return workspace_controller_.get();
78 }
79
[email protected]e74aaf0a2012-10-12 18:42:2880 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
81
82 Launcher* launcher() { return launcher_.get(); }
83
[email protected]88d71122012-10-18 07:11:0184 ShelfLayoutManager* shelf() const { return shelf_; }
[email protected]e74aaf0a2012-10-12 18:42:2885
[email protected]a0afeb12012-12-10 22:57:0986 StatusAreaWidget* status_area_widget() {
[email protected]e74aaf0a2012-10-12 18:42:2887 return status_area_widget_;
[email protected]d90b8392012-06-13 09:34:5688 }
89
[email protected]a0afeb12012-12-10 22:57:0990 // Returns the system tray on this root window. Note that
91 // calling this on the root window that doesn't have a launcher will
92 // lead to a crash.
93 SystemTray* GetSystemTray();
94
[email protected]431552c2012-10-23 00:38:3395 // Shows context menu at the |location_in_screen|. This uses
96 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
97 void ShowContextMenu(const gfx::Point& location_in_screen);
98
[email protected]8674b312012-10-12 19:02:4499 // Returns the layout-manager for the appropriate modal-container. If the
100 // window is inside the lockscreen modal container, then the layout manager
101 // for that is returned. Otherwise the layout manager for the default modal
102 // container is returned.
103 // If no window is specified (i.e. |window| is NULL), then the lockscreen
104 // modal container is used if the screen is currently locked. Otherwise, the
105 // default modal container is used.
106 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
107 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27108
[email protected]d90b8392012-06-13 09:34:56109 aura::Window* GetContainer(int container_id);
110
[email protected]d90b8392012-06-13 09:34:56111 void InitLayoutManagers();
[email protected]697f04c2012-10-03 01:15:10112 void CreateContainers();
113
[email protected]e74aaf0a2012-10-12 18:42:28114 // Initializs the RootWindowController for primary display. This
115 // creates
116 void InitForPrimaryDisplay();
117
[email protected]bca9a7e2012-11-10 06:25:49118 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
119 // |is_first_run_after_boot| determines the background's initial color.
[email protected]697f04c2012-10-03 01:15:10120 void CreateSystemBackground(bool is_first_run_after_boot);
121
[email protected]e74aaf0a2012-10-12 18:42:28122 // Initializes |launcher_|. Does nothing if it's already initialized.
123 void CreateLauncher();
124
125 // Show launcher view if it was created hidden (before session has started).
126 void ShowLauncher();
127
[email protected]16059276d2012-10-22 18:59:50128 // Called when the user logs in.
129 void OnLoginStateChanged(user::LoginStatus status);
130
131 // Called when the login status changes after login (such as lock/unlock).
132 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
133 void UpdateAfterLoginStatusChange(user::LoginStatus status);
134
[email protected]bca9a7e2012-11-10 06:25:49135 // Called when the brightness/grayscale animation from white to the login
136 // desktop background image has started. Starts |boot_splash_screen_|'s
137 // hiding animation (if the screen is non-NULL).
138 void HandleInitialDesktopBackgroundAnimationStarted();
139
140 // Called when the login background is fully visible. Updates |background_|
141 // to be black and drops |boot_splash_screen_|.
[email protected]697f04c2012-10-03 01:15:10142 void HandleDesktopBackgroundVisible();
[email protected]d90b8392012-06-13 09:34:56143
[email protected]6675e1c2012-09-11 09:15:45144 // Deletes associated objects and clears the state, but doesn't delete
145 // the root window yet. This is used to delete a secondary displays'
146 // root window safely when the display disconnect signal is received,
147 // which may come while we're in the nested message loop.
148 void Shutdown();
149
[email protected]d90b8392012-06-13 09:34:56150 // Deletes all child windows and performs necessary cleanup.
151 void CloseChildWindows();
152
[email protected]f1853122012-06-27 16:21:26153 // Moves child windows to |dest|.
154 void MoveWindowsTo(aura::RootWindow* dest);
155
[email protected]e74aaf0a2012-10-12 18:42:28156 // Force the shelf to query for it's current visibility state.
157 void UpdateShelfVisibility();
158
159 // Sets/gets the shelf auto-hide behavior.
160 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
161 ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
162
163 // Sets/gets the shelf alignemnt.
164 bool SetShelfAlignment(ShelfAlignment alignment);
165 ShelfAlignment GetShelfAlignment();
166
[email protected]431552c2012-10-23 00:38:33167 private:
[email protected]a4cd6d32012-09-12 03:42:13168 // Creates each of the special window containers that holds windows of various
169 // types in the shell UI.
170 void CreateContainersInRootWindow(aura::RootWindow* root_window);
171
[email protected]d90b8392012-06-13 09:34:56172 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27173 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56174
[email protected]e74aaf0a2012-10-12 18:42:28175 // Widget containing system tray.
[email protected]88d71122012-10-18 07:11:01176 StatusAreaWidget* status_area_widget_;
[email protected]e74aaf0a2012-10-12 18:42:28177
178 // The shelf for managing the launcher and the status widget.
179 // RootWindowController does not own the shelf. Instead, it is owned
180 // by container of the status area.
[email protected]88d71122012-10-18 07:11:01181 ShelfLayoutManager* shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28182
183 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01184 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28185
186 scoped_ptr<Launcher> launcher_;
187
[email protected]e6e41d2f2012-10-29 19:22:19188 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]bca9a7e2012-11-10 06:25:49189 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]697f04c2012-10-03 01:15:10190
[email protected]c0ce80e2012-10-05 23:28:27191 scoped_ptr<ScreenDimmer> screen_dimmer_;
192 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]d90b8392012-06-13 09:34:56193
[email protected]a4cd6d32012-09-12 03:42:13194 // We need to own event handlers for various containers.
195 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
196 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
197 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
198 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
199
[email protected]d90b8392012-06-13 09:34:56200 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
201};
202
203} // namespace internal
204} // ash
205
206#endif // ASH_ROOT_WINDOW_CONTROLLER_H_