summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-04 20:46:14 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-04 20:46:14 +0000
commit13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5 (patch)
treeada8d64cbd2fd12c7248cca648e47ebd63e6462a /chrome
parentcd4857b64f3e3b10ebfa3f44c38af0dc7376d5bb (diff)
downloadchromium_src-13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5.zip
chromium_src-13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5.tar.gz
chromium_src-13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5.tar.bz2
Change Font.GetStringWidth() to take string16 instead of wstring.
do a bunch of string fixes along the way. BUG=none TEST=trybots Review URL: http://codereview.chromium.org/5985007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.cc4
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc4
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h2
-rw-r--r--chrome/browser/ui/cocoa/status_bubble_mac.mm2
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc7
-rw-r--r--chrome/browser/ui/views/autofill_profiles_view_win.cc4
-rw-r--r--chrome/browser/ui/views/download_item_view.cc4
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.cc4
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.h3
-rw-r--r--chrome/browser/ui/views/sad_tab_view.cc2
-rw-r--r--chrome/browser/ui/views/status_bubble_views.cc4
-rw-r--r--chrome/browser/ui/views/tabs/base_tab.cc5
-rw-r--r--chrome/browser/ui/views/theme_install_bubble_view.cc11
-rw-r--r--chrome/browser/ui/views/theme_install_bubble_view.h7
-rw-r--r--chrome/browser/ui/views/wrench_menu.cc6
15 files changed, 38 insertions, 31 deletions
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc
index 440084b..c0f8e82 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_gtk.cc
@@ -21,7 +21,7 @@
namespace {
// Returns the width of the title for the current font, in pixels.
-int GetTitleWidth(gfx::Font* font, std::wstring title) {
+int GetTitleWidth(gfx::Font* font, string16 title) {
DCHECK(font);
if (title.empty())
return 0;
@@ -338,7 +338,7 @@ void TabGtk::ContextMenuClosed() {
void TabGtk::UpdateTooltipState() {
// Only show the tooltip if the title is truncated.
if (title_width_ > title_bounds().width()) {
- gtk_widget_set_tooltip_text(widget(), WideToUTF8(GetTitle()).c_str());
+ gtk_widget_set_tooltip_text(widget(), UTF16ToUTF8(GetTitle()).c_str());
} else {
gtk_widget_set_has_tooltip(widget(), FALSE);
}
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index fc1f7c2..52ab163 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -562,8 +562,8 @@ void TabRendererGtk::Observe(NotificationType type,
////////////////////////////////////////////////////////////////////////////////
// TabRendererGtk, protected:
-std::wstring TabRendererGtk::GetTitle() const {
- return UTF16ToWideHack(data_.title);
+string16 TabRendererGtk::GetTitle() const {
+ return data_.title;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index 6849a2a..8ec952f 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -225,7 +225,7 @@ class TabRendererGtk : public AnimationDelegate,
const gfx::Rect& close_button_bounds() const { return close_button_bounds_; }
// Returns the title of the Tab.
- std::wstring GetTitle() const;
+ string16 GetTitle() const;
// enter-notify-event handler that signals when the mouse enters the tab.
CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnEnterNotifyEvent,
diff --git a/chrome/browser/ui/cocoa/status_bubble_mac.mm b/chrome/browser/ui/cocoa/status_bubble_mac.mm
index 6231e5d..685096d 100644
--- a/chrome/browser/ui/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/ui/cocoa/status_bubble_mac.mm
@@ -613,7 +613,7 @@ void StatusBubbleMac::ExpandBubble() {
// Scale width from gfx::Font in view coordinates to window coordinates.
int required_width_for_string =
- font_chr.GetStringWidth(UTF16ToWide(expanded_url)) +
+ font_chr.GetStringWidth(expanded_url) +
kTextPadding * 2 + kBubbleViewTextPositionX;
NSSize scaled_width = NSMakeSize(required_width_for_string, 0);
scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil];
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index fa3ab68..857db9d 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -422,7 +422,7 @@ AutocompleteResultView::AutocompleteResultView(
model_index_(model_index),
normal_font_(font),
bold_font_(bold_font),
- ellipsis_width_(font.GetStringWidth(kEllipsis)),
+ ellipsis_width_(font.GetStringWidth(WideToUTF16(kEllipsis))),
mirroring_context_(new MirroringContext()),
match_(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED) {
CHECK(model_index >= 0);
@@ -614,7 +614,8 @@ int AutocompleteResultView::DrawString(
else
current_data->color = GetColor(state, force_dim ? DIMMED_TEXT : TEXT);
current_data->pixel_width =
- current_data->font->GetStringWidth(current_data->text);
+ current_data->font->GetStringWidth(
+ WideToUTF16Hack(current_data->text));
current_run->pixel_width += current_data->pixel_width;
}
DCHECK(!current_run->classifications.empty());
@@ -740,7 +741,7 @@ void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const {
(prior_classification->font == &normal_font_)))
j->font = &normal_font_;
- j->pixel_width = j->font->GetStringWidth(elided_text);
+ j->pixel_width = j->font->GetStringWidth(WideToUTF16Hack(elided_text));
// Erase any other classifications that come after the elided one.
i->classifications.erase(j.base(), i->classifications.end());
diff --git a/chrome/browser/ui/views/autofill_profiles_view_win.cc b/chrome/browser/ui/views/autofill_profiles_view_win.cc
index 2f44c5a..3edac72 100644
--- a/chrome/browser/ui/views/autofill_profiles_view_win.cc
+++ b/chrome/browser/ui/views/autofill_profiles_view_win.cc
@@ -1152,11 +1152,11 @@ void AutoFillProfilesView::EditableSetViewContents::InitLayoutGrid(
// The sizes: 4 characters for drop down icon + 2 for a month or 4 for a year.
column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
0, views::GridLayout::FIXED,
- font.GetStringWidth(std::wstring(L"000000")), 0);
+ font.GetStringWidth(ASCIIToUTF16("000000")), 0);
column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
0, views::GridLayout::FIXED,
- font.GetStringWidth(std::wstring(L"00000000")), 0);
+ font.GetStringWidth(ASCIIToUTF16("00000000")), 0);
column_set = layout->AddColumnSet(three_column_header_);
column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
diff --git a/chrome/browser/ui/views/download_item_view.cc b/chrome/browser/ui/views/download_item_view.cc
index 4c7dc06..27406db 100644
--- a/chrome/browser/ui/views/download_item_view.cc
+++ b/chrome/browser/ui/views/download_item_view.cc
@@ -612,8 +612,8 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
font_, kTextWidth);
} else {
// First, Calculate the download status opening string width.
- std::wstring status_string = UTF16ToWide(
- l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, string16()));
+ string16 status_string =
+ l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, string16());
int status_string_width = font_.GetStringWidth(status_string);
// Then, elide the file name.
string16 filename_string =
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
index cd151bb..a1bf8ee 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
@@ -104,7 +104,7 @@ void ContentSettingImageView::UpdateFromTabContents(TabContents* tab_contents) {
animation_in_progress_ = true;
// Initialize animated string. It will be cleared when animation is
// completed.
- animated_text_ = l10n_util::GetString(animated_string_id);
+ animated_text_ = l10n_util::GetStringUTF16(animated_string_id);
text_size_ = ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::MediumFont).GetStringWidth(animated_text_);
text_size_ += 2 * kTextMarginPixels + kIconLeftMargin;
@@ -183,7 +183,7 @@ void ContentSettingImageView::Paint(gfx::Canvas* canvas) {
if (animation_in_progress_) {
// Paint text to the right of the icon.
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- canvas->DrawStringInt(animated_text_,
+ canvas->DrawStringInt(UTF16ToWideHack(animated_text_),
rb.GetFont(ResourceBundle::MediumFont), SK_ColorBLACK,
GetImageBounds().right() + kTextMarginPixels, y(),
width() - GetImageBounds().width(), height(),
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.h b/chrome/browser/ui/views/location_bar/content_setting_image_view.h
index 297aadb..fd112da 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.h
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.h
@@ -8,6 +8,7 @@
#include "app/linear_animation.h"
#include "base/scoped_ptr.h"
+#include "base/string16.h"
#include "chrome/browser/views/info_bubble.h"
#include "chrome/common/content_settings_types.h"
#include "views/controls/image_view.h"
@@ -67,7 +68,7 @@ class ContentSettingImageView : public views::ImageView,
// The currently shown info bubble if any.
InfoBubble* info_bubble_;
- std::wstring animated_text_;
+ string16 animated_text_;
bool animation_in_progress_;
int text_size_;
int visible_text_size_;
diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc
index 3af2197e..7dbdb71 100644
--- a/chrome/browser/ui/views/sad_tab_view.cc
+++ b/chrome/browser/ui/views/sad_tab_view.cc
@@ -150,7 +150,7 @@ void SadTabView::InitClass() {
sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB);
title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE);
- title_width_ = title_font_->GetStringWidth(title_);
+ title_width_ = title_font_->GetStringWidth(WideToUTF16Hack(title_));
message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE);
initialized = true;
diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc
index 599e726..b4abc31 100644
--- a/chrome/browser/ui/views/status_bubble_views.cc
+++ b/chrome/browser/ui/views/status_bubble_views.cc
@@ -430,7 +430,7 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
// is aligned to the right on RTL UIs, we mirror the text bounds if the
// locale is RTL.
int text_width = std::min(
- views::Label::font().GetStringWidth(UTF16ToWide(text_)),
+ views::Label::font().GetStringWidth(text_),
width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding);
int text_height = height - (kShadowThickness * 2);
gfx::Rect body_bounds(kShadowThickness + kTextPositionX,
@@ -805,7 +805,7 @@ void StatusBubbleViews::ExpandBubble() {
url_text_ = gfx::ElideUrl(url_, view_->Label::font(),
max_status_bubble_width, UTF16ToWideHack(languages_));
int expanded_bubble_width =std::max(GetStandardStatusBubbleWidth(),
- std::min(view_->Label::font().GetStringWidth(UTF16ToWide(url_text_)) +
+ std::min(view_->Label::font().GetStringWidth(url_text_) +
(kShadowThickness * 2) + kTextPositionX +
kTextHorizPadding + 1,
max_status_bubble_width));
diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc
index a33bc8f..4598a8b 100644
--- a/chrome/browser/ui/views/tabs/base_tab.cc
+++ b/chrome/browser/ui/views/tabs/base_tab.cc
@@ -291,10 +291,9 @@ bool BaseTab::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
if (data_.title.empty())
return false;
- std::wstring title = UTF16ToWide(data_.title);
// Only show the tooltip if the title is truncated.
- if (font_->GetStringWidth(title) > title_bounds().width()) {
- *tooltip = title;
+ if (font_->GetStringWidth(data_.title) > title_bounds().width()) {
+ *tooltip = UTF16ToWide(data_.title);
return true;
}
return false;
diff --git a/chrome/browser/ui/views/theme_install_bubble_view.cc b/chrome/browser/ui/views/theme_install_bubble_view.cc
index d811774..157e7fd 100644
--- a/chrome/browser/ui/views/theme_install_bubble_view.cc
+++ b/chrome/browser/ui/views/theme_install_bubble_view.cc
@@ -6,6 +6,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/notification_service.h"
#include "gfx/canvas_skia.h"
@@ -32,7 +33,7 @@ ThemeInstallBubbleView::ThemeInstallBubbleView(TabContents* tab_contents)
if (!tab_contents)
Close();
- text_ = l10n_util::GetString(IDS_THEME_LOADING_TITLE);
+ text_ = l10n_util::GetStringUTF16(IDS_THEME_LOADING_TITLE);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
gfx::Font font(rb.GetFont(ResourceBundle::LargeFont));
SetFont(font);
@@ -134,8 +135,12 @@ void ThemeInstallBubbleView::Paint(gfx::Canvas* canvas) {
body_bounds.set_x(MirroredLeftPointForRect(body_bounds));
SkColor text_color = SK_ColorWHITE;
- canvas->DrawStringInt(text_, views::Label::font(), text_color,
- body_bounds.x(), body_bounds.y(), body_bounds.width(),
+ canvas->DrawStringInt(UTF16ToWideHack(text_),
+ views::Label::font(),
+ text_color,
+ body_bounds.x(),
+ body_bounds.y(),
+ body_bounds.width(),
body_bounds.height());
}
diff --git a/chrome/browser/ui/views/theme_install_bubble_view.h b/chrome/browser/ui/views/theme_install_bubble_view.h
index ca4c827..4bd070f 100644
--- a/chrome/browser/ui/views/theme_install_bubble_view.h
+++ b/chrome/browser/ui/views/theme_install_bubble_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,8 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_THEME_INSTALL_BUBBLE_VIEW_H_
#pragma once
-#include <string>
-
+#include "base/string16.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "gfx/canvas.h"
@@ -66,7 +65,7 @@ class ThemeInstallBubbleView : public NotificationObserver,
views::Widget* popup_;
// Text to show warning that theme is being installed.
- std::wstring text_;
+ string16 text_;
// A scoped container for notification registries.
NotificationRegistrar registrar_;
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc
index 3d86f91..d791005 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -525,11 +525,13 @@ class WrenchMenu::ZoomView : public WrenchMenuView,
int step = (max_percent - min_percent) / 10;
for (int i = min_percent; i <= max_percent; i += step) {
- int w = font.GetStringWidth(l10n_util::GetStringF(IDS_ZOOM_PERCENT, i));
+ int w = font.GetStringWidth(
+ l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i));
max_w = std::max(w, max_w);
}
} else {
- max_w = font.GetStringWidth(l10n_util::GetStringF(IDS_ZOOM_PERCENT, 100));
+ max_w = font.GetStringWidth(
+ l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, 100));
}
return max_w + insets.width();