| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/download_item_view.h" | 5 #include "chrome/browser/views/download_item_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "app/text_elider.h" | 11 #include "app/text_elider.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress(); | 353 download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress(); |
| 354 break; | 354 break; |
| 355 case DownloadItem::COMPLETE: | 355 case DownloadItem::COMPLETE: |
| 356 if (download_->auto_opened()) { | 356 if (download_->auto_opened()) { |
| 357 parent_->RemoveDownloadView(this); // This will delete us! | 357 parent_->RemoveDownloadView(this); // This will delete us! |
| 358 return; | 358 return; |
| 359 } | 359 } |
| 360 StopDownloadProgress(); | 360 StopDownloadProgress(); |
| 361 complete_animation_.reset(new SlideAnimation(this)); | 361 complete_animation_.reset(new SlideAnimation(this)); |
| 362 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); | 362 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); |
| 363 complete_animation_->SetTweenType(SlideAnimation::NONE); | 363 complete_animation_->SetTweenType(Tween::LINEAR); |
| 364 complete_animation_->Show(); | 364 complete_animation_->Show(); |
| 365 if (status_text.empty()) | 365 if (status_text.empty()) |
| 366 show_status_text_ = false; | 366 show_status_text_ = false; |
| 367 SchedulePaint(); | 367 SchedulePaint(); |
| 368 LoadIcon(); | 368 LoadIcon(); |
| 369 break; | 369 break; |
| 370 case DownloadItem::CANCELLED: | 370 case DownloadItem::CANCELLED: |
| 371 StopDownloadProgress(); | 371 StopDownloadProgress(); |
| 372 LoadIcon(); | 372 LoadIcon(); |
| 373 break; | 373 break; |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // triggered only when we think the status might change. | 649 // triggered only when we think the status might change. |
| 650 if (icon) { | 650 if (icon) { |
| 651 if (!IsDangerousMode()) { | 651 if (!IsDangerousMode()) { |
| 652 if (download_->state() == DownloadItem::IN_PROGRESS) { | 652 if (download_->state() == DownloadItem::IN_PROGRESS) { |
| 653 download_util::PaintDownloadProgress(canvas, this, 0, 0, | 653 download_util::PaintDownloadProgress(canvas, this, 0, 0, |
| 654 progress_angle_, | 654 progress_angle_, |
| 655 download_->PercentComplete(), | 655 download_->PercentComplete(), |
| 656 download_util::SMALL); | 656 download_util::SMALL); |
| 657 } else if (download_->state() == DownloadItem::COMPLETE && | 657 } else if (download_->state() == DownloadItem::COMPLETE && |
| 658 complete_animation_.get() && | 658 complete_animation_.get() && |
| 659 complete_animation_->IsAnimating()) { | 659 complete_animation_->is_animating()) { |
| 660 download_util::PaintDownloadComplete(canvas, this, 0, 0, | 660 download_util::PaintDownloadComplete(canvas, this, 0, 0, |
| 661 complete_animation_->GetCurrentValue(), | 661 complete_animation_->GetCurrentValue(), |
| 662 download_util::SMALL); | 662 download_util::SMALL); |
| 663 } | 663 } |
| 664 } | 664 } |
| 665 | 665 |
| 666 // Draw the icon image. | 666 // Draw the icon image. |
| 667 int mirrored_x = MirroredXWithWidthInsideView( | 667 int mirrored_x = MirroredXWithWidthInsideView( |
| 668 download_util::kSmallProgressIconOffset, icon->width()); | 668 download_util::kSmallProgressIconOffset, icon->width()); |
| 669 if (IsEnabled()) { | 669 if (IsEnabled()) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 drop_hover_animation_->Hide(); | 777 drop_hover_animation_->Hide(); |
| 778 } | 778 } |
| 779 | 779 |
| 780 // Display the context menu for this item. | 780 // Display the context menu for this item. |
| 781 bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) { | 781 bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) { |
| 782 // Mouse should not activate us in dangerous mode. | 782 // Mouse should not activate us in dangerous mode. |
| 783 if (IsDangerousMode()) | 783 if (IsDangerousMode()) |
| 784 return true; | 784 return true; |
| 785 | 785 |
| 786 // Stop any completion animation. | 786 // Stop any completion animation. |
| 787 if (complete_animation_.get() && complete_animation_->IsAnimating()) | 787 if (complete_animation_.get() && complete_animation_->is_animating()) |
| 788 complete_animation_->End(); | 788 complete_animation_->End(); |
| 789 | 789 |
| 790 if (event.IsOnlyLeftMouseButton()) { | 790 if (event.IsOnlyLeftMouseButton()) { |
| 791 gfx::Point point(event.location()); | 791 gfx::Point point(event.location()); |
| 792 if (!InDropDownButtonXCoordinateRange(event.x())) { | 792 if (!InDropDownButtonXCoordinateRange(event.x())) { |
| 793 SetState(PUSHED, NORMAL); | 793 SetState(PUSHED, NORMAL); |
| 794 return true; | 794 return true; |
| 795 } | 795 } |
| 796 | 796 |
| 797 drop_down_pressed_ = true; | 797 drop_down_pressed_ = true; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 void DownloadItemView::Reenable() { | 1008 void DownloadItemView::Reenable() { |
| 1009 disabled_while_opening_ = false; | 1009 disabled_while_opening_ = false; |
| 1010 SetEnabled(true); // Triggers a repaint. | 1010 SetEnabled(true); // Triggers a repaint. |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) { | 1013 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) { |
| 1014 if (x > drop_down_x_left_ && x < drop_down_x_right_) | 1014 if (x > drop_down_x_left_ && x < drop_down_x_right_) |
| 1015 return true; | 1015 return true; |
| 1016 return false; | 1016 return false; |
| 1017 } | 1017 } |
| OLD | NEW |