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