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/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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { | 398 bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { |
| 399 // Mouse should not activate us in dangerous mode. | 399 // Mouse should not activate us in dangerous mode. |
| 400 if (IsShowingWarningDialog()) | 400 if (IsShowingWarningDialog()) |
| 401 return true; | 401 return true; |
| 402 | 402 |
| 403 if (!starting_drag_) { | 403 if (!starting_drag_) { |
| 404 starting_drag_ = true; | 404 starting_drag_ = true; |
| 405 drag_start_point_ = event.location(); | 405 drag_start_point_ = event.location(); |
| 406 } | 406 } |
| 407 if (dragging_) { | 407 if (dragging_) { |
| 408 if (download()->IsComplete()) { | 408 if (download()->GetState() == DownloadItem::COMPLETE) { |
| 409 IconManager* im = g_browser_process->icon_manager(); | 409 IconManager* im = g_browser_process->icon_manager(); |
| 410 gfx::Image* icon = im->LookupIconFromFilepath( | 410 gfx::Image* icon = im->LookupIconFromFilepath( |
| 411 download()->GetTargetFilePath(), IconLoader::SMALL); | 411 download()->GetTargetFilePath(), IconLoader::SMALL); |
| 412 if (icon) { | 412 if (icon) { |
| 413 views::Widget* widget = GetWidget(); | 413 views::Widget* widget = GetWidget(); |
| 414 download_util::DragDownload(download(), icon, | 414 download_util::DragDownload(download(), icon, |
| 415 widget ? widget->GetNativeView() : NULL); | 415 widget ? widget->GetNativeView() : NULL); |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { | 418 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 else if (image) | 782 else if (image) |
| 783 icon = image->ToImageSkia(); | 783 icon = image->ToImageSkia(); |
| 784 | 784 |
| 785 // 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 |
| 786 // 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 |
| 787 // 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 |
| 788 // 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 |
| 789 // triggered only when we think the status might change. | 789 // triggered only when we think the status might change. |
| 790 if (icon) { | 790 if (icon) { |
| 791 if (!IsShowingWarningDialog()) { | 791 if (!IsShowingWarningDialog()) { |
| 792 if (download()->IsInProgress()) { | 792 DownloadItem::DownloadState state = download()->GetState(); |
| 793 if (state == DownloadItem::IN_PROGRESS) { | |
| 793 download_util::PaintDownloadProgress(canvas, this, 0, 0, | 794 download_util::PaintDownloadProgress(canvas, this, 0, 0, |
| 794 progress_angle_, | 795 progress_angle_, |
| 795 model_.PercentComplete(), | 796 model_.PercentComplete(), |
| 796 download_util::SMALL); | 797 download_util::SMALL); |
| 797 } else if (download()->IsComplete() && | 798 } else if (state == DownloadItem::COMPLETE && |
| 798 complete_animation_.get() && | 799 complete_animation_.get() && |
| 799 complete_animation_->is_animating()) { | 800 complete_animation_->is_animating()) { |
| 800 if (download()->IsInterrupted()) { | 801 // FIXME: This will be always false, verify how handling of |
|
Paweł Hajdan Jr.
2013/05/28 16:55:59
We use TODO(username) for things like that.
If yo
asanka
2013/05/28 18:43:15
+1
Something like this would work:
else if (comp
| |
| 802 // INTERRUPTED state should be done. | |
| 803 if (state == DownloadItem::INTERRUPTED) { | |
| 801 download_util::PaintDownloadInterrupted(canvas, this, 0, 0, | 804 download_util::PaintDownloadInterrupted(canvas, this, 0, 0, |
| 802 complete_animation_->GetCurrentValue(), | 805 complete_animation_->GetCurrentValue(), |
| 803 download_util::SMALL); | 806 download_util::SMALL); |
| 804 } else { | 807 } else { |
| 805 download_util::PaintDownloadComplete(canvas, this, 0, 0, | 808 download_util::PaintDownloadComplete(canvas, this, 0, 0, |
| 806 complete_animation_->GetCurrentValue(), | 809 complete_animation_->GetCurrentValue(), |
| 807 download_util::SMALL); | 810 download_util::SMALL); |
| 808 } | 811 } |
| 809 } | 812 } |
| 810 } | 813 } |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1212 void DownloadItemView::AnimateStateTransition(State from, State to, | 1215 void DownloadItemView::AnimateStateTransition(State from, State to, |
| 1213 ui::SlideAnimation* animation) { | 1216 ui::SlideAnimation* animation) { |
| 1214 if (from == NORMAL && to == HOT) { | 1217 if (from == NORMAL && to == HOT) { |
| 1215 animation->Show(); | 1218 animation->Show(); |
| 1216 } else if (from == HOT && to == NORMAL) { | 1219 } else if (from == HOT && to == NORMAL) { |
| 1217 animation->Hide(); | 1220 animation->Hide(); |
| 1218 } else if (from != to) { | 1221 } else if (from != to) { |
| 1219 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1222 animation->Reset((to == HOT) ? 1.0 : 0.0); |
| 1220 } | 1223 } |
| 1221 } | 1224 } |
| OLD | NEW |