Properly disable accelerated compositing for extension background pages. Since these
[chromium-blink-merge.git] / ash / root_window_controller.h
blob92185a6a63ea562a710909c986e80f1c80074848
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 "ash/ash_export.h"
9 #include "ash/shelf_types.h"
10 #include "ash/system/user/login_status.h"
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
14 class SkBitmap;
16 namespace aura {
17 class EventFilter;
18 class RootWindow;
19 class Window;
22 namespace gfx {
23 class Point;
26 namespace views {
27 namespace corewm {
28 class InputMethodEventFilter;
29 class RootWindowEventFilter;
33 namespace ash {
34 class Launcher;
35 class SystemTray;
36 class ToplevelWindowEventHandler;
38 namespace internal {
40 class BootSplashScreen;
41 class PanelLayoutManager;
42 class RootWindowLayoutManager;
43 class ScreenDimmer;
44 class ShelfLayoutManager;
45 class StatusAreaWidget;
46 class SystemBackgroundController;
47 class SystemModalContainerLayoutManager;
48 class WorkspaceController;
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.
55 class ASH_EXPORT RootWindowController {
56 public:
57 explicit RootWindowController(aura::RootWindow* root_window);
58 ~RootWindowController();
60 // 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);
66 // Returns a RootWindowController of the window's root window.
67 static RootWindowController* ForWindow(aura::Window* window);
69 // Returns the RootWindowController of the active root window.
70 static internal::RootWindowController* ForActiveRootWindow();
72 aura::RootWindow* root_window() { return root_window_.get(); }
74 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
76 WorkspaceController* workspace_controller() {
77 return workspace_controller_.get();
80 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
82 Launcher* launcher() { return launcher_.get(); }
84 ShelfLayoutManager* shelf() const { return shelf_; }
86 StatusAreaWidget* status_area_widget() {
87 return status_area_widget_;
90 // 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();
95 // 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);
99 // 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);
109 aura::Window* GetContainer(int container_id);
111 void InitLayoutManagers();
112 void CreateContainers();
114 // Initializs the RootWindowController for primary display. This
115 // creates
116 void InitForPrimaryDisplay();
118 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
119 // |is_first_run_after_boot| determines the background's initial color.
120 void CreateSystemBackground(bool is_first_run_after_boot);
122 // Initializes |launcher_|. Does nothing if it's already initialized.
123 void CreateLauncher();
125 // Show launcher view if it was created hidden (before session has started).
126 void ShowLauncher();
128 // Called when the user logs in.
129 void OnLoginStateChanged(user::LoginStatus status);
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);
135 // 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();
140 // Called when the login background is fully visible. Updates |background_|
141 // to be black and drops |boot_splash_screen_|.
142 void HandleDesktopBackgroundVisible();
144 // 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();
150 // Deletes all child windows and performs necessary cleanup.
151 void CloseChildWindows();
153 // Moves child windows to |dest|.
154 void MoveWindowsTo(aura::RootWindow* dest);
156 // Force the shelf to query for it's current visibility state.
157 void UpdateShelfVisibility();
159 // Sets/gets the shelf auto-hide behavior.
160 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
161 ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
163 // Sets/gets the shelf alignemnt.
164 bool SetShelfAlignment(ShelfAlignment alignment);
165 ShelfAlignment GetShelfAlignment();
167 private:
168 // 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);
172 scoped_ptr<aura::RootWindow> root_window_;
173 RootWindowLayoutManager* root_window_layout_;
175 // Widget containing system tray.
176 StatusAreaWidget* status_area_widget_;
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.
181 ShelfLayoutManager* shelf_;
183 // Manages layout of panels. Owned by PanelContainer.
184 PanelLayoutManager* panel_layout_manager_;
186 scoped_ptr<Launcher> launcher_;
188 scoped_ptr<SystemBackgroundController> system_background_;
189 scoped_ptr<BootSplashScreen> boot_splash_screen_;
191 scoped_ptr<ScreenDimmer> screen_dimmer_;
192 scoped_ptr<WorkspaceController> workspace_controller_;
194 // 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_;
200 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
203 } // namespace internal
204 } // ash
206 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_