OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/toolbar/wrench_icon_painter.h" | 5 #include "chrome/browser/ui/toolbar/wrench_icon_painter.h" |
6 | 6 |
7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
8 #include "ui/base/animation/multi_animation.h" | 8 #include "ui/base/animation/multi_animation.h" |
9 #include "ui/base/theme_provider.h" | 9 #include "ui/base/theme_provider.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE: | 45 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE: |
46 return SEVERITY_MEDIUM; | 46 return SEVERITY_MEDIUM; |
47 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL: | 47 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL: |
48 return SEVERITY_HIGH; | 48 return SEVERITY_HIGH; |
49 } | 49 } |
50 NOTREACHED(); | 50 NOTREACHED(); |
51 return SEVERITY_NONE; | 51 return SEVERITY_NONE; |
52 } | 52 } |
53 | 53 |
54 // static | 54 // static |
55 bool WrenchIconPainter::ShouldAnimateUpgradeLevel( | |
56 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level) { | |
57 bool should_animate = true; | |
58 if (level == UpgradeDetector::UPGRADE_ANNOYANCE_LOW) { | |
59 // Only animate low severity upgrades once. | |
60 static bool s_should_animate = true; | |
sky
2013/04/15 21:42:00
s_should_animate -> should_animate
sail
2013/04/15 21:43:53
Done.
| |
61 should_animate = s_should_animate; | |
62 s_should_animate = false; | |
63 } | |
64 return should_animate; | |
65 } | |
66 | |
67 // static | |
55 WrenchIconPainter::Severity WrenchIconPainter::SeverityFromGlobalErrorSeverity( | 68 WrenchIconPainter::Severity WrenchIconPainter::SeverityFromGlobalErrorSeverity( |
56 GlobalError::Severity severity) { | 69 GlobalError::Severity severity) { |
57 switch (severity) { | 70 switch (severity) { |
58 case GlobalError::SEVERITY_LOW: | 71 case GlobalError::SEVERITY_LOW: |
59 return SEVERITY_LOW; | 72 return SEVERITY_LOW; |
60 case GlobalError::SEVERITY_MEDIUM: | 73 case GlobalError::SEVERITY_MEDIUM: |
61 return SEVERITY_MEDIUM; | 74 return SEVERITY_MEDIUM; |
62 case GlobalError::SEVERITY_HIGH: | 75 case GlobalError::SEVERITY_HIGH: |
63 return SEVERITY_HIGH; | 76 return SEVERITY_HIGH; |
64 } | 77 } |
65 NOTREACHED(); | 78 NOTREACHED(); |
66 return SEVERITY_LOW; | 79 return SEVERITY_LOW; |
67 } | 80 } |
68 | 81 |
69 WrenchIconPainter::WrenchIconPainter(Delegate* delegate) | 82 WrenchIconPainter::WrenchIconPainter(Delegate* delegate) |
70 : delegate_(delegate), | 83 : delegate_(delegate), |
71 severity_(SEVERITY_NONE) { | 84 severity_(SEVERITY_NONE) { |
72 } | 85 } |
73 | 86 |
74 WrenchIconPainter::~WrenchIconPainter() {} | 87 WrenchIconPainter::~WrenchIconPainter() {} |
75 | 88 |
76 void WrenchIconPainter::SetSeverity(Severity severity) { | 89 void WrenchIconPainter::SetSeverity(Severity severity, bool animate) { |
77 if (severity_ == severity) | 90 if (severity_ == severity) |
78 return; | 91 return; |
79 | 92 |
80 severity_ = severity; | 93 severity_ = severity; |
81 delegate_->ScheduleWrenchIconPaint(); | 94 delegate_->ScheduleWrenchIconPaint(); |
82 animation_.reset(); | 95 animation_.reset(); |
83 if (severity_ == SEVERITY_NONE) | 96 if (severity_ == SEVERITY_NONE || !animate) |
84 return; | 97 return; |
85 | 98 |
86 ui::MultiAnimation::Parts parts; | 99 ui::MultiAnimation::Parts parts; |
87 // Animate the bars left to right. | 100 // Animate the bars left to right. |
88 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); | 101 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); |
89 // Fade out animation. | 102 // Fade out animation. |
90 parts.push_back(ui::MultiAnimation::Part(1000, ui::Tween::EASE_IN)); | 103 parts.push_back(ui::MultiAnimation::Part(1000, ui::Tween::EASE_IN)); |
91 // Again, animate the bars left to right. | 104 // Again, animate the bars left to right. |
92 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); | 105 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); |
93 | 106 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 case SEVERITY_LOW: | 186 case SEVERITY_LOW: |
174 return IDR_TOOLS_BAR_LOW; | 187 return IDR_TOOLS_BAR_LOW; |
175 case SEVERITY_MEDIUM: | 188 case SEVERITY_MEDIUM: |
176 return IDR_TOOLS_BAR_MEDIUM; | 189 return IDR_TOOLS_BAR_MEDIUM; |
177 case SEVERITY_HIGH: | 190 case SEVERITY_HIGH: |
178 return IDR_TOOLS_BAR_HIGH; | 191 return IDR_TOOLS_BAR_HIGH; |
179 } | 192 } |
180 NOTREACHED(); | 193 NOTREACHED(); |
181 return 0; | 194 return 0; |
182 } | 195 } |
OLD | NEW |