summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 23:00:42 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 23:00:42 +0000
commit84a761ee5394832fe52e3bba7e158d94254d3709 (patch)
tree2adb2981f3c8899c34c81b773a92e165321e623a /chrome
parent05f0f9d02bf3c8124f68abd3446c9a981ec51913 (diff)
downloadchromium_src-84a761ee5394832fe52e3bba7e158d94254d3709.zip
chromium_src-84a761ee5394832fe52e3bba7e158d94254d3709.tar.gz
chromium_src-84a761ee5394832fe52e3bba7e158d94254d3709.tar.bz2
Convert ElideFilename from using wstring to string16.
Some small cleanups of wstring::npos usage. BUG=23581 Review URL: http://codereview.chromium.org/3390035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/download_item_cell.mm2
-rw-r--r--chrome/browser/cocoa/download_item_controller.mm5
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc20
-rw-r--r--chrome/browser/gtk/edit_search_engine_dialog.cc6
-rw-r--r--chrome/browser/gtk/infobar_gtk.cc4
-rw-r--r--chrome/browser/views/download_item_view.cc10
6 files changed, 25 insertions, 22 deletions
diff --git a/chrome/browser/cocoa/download_item_cell.mm b/chrome/browser/cocoa/download_item_cell.mm
index 935108f..93687f4 100644
--- a/chrome/browser/cocoa/download_item_cell.mm
+++ b/chrome/browser/cocoa/download_item_cell.mm
@@ -398,7 +398,7 @@ NSGradient* BackgroundTheme::GetNSGradient(int id) const {
gfx::Font font_chr(base::SysNSStringToWide([font fontName]),
[font pointSize]);
- return base::SysWideToNSString(
+ return base::SysUTF16ToNSString(
ElideFilename(downloadPath_, font_chr, availableWidth));
}
diff --git a/chrome/browser/cocoa/download_item_controller.mm b/chrome/browser/cocoa/download_item_controller.mm
index eaf966c..cbd18fc 100644
--- a/chrome/browser/cocoa/download_item_controller.mm
+++ b/chrome/browser/cocoa/download_item_controller.mm
@@ -9,6 +9,7 @@
#include "app/text_elider.h"
#include "base/histogram.h"
#include "base/mac_util.h"
+#include "base/string16.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
@@ -266,10 +267,10 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
}
- (void)updateToolTip {
- std::wstring elidedFilename = gfx::ElideFilename(
+ string16 elidedFilename = gfx::ElideFilename(
[self download]->GetFileName(),
gfx::Font(), kToolTipMaxWidth);
- [progressView_ setToolTip:base::SysWideToNSString(elidedFilename)];
+ [progressView_ setToolTip:base::SysUTF16ToNSString(elidedFilename)];
}
- (void)clearDangerousMode {
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 02edbad..536d2b4 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -503,10 +503,11 @@ void DownloadItemGtk::LoadIcon() {
}
void DownloadItemGtk::UpdateTooltip() {
- std::wstring elided_filename = gfx::ElideFilename(
+ string16 elided_filename = gfx::ElideFilename(
get_download()->GetFileName(),
gfx::Font(), kTooltipMaxWidth);
- gtk_widget_set_tooltip_text(body_.get(), WideToUTF8(elided_filename).c_str());
+ gtk_widget_set_tooltip_text(body_.get(),
+ UTF16ToUTF8(elided_filename).c_str());
}
void DownloadItemGtk::UpdateNameLabel() {
@@ -514,7 +515,7 @@ void DownloadItemGtk::UpdateNameLabel() {
// use gfx::Font() to draw the text. This is why we need to add so
// much padding when we set the size request. We need to either use gfx::Font
// or somehow extend TextElider.
- std::wstring elided_filename = gfx::ElideFilename(
+ string16 elided_filename = gfx::ElideFilename(
get_download()->GetFileName(),
gfx::Font(), kTextWidth);
@@ -523,7 +524,7 @@ void DownloadItemGtk::UpdateNameLabel() {
gtk_util::SetLabelColor(name_label_, theme_provider_->UseGtkTheme() ?
NULL : &color);
gtk_label_set_text(GTK_LABEL(name_label_),
- WideToUTF8(elided_filename).c_str());
+ UTF16ToUTF8(elided_filename).c_str());
}
void DownloadItemGtk::UpdateStatusLabel(const std::string& status_text) {
@@ -560,16 +561,17 @@ void DownloadItemGtk::UpdateDangerWarning() {
if (dangerous_prompt_) {
// We create |dangerous_warning| as a wide string so we can more easily
// calculate its length in characters.
- std::wstring dangerous_warning;
+ string16 dangerous_warning;
if (get_download()->is_extension_install()) {
dangerous_warning =
- l10n_util::GetString(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
+ l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
} else {
- std::wstring elided_filename = gfx::ElideFilename(
+ string16 elided_filename = gfx::ElideFilename(
get_download()->original_name(), gfx::Font(), kTextWidth);
dangerous_warning =
- l10n_util::GetStringF(IDS_PROMPT_DANGEROUS_DOWNLOAD, elided_filename);
+ l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD,
+ elided_filename);
}
if (theme_provider_->UseGtkTheme()) {
@@ -589,7 +591,7 @@ void DownloadItemGtk::UpdateDangerWarning() {
}
gtk_label_set_text(GTK_LABEL(dangerous_label_),
- WideToUTF8(dangerous_warning).c_str());
+ UTF16ToUTF8(dangerous_warning).c_str());
// Until we switch to vector graphics, force the font size.
gtk_util::ForceFontSizePixels(dangerous_label_, kTextSize);
diff --git a/chrome/browser/gtk/edit_search_engine_dialog.cc b/chrome/browser/gtk/edit_search_engine_dialog.cc
index 52c3346..3c4c58a 100644
--- a/chrome/browser/gtk/edit_search_engine_dialog.cc
+++ b/chrome/browser/gtk/edit_search_engine_dialog.cc
@@ -206,12 +206,12 @@ void EditSearchEngineDialog::Init(GtkWindow* parent_window, Profile* profile) {
l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL);
if (base::i18n::IsRTL()) {
const std::string reversed_percent("s%");
- std::wstring::size_type percent_index =
- description.find("%s", static_cast<std::string::size_type>(0));
- if (percent_index != std::string::npos)
+ std::string::size_type percent_index = description.find("%s");
+ if (percent_index != std::string::npos) {
description.replace(percent_index,
reversed_percent.length(),
reversed_percent);
+ }
}
GtkWidget* description_label = gtk_label_new(description.c_str());
diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc
index cef8157..b14b00d 100644
--- a/chrome/browser/gtk/infobar_gtk.cc
+++ b/chrome/browser/gtk/infobar_gtk.cc
@@ -151,7 +151,7 @@ void InfoBar::AddLabelAndLink(const string16& display_text,
GtkWidget* link_button = NULL;
if (link_text.empty()) {
// No link text, so skip creating the link and splitting display_text.
- link_offset = std::wstring::npos;
+ link_offset = string16::npos;
} else {
// If we have some link text, create the link button.
link_button = gtk_chrome_link_button_new(UTF16ToUTF8(link_text).c_str());
@@ -170,7 +170,7 @@ void InfoBar::AddLabelAndLink(const string16& display_text,
// If link_offset is npos, we right-align the link instead of embedding it
// in the text.
- if (link_offset == std::wstring::npos) {
+ if (link_offset == string16::npos) {
if (link_button)
gtk_box_pack_end(GTK_BOX(hbox), link_button, FALSE, FALSE, 0);
GtkWidget* label = gtk_label_new(UTF16ToUTF8(display_text).c_str());
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index c2f2442..1f753e9 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -596,7 +596,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// Last value of x was the end of the right image, just before the button.
// Note that in dangerous mode we use a label (as the text is multi-line).
if (!IsDangerousMode()) {
- std::wstring filename;
+ string16 filename;
if (!disabled_while_opening_) {
filename = gfx::ElideFilename(download_->GetFileName(),
font_, kTextWidth);
@@ -607,12 +607,12 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPENING, empty_string);
int status_string_width = font_.GetStringWidth(status_string);
// Then, elide the file name.
- std::wstring filename_string =
+ string16 filename_string =
gfx::ElideFilename(download_->GetFileName(), font_,
kTextWidth - status_string_width);
// Last, concat the whole string.
- filename = l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPENING,
- filename_string);
+ filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING,
+ filename_string);
}
int mirrored_x = MirroredXWithWidthInsideView(
@@ -624,7 +624,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
(box_height_ - font_.GetHeight()) / 2);
// Draw the file's name.
- canvas->DrawStringInt(filename, font_,
+ canvas->DrawStringInt(UTF16ToWide(filename), font_,
IsEnabled() ? file_name_color :
kFileNameDisabledColor,
mirrored_x, y, kTextWidth, font_.GetHeight());