| 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/download/download_item_view.h" | 5 #include "chrome/browser/ui/views/download/download_item_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 StopDownloadProgress(); | 279 StopDownloadProgress(); |
| 280 complete_animation_.reset(new ui::SlideAnimation(this)); | 280 complete_animation_.reset(new ui::SlideAnimation(this)); |
| 281 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); | 281 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); |
| 282 complete_animation_->SetTweenType(ui::Tween::LINEAR); | 282 complete_animation_->SetTweenType(ui::Tween::LINEAR); |
| 283 complete_animation_->Show(); | 283 complete_animation_->Show(); |
| 284 SchedulePaint(); | 284 SchedulePaint(); |
| 285 LoadIcon(); | 285 LoadIcon(); |
| 286 break; | 286 break; |
| 287 case DownloadItem::CANCELLED: | 287 case DownloadItem::CANCELLED: |
| 288 StopDownloadProgress(); | 288 StopDownloadProgress(); |
| 289 if (complete_animation_) |
| 290 complete_animation_->Stop(); |
| 289 LoadIcon(); | 291 LoadIcon(); |
| 290 break; | 292 break; |
| 291 default: | 293 default: |
| 292 NOTREACHED(); | 294 NOTREACHED(); |
| 293 } | 295 } |
| 294 status_text_ = status_text; | 296 status_text_ = status_text; |
| 295 } | 297 } |
| 296 | 298 |
| 297 string16 new_tip = model_.GetTooltipText(font_, kTooltipMaxWidth); | 299 string16 new_tip = model_.GetTooltipText(font_, kTooltipMaxWidth); |
| 298 if (new_tip != tooltip_text_) { | 300 if (new_tip != tooltip_text_) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { | 400 bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { |
| 399 // Mouse should not activate us in dangerous mode. | 401 // Mouse should not activate us in dangerous mode. |
| 400 if (IsShowingWarningDialog()) | 402 if (IsShowingWarningDialog()) |
| 401 return true; | 403 return true; |
| 402 | 404 |
| 403 if (!starting_drag_) { | 405 if (!starting_drag_) { |
| 404 starting_drag_ = true; | 406 starting_drag_ = true; |
| 405 drag_start_point_ = event.location(); | 407 drag_start_point_ = event.location(); |
| 406 } | 408 } |
| 407 if (dragging_) { | 409 if (dragging_) { |
| 408 if (download()->IsComplete()) { | 410 if (download()->GetState() == DownloadItem::COMPLETE) { |
| 409 IconManager* im = g_browser_process->icon_manager(); | 411 IconManager* im = g_browser_process->icon_manager(); |
| 410 gfx::Image* icon = im->LookupIconFromFilepath( | 412 gfx::Image* icon = im->LookupIconFromFilepath( |
| 411 download()->GetTargetFilePath(), IconLoader::SMALL); | 413 download()->GetTargetFilePath(), IconLoader::SMALL); |
| 412 if (icon) { | 414 if (icon) { |
| 413 views::Widget* widget = GetWidget(); | 415 views::Widget* widget = GetWidget(); |
| 414 download_util::DragDownload(download(), icon, | 416 download_util::DragDownload(download(), icon, |
| 415 widget ? widget->GetNativeView() : NULL); | 417 widget ? widget->GetNativeView() : NULL); |
| 416 } | 418 } |
| 417 } | 419 } |
| 418 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { | 420 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 else if (image) | 782 else if (image) |
| 781 icon = image->ToImageSkia(); | 783 icon = image->ToImageSkia(); |
| 782 | 784 |
| 783 // We count on the fact that the icon manager will cache the icons and if one | 785 // We count on the fact that the icon manager will cache the icons and if one |
| 784 // is available, it will be cached here. We *don't* want to request the icon | 786 // is available, it will be cached here. We *don't* want to request the icon |
| 785 // to be loaded here, since this will also get called if the icon can't be | 787 // to be loaded here, since this will also get called if the icon can't be |
| 786 // loaded, in which case LookupIcon will always be NULL. The loading will be | 788 // loaded, in which case LookupIcon will always be NULL. The loading will be |
| 787 // triggered only when we think the status might change. | 789 // triggered only when we think the status might change. |
| 788 if (icon) { | 790 if (icon) { |
| 789 if (!IsShowingWarningDialog()) { | 791 if (!IsShowingWarningDialog()) { |
| 790 if (download()->IsInProgress()) { | 792 DownloadItem::DownloadState state = download()->GetState(); |
| 793 if (state == DownloadItem::IN_PROGRESS) { |
| 791 download_util::PaintDownloadProgress(canvas, this, 0, 0, | 794 download_util::PaintDownloadProgress(canvas, this, 0, 0, |
| 792 progress_angle_, | 795 progress_angle_, |
| 793 model_.PercentComplete(), | 796 model_.PercentComplete(), |
| 794 download_util::SMALL); | 797 download_util::SMALL); |
| 795 } else if (download()->IsComplete() && | 798 } else if (complete_animation_.get() && |
| 796 complete_animation_.get() && | |
| 797 complete_animation_->is_animating()) { | 799 complete_animation_->is_animating()) { |
| 798 if (download()->IsInterrupted()) { | 800 if (state == DownloadItem::INTERRUPTED) { |
| 799 download_util::PaintDownloadInterrupted(canvas, this, 0, 0, | 801 download_util::PaintDownloadInterrupted(canvas, this, 0, 0, |
| 800 complete_animation_->GetCurrentValue(), | 802 complete_animation_->GetCurrentValue(), |
| 801 download_util::SMALL); | 803 download_util::SMALL); |
| 802 } else { | 804 } else { |
| 805 DCHECK_EQ(DownloadItem::COMPLETE, state); |
| 803 download_util::PaintDownloadComplete(canvas, this, 0, 0, | 806 download_util::PaintDownloadComplete(canvas, this, 0, 0, |
| 804 complete_animation_->GetCurrentValue(), | 807 complete_animation_->GetCurrentValue(), |
| 805 download_util::SMALL); | 808 download_util::SMALL); |
| 806 } | 809 } |
| 807 } | 810 } |
| 808 } | 811 } |
| 809 | 812 |
| 810 // Draw the icon image. | 813 // Draw the icon image. |
| 811 int icon_x, icon_y; | 814 int icon_x, icon_y; |
| 812 | 815 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 void DownloadItemView::AnimateStateTransition(State from, State to, | 1213 void DownloadItemView::AnimateStateTransition(State from, State to, |
| 1211 ui::SlideAnimation* animation) { | 1214 ui::SlideAnimation* animation) { |
| 1212 if (from == NORMAL && to == HOT) { | 1215 if (from == NORMAL && to == HOT) { |
| 1213 animation->Show(); | 1216 animation->Show(); |
| 1214 } else if (from == HOT && to == NORMAL) { | 1217 } else if (from == HOT && to == NORMAL) { |
| 1215 animation->Hide(); | 1218 animation->Hide(); |
| 1216 } else if (from != to) { | 1219 } else if (from != to) { |
| 1217 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1220 animation->Reset((to == HOT) ? 1.0 : 0.0); |
| 1218 } | 1221 } |
| 1219 } | 1222 } |
| OLD | NEW |