Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: chrome/browser/views/download_item_view.cc

Issue 3127008: Preliminary work on resuming downloads whose connections have expired.
Patch Set: Waiting to send download automation error message until after other downloads are canceled. Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/views/download_item_view.cc
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index c2f2442a91a983ece10ec64e7260188c5d9ee681..29cb6e7c01396f723087875f200db0cf1e64d67e 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -62,6 +62,9 @@ static const SkColor kFileNameDisabledColor = SkColorSetRGB(171, 192, 212);
// How long the 'download complete' animation should last for.
static const int kCompleteAnimationDurationMs = 2500;
+// How long the 'download interrupted' animation should last for.
+static const int kInterruptedAnimationDurationMs = 2500;
+
// How long we keep the item disabled after the user clicked it to open the
// downloaded item.
static const int kDisabledOnOpenDuration = 3000;
@@ -352,6 +355,17 @@ void DownloadItemView::OnDownloadUpdated(DownloadItem* download) {
case DownloadItem::IN_PROGRESS:
download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress();
break;
+ case DownloadItem::INTERRUPTED:
+ StopDownloadProgress();
+ interrupted_animation_.reset(new SlideAnimation(this));
+ interrupted_animation_->SetSlideDuration(kInterruptedAnimationDurationMs);
+ interrupted_animation_->SetTweenType(Tween::LINEAR);
+ interrupted_animation_->Show();
+ if (status_text.empty())
+ show_status_text_ = false;
+ SchedulePaint();
+ LoadIcon();
+ break;
case DownloadItem::COMPLETE:
if (download_->auto_opened()) {
parent_->RemoveDownloadView(this); // This will delete us!
@@ -426,7 +440,7 @@ void DownloadItemView::ButtonPressed(
if (sender == discard_button_) {
UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
base::Time::Now() - creation_time_);
- if (download_->state() == DownloadItem::IN_PROGRESS)
+ if (download_->IsPartialDownload())
download_->Cancel(true);
download_->Remove(true);
// WARNING: we are deleted at this point. Don't access 'this'.
@@ -653,6 +667,12 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
download_util::PaintDownloadComplete(canvas, this, 0, 0,
complete_animation_->GetCurrentValue(),
download_util::SMALL);
+ } else if ((download_->state() == DownloadItem::INTERRUPTED) &&
+ interrupted_animation_.get() &&
+ interrupted_animation_->is_animating()) {
+ download_util::PaintDownloadInterrupted(canvas, this, 0, 0,
+ interrupted_animation_->GetCurrentValue(),
+ download_util::SMALL);
}
}
@@ -780,6 +800,10 @@ bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) {
if (complete_animation_.get() && complete_animation_->is_animating())
complete_animation_->End();
+ // Stop any 'interrupted' animation.
+ if (interrupted_animation_.get() && interrupted_animation_->is_animating())
+ interrupted_animation_->End();
+
if (event.IsOnlyLeftMouseButton()) {
gfx::Point point(event.location());
if (!InDropDownButtonXCoordinateRange(event.x())) {

Powered by Google App Engine
This is Rietveld 408576698