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