| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/tabs/tab_utils.h" | 5 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Animation that throbs in (towards 1.0) and out (towards 0.0), and ends in the | 61 // Animation that throbs in (towards 1.0) and out (towards 0.0), and ends in the |
| 62 // "in" state. | 62 // "in" state. |
| 63 class TabRecordingIndicatorAnimation : public gfx::MultiAnimation { | 63 class TabRecordingIndicatorAnimation : public gfx::MultiAnimation { |
| 64 public: | 64 public: |
| 65 ~TabRecordingIndicatorAnimation() override {} | 65 ~TabRecordingIndicatorAnimation() override {} |
| 66 | 66 |
| 67 // Overridden to provide alternating "towards in" and "towards out" behavior. | 67 // Overridden to provide alternating "towards in" and "towards out" behavior. |
| 68 double GetCurrentValue() const override; | 68 double GetCurrentValue() const override; |
| 69 | 69 |
| 70 static scoped_ptr<TabRecordingIndicatorAnimation> Create(); | 70 static std::unique_ptr<TabRecordingIndicatorAnimation> Create(); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 TabRecordingIndicatorAnimation(const gfx::MultiAnimation::Parts& parts, | 73 TabRecordingIndicatorAnimation(const gfx::MultiAnimation::Parts& parts, |
| 74 const base::TimeDelta interval) | 74 const base::TimeDelta interval) |
| 75 : MultiAnimation(parts, interval) {} | 75 : MultiAnimation(parts, interval) {} |
| 76 | 76 |
| 77 // Number of times to "toggle throb" the recording and tab capture indicators | 77 // Number of times to "toggle throb" the recording and tab capture indicators |
| 78 // when they first appear. | 78 // when they first appear. |
| 79 static const int kCaptureIndicatorThrobCycles = 5; | 79 static const int kCaptureIndicatorThrobCycles = 5; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 double TabRecordingIndicatorAnimation::GetCurrentValue() const { | 82 double TabRecordingIndicatorAnimation::GetCurrentValue() const { |
| 83 return current_part_index() % 2 ? | 83 return current_part_index() % 2 ? |
| 84 1.0 - MultiAnimation::GetCurrentValue() : | 84 1.0 - MultiAnimation::GetCurrentValue() : |
| 85 MultiAnimation::GetCurrentValue(); | 85 MultiAnimation::GetCurrentValue(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 scoped_ptr<TabRecordingIndicatorAnimation> | 88 std::unique_ptr<TabRecordingIndicatorAnimation> |
| 89 TabRecordingIndicatorAnimation::Create() { | 89 TabRecordingIndicatorAnimation::Create() { |
| 90 MultiAnimation::Parts parts; | 90 MultiAnimation::Parts parts; |
| 91 static_assert(kCaptureIndicatorThrobCycles % 2 != 0, | 91 static_assert(kCaptureIndicatorThrobCycles % 2 != 0, |
| 92 "odd number of cycles required so animation finishes in showing state"); | 92 "odd number of cycles required so animation finishes in showing state"); |
| 93 for (int i = 0; i < kCaptureIndicatorThrobCycles; ++i) { | 93 for (int i = 0; i < kCaptureIndicatorThrobCycles; ++i) { |
| 94 parts.push_back(MultiAnimation::Part( | 94 parts.push_back(MultiAnimation::Part( |
| 95 i % 2 ? kIndicatorFadeOutDurationMs : kIndicatorFadeInDurationMs, | 95 i % 2 ? kIndicatorFadeOutDurationMs : kIndicatorFadeInDurationMs, |
| 96 gfx::Tween::EASE_IN)); | 96 gfx::Tween::EASE_IN)); |
| 97 } | 97 } |
| 98 const base::TimeDelta interval = | 98 const base::TimeDelta interval = |
| 99 base::TimeDelta::FromMilliseconds(kIndicatorFrameIntervalMs); | 99 base::TimeDelta::FromMilliseconds(kIndicatorFrameIntervalMs); |
| 100 scoped_ptr<TabRecordingIndicatorAnimation> animation( | 100 std::unique_ptr<TabRecordingIndicatorAnimation> animation( |
| 101 new TabRecordingIndicatorAnimation(parts, interval)); | 101 new TabRecordingIndicatorAnimation(parts, interval)); |
| 102 animation->set_continuous(false); | 102 animation->set_continuous(false); |
| 103 return animation; | 103 return animation; |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace | 106 } // namespace |
| 107 | 107 |
| 108 bool ShouldTabShowFavicon(int capacity, | 108 bool ShouldTabShowFavicon(int capacity, |
| 109 bool is_pinned_tab, | 109 bool is_pinned_tab, |
| 110 bool is_active_tab, | 110 bool is_active_tab, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 case TabAlertState::NONE: | 226 case TabAlertState::NONE: |
| 227 case TabAlertState::MEDIA_RECORDING: | 227 case TabAlertState::MEDIA_RECORDING: |
| 228 case TabAlertState::TAB_CAPTURING: | 228 case TabAlertState::TAB_CAPTURING: |
| 229 case TabAlertState::BLUETOOTH_CONNECTED: | 229 case TabAlertState::BLUETOOTH_CONNECTED: |
| 230 return GetTabAlertIndicatorImage(alert_state, button_color); | 230 return GetTabAlertIndicatorImage(alert_state, button_color); |
| 231 } | 231 } |
| 232 NOTREACHED(); | 232 NOTREACHED(); |
| 233 return GetTabAlertIndicatorImage(alert_state, button_color); | 233 return GetTabAlertIndicatorImage(alert_state, button_color); |
| 234 } | 234 } |
| 235 | 235 |
| 236 scoped_ptr<gfx::Animation> CreateTabAlertIndicatorFadeAnimation( | 236 std::unique_ptr<gfx::Animation> CreateTabAlertIndicatorFadeAnimation( |
| 237 TabAlertState alert_state) { | 237 TabAlertState alert_state) { |
| 238 if (alert_state == TabAlertState::MEDIA_RECORDING || | 238 if (alert_state == TabAlertState::MEDIA_RECORDING || |
| 239 alert_state == TabAlertState::TAB_CAPTURING) { | 239 alert_state == TabAlertState::TAB_CAPTURING) { |
| 240 return TabRecordingIndicatorAnimation::Create(); | 240 return TabRecordingIndicatorAnimation::Create(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 // Note: While it seems silly to use a one-part MultiAnimation, it's the only | 243 // Note: While it seems silly to use a one-part MultiAnimation, it's the only |
| 244 // gfx::Animation implementation that lets us control the frame interval. | 244 // gfx::Animation implementation that lets us control the frame interval. |
| 245 gfx::MultiAnimation::Parts parts; | 245 gfx::MultiAnimation::Parts parts; |
| 246 const bool is_for_fade_in = (alert_state != TabAlertState::NONE); | 246 const bool is_for_fade_in = (alert_state != TabAlertState::NONE); |
| 247 parts.push_back(gfx::MultiAnimation::Part( | 247 parts.push_back(gfx::MultiAnimation::Part( |
| 248 is_for_fade_in ? kIndicatorFadeInDurationMs : kIndicatorFadeOutDurationMs, | 248 is_for_fade_in ? kIndicatorFadeInDurationMs : kIndicatorFadeOutDurationMs, |
| 249 gfx::Tween::EASE_IN)); | 249 gfx::Tween::EASE_IN)); |
| 250 const base::TimeDelta interval = | 250 const base::TimeDelta interval = |
| 251 base::TimeDelta::FromMilliseconds(kIndicatorFrameIntervalMs); | 251 base::TimeDelta::FromMilliseconds(kIndicatorFrameIntervalMs); |
| 252 scoped_ptr<gfx::MultiAnimation> animation( | 252 std::unique_ptr<gfx::MultiAnimation> animation( |
| 253 new gfx::MultiAnimation(parts, interval)); | 253 new gfx::MultiAnimation(parts, interval)); |
| 254 animation->set_continuous(false); | 254 animation->set_continuous(false); |
| 255 return std::move(animation); | 255 return std::move(animation); |
| 256 } | 256 } |
| 257 | 257 |
| 258 base::string16 AssembleTabTooltipText(const base::string16& title, | 258 base::string16 AssembleTabTooltipText(const base::string16& title, |
| 259 TabAlertState alert_state) { | 259 TabAlertState alert_state) { |
| 260 if (alert_state == TabAlertState::NONE) | 260 if (alert_state == TabAlertState::NONE) |
| 261 return title; | 261 return title; |
| 262 | 262 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 const std::vector<int>& indices) { | 375 const std::vector<int>& indices) { |
| 376 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end(); | 376 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end(); |
| 377 ++i) { | 377 ++i) { |
| 378 if (!tab_strip.GetWebContentsAt(*i)->IsAudioMuted()) | 378 if (!tab_strip.GetWebContentsAt(*i)->IsAudioMuted()) |
| 379 return false; | 379 return false; |
| 380 } | 380 } |
| 381 return true; | 381 return true; |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace chrome | 384 } // namespace chrome |
| OLD | NEW |