OLD | NEW |
1 // Copyright (c) 2010 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/gtk/download_item_gtk.h" | 5 #include "chrome/browser/gtk/download_item_gtk.h" |
6 | 6 |
7 #include "app/gtk_util.h" | 7 #include "app/gtk_util.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/menus/simple_menu_model.h" | 9 #include "app/menus/simple_menu_model.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget)); | 774 GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget)); |
775 if (child) | 775 if (child) |
776 gtk_container_propagate_expose(GTK_CONTAINER(widget), child, e); | 776 gtk_container_propagate_expose(GTK_CONTAINER(widget), child, e); |
777 | 777 |
778 return TRUE; | 778 return TRUE; |
779 } | 779 } |
780 | 780 |
781 void DownloadItemGtk::OnClick(GtkWidget* widget) { | 781 void DownloadItemGtk::OnClick(GtkWidget* widget) { |
782 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", | 782 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", |
783 base::Time::Now() - creation_time_); | 783 base::Time::Now() - creation_time_); |
784 | 784 get_download()->OpenDownload(); |
785 DownloadItem* download = get_download(); | |
786 | |
787 if (download->state() == DownloadItem::IN_PROGRESS) { | |
788 download->set_open_when_complete( | |
789 !download->open_when_complete()); | |
790 } else if (download->state() == DownloadItem::COMPLETE) { | |
791 download_util::OpenDownload(download); | |
792 } | |
793 } | 785 } |
794 | 786 |
795 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, | 787 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, |
796 GdkEventExpose* event) { | 788 GdkEventExpose* event) { |
797 // Create a transparent canvas. | 789 // Create a transparent canvas. |
798 gfx::CanvasSkiaPaint canvas(event, false); | 790 gfx::CanvasSkiaPaint canvas(event, false); |
799 if (complete_animation_.get()) { | 791 if (complete_animation_.get()) { |
800 if (complete_animation_->is_animating()) { | 792 if (complete_animation_->is_animating()) { |
801 download_util::PaintDownloadComplete(&canvas, | 793 download_util::PaintDownloadComplete(&canvas, |
802 widget->allocation.x, widget->allocation.y, | 794 widget->allocation.x, widget->allocation.y, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 if (!theme_provider_->UseGtkTheme()) { | 843 if (!theme_provider_->UseGtkTheme()) { |
852 // The hbox renderer will take care of the border when in GTK mode. | 844 // The hbox renderer will take care of the border when in GTK mode. |
853 dangerous_nine_box_->RenderToWidget(widget); | 845 dangerous_nine_box_->RenderToWidget(widget); |
854 } | 846 } |
855 return FALSE; // Continue propagation. | 847 return FALSE; // Continue propagation. |
856 } | 848 } |
857 | 849 |
858 void DownloadItemGtk::OnDangerousAccept(GtkWidget* button) { | 850 void DownloadItemGtk::OnDangerousAccept(GtkWidget* button) { |
859 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", | 851 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", |
860 base::Time::Now() - creation_time_); | 852 base::Time::Now() - creation_time_); |
861 get_download()->manager()->DangerousDownloadValidated(get_download()); | 853 get_download()->DangerousDownloadValidated(); |
862 } | 854 } |
863 | 855 |
864 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 856 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
865 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 857 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
866 base::Time::Now() - creation_time_); | 858 base::Time::Now() - creation_time_); |
867 if (get_download()->state() == DownloadItem::IN_PROGRESS) | 859 if (get_download()->state() == DownloadItem::IN_PROGRESS) |
868 get_download()->Cancel(true); | 860 get_download()->Cancel(true); |
869 get_download()->Remove(true); | 861 get_download()->Remove(true); |
870 } | 862 } |
OLD | NEW |