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

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

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « chrome/browser/ui/gtk/download_item_gtk.h ('k') | chrome/browser/ui/gtk/download_shelf_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_item_gtk.h" 5 #include "chrome/browser/ui/gtk/download_item_gtk.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "app/text_elider.h"
10 #include "base/basictypes.h" 9 #include "base/basictypes.h"
11 #include "base/callback.h" 10 #include "base/callback.h"
12 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
13 #include "base/string_util.h" 12 #include "base/string_util.h"
14 #include "base/time.h" 13 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/download/download_item.h" 16 #include "chrome/browser/download/download_item.h"
18 #include "chrome/browser/download/download_item_model.h" 17 #include "chrome/browser/download/download_item_model.h"
19 #include "chrome/browser/download/download_manager.h" 18 #include "chrome/browser/download/download_manager.h"
20 #include "chrome/browser/download/download_shelf.h" 19 #include "chrome/browser/download/download_shelf.h"
21 #include "chrome/browser/download/download_util.h" 20 #include "chrome/browser/download/download_util.h"
22 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/gtk/custom_drag.h" 22 #include "chrome/browser/ui/gtk/custom_drag.h"
24 #include "chrome/browser/ui/gtk/download_shelf_gtk.h" 23 #include "chrome/browser/ui/gtk/download_shelf_gtk.h"
25 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" 24 #include "chrome/browser/ui/gtk/gtk_theme_provider.h"
26 #include "chrome/browser/ui/gtk/gtk_util.h" 25 #include "chrome/browser/ui/gtk/gtk_util.h"
27 #include "chrome/browser/ui/gtk/menu_gtk.h" 26 #include "chrome/browser/ui/gtk/menu_gtk.h"
28 #include "chrome/browser/ui/gtk/nine_box.h" 27 #include "chrome/browser/ui/gtk/nine_box.h"
29 #include "chrome/common/notification_service.h" 28 #include "chrome/common/notification_service.h"
30 #include "gfx/canvas_skia_paint.h" 29 #include "gfx/canvas_skia_paint.h"
31 #include "gfx/color_utils.h" 30 #include "gfx/color_utils.h"
32 #include "gfx/font.h" 31 #include "gfx/font.h"
33 #include "gfx/skia_utils_gtk.h" 32 #include "gfx/skia_utils_gtk.h"
34 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
35 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
36 #include "third_party/skia/include/core/SkBitmap.h" 35 #include "third_party/skia/include/core/SkBitmap.h"
37 #include "ui/base/animation/slide_animation.h" 36 #include "ui/base/animation/slide_animation.h"
37 #include "ui/base/text/text_elider.h"
38 38
39 namespace { 39 namespace {
40 40
41 // The width of the |menu_button_| widget. It has to be at least as wide as the 41 // The width of the |menu_button_| widget. It has to be at least as wide as the
42 // bitmap that we use to draw it, i.e. 16, but can be more. 42 // bitmap that we use to draw it, i.e. 16, but can be more.
43 const int kMenuButtonWidth = 16; 43 const int kMenuButtonWidth = 16;
44 44
45 // Padding on left and right of items in dangerous download prompt. 45 // Padding on left and right of items in dangerous download prompt.
46 const int kDangerousElementPadding = 3; 46 const int kDangerousElementPadding = 3;
47 47
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 icon_filepath_ = get_download()->GetUserVerifiedFilePath(); 512 icon_filepath_ = get_download()->GetUserVerifiedFilePath();
513 im->LoadIcon(icon_filepath_, 513 im->LoadIcon(icon_filepath_,
514 IconLoader::SMALL, &icon_consumer_, 514 IconLoader::SMALL, &icon_consumer_,
515 NewCallback(this, &DownloadItemGtk::OnLoadSmallIconComplete)); 515 NewCallback(this, &DownloadItemGtk::OnLoadSmallIconComplete));
516 im->LoadIcon(icon_filepath_, 516 im->LoadIcon(icon_filepath_,
517 IconLoader::LARGE, &icon_consumer_, 517 IconLoader::LARGE, &icon_consumer_,
518 NewCallback(this, &DownloadItemGtk::OnLoadLargeIconComplete)); 518 NewCallback(this, &DownloadItemGtk::OnLoadLargeIconComplete));
519 } 519 }
520 520
521 void DownloadItemGtk::UpdateTooltip() { 521 void DownloadItemGtk::UpdateTooltip() {
522 string16 elided_filename = gfx::ElideFilename( 522 string16 elided_filename = ui::ElideFilename(
523 get_download()->GetFileNameToReportUser(), 523 get_download()->GetFileNameToReportUser(),
524 gfx::Font(), kTooltipMaxWidth); 524 gfx::Font(), kTooltipMaxWidth);
525 gtk_widget_set_tooltip_text(body_.get(), 525 gtk_widget_set_tooltip_text(body_.get(),
526 UTF16ToUTF8(elided_filename).c_str()); 526 UTF16ToUTF8(elided_filename).c_str());
527 } 527 }
528 528
529 void DownloadItemGtk::UpdateNameLabel() { 529 void DownloadItemGtk::UpdateNameLabel() {
530 // TODO(estade): This is at best an educated guess, since we don't actually 530 // TODO(estade): This is at best an educated guess, since we don't actually
531 // use gfx::Font() to draw the text. This is why we need to add so 531 // use gfx::Font() to draw the text. This is why we need to add so
532 // much padding when we set the size request. We need to either use gfx::Font 532 // much padding when we set the size request. We need to either use gfx::Font
533 // or somehow extend TextElider. 533 // or somehow extend TextElider.
534 string16 elided_filename = gfx::ElideFilename( 534 string16 elided_filename = ui::ElideFilename(
535 get_download()->GetFileNameToReportUser(), 535 get_download()->GetFileNameToReportUser(),
536 gfx::Font(), kTextWidth); 536 gfx::Font(), kTextWidth);
537 537
538 GdkColor color = theme_provider_->GetGdkColor( 538 GdkColor color = theme_provider_->GetGdkColor(
539 BrowserThemeProvider::COLOR_BOOKMARK_TEXT); 539 BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
540 gtk_util::SetLabelColor(name_label_, theme_provider_->UseGtkTheme() ? 540 gtk_util::SetLabelColor(name_label_, theme_provider_->UseGtkTheme() ?
541 NULL : &color); 541 NULL : &color);
542 gtk_label_set_text(GTK_LABEL(name_label_), 542 gtk_label_set_text(GTK_LABEL(name_label_),
543 UTF16ToUTF8(elided_filename).c_str()); 543 UTF16ToUTF8(elided_filename).c_str());
544 } 544 }
(...skipping 30 matching lines...) Expand all
575 575
576 void DownloadItemGtk::UpdateDangerWarning() { 576 void DownloadItemGtk::UpdateDangerWarning() {
577 if (dangerous_prompt_) { 577 if (dangerous_prompt_) {
578 // We create |dangerous_warning| as a wide string so we can more easily 578 // We create |dangerous_warning| as a wide string so we can more easily
579 // calculate its length in characters. 579 // calculate its length in characters.
580 string16 dangerous_warning; 580 string16 dangerous_warning;
581 if (get_download()->is_extension_install()) { 581 if (get_download()->is_extension_install()) {
582 dangerous_warning = 582 dangerous_warning =
583 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); 583 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
584 } else { 584 } else {
585 string16 elided_filename = gfx::ElideFilename( 585 string16 elided_filename = ui::ElideFilename(
586 get_download()->target_name(), gfx::Font(), kTextWidth); 586 get_download()->target_name(), gfx::Font(), kTextWidth);
587 587
588 dangerous_warning = 588 dangerous_warning =
589 l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD, 589 l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD,
590 elided_filename); 590 elided_filename);
591 } 591 }
592 592
593 if (theme_provider_->UseGtkTheme()) { 593 if (theme_provider_->UseGtkTheme()) {
594 gtk_image_set_from_stock(GTK_IMAGE(dangerous_image_), 594 gtk_image_set_from_stock(GTK_IMAGE(dangerous_image_),
595 GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); 595 GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 get_download()->DangerousDownloadValidated(); 870 get_download()->DangerousDownloadValidated();
871 } 871 }
872 872
873 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 873 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
874 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 874 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
875 base::Time::Now() - creation_time_); 875 base::Time::Now() - creation_time_);
876 if (get_download()->state() == DownloadItem::IN_PROGRESS) 876 if (get_download()->state() == DownloadItem::IN_PROGRESS)
877 get_download()->Cancel(true); 877 get_download()->Cancel(true);
878 get_download()->Remove(true); 878 get_download()->Remove(true);
879 } 879 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/download_item_gtk.h ('k') | chrome/browser/ui/gtk/download_shelf_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698