OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/ui/gtk/gtk_util.h" | 24 #include "chrome/browser/ui/gtk/gtk_util.h" |
25 #include "chrome/browser/ui/gtk/nine_box.h" | 25 #include "chrome/browser/ui/gtk/nine_box.h" |
26 #include "content/public/browser/download_manager.h" | 26 #include "content/public/browser/download_manager.h" |
27 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
30 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
31 #include "ui/base/animation/slide_animation.h" | 31 #include "ui/base/animation/slide_animation.h" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
34 #include "ui/base/text/text_elider.h" | |
35 #include "ui/gfx/canvas_skia_paint.h" | 34 #include "ui/gfx/canvas_skia_paint.h" |
36 #include "ui/gfx/color_utils.h" | 35 #include "ui/gfx/color_utils.h" |
37 #include "ui/gfx/image/image.h" | 36 #include "ui/gfx/image/image.h" |
38 #include "ui/gfx/skia_utils_gtk.h" | 37 #include "ui/gfx/skia_utils_gtk.h" |
| 38 #include "ui/gfx/text_elider.h" |
39 #include "ui/gfx/text_utils.h" | 39 #include "ui/gfx/text_utils.h" |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 // The width of the |menu_button_| widget. It has to be at least as wide as the | 43 // The width of the |menu_button_| widget. It has to be at least as wide as the |
44 // bitmap that we use to draw it, i.e. 16, but can be more. | 44 // bitmap that we use to draw it, i.e. 16, but can be more. |
45 const int kMenuButtonWidth = 16; | 45 const int kMenuButtonWidth = 16; |
46 | 46 |
47 // Padding on left and right of items in dangerous download prompt. | 47 // Padding on left and right of items in dangerous download prompt. |
48 const int kDangerousElementPadding = 3; | 48 const int kDangerousElementPadding = 3; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 download_model_.GetTooltipText(font_list, kTooltipMaxWidth); | 485 download_model_.GetTooltipText(font_list, kTooltipMaxWidth); |
486 gtk_widget_set_tooltip_text(body_.get(), UTF16ToUTF8(tooltip_text).c_str()); | 486 gtk_widget_set_tooltip_text(body_.get(), UTF16ToUTF8(tooltip_text).c_str()); |
487 } | 487 } |
488 | 488 |
489 void DownloadItemGtk::UpdateNameLabel() { | 489 void DownloadItemGtk::UpdateNameLabel() { |
490 const gfx::FontList& font_list = | 490 const gfx::FontList& font_list = |
491 ui::ResourceBundle::GetSharedInstance().GetFontList( | 491 ui::ResourceBundle::GetSharedInstance().GetFontList( |
492 ui::ResourceBundle::BaseFont); | 492 ui::ResourceBundle::BaseFont); |
493 string16 filename; | 493 string16 filename; |
494 if (!disabled_while_opening_) { | 494 if (!disabled_while_opening_) { |
495 filename = ui::ElideFilename( | 495 filename = gfx::ElideFilename( |
496 download()->GetFileNameToReportUser(), font_list, kTextWidth); | 496 download()->GetFileNameToReportUser(), font_list, kTextWidth); |
497 } else { | 497 } else { |
498 // First, Calculate the download status opening string width. | 498 // First, Calculate the download status opening string width. |
499 string16 status_string = | 499 string16 status_string = |
500 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, string16()); | 500 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, string16()); |
501 int status_string_width = gfx::GetStringWidth(status_string, font_list); | 501 int status_string_width = gfx::GetStringWidth(status_string, font_list); |
502 // Then, elide the file name. | 502 // Then, elide the file name. |
503 string16 filename_string = | 503 string16 filename_string = |
504 ui::ElideFilename(download()->GetFileNameToReportUser(), font_list, | 504 gfx::ElideFilename(download()->GetFileNameToReportUser(), font_list, |
505 kTextWidth - status_string_width); | 505 kTextWidth - status_string_width); |
506 // Last, concat the whole string. | 506 // Last, concat the whole string. |
507 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, | 507 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, |
508 filename_string); | 508 filename_string); |
509 } | 509 } |
510 | 510 |
511 GdkColor color = theme_service_->GetGdkColor( | 511 GdkColor color = theme_service_->GetGdkColor( |
512 ThemeProperties::COLOR_BOOKMARK_TEXT); | 512 ThemeProperties::COLOR_BOOKMARK_TEXT); |
513 gtk_util::SetLabelColor( | 513 gtk_util::SetLabelColor( |
514 name_label_, | 514 name_label_, |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", | 928 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", |
929 base::Time::Now() - creation_time_); | 929 base::Time::Now() - creation_time_); |
930 download()->ValidateDangerousDownload(); | 930 download()->ValidateDangerousDownload(); |
931 } | 931 } |
932 | 932 |
933 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 933 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
934 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 934 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
935 base::Time::Now() - creation_time_); | 935 base::Time::Now() - creation_time_); |
936 download()->Remove(); | 936 download()->Remove(); |
937 } | 937 } |
OLD | NEW |