OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
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_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/timer/timer.h" | |
12 | |
13 namespace aura { | |
14 class Window; | |
15 } // namespace aura | |
16 | |
17 namespace chrome { | |
18 | |
19 class MultiUserWindowManagerChromeOS; | |
20 | |
21 // A class which performs transitions animations between users. Upon creation, | |
22 // the animation gets started and upon destruction the animation gets finished | |
23 // if not done yet. | |
24 // Specifying |animation_disabled| upon creation will perform the transition | |
25 // without visible animations. | |
26 class UserSwichAnimatorChromeOS { | |
27 public: | |
28 // The animation step for the user change animation. | |
29 enum AnimationStep { | |
30 ANIMATION_STEP_HIDE_OLD_USER, // Hiding the old user (and shelf). | |
31 ANIMATION_STEP_SHOW_NEW_USER, // Show the shelf of the new user. | |
32 ANIMATION_STEP_FINALIZE, // All animations are done - final cleanup. | |
33 ANIMATION_STEP_ENDED // The animation has ended. | |
34 }; | |
35 | |
36 UserSwichAnimatorChromeOS(MultiUserWindowManagerChromeOS* owner, | |
37 const std::string& new_user_id, | |
38 bool animation_disabled); | |
39 ~UserSwichAnimatorChromeOS(); | |
40 | |
41 // Check if a window is covering the entire work area of the screen it is on. | |
42 static bool CoversScreen(aura::Window* window); | |
43 | |
44 bool IsAnimationFinished() { | |
45 return animation_step_ == ANIMATION_STEP_ENDED; | |
46 } | |
47 | |
48 // Returns the user id for which the wallpaper is currently shown. | |
49 // If a wallpaper is transitioning to B it will be returned as "->B". | |
50 const std::string& wallpaper_user_id_for_test() { return wallpaper_user_id_; } | |
51 | |
52 // Advances the user switch animation to the next step. It reads the current | |
53 // step from |animation_step_| and increments it thereafter. When | |
54 // |ANIMATION_STEP_FINALIZE| gets executed, the animation is finished and the | |
55 // timer (if one exists) will get destroyed. | |
56 void AdvanceUserTransitionAnimation(); | |
57 | |
58 private: | |
59 // The window configuration of screen covering windows before an animation. | |
60 enum TransitioningScreenCover { | |
61 NO_USER_COVERS_SCREEN, // No window covers the entire screen. | |
62 OLD_USER_COVERS_SCREEN, // The current user has at least one window | |
63 // covering the entire screen. | |
64 NEW_USER_COVERS_SCREEN, // The user which becomes active has at least one | |
65 // window covering the entire screen. | |
66 BOTH_USERS_COVER_SCREEN // Both users have at least one window each | |
67 // covering the entire screen. | |
68 }; | |
69 | |
70 // Finalizes the animation and ends the timer (if there is one). | |
71 void FinalizeAnimation(); | |
72 | |
73 // Execute the user wallpaper animations for |animation_step|. | |
74 void TransitionWallpaper(AnimationStep animtion_step); | |
75 | |
76 // Execute the user shelf animations for |animation_step|. | |
77 void TransitionUserShelf(AnimationStep animtion_step); | |
78 | |
79 // Execute the window animations for |animation_step|. | |
80 void TransitionWindows(AnimationStep animation_step); | |
81 | |
82 // Check if a window is maximized / fullscreen / covering the entire screen. | |
83 // TODO(skuhne): We might want to do this on a per screen basis. | |
84 TransitioningScreenCover GetScreenCover(); | |
85 | |
86 // The owning window manager. | |
87 MultiUserWindowManagerChromeOS* owner_; | |
88 | |
89 // The new user to set. | |
90 std::string new_user_id_; | |
91 | |
92 // If true, all animations will be suppressed. | |
93 bool animation_disabled_; | |
94 | |
95 // The next animation step for AdvanceUserTransitionAnimation(). | |
96 AnimationStep animation_step_; | |
97 | |
98 // The screen cover status before the animation has started. | |
99 TransitioningScreenCover screen_cover_; | |
100 | |
101 // A timer which watches to executes the second part of a "user changed" | |
102 // animation. Note that this timer exists only during such an animation. | |
103 scoped_ptr<base::Timer> user_changed_animation_timer_; | |
104 | |
105 // For unit tests: Check which wallpaper was set. | |
106 std::string wallpaper_user_id_; | |
107 | |
108 DISALLOW_COPY_AND_ASSIGN(UserSwichAnimatorChromeOS); | |
109 }; | |
110 | |
111 } // namespace chrome | |
112 | |
113 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_ | |
OLD | NEW |