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 343 matching lines...) Loading... |
354 parent_shelf_->RemoveDownloadItem(this); // This will delete us! | 354 parent_shelf_->RemoveDownloadItem(this); // This will delete us! |
355 return; | 355 return; |
356 } | 356 } |
357 StopDownloadProgress(); | 357 StopDownloadProgress(); |
358 | 358 |
359 // Set up the widget as a drag source. | 359 // Set up the widget as a drag source. |
360 DownloadItemDrag::SetSource(body_.get(), get_download(), icon_large_); | 360 DownloadItemDrag::SetSource(body_.get(), get_download(), icon_large_); |
361 | 361 |
362 complete_animation_.reset(new SlideAnimation(this)); | 362 complete_animation_.reset(new SlideAnimation(this)); |
363 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); | 363 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); |
364 complete_animation_->SetTweenType(SlideAnimation::NONE); | 364 complete_animation_->SetTweenType(Tween::LINEAR); |
365 complete_animation_->Show(); | 365 complete_animation_->Show(); |
366 break; | 366 break; |
367 case DownloadItem::IN_PROGRESS: | 367 case DownloadItem::IN_PROGRESS: |
368 get_download()->is_paused() ? | 368 get_download()->is_paused() ? |
369 StopDownloadProgress() : StartDownloadProgress(); | 369 StopDownloadProgress() : StartDownloadProgress(); |
370 break; | 370 break; |
371 default: | 371 default: |
372 NOTREACHED(); | 372 NOTREACHED(); |
373 } | 373 } |
374 | 374 |
(...skipping 419 matching lines...) Loading... |
794 download_util::OpenDownload(download); | 794 download_util::OpenDownload(download); |
795 } | 795 } |
796 } | 796 } |
797 | 797 |
798 // static | 798 // static |
799 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, | 799 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, |
800 GdkEventExpose* event, DownloadItemGtk* download_item) { | 800 GdkEventExpose* event, DownloadItemGtk* download_item) { |
801 // Create a transparent canvas. | 801 // Create a transparent canvas. |
802 gfx::CanvasPaint canvas(event, false); | 802 gfx::CanvasPaint canvas(event, false); |
803 if (download_item->complete_animation_.get()) { | 803 if (download_item->complete_animation_.get()) { |
804 if (download_item->complete_animation_->IsAnimating()) { | 804 if (download_item->complete_animation_->is_animating()) { |
805 download_util::PaintDownloadComplete(&canvas, | 805 download_util::PaintDownloadComplete(&canvas, |
806 widget->allocation.x, widget->allocation.y, | 806 widget->allocation.x, widget->allocation.y, |
807 download_item->complete_animation_->GetCurrentValue(), | 807 download_item->complete_animation_->GetCurrentValue(), |
808 download_util::SMALL); | 808 download_util::SMALL); |
809 } | 809 } |
810 } else if (download_item->get_download()->state() != | 810 } else if (download_item->get_download()->state() != |
811 DownloadItem::CANCELLED) { | 811 DownloadItem::CANCELLED) { |
812 download_util::PaintDownloadProgress(&canvas, | 812 download_util::PaintDownloadProgress(&canvas, |
813 widget->allocation.x, widget->allocation.y, | 813 widget->allocation.x, widget->allocation.y, |
814 download_item->progress_angle_, | 814 download_item->progress_angle_, |
(...skipping 12 matching lines...) Loading... |
827 | 827 |
828 return TRUE; | 828 return TRUE; |
829 } | 829 } |
830 | 830 |
831 // static | 831 // static |
832 gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button, | 832 gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button, |
833 GdkEvent* event, | 833 GdkEvent* event, |
834 DownloadItemGtk* item) { | 834 DownloadItemGtk* item) { |
835 // Stop any completion animation. | 835 // Stop any completion animation. |
836 if (item->complete_animation_.get() && | 836 if (item->complete_animation_.get() && |
837 item->complete_animation_->IsAnimating()) { | 837 item->complete_animation_->is_animating()) { |
838 item->complete_animation_->End(); | 838 item->complete_animation_->End(); |
839 } | 839 } |
840 | 840 |
841 if (event->type == GDK_BUTTON_PRESS) { | 841 if (event->type == GDK_BUTTON_PRESS) { |
842 GdkEventButton* event_button = reinterpret_cast<GdkEventButton*>(event); | 842 GdkEventButton* event_button = reinterpret_cast<GdkEventButton*>(event); |
843 if (event_button->button == 1) { | 843 if (event_button->button == 1) { |
844 if (item->menu_.get() == NULL) { | 844 if (item->menu_.get() == NULL) { |
845 item->menu_.reset(new DownloadShelfContextMenuGtk( | 845 item->menu_.reset(new DownloadShelfContextMenuGtk( |
846 item->download_model_.get(), item)); | 846 item->download_model_.get(), item)); |
847 } | 847 } |
(...skipping 27 matching lines...) Loading... |
875 | 875 |
876 // static | 876 // static |
877 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button, | 877 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button, |
878 DownloadItemGtk* item) { | 878 DownloadItemGtk* item) { |
879 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 879 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
880 base::Time::Now() - item->creation_time_); | 880 base::Time::Now() - item->creation_time_); |
881 if (item->get_download()->state() == DownloadItem::IN_PROGRESS) | 881 if (item->get_download()->state() == DownloadItem::IN_PROGRESS) |
882 item->get_download()->Cancel(true); | 882 item->get_download()->Cancel(true); |
883 item->get_download()->Remove(true); | 883 item->get_download()->Remove(true); |
884 } | 884 } |
OLD | NEW |