platformKeys: Add per-extension sign permissions.
[chromium-blink-merge.git] / ash / wm / overview / scoped_overview_animation_settings.cc
blob3cb6bcbcc8b047400752bc09ee76f5059fc0a8b4
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 #include "ash/wm/overview/scoped_overview_animation_settings.h"
7 #include "ash/wm/overview/overview_animation_type.h"
8 #include "base/time/time.h"
9 #include "ui/aura/window.h"
10 #include "ui/compositor/layer.h"
11 #include "ui/gfx/animation/tween.h"
13 namespace ash {
15 namespace {
17 // The time duration for transformation animations.
18 const int kTransitionMilliseconds = 200;
20 // The time duration for widgets to fade in.
21 const int kFadeInMilliseconds = 80;
23 // The time duration for widgets to fade out.
24 const int kFadeOutMilliseconds = 100;
26 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
27 switch (animation_type) {
28 case OVERVIEW_ANIMATION_NONE:
29 case OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM:
30 return base::TimeDelta();
31 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
32 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds);
33 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT:
34 return base::TimeDelta::FromMilliseconds(kFadeOutMilliseconds);
35 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
36 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
37 case OVERVIEW_ANIMATION_HIDE_WINDOW:
38 case OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL:
39 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds);
41 NOTREACHED();
42 return base::TimeDelta();
45 } // namespace
47 ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
48 OverviewAnimationType animation_type,
49 aura::Window* window)
50 : animation_settings_(window->layer()->GetAnimator()) {
52 switch (animation_type) {
53 case OVERVIEW_ANIMATION_NONE:
54 case OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM:
55 animation_settings_.SetPreemptionStrategy(
56 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
57 break;
58 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
59 window->layer()->GetAnimator()->SchedulePauseForProperties(
60 GetAnimationDuration(
61 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS),
62 ui::LayerAnimationElement::OPACITY);
63 animation_settings_.SetPreemptionStrategy(
64 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
65 break;
66 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT:
67 animation_settings_.SetPreemptionStrategy(
68 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
69 break;
70 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
71 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
72 animation_settings_.SetPreemptionStrategy(
73 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
74 animation_settings_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
75 break;
76 case OVERVIEW_ANIMATION_HIDE_WINDOW:
77 animation_settings_.SetPreemptionStrategy(
78 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
79 break;
80 case OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL:
81 animation_settings_.SetPreemptionStrategy(
82 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
83 animation_settings_.SetTweenType(gfx::Tween::EASE_IN_OUT);
84 break;
86 animation_settings_.SetTransitionDuration(
87 GetAnimationDuration(animation_type));
90 ScopedOverviewAnimationSettings::~ScopedOverviewAnimationSettings() {
93 } // namespace ash