OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 ShowPopupMenu(NULL, event); | 852 ShowPopupMenu(NULL, event); |
853 return TRUE; | 853 return TRUE; |
854 } | 854 } |
855 | 855 |
856 return FALSE; | 856 return FALSE; |
857 } | 857 } |
858 | 858 |
859 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, | 859 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, |
860 GdkEventExpose* event) { | 860 GdkEventExpose* event) { |
861 // Create a transparent canvas. | 861 // Create a transparent canvas. |
862 gfx::CanvasSkiaPaint canvas(event, false); | 862 gfx::CanvasSkiaPaint canvas_paint(event, false); |
| 863 gfx::Canvas* canvas = canvas_paint.AsCanvas(); |
863 if (complete_animation_.is_animating()) { | 864 if (complete_animation_.is_animating()) { |
864 if (get_download()->IsInterrupted()) { | 865 if (get_download()->IsInterrupted()) { |
865 download_util::PaintDownloadInterrupted(&canvas, | 866 download_util::PaintDownloadInterrupted(canvas, |
866 widget->allocation.x, widget->allocation.y, | 867 widget->allocation.x, widget->allocation.y, |
867 complete_animation_.GetCurrentValue(), | 868 complete_animation_.GetCurrentValue(), |
868 download_util::SMALL); | 869 download_util::SMALL); |
869 } else { | 870 } else { |
870 download_util::PaintDownloadComplete(&canvas, | 871 download_util::PaintDownloadComplete(canvas, |
871 widget->allocation.x, widget->allocation.y, | 872 widget->allocation.x, widget->allocation.y, |
872 complete_animation_.GetCurrentValue(), | 873 complete_animation_.GetCurrentValue(), |
873 download_util::SMALL); | 874 download_util::SMALL); |
874 } | 875 } |
875 } else if (!get_download()->IsCancelled()) { | 876 } else if (!get_download()->IsCancelled()) { |
876 download_util::PaintDownloadProgress(&canvas, | 877 download_util::PaintDownloadProgress(canvas, |
877 widget->allocation.x, widget->allocation.y, | 878 widget->allocation.x, widget->allocation.y, |
878 progress_angle_, | 879 progress_angle_, |
879 get_download()->PercentComplete(), | 880 get_download()->PercentComplete(), |
880 download_util::SMALL); | 881 download_util::SMALL); |
881 } | 882 } |
882 | 883 |
883 // |icon_small_| may be NULL if it is still loading. If the file is an | 884 // |icon_small_| may be NULL if it is still loading. If the file is an |
884 // unrecognized type then we will get back a generic system icon. Hence | 885 // unrecognized type then we will get back a generic system icon. Hence |
885 // there is no need to use the chromium-specific default download item icon. | 886 // there is no need to use the chromium-specific default download item icon. |
886 if (icon_small_) { | 887 if (icon_small_) { |
887 const int offset = download_util::kSmallProgressIconOffset; | 888 const int offset = download_util::kSmallProgressIconOffset; |
888 canvas.DrawBitmapInt(*icon_small_, | 889 canvas->DrawBitmapInt(*icon_small_, |
889 widget->allocation.x + offset, widget->allocation.y + offset); | 890 widget->allocation.x + offset, widget->allocation.y + offset); |
890 } | 891 } |
891 | 892 |
892 return TRUE; | 893 return TRUE; |
893 } | 894 } |
894 | 895 |
895 gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button, | 896 gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button, |
896 GdkEventButton* event) { | 897 GdkEventButton* event) { |
897 if (event->type == GDK_BUTTON_PRESS && event->button == 1) { | 898 if (event->type == GDK_BUTTON_PRESS && event->button == 1) { |
898 ShowPopupMenu(button, event); | 899 ShowPopupMenu(button, event); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 get_download()->DangerousDownloadValidated(); | 931 get_download()->DangerousDownloadValidated(); |
931 } | 932 } |
932 | 933 |
933 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 934 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
934 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 935 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
935 base::Time::Now() - creation_time_); | 936 base::Time::Now() - creation_time_); |
936 if (get_download()->IsPartialDownload()) | 937 if (get_download()->IsPartialDownload()) |
937 get_download()->Cancel(true); | 938 get_download()->Cancel(true); |
938 get_download()->Remove(true); | 939 get_download()->Remove(true); |
939 } | 940 } |
OLD | NEW |