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

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

Issue 6969009: Reduced the lifetime of DownloadCreateInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Stupid clang! Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 600
601 void DownloadItemGtk::UpdateDangerWarning() { 601 void DownloadItemGtk::UpdateDangerWarning() {
602 if (dangerous_prompt_) { 602 if (dangerous_prompt_) {
603 UpdateDangerIcon(); 603 UpdateDangerIcon();
604 604
605 // We create |dangerous_warning| as a wide string so we can more easily 605 // We create |dangerous_warning| as a wide string so we can more easily
606 // calculate its length in characters. 606 // calculate its length in characters.
607 string16 dangerous_warning; 607 string16 dangerous_warning;
608 608
609 // The dangerous download label text is different for different cases. 609 // The dangerous download label text is different for different cases.
610 if (get_download()->danger_type() == DownloadItem::DANGEROUS_URL) { 610 if (get_download()->GetDangerType() == DownloadItem::DANGEROUS_URL) {
611 // Safebrowsing shows the download URL leads to malicious file. 611 // Safebrowsing shows the download URL leads to malicious file.
612 dangerous_warning = 612 dangerous_warning =
613 l10n_util::GetStringUTF16(IDS_PROMPT_UNSAFE_DOWNLOAD_URL); 613 l10n_util::GetStringUTF16(IDS_PROMPT_UNSAFE_DOWNLOAD_URL);
614 } else { 614 } else {
615 // It's a dangerous file type (e.g.: an executable). 615 // It's a dangerous file type (e.g.: an executable).
616 DCHECK(get_download()->danger_type() == DownloadItem::DANGEROUS_FILE); 616 DCHECK(get_download()->GetDangerType() ==
617 DownloadItem::DANGEROUS_FILE);
617 if (get_download()->is_extension_install()) { 618 if (get_download()->is_extension_install()) {
618 dangerous_warning = 619 dangerous_warning =
619 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); 620 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
620 } else { 621 } else {
621 string16 elided_filename = ui::ElideFilename( 622 string16 elided_filename = ui::ElideFilename(
622 get_download()->target_name(), gfx::Font(), kTextWidth); 623 get_download()->target_name(), gfx::Font(), kTextWidth);
623 dangerous_warning = 624 dangerous_warning =
624 l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD, 625 l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD,
625 elided_filename); 626 elided_filename);
626 } 627 }
(...skipping 29 matching lines...) Expand all
656 // change the label above. 657 // change the label above.
657 gtk_widget_size_request(dangerous_hbox_.get(), &req); 658 gtk_widget_size_request(dangerous_hbox_.get(), &req);
658 dangerous_hbox_full_width_ = req.width; 659 dangerous_hbox_full_width_ = req.width;
659 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - label_width; 660 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - label_width;
660 } 661 }
661 } 662 }
662 663
663 void DownloadItemGtk::UpdateDangerIcon() { 664 void DownloadItemGtk::UpdateDangerIcon() {
664 if (theme_service_->UsingNativeTheme()) { 665 if (theme_service_->UsingNativeTheme()) {
665 const char* stock = 666 const char* stock =
666 get_download()->danger_type() == DownloadItem::DANGEROUS_URL ? 667 get_download()->GetDangerType() == DownloadItem::DANGEROUS_URL ?
667 GTK_STOCK_DIALOG_ERROR : GTK_STOCK_DIALOG_WARNING; 668 GTK_STOCK_DIALOG_ERROR : GTK_STOCK_DIALOG_WARNING;
668 gtk_image_set_from_stock( 669 gtk_image_set_from_stock(
669 GTK_IMAGE(dangerous_image_), stock, GTK_ICON_SIZE_SMALL_TOOLBAR); 670 GTK_IMAGE(dangerous_image_), stock, GTK_ICON_SIZE_SMALL_TOOLBAR);
670 } else { 671 } else {
671 // Set the warning icon. 672 // Set the warning icon.
672 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 673 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
673 int pixbuf_id = 674 int pixbuf_id =
674 get_download()->danger_type() == DownloadItem::DANGEROUS_URL ? 675 get_download()->GetDangerType() == DownloadItem::DANGEROUS_URL ?
675 IDR_SAFEBROWSING_WARNING : IDR_WARNING; 676 IDR_SAFEBROWSING_WARNING : IDR_WARNING;
676 GdkPixbuf* download_pixbuf = rb.GetNativeImageNamed(pixbuf_id); 677 GdkPixbuf* download_pixbuf = rb.GetNativeImageNamed(pixbuf_id);
677 gtk_image_set_from_pixbuf(GTK_IMAGE(dangerous_image_), download_pixbuf); 678 gtk_image_set_from_pixbuf(GTK_IMAGE(dangerous_image_), download_pixbuf);
678 } 679 }
679 } 680 }
680 681
681 // static 682 // static
682 void DownloadItemGtk::InitNineBoxes() { 683 void DownloadItemGtk::InitNineBoxes() {
683 if (body_nine_box_normal_) 684 if (body_nine_box_normal_)
684 return; 685 return;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 get_download()->DangerousDownloadValidated(); 933 get_download()->DangerousDownloadValidated();
933 } 934 }
934 935
935 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 936 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
936 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 937 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
937 base::Time::Now() - creation_time_); 938 base::Time::Now() - creation_time_);
938 if (get_download()->IsPartialDownload()) 939 if (get_download()->IsPartialDownload())
939 get_download()->Cancel(true); 940 get_download()->Cancel(true);
940 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 941 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
941 } 942 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_item_controller.mm ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698