Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / ash / wm / session_state_animator_impl.h
1 // Copyright (c) 2012 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 ASH_WM_SESSION_STATE_ANIMATOR_IMPL_H_
6 #define ASH_WM_SESSION_STATE_ANIMATOR_IMPL_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/wm/session_state_animator.h"
10 #include "base/basictypes.h"
11 #include "ui/aura/window.h"
12
13 namespace ui {
14 class LayerAnimationObserver;
15 }
16
17 namespace ash {
18
19 // Displays onscreen animations for session state changes (lock/unlock, sign
20 // out, shut down).
21 class ASH_EXPORT SessionStateAnimatorImpl : public SessionStateAnimator {
22  public:
23   // Helper class used by tests to access internal state.
24   class ASH_EXPORT TestApi {
25    public:
26     explicit TestApi(SessionStateAnimatorImpl* animator)
27         : animator_(animator) {}
28
29     // Returns true if containers of a given |container_mask|
30     // were last animated with |type| (probably; the analysis is fairly ad-hoc).
31     // |container_mask| is a bitfield of a Container.
32     bool ContainersAreAnimated(int container_mask,
33                                SessionStateAnimator::AnimationType type) const;
34
35     // Returns true if root window was last animated with |type| (probably;
36     // the analysis is fairly ad-hoc).
37     bool RootWindowIsAnimated(SessionStateAnimator::AnimationType type) const;
38
39    private:
40     SessionStateAnimatorImpl* animator_;  // not owned
41
42     DISALLOW_COPY_AND_ASSIGN(TestApi);
43   };
44
45   SessionStateAnimatorImpl();
46   virtual ~SessionStateAnimatorImpl();
47
48   // Fills |containers| with the containers included in |container_mask|.
49   static void GetContainers(int container_mask,
50                             aura::Window::Windows* containers);
51
52   // ash::SessionStateAnimator:
53   virtual void StartAnimation(int container_mask,
54                               AnimationType type,
55                               AnimationSpeed speed) OVERRIDE;
56   virtual void StartAnimationWithCallback(
57       int container_mask,
58       AnimationType type,
59       AnimationSpeed speed,
60       base::Closure callback) OVERRIDE;
61   virtual AnimationSequence* BeginAnimationSequence(
62       base::Closure callback) OVERRIDE;
63   virtual bool IsBackgroundHidden() const OVERRIDE;
64   virtual void ShowBackground() OVERRIDE;
65   virtual void HideBackground() OVERRIDE;
66
67  private:
68   class AnimationSequence;
69   friend class AnimationSequence;
70
71   virtual void StartAnimationInSequence(int container_mask,
72       AnimationType type,
73       AnimationSpeed speed,
74       AnimationSequence* observer);
75
76   // Apply animation |type| to window |window| with |speed| and add |observer|
77   // if it is not NULL to the last animation sequence.
78   void RunAnimationForWindow(aura::Window* window,
79                              SessionStateAnimator::AnimationType type,
80                              SessionStateAnimator::AnimationSpeed speed,
81                              ui::LayerAnimationObserver* observer);
82
83   DISALLOW_COPY_AND_ASSIGN(SessionStateAnimatorImpl);
84 };
85
86 }  // namespace ash
87
88 #endif  // ASH_WM_SESSION_STATE_ANIMATOR_IMPL_H_