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 "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/timer/timer.h" | |
16 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
17 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
19 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
20 #include "ui/wm/core/transient_window_observer.h" | 19 #include "ui/wm/core/transient_window_observer.h" |
21 | 20 |
22 class Browser; | 21 class Browser; |
23 class MultiUserNotificationBlockerChromeOS; | 22 class MultiUserNotificationBlockerChromeOS; |
24 class MultiUserNotificationBlockerChromeOSTest; | 23 class MultiUserNotificationBlockerChromeOSTest; |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 class BrowserContext; | 26 class BrowserContext; |
28 } | 27 } |
29 | 28 |
30 namespace aura { | 29 namespace aura { |
31 class Window; | 30 class Window; |
32 } // namespace aura | 31 } // namespace aura |
33 | 32 |
34 namespace ash { | 33 namespace ash { |
35 namespace test { | 34 namespace test { |
36 class MultiUserWindowManagerChromeOSTest; | 35 class MultiUserWindowManagerChromeOSTest; |
37 } // namespace test | 36 } // namespace test |
38 } // namespace ash | 37 } // namespace ash |
39 | 38 |
40 namespace chrome { | 39 namespace chrome { |
41 | 40 |
42 class AppObserver; | 41 class AppObserver; |
| 42 class UserSwichAnimatorChromeOS; |
43 | 43 |
44 // This ChromeOS implementation of the MultiUserWindowManager interface is | 44 // This ChromeOS implementation of the MultiUserWindowManager interface is |
45 // detecting app and browser creations, tagging their windows automatically and | 45 // detecting app and browser creations, tagging their windows automatically and |
46 // using (currently) show and hide to make the owned windows visible - or not. | 46 // using (currently) show and hide to make the owned windows visible - or not. |
47 // If it becomes necessary, the function |SetWindowVisibility| can be | 47 // If it becomes necessary, the function |SetWindowVisibility| can be |
48 // overwritten to match new ways of doing this. | 48 // overwritten to match new ways of doing this. |
49 // Note: | 49 // Note: |
50 // - aura::Window::Hide() is currently hiding the window and all owned transient | 50 // - aura::Window::Hide() is currently hiding the window and all owned transient |
51 // children. However aura::Window::Show() is only showing the window itself. | 51 // children. However aura::Window::Show() is only showing the window itself. |
52 // To address that, all transient children (and their children) are remembered | 52 // To address that, all transient children (and their children) are remembered |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Disable any animations for unit tests. | 106 // Disable any animations for unit tests. |
107 void SetAnimationsForTest(bool disable); | 107 void SetAnimationsForTest(bool disable); |
108 | 108 |
109 // Returns true when a user switch animation is running. For unit tests. | 109 // Returns true when a user switch animation is running. For unit tests. |
110 bool IsAnimationRunningForTest(); | 110 bool IsAnimationRunningForTest(); |
111 | 111 |
112 // Returns the current user for unit tests. | 112 // Returns the current user for unit tests. |
113 const std::string& GetCurrentUserForTest(); | 113 const std::string& GetCurrentUserForTest(); |
114 | 114 |
115 private: | 115 protected: |
116 friend class ::MultiUserNotificationBlockerChromeOSTest; | 116 friend class UserSwichAnimatorChromeOS; |
117 friend class ash::test::MultiUserWindowManagerChromeOSTest; | |
118 | 117 |
119 class WindowEntry { | 118 class WindowEntry { |
120 public: | 119 public: |
121 explicit WindowEntry(const std::string& user_id) | 120 explicit WindowEntry(const std::string& user_id) |
122 : owner_(user_id), | 121 : owner_(user_id), |
123 show_for_user_(user_id), | 122 show_for_user_(user_id), |
124 show_(true) {} | 123 show_(true) {} |
125 virtual ~WindowEntry() {} | 124 virtual ~WindowEntry() {} |
126 | 125 |
127 // Returns the owner of this window. This cannot be changed. | 126 // Returns the owner of this window. This cannot be changed. |
(...skipping 21 matching lines...) Expand all Loading... |
149 // The user id of the user on which desktop the window gets shown. | 148 // The user id of the user on which desktop the window gets shown. |
150 std::string show_for_user_; | 149 std::string show_for_user_; |
151 | 150 |
152 // True if the window should be visible for the user which shows the window. | 151 // True if the window should be visible for the user which shows the window. |
153 bool show_; | 152 bool show_; |
154 | 153 |
155 DISALLOW_COPY_AND_ASSIGN(WindowEntry); | 154 DISALLOW_COPY_AND_ASSIGN(WindowEntry); |
156 }; | 155 }; |
157 | 156 |
158 typedef std::map<aura::Window*, WindowEntry*> WindowToEntryMap; | 157 typedef std::map<aura::Window*, WindowEntry*> WindowToEntryMap; |
159 typedef std::map<std::string, AppObserver*> UserIDToAppWindowObserver; | |
160 typedef std::map<aura::Window*, bool> TransientWindowToVisibility; | |
161 | |
162 // The animation step for the user change animation. First the old user gets | |
163 // hidden and then the new one gets presented. | |
164 enum AnimationStep { | |
165 HIDE_OLD_USER, | |
166 SHOW_NEW_USER | |
167 }; | |
168 | 158 |
169 // Show a window for a user without switching the user. | 159 // Show a window for a user without switching the user. |
170 // Returns true when the window moved to a new desktop. | 160 // Returns true when the window moved to a new desktop. |
171 bool ShowWindowForUserIntern(aura::Window* window, | 161 bool ShowWindowForUserIntern(aura::Window* window, |
172 const std::string& user_id); | 162 const std::string& user_id); |
173 | 163 |
174 // Start the user change animation required for |animation_step|. | |
175 // Note that a call with SHOW_NEW_USER will finalize the animation and kill | |
176 // the timer (if there is one). | |
177 void TransitionUser(AnimationStep animtion_step); | |
178 | |
179 // Start the user wallpaper animations. | |
180 void TransitionWallpaper(AnimationStep animtion_step); | |
181 | |
182 // Start the user shelf animations. | |
183 void TransitionUserShelf(AnimationStep animtion_step); | |
184 | |
185 // Add a browser window to the system so that the owner can be remembered. | |
186 void AddBrowserWindow(Browser* browser); | |
187 | |
188 // Show / hide the given window. Note: By not doing this within the functions, | 164 // Show / hide the given window. Note: By not doing this within the functions, |
189 // this allows to either switching to different ways to show/hide and / or to | 165 // this allows to either switching to different ways to show/hide and / or to |
190 // distinguish state changes performed by this class vs. state changes | 166 // distinguish state changes performed by this class vs. state changes |
191 // performed by the others. Note furthermore that system modal dialogs will | 167 // performed by the others. Note furthermore that system modal dialogs will |
192 // not get hidden. We will switch instead to the owners desktop. | 168 // not get hidden. We will switch instead to the owners desktop. |
193 // The |animation_time_in_ms| is the time the animation should take. Set to 0 | 169 // The |animation_time_in_ms| is the time the animation should take. Set to 0 |
194 // if it should get set instantly. | 170 // if it should get set instantly. |
195 void SetWindowVisibility(aura::Window* window, | 171 void SetWindowVisibility(aura::Window* window, |
196 bool visible, | 172 bool visible, |
197 int animation_time_in_ms); | 173 int animation_time_in_ms); |
198 | 174 |
| 175 const WindowToEntryMap& window_to_entry() { return window_to_entry_; } |
| 176 MultiUserNotificationBlockerChromeOS* notification_blocker() { |
| 177 return notification_blocker_.get(); |
| 178 } |
| 179 |
| 180 private: |
| 181 friend class ::MultiUserNotificationBlockerChromeOSTest; |
| 182 friend class ash::test::MultiUserWindowManagerChromeOSTest; |
| 183 |
| 184 typedef std::map<std::string, AppObserver*> UserIDToAppWindowObserver; |
| 185 typedef std::map<aura::Window*, bool> TransientWindowToVisibility; |
| 186 |
| 187 // Add a browser window to the system so that the owner can be remembered. |
| 188 void AddBrowserWindow(Browser* browser); |
| 189 |
199 // Show the window and its transient children. However - if a transient child | 190 // Show the window and its transient children. However - if a transient child |
200 // was turned invisible by some other operation, it will stay invisible. | 191 // was turned invisible by some other operation, it will stay invisible. |
201 // Use the given |animation_time_in_ms| for transitioning. | 192 // Use the given |animation_time_in_ms| for transitioning. |
202 void ShowWithTransientChildrenRecursive(aura::Window* window, | 193 void ShowWithTransientChildrenRecursive(aura::Window* window, |
203 int animation_time_in_ms); | 194 int animation_time_in_ms); |
204 | 195 |
205 // Find the first owned window in the chain. | 196 // Find the first owned window in the chain. |
206 // Returns NULL when the window itself is owned. | 197 // Returns NULL when the window itself is owned. |
207 aura::Window* GetOwningWindowInTransientChain(aura::Window* window); | 198 aura::Window* GetOwningWindowInTransientChain(aura::Window* window); |
208 | 199 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // The notification registrar to track the creation of browser windows. | 237 // The notification registrar to track the creation of browser windows. |
247 content::NotificationRegistrar registrar_; | 238 content::NotificationRegistrar registrar_; |
248 | 239 |
249 // Suppress changes to the visibility flag while we are changing it ourselves. | 240 // Suppress changes to the visibility flag while we are changing it ourselves. |
250 bool suppress_visibility_changes_; | 241 bool suppress_visibility_changes_; |
251 | 242 |
252 // Caching the current multi profile mode since the detection which mode is | 243 // Caching the current multi profile mode since the detection which mode is |
253 // used is quite expensive. | 244 // used is quite expensive. |
254 static MultiProfileMode multi_user_mode_; | 245 static MultiProfileMode multi_user_mode_; |
255 | 246 |
256 // A timer which watches to executes the second part of a "user changed" | |
257 // animation. Note that this timer exists only during such an animation. | |
258 scoped_ptr<base::Timer> user_changed_animation_timer_; | |
259 | |
260 // If true, all animations will be suppressed. | 247 // If true, all animations will be suppressed. |
261 bool animations_disabled_; | 248 bool animations_disabled_; |
262 | 249 |
| 250 // The animation between users. |
| 251 scoped_ptr<UserSwichAnimatorChromeOS> animation_; |
| 252 |
263 DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOS); | 253 DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOS); |
264 }; | 254 }; |
265 | 255 |
266 } // namespace chrome | 256 } // namespace chrome |
267 | 257 |
268 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H
_ | 258 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_CHROMEOS_H
_ |
OLD | NEW |