Chromium Code Reviews| 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/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 // automatically since we don't want to get into a crash loop. | 505 // automatically since we don't want to get into a crash loop. |
| 506 if (IsSelected() || | 506 if (IsSelected() || |
| 507 data_.crashed_status != base::TERMINATION_STATUS_PROCESS_WAS_KILLED) | 507 data_.crashed_status != base::TERMINATION_STATUS_PROCESS_WAS_KILLED) |
| 508 StartCrashAnimation(); | 508 StartCrashAnimation(); |
| 509 #else | 509 #else |
| 510 StartCrashAnimation(); | 510 StartCrashAnimation(); |
| 511 #endif | 511 #endif |
| 512 } | 512 } |
| 513 } else if ((data_.capture_state == TabRendererData::CAPTURE_STATE_NONE) && | 513 } else if ((data_.capture_state == TabRendererData::CAPTURE_STATE_NONE) && |
| 514 (old.capture_state != TabRendererData::CAPTURE_STATE_NONE)) { | 514 (old.capture_state != TabRendererData::CAPTURE_STATE_NONE)) { |
| 515 StopRecordingAnimation(); | 515 StopIconAnimation(); |
| 516 } else if ((data_.capture_state != TabRendererData::CAPTURE_STATE_NONE) && | 516 } else if ((data_.capture_state != TabRendererData::CAPTURE_STATE_NONE) && |
| 517 (old.capture_state == TabRendererData::CAPTURE_STATE_NONE)) { | 517 (old.capture_state == TabRendererData::CAPTURE_STATE_NONE)) { |
| 518 StartRecordingAnimation(); | 518 StartRecordingAnimation(); |
| 519 } else if ((data_.audio_state == TabRendererData::AUDIO_STATE_NONE) && | |
| 520 (old.audio_state != TabRendererData::AUDIO_STATE_NONE)) { | |
| 521 StopAudioPlayingAnimation(); | |
| 522 } else if ((data_.audio_state != TabRendererData::AUDIO_STATE_NONE) && | |
| 523 (old.audio_state == TabRendererData::AUDIO_STATE_NONE)) { | |
| 524 StartAudioPlayingAnimation(); | |
| 525 } else { | 519 } else { |
| 526 if (IsPerformingCrashAnimation()) | 520 if (IsPerformingCrashAnimation()) |
| 527 StopCrashAnimation(); | 521 StopIconAnimation(); |
| 528 ResetCrashedFavicon(); | 522 ResetCrashedFavicon(); |
| 529 } | 523 } |
| 530 | 524 |
| 525 // Don't clobber the recording or projecting animation for audio indicator. | |
| 526 if (data_.capture_state == TabRendererData::CAPTURE_STATE_NONE) { | |
| 527 if ((data_.audio_state == TabRendererData::AUDIO_STATE_NONE) && | |
| 528 (old.audio_state != TabRendererData::AUDIO_STATE_NONE)) { | |
| 529 StopIconAnimation(); | |
| 530 } else if ((data_.audio_state != TabRendererData::AUDIO_STATE_NONE) && | |
| 531 (old.audio_state == TabRendererData::AUDIO_STATE_NONE)) { | |
| 532 StartAudioPlayingAnimation(); | |
| 533 } | |
| 534 } | |
| 535 | |
| 531 if (old.mini != data_.mini) { | 536 if (old.mini != data_.mini) { |
| 532 if (tab_animation_.get() && tab_animation_->is_animating()) { | 537 if (tab_animation_.get() && tab_animation_->is_animating()) { |
| 533 tab_animation_->Stop(); | 538 tab_animation_->Stop(); |
| 534 tab_animation_.reset(NULL); | 539 tab_animation_.reset(NULL); |
| 535 } | 540 } |
| 536 } | 541 } |
| 537 | 542 |
| 538 // If the favicon changed, re-compute its dominant color. | 543 // If the favicon changed, re-compute its dominant color. |
| 539 if (controller() && | 544 if (controller() && |
| 540 controller()->IsImmersiveStyle() && | 545 controller()->IsImmersiveStyle() && |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1588 } | 1593 } |
| 1589 | 1594 |
| 1590 void Tab::DisplayCrashedFavicon() { | 1595 void Tab::DisplayCrashedFavicon() { |
| 1591 should_display_crashed_favicon_ = true; | 1596 should_display_crashed_favicon_ = true; |
| 1592 } | 1597 } |
| 1593 | 1598 |
| 1594 void Tab::ResetCrashedFavicon() { | 1599 void Tab::ResetCrashedFavicon() { |
| 1595 should_display_crashed_favicon_ = false; | 1600 should_display_crashed_favicon_ = false; |
| 1596 } | 1601 } |
| 1597 | 1602 |
| 1603 void Tab::StopIconAnimation() { | |
| 1604 if (!icon_animation_.get()) | |
| 1605 return; | |
| 1606 icon_animation_->Stop(); | |
|
sky
2013/02/25 22:58:12
Do you need the Stop()? Can this just reset()?
| |
| 1607 icon_animation_.reset(); | |
| 1608 } | |
| 1609 | |
| 1598 void Tab::StartCrashAnimation() { | 1610 void Tab::StartCrashAnimation() { |
| 1599 icon_animation_.reset(new FaviconCrashAnimation(this)); | 1611 icon_animation_.reset(new FaviconCrashAnimation(this)); |
| 1600 icon_animation_->Start(); | 1612 icon_animation_->Start(); |
| 1601 } | 1613 } |
| 1602 | 1614 |
| 1603 void Tab::StopCrashAnimation() { | |
| 1604 if (!icon_animation_.get()) | |
| 1605 return; | |
| 1606 icon_animation_.reset(); | |
| 1607 } | |
| 1608 | |
| 1609 void Tab::StartRecordingAnimation() { | 1615 void Tab::StartRecordingAnimation() { |
| 1610 ui::ThrobAnimation* animation = new ui::ThrobAnimation(this); | 1616 ui::ThrobAnimation* animation = new ui::ThrobAnimation(this); |
| 1611 animation->SetTweenType(ui::Tween::EASE_IN_OUT); | 1617 animation->SetTweenType(ui::Tween::EASE_IN_OUT); |
| 1612 animation->SetThrobDuration(kRecordingDurationMs); | 1618 animation->SetThrobDuration(kRecordingDurationMs); |
| 1613 animation->StartThrobbing(-1); | 1619 animation->StartThrobbing(-1); |
| 1614 icon_animation_.reset(animation); | 1620 icon_animation_.reset(animation); |
| 1615 } | 1621 } |
| 1616 | 1622 |
| 1617 void Tab::StopRecordingAnimation() { | |
| 1618 if (!icon_animation_.get()) | |
| 1619 return; | |
| 1620 icon_animation_->Stop(); | |
| 1621 icon_animation_.reset(); | |
| 1622 } | |
| 1623 | |
| 1624 void Tab::StartAudioPlayingAnimation() { | 1623 void Tab::StartAudioPlayingAnimation() { |
| 1625 ui::ThrobAnimation* animation = new ui::ThrobAnimation(this); | 1624 ui::ThrobAnimation* animation = new ui::ThrobAnimation(this); |
| 1626 animation->SetTweenType(ui::Tween::LINEAR); | 1625 animation->SetTweenType(ui::Tween::LINEAR); |
| 1627 animation->SetThrobDuration(2000); | 1626 animation->SetThrobDuration(2000); |
| 1628 animation->StartThrobbing(-1); | 1627 animation->StartThrobbing(-1); |
| 1629 icon_animation_.reset(animation); | 1628 icon_animation_.reset(animation); |
| 1630 } | 1629 } |
| 1631 | 1630 |
| 1632 void Tab::StopAudioPlayingAnimation() { | |
| 1633 if (!icon_animation_.get()) | |
| 1634 return; | |
| 1635 icon_animation_->Stop(); | |
| 1636 icon_animation_.reset(); | |
| 1637 } | |
| 1638 | |
| 1639 bool Tab::IsPerformingCrashAnimation() const { | 1631 bool Tab::IsPerformingCrashAnimation() const { |
| 1640 return icon_animation_.get() && data_.IsCrashed(); | 1632 return icon_animation_.get() && data_.IsCrashed(); |
| 1641 } | 1633 } |
| 1642 | 1634 |
| 1643 void Tab::ScheduleIconPaint() { | 1635 void Tab::ScheduleIconPaint() { |
| 1644 gfx::Rect bounds = GetIconBounds(); | 1636 gfx::Rect bounds = GetIconBounds(); |
| 1645 if (bounds.IsEmpty()) | 1637 if (bounds.IsEmpty()) |
| 1646 return; | 1638 return; |
| 1647 | 1639 |
| 1648 // Extends the area to the bottom when sad_favicon is | 1640 // Extends the area to the bottom when sad_favicon is |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1715 const gfx::ImageSkia& image) { | 1707 const gfx::ImageSkia& image) { |
| 1716 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1708 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1717 ImageCacheEntry entry; | 1709 ImageCacheEntry entry; |
| 1718 entry.resource_id = resource_id; | 1710 entry.resource_id = resource_id; |
| 1719 entry.scale_factor = scale_factor; | 1711 entry.scale_factor = scale_factor; |
| 1720 entry.image = image; | 1712 entry.image = image; |
| 1721 image_cache_->push_front(entry); | 1713 image_cache_->push_front(entry); |
| 1722 if (image_cache_->size() > kMaxImageCacheSize) | 1714 if (image_cache_->size() > kMaxImageCacheSize) |
| 1723 image_cache_->pop_back(); | 1715 image_cache_->pop_back(); |
| 1724 } | 1716 } |
| OLD | NEW |