Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_
6 #define CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_ 6 #define CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "components/user_manager/user_id.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 15
15 namespace chrome { 16 namespace chrome {
16 17
17 class MultiUserWindowManagerChromeOS; 18 class MultiUserWindowManagerChromeOS;
18 19
19 // A class which performs transitions animations between users. Upon creation, 20 // A class which performs transitions animations between users. Upon creation,
20 // the animation gets started and upon destruction the animation gets finished 21 // the animation gets started and upon destruction the animation gets finished
21 // if not done yet. 22 // if not done yet.
22 // Specifying |animation_disabled| upon creation will perform the transition 23 // Specifying |animation_disabled| upon creation will perform the transition
23 // without visible animations. 24 // without visible animations.
24 class UserSwitchAnimatorChromeOS { 25 class UserSwitchAnimatorChromeOS {
25 public: 26 public:
26 // The animation step for the user change animation. 27 // The animation step for the user change animation.
27 enum AnimationStep { 28 enum AnimationStep {
28 ANIMATION_STEP_HIDE_OLD_USER, // Hiding the old user (and shelf). 29 ANIMATION_STEP_HIDE_OLD_USER, // Hiding the old user (and shelf).
29 ANIMATION_STEP_SHOW_NEW_USER, // Show the shelf of the new user. 30 ANIMATION_STEP_SHOW_NEW_USER, // Show the shelf of the new user.
30 ANIMATION_STEP_FINALIZE, // All animations are done - final cleanup. 31 ANIMATION_STEP_FINALIZE, // All animations are done - final cleanup.
31 ANIMATION_STEP_ENDED // The animation has ended. 32 ANIMATION_STEP_ENDED // The animation has ended.
32 }; 33 };
33 34
34 UserSwitchAnimatorChromeOS(MultiUserWindowManagerChromeOS* owner, 35 UserSwitchAnimatorChromeOS(MultiUserWindowManagerChromeOS* owner,
35 const std::string& new_user_id, 36 const user_manager::UserID& new_user_id,
36 int animation_speed_ms); 37 int animation_speed_ms);
37 ~UserSwitchAnimatorChromeOS(); 38 ~UserSwitchAnimatorChromeOS();
38 39
39 // Check if a window is covering the entire work area of the screen it is on. 40 // Check if a window is covering the entire work area of the screen it is on.
40 static bool CoversScreen(aura::Window* window); 41 static bool CoversScreen(aura::Window* window);
41 42
42 bool IsAnimationFinished() { 43 bool IsAnimationFinished() {
43 return animation_step_ == ANIMATION_STEP_ENDED; 44 return animation_step_ == ANIMATION_STEP_ENDED;
44 } 45 }
45 46
46 // Returns the user id for which the wallpaper is currently shown. 47 // Returns the user id for which the wallpaper is currently shown.
47 // If a wallpaper is transitioning to B it will be returned as "->B". 48 // If a wallpaper is transitioning to B it will be returned as "->B".
48 const std::string& wallpaper_user_id_for_test() { return wallpaper_user_id_; } 49 const std::string& wallpaper_user_email_for_test() { return wallpaper_user_ema il_; }
49 50
50 // Advances the user switch animation to the next step. It reads the current 51 // Advances the user switch animation to the next step. It reads the current
51 // step from |animation_step_| and increments it thereafter. When 52 // step from |animation_step_| and increments it thereafter. When
52 // |ANIMATION_STEP_FINALIZE| gets executed, the animation is finished and the 53 // |ANIMATION_STEP_FINALIZE| gets executed, the animation is finished and the
53 // timer (if one exists) will get destroyed. 54 // timer (if one exists) will get destroyed.
54 void AdvanceUserTransitionAnimation(); 55 void AdvanceUserTransitionAnimation();
55 56
56 // When the system is shutting down, the animation can be stopped without 57 // When the system is shutting down, the animation can be stopped without
57 // ending it. 58 // ending it.
58 void CancelAnimation(); 59 void CancelAnimation();
(...skipping 29 matching lines...) Expand all
88 89
89 // Builds the map that a user ID to the list of windows that should be shown 90 // Builds the map that a user ID to the list of windows that should be shown
90 // for this user. This operation happens once upon the construction of this 91 // for this user. This operation happens once upon the construction of this
91 // animation. 92 // animation.
92 void BuildUserToWindowsListMap(); 93 void BuildUserToWindowsListMap();
93 94
94 // The owning window manager. 95 // The owning window manager.
95 MultiUserWindowManagerChromeOS* owner_; 96 MultiUserWindowManagerChromeOS* owner_;
96 97
97 // The new user to set. 98 // The new user to set.
98 std::string new_user_id_; 99 user_manager::UserID new_user_id_;
99 100
100 // The animation speed in ms. If 0, animations are disabled. 101 // The animation speed in ms. If 0, animations are disabled.
101 int animation_speed_ms_; 102 int animation_speed_ms_;
102 103
103 // The next animation step for AdvanceUserTransitionAnimation(). 104 // The next animation step for AdvanceUserTransitionAnimation().
104 AnimationStep animation_step_; 105 AnimationStep animation_step_;
105 106
106 // The screen cover status before the animation has started. 107 // The screen cover status before the animation has started.
107 TransitioningScreenCover screen_cover_; 108 TransitioningScreenCover screen_cover_;
108 109
109 // Mapping users IDs to the list of windows to show for these users. 110 // Mapping users IDs to the list of windows to show for these users.
110 typedef std::map<std::string, aura::Window::Windows> UserToWindowsMap; 111 typedef std::map<user_manager::UserID, aura::Window::Windows> UserToWindowsMap ;
111 UserToWindowsMap windows_by_user_id_; 112 UserToWindowsMap windows_by_user_id_;
112 113
113 // A timer which watches to executes the second part of a "user changed" 114 // A timer which watches to executes the second part of a "user changed"
114 // animation. Note that this timer exists only during such an animation. 115 // animation. Note that this timer exists only during such an animation.
115 scoped_ptr<base::Timer> user_changed_animation_timer_; 116 scoped_ptr<base::Timer> user_changed_animation_timer_;
116 117
117 // For unit tests: Check which wallpaper was set. 118 // For unit tests: Check which wallpaper was set.
118 std::string wallpaper_user_id_; 119 std::string wallpaper_user_email_;
119 120
120 DISALLOW_COPY_AND_ASSIGN(UserSwitchAnimatorChromeOS); 121 DISALLOW_COPY_AND_ASSIGN(UserSwitchAnimatorChromeOS);
121 }; 122 };
122 123
123 } // namespace chrome 124 } // namespace chrome
124 125
125 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_ 126 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698