OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h" | 5 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h" |
6 | 6 |
7 #include "ash/desktop_background/user_wallpaper_delegate.h" | 7 #include "ash/desktop_background/user_wallpaper_delegate.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 ChromeLauncherController::instance(); | 219 ChromeLauncherController::instance(); |
220 // The shelf animation duration override. | 220 // The shelf animation duration override. |
221 int duration_override = animation_speed_ms_; | 221 int duration_override = animation_speed_ms_; |
222 // Handle the shelf order of items. This is done once the old user is hidden. | 222 // Handle the shelf order of items. This is done once the old user is hidden. |
223 if (animation_step == ANIMATION_STEP_SHOW_NEW_USER) { | 223 if (animation_step == ANIMATION_STEP_SHOW_NEW_USER) { |
224 // Some unit tests have no ChromeLauncherController. | 224 // Some unit tests have no ChromeLauncherController. |
225 if (chrome_launcher_controller) | 225 if (chrome_launcher_controller) |
226 chrome_launcher_controller->ActiveUserChanged( | 226 chrome_launcher_controller->ActiveUserChanged( |
227 new_account_id_.GetUserEmail()); | 227 new_account_id_.GetUserEmail()); |
228 // Hide the black rectangle on top of each shelf again. | 228 // Hide the black rectangle on top of each shelf again. |
229 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 229 for (aura::Window* window : ash::Shell::GetAllRootWindows()) { |
230 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | 230 ash::ShelfWidget* shelf = ash::Shelf::ForWindow(window)->shelf_widget(); |
231 iter != root_windows.end(); ++iter) { | |
232 ash::ShelfWidget* shelf = | |
233 ash::RootWindowController::ForWindow(*iter)->shelf(); | |
234 shelf->HideShelfBehindBlackBar(false, duration_override); | 231 shelf->HideShelfBehindBlackBar(false, duration_override); |
235 } | 232 } |
236 // We kicked off the shelf animation above and the override can be | 233 // We kicked off the shelf animation above and the override can be |
237 // removed. | 234 // removed. |
238 duration_override = 0; | 235 duration_override = 0; |
239 } | 236 } |
240 | 237 |
241 if (!animation_speed_ms_ || animation_step == ANIMATION_STEP_FINALIZE) | 238 if (!animation_speed_ms_ || animation_step == ANIMATION_STEP_FINALIZE) |
242 return; | 239 return; |
243 | 240 |
244 // Note: The animation duration override will be set before the old user gets | 241 // Note: The animation duration override will be set before the old user gets |
245 // hidden and reset after the animations for the new user got kicked off. | 242 // hidden and reset after the animations for the new user got kicked off. |
246 ash::Shell::RootWindowControllerList controller = | 243 ash::Shell::RootWindowControllerList controller = |
247 ash::Shell::GetInstance()->GetAllRootWindowControllers(); | 244 ash::Shell::GetInstance()->GetAllRootWindowControllers(); |
248 for (ash::Shell::RootWindowControllerList::iterator iter = controller.begin(); | 245 for (ash::Shell::RootWindowControllerList::iterator iter = controller.begin(); |
249 iter != controller.end(); ++iter) { | 246 iter != controller.end(); ++iter) { |
250 (*iter)->GetShelfLayoutManager()->SetAnimationDurationOverride( | 247 (*iter)->GetShelfLayoutManager()->SetAnimationDurationOverride( |
251 duration_override); | 248 duration_override); |
252 } | 249 } |
253 | 250 |
254 if (animation_step != ANIMATION_STEP_HIDE_OLD_USER) | 251 if (animation_step != ANIMATION_STEP_HIDE_OLD_USER) |
255 return; | 252 return; |
256 | 253 |
257 // For each root window hide the shelf. | 254 // For each root window hide the shelf. |
258 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 255 for (aura::Window* window : ash::Shell::GetAllRootWindows()) { |
259 | |
260 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | |
261 iter != root_windows.end(); ++iter) { | |
262 // Hiding the shelf will cause a resize on a maximized window. | 256 // Hiding the shelf will cause a resize on a maximized window. |
263 // If the shelf is then shown for the following user in the same location, | 257 // If the shelf is then shown for the following user in the same location, |
264 // the window gets resized again. Since each resize can cause a considerable | 258 // the window gets resized again. Since each resize can cause a considerable |
265 // CPU usage and therefore effect jank, we should avoid hiding the shelf if | 259 // CPU usage and therefore effect jank, we should avoid hiding the shelf if |
266 // the start and end location are the same and cover the shelf instead with | 260 // the start and end location are the same and cover the shelf instead with |
267 // a black rectangle on top. | 261 // a black rectangle on top. |
268 if (GetScreenCover(*iter) != NO_USER_COVERS_SCREEN && | 262 ash::Shelf* shelf = ash::Shelf::ForWindow(window); |
| 263 if (GetScreenCover(window) != NO_USER_COVERS_SCREEN && |
269 (!chrome_launcher_controller || | 264 (!chrome_launcher_controller || |
270 !chrome_launcher_controller->ShelfBoundsChangesProbablyWithUser( | 265 !chrome_launcher_controller->ShelfBoundsChangesProbablyWithUser( |
271 *iter, new_account_id_.GetUserEmail()))) { | 266 shelf, new_account_id_.GetUserEmail()))) { |
272 ash::ShelfWidget* shelf = | 267 shelf->shelf_widget()->HideShelfBehindBlackBar(true, duration_override); |
273 ash::RootWindowController::ForWindow(*iter)->shelf(); | |
274 shelf->HideShelfBehindBlackBar(true, duration_override); | |
275 } else { | 268 } else { |
276 // This shelf change is only part of the animation and will be updated by | 269 // This shelf change is only part of the animation and will be updated by |
277 // ChromeLauncherController::ActiveUserChanged() to the new users value. | 270 // ChromeLauncherController::ActiveUserChanged() to the new users value. |
278 // Note that the user preference will not be changed. | 271 // Note that the user preference will not be changed. |
279 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( | 272 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
280 ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN, *iter); | |
281 } | 273 } |
282 } | 274 } |
283 } | 275 } |
284 | 276 |
285 void UserSwitchAnimatorChromeOS::TransitionWindows( | 277 void UserSwitchAnimatorChromeOS::TransitionWindows( |
286 AnimationStep animation_step) { | 278 AnimationStep animation_step) { |
287 // Disable the window position manager and the MRU window tracker temporarily. | 279 // Disable the window position manager and the MRU window tracker temporarily. |
288 UserChangeActionDisabler disabler; | 280 UserChangeActionDisabler disabler; |
289 | 281 |
290 // Animation duration. | 282 // Animation duration. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 if (itr != window_to_entry_map.end()) { | 430 if (itr != window_to_entry_map.end()) { |
439 windows_by_account_id_[itr->second->show_for_user()].push_back( | 431 windows_by_account_id_[itr->second->show_for_user()].push_back( |
440 child_window); | 432 child_window); |
441 } | 433 } |
442 } | 434 } |
443 } | 435 } |
444 } | 436 } |
445 } | 437 } |
446 | 438 |
447 } // namespace chrome | 439 } // namespace chrome |
OLD | NEW |