OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H_ |
6 #define CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H_ | 6 #define CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ash/session_state_observer.h" | 11 #include "ash/session_state_observer.h" |
12 #include "ash/wm/window_state_observer.h" | 12 #include "ash/wm/window_state_observer.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/timer/timer.h" |
15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 16 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "ui/aura/window_observer.h" | 19 #include "ui/aura/window_observer.h" |
19 #include "ui/views/corewm/transient_window_observer.h" | 20 #include "ui/views/corewm/transient_window_observer.h" |
20 | 21 |
21 class Browser; | 22 class Browser; |
22 class MultiUserNotificationBlockerChromeOS; | 23 class MultiUserNotificationBlockerChromeOS; |
23 class MultiUserNotificationBlockerChromeOSTest; | 24 class MultiUserNotificationBlockerChromeOSTest; |
24 class Profile; | 25 class Profile; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Window .. overrides: | 92 // Window .. overrides: |
92 virtual void OnWindowShowTypeChanged( | 93 virtual void OnWindowShowTypeChanged( |
93 ash::wm::WindowState* state, | 94 ash::wm::WindowState* state, |
94 ash::wm::WindowShowType old_type) OVERRIDE; | 95 ash::wm::WindowShowType old_type) OVERRIDE; |
95 | 96 |
96 // content::NotificationObserver overrides: | 97 // content::NotificationObserver overrides: |
97 virtual void Observe(int type, | 98 virtual void Observe(int type, |
98 const content::NotificationSource& source, | 99 const content::NotificationSource& source, |
99 const content::NotificationDetails& details) OVERRIDE; | 100 const content::NotificationDetails& details) OVERRIDE; |
100 | 101 |
| 102 // Disable any animations for unit tests. |
| 103 void SetAnimationsForTest(bool disable); |
| 104 |
| 105 // Returns true when a user switch animation is running. For unit tests. |
| 106 bool IsAnimationRunningForTest(); |
| 107 |
101 private: | 108 private: |
102 friend class ::MultiUserNotificationBlockerChromeOSTest; | 109 friend class ::MultiUserNotificationBlockerChromeOSTest; |
103 | 110 |
104 class WindowEntry { | 111 class WindowEntry { |
105 public: | 112 public: |
106 explicit WindowEntry(const std::string& user_id) | 113 explicit WindowEntry(const std::string& user_id) |
107 : owner_(user_id), | 114 : owner_(user_id), |
108 show_for_user_(user_id), | 115 show_for_user_(user_id), |
109 show_(true) {} | 116 show_(true) {} |
110 virtual ~WindowEntry() {} | 117 virtual ~WindowEntry() {} |
(...skipping 26 matching lines...) Expand all Loading... |
137 // True if the window should be visible for the user which shows the window. | 144 // True if the window should be visible for the user which shows the window. |
138 bool show_; | 145 bool show_; |
139 | 146 |
140 DISALLOW_COPY_AND_ASSIGN(WindowEntry); | 147 DISALLOW_COPY_AND_ASSIGN(WindowEntry); |
141 }; | 148 }; |
142 | 149 |
143 typedef std::map<aura::Window*, WindowEntry*> WindowToEntryMap; | 150 typedef std::map<aura::Window*, WindowEntry*> WindowToEntryMap; |
144 typedef std::map<std::string, AppObserver*> UserIDToShellWindowObserver; | 151 typedef std::map<std::string, AppObserver*> UserIDToShellWindowObserver; |
145 typedef std::map<aura::Window*, bool> TransientWindowToVisibility; | 152 typedef std::map<aura::Window*, bool> TransientWindowToVisibility; |
146 | 153 |
| 154 // The animation step for the user change animation. First the old user gets |
| 155 // hidden and then the new one gets presented. |
| 156 enum AnimationStep { |
| 157 HIDE_OLD_USER, |
| 158 SHOW_NEW_USER |
| 159 }; |
| 160 |
| 161 // Start the user change animation required for |animation_step|. |
| 162 // Note that a call with SHOW_NEW_USER will finalize the animation and kill |
| 163 // the timer (if there is one). |
| 164 void TransitionUser(AnimationStep animtion_step); |
| 165 |
| 166 // Start the user wallpaper animations. |
| 167 void TransitionWallpaper(AnimationStep animtion_step); |
| 168 |
| 169 // Start the user shelf animations. |
| 170 void TransitionUserShelf(AnimationStep animtion_step); |
| 171 |
147 // Add a browser window to the system so that the owner can be remembered. | 172 // Add a browser window to the system so that the owner can be remembered. |
148 void AddBrowserWindow(Browser* browser); | 173 void AddBrowserWindow(Browser* browser); |
149 | 174 |
150 // Show / hide the given window. Note: By not doing this within the functions, | 175 // Show / hide the given window. Note: By not doing this within the functions, |
151 // this allows to either switching to different ways to show/hide and / or to | 176 // this allows to either switching to different ways to show/hide and / or to |
152 // distinguish state changes performed by this class vs. state changes | 177 // distinguish state changes performed by this class vs. state changes |
153 // performed by the others. Note furthermore that system modal dialogs will | 178 // performed by the others. Note furthermore that system modal dialogs will |
154 // not get hidden. We will switch instead to the owners desktop. | 179 // not get hidden. We will switch instead to the owners desktop. |
155 void SetWindowVisibility(aura::Window* window, bool visible); | 180 // The |animation_time_in_ms| is the time the animation should take. Set to 0 |
| 181 // if it should get set instantly. |
| 182 void SetWindowVisibility(aura::Window* window, |
| 183 bool visible, |
| 184 int animation_time_in_ms); |
156 | 185 |
157 // Show the window and its transient children. However - if a transient child | 186 // Show the window and its transient children. However - if a transient child |
158 // was turned invisible by some other operation, it will stay invisible. | 187 // was turned invisible by some other operation, it will stay invisible. |
159 void ShowWithTransientChildrenRecursive(aura::Window* window); | 188 // Use the given |animation_time_in_ms| for transitioning. |
| 189 void ShowWithTransientChildrenRecursive(aura::Window* window, |
| 190 int animation_time_in_ms); |
160 | 191 |
161 // Find the first owned window in the chain. | 192 // Find the first owned window in the chain. |
162 // Returns NULL when the window itself is owned. | 193 // Returns NULL when the window itself is owned. |
163 aura::Window* GetOwningWindowInTransientChain(aura::Window* window); | 194 aura::Window* GetOwningWindowInTransientChain(aura::Window* window); |
164 | 195 |
165 // A |window| and its children were attached as transient children to an | 196 // A |window| and its children were attached as transient children to an |
166 // |owning_parent| and need to be registered. Note that the |owning_parent| | 197 // |owning_parent| and need to be registered. Note that the |owning_parent| |
167 // itself will not be registered, but its children will. | 198 // itself will not be registered, but its children will. |
168 void AddTransientOwnerRecursive(aura::Window* window, | 199 void AddTransientOwnerRecursive(aura::Window* window, |
169 aura::Window* owning_parent); | 200 aura::Window* owning_parent); |
170 | 201 |
171 // A window and its children were removed from its parent and can be | 202 // A window and its children were removed from its parent and can be |
172 // unregistered. | 203 // unregistered. |
173 void RemoveTransientOwnerRecursive(aura::Window* window); | 204 void RemoveTransientOwnerRecursive(aura::Window* window); |
174 | 205 |
| 206 // Animate a |window| to be |visible| in |animation_time_in_ms|. |
| 207 void SetWindowVisible(aura::Window* window, |
| 208 bool visible, |
| 209 int aimation_time_in_ms); |
| 210 |
175 // A lookup to see to which user the given window belongs to, where and if it | 211 // A lookup to see to which user the given window belongs to, where and if it |
176 // should get shown. | 212 // should get shown. |
177 WindowToEntryMap window_to_entry_; | 213 WindowToEntryMap window_to_entry_; |
178 | 214 |
179 // A list of all known users and their shell window observers. | 215 // A list of all known users and their shell window observers. |
180 UserIDToShellWindowObserver user_id_to_app_observer_; | 216 UserIDToShellWindowObserver user_id_to_app_observer_; |
181 | 217 |
182 // A map which remembers for owned transient windows their own visibility. | 218 // A map which remembers for owned transient windows their own visibility. |
183 TransientWindowToVisibility transient_window_to_visibility_; | 219 TransientWindowToVisibility transient_window_to_visibility_; |
184 | 220 |
185 // The currently selected active user. It is used to find the proper | 221 // The currently selected active user. It is used to find the proper |
186 // visibility state in various cases. The state is stored here instead of | 222 // visibility state in various cases. The state is stored here instead of |
187 // being read from the user manager to be in sync while a switch occurs. | 223 // being read from the user manager to be in sync while a switch occurs. |
188 std::string current_user_id_; | 224 std::string current_user_id_; |
189 | 225 |
190 // The blocker which controls the desktop notification visibility based on the | 226 // The blocker which controls the desktop notification visibility based on the |
191 // current multi-user status. | 227 // current multi-user status. |
192 scoped_ptr<MultiUserNotificationBlockerChromeOS> notification_blocker_; | 228 scoped_ptr<MultiUserNotificationBlockerChromeOS> notification_blocker_; |
193 | 229 |
194 // The notification registrar to track the creation of browser windows. | 230 // The notification registrar to track the creation of browser windows. |
195 content::NotificationRegistrar registrar_; | 231 content::NotificationRegistrar registrar_; |
196 | 232 |
197 // Suppress changes to the visibility flag while we are changing it ourselves. | 233 // Suppress changes to the visibility flag while we are changing it ourselves. |
198 bool suppress_visibility_changes_; | 234 bool suppress_visibility_changes_; |
199 | 235 |
200 // Caching the current multi profile mode since the detection which mode is | 236 // Caching the current multi profile mode since the detection which mode is |
201 // used is quite expensive. | 237 // used is quite expensive. |
202 static MultiProfileMode multi_user_mode_; | 238 static MultiProfileMode multi_user_mode_; |
203 | 239 |
| 240 // A timer which watches to executes the second part of a "user changed" |
| 241 // animation. Note that this timer exists only during such an animation. |
| 242 scoped_ptr<base::Timer> user_changed_animation_timer_; |
| 243 |
| 244 // If true, all animations will be suppressed. |
| 245 bool animations_disabled_; |
| 246 |
204 DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOS); | 247 DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOS); |
205 }; | 248 }; |
206 | 249 |
207 } // namespace chrome | 250 } // namespace chrome |
208 | 251 |
209 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H
_ | 252 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H
_ |
OLD | NEW |