Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / ash / multi_user / user_switch_animator_chromeos.h
blobe213218ce6b5d88ec120a572703743f288f8c636
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.
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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/timer/timer.h"
13 namespace aura {
14 class Window;
15 } // namespace aura
17 namespace chrome {
19 class MultiUserWindowManagerChromeOS;
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 UserSwitchAnimatorChromeOS {
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.
36 UserSwitchAnimatorChromeOS(MultiUserWindowManagerChromeOS* owner,
37 const std::string& new_user_id,
38 int animation_speed_ms);
39 ~UserSwitchAnimatorChromeOS();
41 // Check if a window is covering the entire work area of the screen it is on.
42 static bool CoversScreen(aura::Window* window);
44 bool IsAnimationFinished() {
45 return animation_step_ == ANIMATION_STEP_ENDED;
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_; }
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();
58 // When the system is shutting down, the animation can be stopped without
59 // ending it.
60 void CancelAnimation();
62 private:
63 // The window configuration of screen covering windows before an animation.
64 enum TransitioningScreenCover {
65 NO_USER_COVERS_SCREEN, // No window covers the entire screen.
66 OLD_USER_COVERS_SCREEN, // The current user has at least one window
67 // covering the entire screen.
68 NEW_USER_COVERS_SCREEN, // The user which becomes active has at least one
69 // window covering the entire screen.
70 BOTH_USERS_COVER_SCREEN // Both users have at least one window each
71 // covering the entire screen.
74 // Finalizes the animation and ends the timer (if there is one).
75 void FinalizeAnimation();
77 // Execute the user wallpaper animations for |animation_step|.
78 void TransitionWallpaper(AnimationStep animtion_step);
80 // Execute the user shelf animations for |animation_step|.
81 void TransitionUserShelf(AnimationStep animtion_step);
83 // Execute the window animations for |animation_step|.
84 void TransitionWindows(AnimationStep animation_step);
86 // Check if a window is maximized / fullscreen / covering the entire screen.
87 // If a |root_window| is given, the screen coverage of that root_window is
88 // tested, otherwise all screens.
89 TransitioningScreenCover GetScreenCover(aura::Window* root_window);
91 // The owning window manager.
92 MultiUserWindowManagerChromeOS* owner_;
94 // The new user to set.
95 std::string new_user_id_;
97 // The animation speed in ms. If 0, animations are disabled.
98 int animation_speed_ms_;
100 // The next animation step for AdvanceUserTransitionAnimation().
101 AnimationStep animation_step_;
103 // The screen cover status before the animation has started.
104 TransitioningScreenCover screen_cover_;
106 // A timer which watches to executes the second part of a "user changed"
107 // animation. Note that this timer exists only during such an animation.
108 scoped_ptr<base::Timer> user_changed_animation_timer_;
110 // For unit tests: Check which wallpaper was set.
111 std::string wallpaper_user_id_;
113 DISALLOW_COPY_AND_ASSIGN(UserSwitchAnimatorChromeOS);
116 } // namespace chrome
118 #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_USER_SWITCH_ANIMATOR_CHROMEOS_H_