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

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

Issue 112913004: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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) 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 GtkWidget* dangerous_decline = gtk_button_new_with_label( 233 GtkWidget* dangerous_decline = gtk_button_new_with_label(
234 l10n_util::GetStringUTF8(IDS_DISCARD_DOWNLOAD).c_str()); 234 l10n_util::GetStringUTF8(IDS_DISCARD_DOWNLOAD).c_str());
235 g_signal_connect(dangerous_decline, "clicked", 235 g_signal_connect(dangerous_decline, "clicked",
236 G_CALLBACK(OnDangerousDeclineThunk), this); 236 G_CALLBACK(OnDangerousDeclineThunk), this);
237 gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_decline, 237 gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_decline,
238 false, 0); 238 false, 0);
239 239
240 // Create the ok button, if this is the kind that can be bypassed. 240 // Create the ok button, if this is the kind that can be bypassed.
241 if (!download_model_.IsMalicious()) { 241 if (!download_model_.IsMalicious()) {
242 GtkWidget* dangerous_accept = gtk_button_new_with_label( 242 GtkWidget* dangerous_accept = gtk_button_new_with_label(
243 UTF16ToUTF8(download_model_.GetWarningConfirmButtonText()).c_str()); 243 base::UTF16ToUTF8(
244 download_model_.GetWarningConfirmButtonText()).c_str());
244 g_signal_connect(dangerous_accept, "clicked", 245 g_signal_connect(dangerous_accept, "clicked",
245 G_CALLBACK(OnDangerousAcceptThunk), this); 246 G_CALLBACK(OnDangerousAcceptThunk), this);
246 gtk_util::CenterWidgetInHBox( 247 gtk_util::CenterWidgetInHBox(
247 dangerous_hbox_.get(), dangerous_accept, false, 0); 248 dangerous_hbox_.get(), dangerous_accept, false, 0);
248 } 249 }
249 250
250 // Put it in an alignment so that padding will be added on the left and 251 // Put it in an alignment so that padding will be added on the left and
251 // right. 252 // right.
252 dangerous_prompt_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 253 dangerous_prompt_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
253 gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_), 254 gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 download_complete_ = true; 360 download_complete_ = true;
360 break; 361 break;
361 case DownloadItem::IN_PROGRESS: 362 case DownloadItem::IN_PROGRESS:
362 download()->IsPaused() ? 363 download()->IsPaused() ?
363 StopDownloadProgress() : StartDownloadProgress(); 364 StopDownloadProgress() : StartDownloadProgress();
364 break; 365 break;
365 default: 366 default:
366 NOTREACHED(); 367 NOTREACHED();
367 } 368 }
368 369
369 status_text_ = UTF16ToUTF8(download_model_.GetStatusText()); 370 status_text_ = base::UTF16ToUTF8(download_model_.GetStatusText());
370 UpdateStatusLabel(status_text_); 371 UpdateStatusLabel(status_text_);
371 } 372 }
372 373
373 void DownloadItemGtk::OnDownloadDestroyed(DownloadItem* download_item) { 374 void DownloadItemGtk::OnDownloadDestroyed(DownloadItem* download_item) {
374 DCHECK_EQ(download(), download_item); 375 DCHECK_EQ(download(), download_item);
375 parent_shelf_->RemoveDownloadItem(this); 376 parent_shelf_->RemoveDownloadItem(this);
376 // This will delete us! 377 // This will delete us!
377 } 378 }
378 379
379 void DownloadItemGtk::AnimationProgressed(const gfx::Animation* animation) { 380 void DownloadItemGtk::AnimationProgressed(const gfx::Animation* animation) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 base::Unretained(this)), 479 base::Unretained(this)),
479 &cancelable_task_tracker_); 480 &cancelable_task_tracker_);
480 } 481 }
481 482
482 void DownloadItemGtk::UpdateTooltip() { 483 void DownloadItemGtk::UpdateTooltip() {
483 const gfx::FontList& font_list = 484 const gfx::FontList& font_list =
484 ui::ResourceBundle::GetSharedInstance().GetFontList( 485 ui::ResourceBundle::GetSharedInstance().GetFontList(
485 ui::ResourceBundle::BaseFont); 486 ui::ResourceBundle::BaseFont);
486 base::string16 tooltip_text = 487 base::string16 tooltip_text =
487 download_model_.GetTooltipText(font_list, kTooltipMaxWidth); 488 download_model_.GetTooltipText(font_list, kTooltipMaxWidth);
488 gtk_widget_set_tooltip_text(body_.get(), UTF16ToUTF8(tooltip_text).c_str()); 489 gtk_widget_set_tooltip_text(body_.get(),
490 base::UTF16ToUTF8(tooltip_text).c_str());
489 } 491 }
490 492
491 void DownloadItemGtk::UpdateNameLabel() { 493 void DownloadItemGtk::UpdateNameLabel() {
492 const gfx::FontList& font_list = 494 const gfx::FontList& font_list =
493 ui::ResourceBundle::GetSharedInstance().GetFontList( 495 ui::ResourceBundle::GetSharedInstance().GetFontList(
494 ui::ResourceBundle::BaseFont); 496 ui::ResourceBundle::BaseFont);
495 base::string16 filename; 497 base::string16 filename;
496 if (!disabled_while_opening_) { 498 if (!disabled_while_opening_) {
497 filename = gfx::ElideFilename( 499 filename = gfx::ElideFilename(
498 download()->GetFileNameToReportUser(), font_list, kTextWidth); 500 download()->GetFileNameToReportUser(), font_list, kTextWidth);
(...skipping 11 matching lines...) Expand all
510 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, 512 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING,
511 filename_string); 513 filename_string);
512 } 514 }
513 515
514 GdkColor color = theme_service_->GetGdkColor( 516 GdkColor color = theme_service_->GetGdkColor(
515 ThemeProperties::COLOR_BOOKMARK_TEXT); 517 ThemeProperties::COLOR_BOOKMARK_TEXT);
516 gtk_util::SetLabelColor( 518 gtk_util::SetLabelColor(
517 name_label_, 519 name_label_,
518 theme_service_->UsingNativeTheme() ? NULL : &color); 520 theme_service_->UsingNativeTheme() ? NULL : &color);
519 gtk_label_set_text(GTK_LABEL(name_label_), 521 gtk_label_set_text(GTK_LABEL(name_label_),
520 UTF16ToUTF8(filename).c_str()); 522 base::UTF16ToUTF8(filename).c_str());
521 } 523 }
522 524
523 void DownloadItemGtk::UpdateStatusLabel(const std::string& status_text) { 525 void DownloadItemGtk::UpdateStatusLabel(const std::string& status_text) {
524 if (!text_stack_) { 526 if (!text_stack_) {
525 // At least our container has been destroyed, which means that 527 // At least our container has been destroyed, which means that
526 // this item is on the way to being destroyed; don't do anything. 528 // this item is on the way to being destroyed; don't do anything.
527 return; 529 return;
528 } 530 }
529 531
530 // If |status_text| is empty, only |name_label_| is displayed at the 532 // If |status_text| is empty, only |name_label_| is displayed at the
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 download_model_.GetWarningText(font_list, kTextWidth); 591 download_model_.GetWarningText(font_list, kTextWidth);
590 if (theme_service_->UsingNativeTheme()) { 592 if (theme_service_->UsingNativeTheme()) {
591 gtk_util::SetLabelColor(dangerous_label_, NULL); 593 gtk_util::SetLabelColor(dangerous_label_, NULL);
592 } else { 594 } else {
593 GdkColor color = theme_service_->GetGdkColor( 595 GdkColor color = theme_service_->GetGdkColor(
594 ThemeProperties::COLOR_BOOKMARK_TEXT); 596 ThemeProperties::COLOR_BOOKMARK_TEXT);
595 gtk_util::SetLabelColor(dangerous_label_, &color); 597 gtk_util::SetLabelColor(dangerous_label_, &color);
596 } 598 }
597 599
598 gtk_label_set_text(GTK_LABEL(dangerous_label_), 600 gtk_label_set_text(GTK_LABEL(dangerous_label_),
599 UTF16ToUTF8(dangerous_warning).c_str()); 601 base::UTF16ToUTF8(dangerous_warning).c_str());
600 602
601 // Until we switch to vector graphics, force the font size. 603 // Until we switch to vector graphics, force the font size.
602 gtk_util::ForceFontSizePixels(dangerous_label_, kTextSize); 604 gtk_util::ForceFontSizePixels(dangerous_label_, kTextSize);
603 605
604 gtk_widget_set_size_request(dangerous_label_, -1, -1); 606 gtk_widget_set_size_request(dangerous_label_, -1, -1);
605 gtk_label_set_line_wrap(GTK_LABEL(dangerous_label_), FALSE); 607 gtk_label_set_line_wrap(GTK_LABEL(dangerous_label_), FALSE);
606 608
607 GtkRequisition req; 609 GtkRequisition req;
608 gtk_widget_size_request(dangerous_label_, &req); 610 gtk_widget_size_request(dangerous_label_, &req);
609 611
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", 934 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download",
933 base::Time::Now() - creation_time_); 935 base::Time::Now() - creation_time_);
934 download()->ValidateDangerousDownload(); 936 download()->ValidateDangerousDownload();
935 } 937 }
936 938
937 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 939 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
938 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 940 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
939 base::Time::Now() - creation_time_); 941 base::Time::Now() - creation_time_);
940 download()->Remove(); 942 download()->Remove();
941 } 943 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/crypto_module_password_dialog_gtk.cc ('k') | chrome/browser/ui/gtk/edit_search_engine_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698