[email protected] | d90b839 | 2012-06-13 09:34:56 | [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_ROOT_WINDOW_CONTROLLER_H_ | ||||
6 | #define ASH_ROOT_WINDOW_CONTROLLER_H_ | ||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 7 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 8 | #include "ash/ash_export.h" |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 9 | #include "ash/system/user/login_status.h" |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 10 | #include "ash/wm/shelf_types.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 11 | #include "base/basictypes.h" |
12 | #include "base/memory/scoped_ptr.h" | ||||
13 | |||||
14 | class SkBitmap; | ||||
15 | |||||
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 16 | namespace gfx { |
17 | class Point; | ||||
18 | } | ||||
19 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 20 | namespace aura { |
21 | class EventFilter; | ||||
22 | class RootWindow; | ||||
23 | class Window; | ||||
24 | namespace shared { | ||||
25 | class InputMethodEventFilter; | ||||
26 | class RootWindowEventFilter; | ||||
27 | } // namespace shared | ||||
28 | } // namespace aura | ||||
29 | |||||
30 | namespace ash { | ||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 31 | class Launcher; |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 32 | class ToplevelWindowEventHandler; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 33 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 34 | namespace internal { |
35 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 36 | class PanelLayoutManager; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 37 | class RootWindowLayoutManager; |
38 | class ScreenDimmer; | ||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 39 | class ShelfLayoutManager; |
40 | class StatusAreaWidget; | ||||
41 | class SystemBackgroundController; | ||||
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 42 | class SystemModalContainerLayoutManager; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 43 | class WorkspaceController; |
44 | |||||
45 | // This class maintains the per root window state for ash. This class | ||||
46 | // owns the root window and other dependent objects that should be | ||||
47 | // deleted upon the deletion of the root window. The RootWindowController | ||||
48 | // for particular root window is stored as a property and can be obtained | ||||
49 | // using |GetRootWindowController(aura::RootWindow*)| function. | ||||
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 50 | class ASH_EXPORT RootWindowController { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 51 | public: |
52 | explicit RootWindowController(aura::RootWindow* root_window); | ||||
53 | ~RootWindowController(); | ||||
54 | |||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 55 | // Returns a RootWindowController that has a launcher for given |
56 | // |window|. This returns the RootWindowController for the |window|'s | ||||
57 | // root window when multiple launcher mode is enabled, or the primary | ||||
58 | // RootWindowController otherwise. | ||||
59 | static RootWindowController* ForLauncher(aura::Window* window); | ||||
60 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 61 | aura::RootWindow* root_window() { return root_window_.get(); } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 62 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 63 | RootWindowLayoutManager* root_window_layout() { return root_window_layout_; } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 64 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 65 | WorkspaceController* workspace_controller() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 66 | return workspace_controller_.get(); |
67 | } | ||||
68 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 69 | ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); } |
70 | |||||
71 | Launcher* launcher() { return launcher_.get(); } | ||||
72 | |||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 73 | ShelfLayoutManager* shelf() const { return shelf_; } |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 74 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 75 | StatusAreaWidget* status_area_widget() const { |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 76 | return status_area_widget_; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 77 | } |
78 | |||||
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 79 | // Shows context menu at the |location_in_screen|. This uses |
80 | // |ShellDelegate::CreateContextMenu| to define the content of the menu. | ||||
81 | void ShowContextMenu(const gfx::Point& location_in_screen); | ||||
82 | |||||
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 83 | // Returns the layout-manager for the appropriate modal-container. If the |
84 | // window is inside the lockscreen modal container, then the layout manager | ||||
85 | // for that is returned. Otherwise the layout manager for the default modal | ||||
86 | // container is returned. | ||||
87 | // If no window is specified (i.e. |window| is NULL), then the lockscreen | ||||
88 | // modal container is used if the screen is currently locked. Otherwise, the | ||||
89 | // default modal container is used. | ||||
90 | SystemModalContainerLayoutManager* GetSystemModalLayoutManager( | ||||
91 | aura::Window* window); | ||||
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 92 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 93 | aura::Window* GetContainer(int container_id); |
94 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 95 | void InitLayoutManagers(); |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 96 | void CreateContainers(); |
97 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 98 | // Initializs the RootWindowController for primary display. This |
99 | // creates | ||||
100 | void InitForPrimaryDisplay(); | ||||
101 | |||||
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame^] | 102 | // Initializes |system_background_|. |is_first_run_after_boot| determines the |
103 | // background's initial content. | ||||
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 104 | void CreateSystemBackground(bool is_first_run_after_boot); |
105 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 106 | // Initializes |launcher_|. Does nothing if it's already initialized. |
107 | void CreateLauncher(); | ||||
108 | |||||
109 | // Show launcher view if it was created hidden (before session has started). | ||||
110 | void ShowLauncher(); | ||||
111 | |||||
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 112 | // Called when the user logs in. |
113 | void OnLoginStateChanged(user::LoginStatus status); | ||||
114 | |||||
115 | // Called when the login status changes after login (such as lock/unlock). | ||||
116 | // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. | ||||
117 | void UpdateAfterLoginStatusChange(user::LoginStatus status); | ||||
118 | |||||
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 119 | // Updates |background_| to be black after the desktop background is visible. |
120 | void HandleDesktopBackgroundVisible(); | ||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 121 | |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 122 | // Deletes associated objects and clears the state, but doesn't delete |
123 | // the root window yet. This is used to delete a secondary displays' | ||||
124 | // root window safely when the display disconnect signal is received, | ||||
125 | // which may come while we're in the nested message loop. | ||||
126 | void Shutdown(); | ||||
127 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 128 | // Deletes all child windows and performs necessary cleanup. |
129 | void CloseChildWindows(); | ||||
130 | |||||
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 131 | // Moves child windows to |dest|. |
132 | void MoveWindowsTo(aura::RootWindow* dest); | ||||
133 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 134 | // Force the shelf to query for it's current visibility state. |
135 | void UpdateShelfVisibility(); | ||||
136 | |||||
137 | // Sets/gets the shelf auto-hide behavior. | ||||
138 | void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior); | ||||
139 | ShelfAutoHideBehavior GetShelfAutoHideBehavior() const; | ||||
140 | |||||
141 | // Sets/gets the shelf alignemnt. | ||||
142 | bool SetShelfAlignment(ShelfAlignment alignment); | ||||
143 | ShelfAlignment GetShelfAlignment(); | ||||
144 | |||||
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 145 | // Get the shelf's auto hide status. |
146 | bool IsShelfAutoHideMenuHideChecked(); | ||||
147 | ShelfAutoHideBehavior GetToggledShelfAutoHideBehavior(); | ||||
148 | |||||
149 | private: | ||||
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 150 | // Creates each of the special window containers that holds windows of various |
151 | // types in the shell UI. | ||||
152 | void CreateContainersInRootWindow(aura::RootWindow* root_window); | ||||
153 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 154 | scoped_ptr<aura::RootWindow> root_window_; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 155 | RootWindowLayoutManager* root_window_layout_; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 156 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 157 | // Widget containing system tray. |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 158 | StatusAreaWidget* status_area_widget_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 159 | |
160 | // The shelf for managing the launcher and the status widget. | ||||
161 | // RootWindowController does not own the shelf. Instead, it is owned | ||||
162 | // by container of the status area. | ||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 163 | ShelfLayoutManager* shelf_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 164 | |
165 | // Manages layout of panels. Owned by PanelContainer. | ||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 166 | PanelLayoutManager* panel_layout_manager_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 167 | |
168 | scoped_ptr<Launcher> launcher_; | ||||
169 | |||||
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame^] | 170 | scoped_ptr<SystemBackgroundController> system_background_; |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 171 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 172 | scoped_ptr<ScreenDimmer> screen_dimmer_; |
173 | scoped_ptr<WorkspaceController> workspace_controller_; | ||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 174 | |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 175 | // We need to own event handlers for various containers. |
176 | scoped_ptr<ToplevelWindowEventHandler> default_container_handler_; | ||||
177 | scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_; | ||||
178 | scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_; | ||||
179 | scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_; | ||||
180 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 181 | DISALLOW_COPY_AND_ASSIGN(RootWindowController); |
182 | }; | ||||
183 | |||||
184 | } // namespace internal | ||||
185 | } // ash | ||||
186 | |||||
187 | #endif // ASH_ROOT_WINDOW_CONTROLLER_H_ |