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

Side by Side Diff: chrome/browser/ui/gtk/download/download_item_gtk.cc

Issue 16018005: Use DownloadItem::GetState() in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stopping complete_animation_ when download is cancelled Created 7 years, 6 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 unified diff | Download patch
OLDNEW
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/gtk/download/download_item_gtk.h" 5 #include "chrome/browser/ui/gtk/download/download_item_gtk.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 // Icon loading functions. 450 // Icon loading functions.
451 451
452 void DownloadItemGtk::OnLoadSmallIconComplete(gfx::Image* image) { 452 void DownloadItemGtk::OnLoadSmallIconComplete(gfx::Image* image) {
453 icon_small_ = image; 453 icon_small_ = image;
454 gtk_widget_queue_draw(progress_area_.get()); 454 gtk_widget_queue_draw(progress_area_.get());
455 } 455 }
456 456
457 void DownloadItemGtk::OnLoadLargeIconComplete(gfx::Image* image) { 457 void DownloadItemGtk::OnLoadLargeIconComplete(gfx::Image* image) {
458 icon_large_ = image; 458 icon_large_ = image;
459 if (download()->IsComplete()) 459 if (download()->GetState() == DownloadItem::COMPLETE)
460 DownloadItemDrag::SetSource(body_.get(), download(), icon_large_); 460 DownloadItemDrag::SetSource(body_.get(), download(), icon_large_);
461 // Else, the download will be made draggable once an OnDownloadUpdated() 461 // Else, the download will be made draggable once an OnDownloadUpdated()
462 // notification is received with download->IsComplete(). 462 // notification is received with a download in COMPLETE state.
463 } 463 }
464 464
465 void DownloadItemGtk::LoadIcon() { 465 void DownloadItemGtk::LoadIcon() {
466 cancelable_task_tracker_.TryCancelAll(); 466 cancelable_task_tracker_.TryCancelAll();
467 IconManager* im = g_browser_process->icon_manager(); 467 IconManager* im = g_browser_process->icon_manager();
468 icon_filepath_ = download()->GetTargetFilePath(); 468 icon_filepath_ = download()->GetTargetFilePath();
469 im->LoadIcon(icon_filepath_, 469 im->LoadIcon(icon_filepath_,
470 IconLoader::SMALL, 470 IconLoader::SMALL,
471 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete, 471 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete,
472 base::Unretained(this)), 472 base::Unretained(this)),
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 842
843 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, 843 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget,
844 GdkEventExpose* event) { 844 GdkEventExpose* event) {
845 TRACE_EVENT0("ui::gtk", "DownloadItemGtk::OnProgressAreaExpose"); 845 TRACE_EVENT0("ui::gtk", "DownloadItemGtk::OnProgressAreaExpose");
846 846
847 GtkAllocation allocation; 847 GtkAllocation allocation;
848 gtk_widget_get_allocation(widget, &allocation); 848 gtk_widget_get_allocation(widget, &allocation);
849 849
850 // Create a transparent canvas. 850 // Create a transparent canvas.
851 gfx::CanvasSkiaPaint canvas(event, false); 851 gfx::CanvasSkiaPaint canvas(event, false);
852 DownloadItem::DownloadState state = download()->GetState();
852 if (complete_animation_.is_animating()) { 853 if (complete_animation_.is_animating()) {
853 if (download()->IsInterrupted()) { 854 if (state == DownloadItem::INTERRUPTED) {
854 download_util::PaintDownloadInterrupted(&canvas, 855 download_util::PaintDownloadInterrupted(&canvas,
855 allocation.x, allocation.y, 856 allocation.x, allocation.y,
856 complete_animation_.GetCurrentValue(), 857 complete_animation_.GetCurrentValue(),
857 download_util::SMALL); 858 download_util::SMALL);
858 } else { 859 } else {
859 download_util::PaintDownloadComplete(&canvas, 860 download_util::PaintDownloadComplete(&canvas,
860 allocation.x, allocation.y, 861 allocation.x, allocation.y,
861 complete_animation_.GetCurrentValue(), 862 complete_animation_.GetCurrentValue(),
862 download_util::SMALL); 863 download_util::SMALL);
863 } 864 }
864 } else if (download()->IsInProgress()) { 865 } else if (state == DownloadItem::IN_PROGRESS) {
865 download_util::PaintDownloadProgress(&canvas, 866 download_util::PaintDownloadProgress(&canvas,
866 allocation.x, allocation.y, 867 allocation.x, allocation.y,
867 progress_angle_, 868 progress_angle_,
868 download_model_.PercentComplete(), 869 download_model_.PercentComplete(),
869 download_util::SMALL); 870 download_util::SMALL);
870 } 871 }
871 872
872 // |icon_small_| may be NULL if it is still loading. If the file is an 873 // |icon_small_| may be NULL if it is still loading. If the file is an
873 // unrecognized type then we will get back a generic system icon. Hence 874 // unrecognized type then we will get back a generic system icon. Hence
874 // there is no need to use the chromium-specific default download item icon. 875 // there is no need to use the chromium-specific default download item icon.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", 920 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download",
920 base::Time::Now() - creation_time_); 921 base::Time::Now() - creation_time_);
921 download()->ValidateDangerousDownload(); 922 download()->ValidateDangerousDownload();
922 } 923 }
923 924
924 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 925 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
925 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 926 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
926 base::Time::Now() - creation_time_); 927 base::Time::Now() - creation_time_);
927 download()->Remove(); 928 download()->Remove();
928 } 929 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/custom_drag.cc ('k') | chrome/browser/ui/gtk/download/download_shelf_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698