diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 01:57:22 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 01:57:22 +0000 |
commit | 20512e18b7e9c13c689c7085b82b8cda54ec22f9 (patch) | |
tree | 28394493aafe91de32531e654bee39f627f97c55 /chrome | |
parent | 3c5f6db2ef15a4ac179351764f320e16364fa457 (diff) | |
download | chromium_src-20512e18b7e9c13c689c7085b82b8cda54ec22f9.zip chromium_src-20512e18b7e9c13c689c7085b82b8cda54ec22f9.tar.gz chromium_src-20512e18b7e9c13c689c7085b82b8cda54ec22f9.tar.bz2 |
views: Change TextButtonBase API to string16.
BUG=68267
R=sky@chromium.org
Review URL: http://codereview.chromium.org/8262003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
16 files changed, 41 insertions, 48 deletions
diff --git a/chrome/browser/chromeos/login/eula_view.cc b/chrome/browser/chromeos/login/eula_view.cc index 79b6f11..add12169 100644 --- a/chrome/browser/chromeos/login/eula_view.cc +++ b/chrome/browser/chromeos/login/eula_view.cc @@ -382,14 +382,13 @@ void EulaView::UpdateLocalizedStrings() { // Load other labels from resources. usage_statistics_checkbox_->SetText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_EULA_CHECKBOX_ENABLE_LOGGING))); + l10n_util::GetStringUTF16(IDS_EULA_CHECKBOX_ENABLE_LOGGING)); learn_more_link_->SetText(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); system_security_settings_link_->SetText( l10n_util::GetStringUTF16(IDS_EULA_SYSTEM_SECURITY_SETTING)); - continue_button_->SetText(UTF16ToWide( - l10n_util::GetStringUTF16(IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON))); - back_button_->SetText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_EULA_BACK_BUTTON))); + continue_button_->SetText( + l10n_util::GetStringUTF16(IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON)); + back_button_->SetText(l10n_util::GetStringUTF16(IDS_EULA_BACK_BUTTON)); } bool EulaView::IsUsageStatsChecked() const { diff --git a/chrome/browser/chromeos/login/network_selection_view.cc b/chrome/browser/chromeos/login/network_selection_view.cc index 737cd26..6150647 100644 --- a/chrome/browser/chromeos/login/network_selection_view.cc +++ b/chrome/browser/chromeos/login/network_selection_view.cc @@ -347,10 +347,10 @@ void NetworkSelectionView::UpdateLocalizedStringsAndFonts() { SetMenuButtonFont(languages_menubutton_, base_font); languages_menubutton_->SetText( - UTF16ToWide(actor_->language_switch_menu()->GetCurrentLocaleName())); + actor_->language_switch_menu()->GetCurrentLocaleName()); SetMenuButtonFont(keyboards_menubutton_, base_font); keyboards_menubutton_->SetText( - UTF16ToWide(actor_->keyboard_switch_menu()->GetCurrentKeyboardName())); + actor_->keyboard_switch_menu()->GetCurrentKeyboardName()); welcome_label_->SetFont(welcome_label_font); welcome_label_->SetText( l10n_util::GetStringUTF16(IDS_NETWORK_SELECTION_TITLE)); diff --git a/chrome/browser/chromeos/login/new_user_view.cc b/chrome/browser/chromeos/login/new_user_view.cc index 694db92..0830eed 100644 --- a/chrome/browser/chromeos/login/new_user_view.cc +++ b/chrome/browser/chromeos/login/new_user_view.cc @@ -298,8 +298,7 @@ void NewUserView::UpdateLocalizedStringsAndFonts() { SetAndCorrectTextfieldFont(password_field_, base_font); password_field_->set_text_to_display_when_empty( l10n_util::GetStringUTF16(IDS_LOGIN_PASSWORD)); - sign_in_button_->SetText(UTF16ToWide( - l10n_util::GetStringUTF16(IDS_LOGIN_BUTTON))); + sign_in_button_->SetText(l10n_util::GetStringUTF16(IDS_LOGIN_BUTTON)); if (need_guest_link_) { guest_link_->SetFont(base_font); guest_link_->SetText( @@ -311,8 +310,7 @@ void NewUserView::UpdateLocalizedStringsAndFonts() { l10n_util::GetStringUTF16(IDS_CREATE_ACCOUNT_BUTTON)); } delegate_->ClearErrors(); - languages_menubutton_->SetText( - UTF16ToWide(language_switch_menu_.GetCurrentLocaleName())); + languages_menubutton_->SetText(language_switch_menu_.GetCurrentLocaleName()); } void NewUserView::OnLocaleChanged() { diff --git a/chrome/browser/chromeos/login/shutdown_button.cc b/chrome/browser/chromeos/login/shutdown_button.cc index 9ba532a..8cd5b6b 100644 --- a/chrome/browser/chromeos/login/shutdown_button.cc +++ b/chrome/browser/chromeos/login/shutdown_button.cc @@ -105,7 +105,7 @@ gfx::NativeCursor ShutdownButton::GetCursor(const views::MouseEvent& event) { } void ShutdownButton::OnLocaleChanged() { - SetText(UTF8ToWide(l10n_util::GetStringUTF8(IDS_SHUTDOWN_BUTTON))); + SetText(l10n_util::GetStringUTF16(IDS_SHUTDOWN_BUTTON)); if (parent()) { parent()->Layout(); parent()->SchedulePaint(); diff --git a/chrome/browser/chromeos/login/user_view.cc b/chrome/browser/chromeos/login/user_view.cc index e59a7f9..9133b3e 100644 --- a/chrome/browser/chromeos/login/user_view.cc +++ b/chrome/browser/chromeos/login/user_view.cc @@ -116,7 +116,7 @@ class RemoveButton : public views::TextButton { public: RemoveButton(views::ButtonListener* listener, const SkBitmap& icon, - const std::wstring& text, + const string16& text, const gfx::Point& top_right) : views::TextButton(listener, std::wstring()), icon_(icon), @@ -135,7 +135,7 @@ class RemoveButton : public views::TextButton { // Overridden from View: virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE { SetIcon(icon_); - views::TextButton::SetText(std::wstring()); + views::TextButton::SetText(string16()); ClearMaxTextSize(); set_background(NULL); set_border(new views::TextButtonBorder); @@ -171,7 +171,7 @@ class RemoveButton : public views::TextButton { } } - virtual void SetText(const std::wstring& text) OVERRIDE { + virtual void SetText(const string16& text) OVERRIDE { text_ = text; } @@ -188,7 +188,7 @@ class RemoveButton : public views::TextButton { } SkBitmap icon_; - std::wstring text_; + string16 text_; gfx::Point top_right_; bool was_first_click_; @@ -265,7 +265,7 @@ void UserView::Init(bool need_background) { remove_button_ = new RemoveButton( this, *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_CLOSE_BAR_H), - UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE)), + l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE), gfx::Point(kUserImageSize - kRemoveButtonPadding, kRemoveButtonPadding)); remove_button_->SetVisible(false); AddChildView(remove_button_); @@ -314,8 +314,7 @@ void UserView::ButtonPressed(views::Button* sender, const views::Event& event) { } void UserView::OnLocaleChanged() { - remove_button_->SetText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE))); + remove_button_->SetText(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE)); delegate_->OnLocaleChanged(); } diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc index ef660f0..6921a1a 100644 --- a/chrome/browser/chromeos/status/clock_menu_button.cc +++ b/chrome/browser/chromeos/status/clock_menu_button.cc @@ -91,10 +91,10 @@ void ClockMenuButton::UpdateText() { const bool use_24hour_clock = host_->GetProfile() ? host_->GetProfile()->GetPrefs()->GetBoolean(prefs::kUse24HourClock) : default_use_24hour_clock_; - SetText(UTF16ToWide(base::TimeFormatTimeOfDayWithHourClockType( + SetText(base::TimeFormatTimeOfDayWithHourClockType( time, use_24hour_clock ? base::k24HourClock : base::k12HourClock, - base::kDropAmPm))); + base::kDropAmPm)); SetTooltipText(base::TimeFormatFriendlyDateAndTime(time)); SetAccessibleName(base::TimeFormatFriendlyDateAndTime(time)); SchedulePaint(); diff --git a/chrome/browser/chromeos/status/input_method_menu_button.cc b/chrome/browser/chromeos/status/input_method_menu_button.cc index 291edc8..1a12e02 100644 --- a/chrome/browser/chromeos/status/input_method_menu_button.cc +++ b/chrome/browser/chromeos/status/input_method_menu_button.cc @@ -120,7 +120,7 @@ void InputMethodMenuButton::UpdateUI(const std::string& input_method_id, input_method::InputMethodUtil::IsKeyboardLayout(input_method_id) && host_->GetScreenMode() == StatusAreaHost::kBrowserMode; SetVisible(!hide_button); - SetText(UTF16ToWideHack(name)); + SetText(name); SetTooltipText(tooltip); SetAccessibleName(tooltip); diff --git a/chrome/browser/chromeos/status/memory_menu_button.cc b/chrome/browser/chromeos/status/memory_menu_button.cc index 48989d8..5d96764 100644 --- a/chrome/browser/chromeos/status/memory_menu_button.cc +++ b/chrome/browser/chromeos/status/memory_menu_button.cc @@ -78,15 +78,14 @@ void MemoryMenuButton::UpdateText() { // represents memory that has been dynamically allocated to a process. // It thus approximates heap memory usage across all processes. int anon_kb = meminfo_->active_anon + meminfo_->inactive_anon; - std::wstring label = base::StringPrintf(L"%d MB (%d)", - anon_kb / 1024, - renderer_kills_); - SetText(label); - std::string tooltip = base::StringPrintf( - "%d MB allocated (anonymous)\n" - "%d renderer kill(s)", - anon_kb / 1024, - renderer_kills_); + std::string label = base::StringPrintf("%d MB (%d)", + anon_kb / 1024, + renderer_kills_); + SetText(ASCIIToUTF16(label)); + std::string tooltip = base::StringPrintf("%d MB allocated (anonymous)\n" + "%d renderer kill(s)", + anon_kb / 1024, + renderer_kills_); SetTooltipText(ASCIIToUTF16(tooltip)); SchedulePaint(); } diff --git a/chrome/browser/chromeos/status/network_dropdown_button.cc b/chrome/browser/chromeos/status/network_dropdown_button.cc index ac8e678..abef11c 100644 --- a/chrome/browser/chromeos/status/network_dropdown_button.cc +++ b/chrome/browser/chromeos/status/network_dropdown_button.cc @@ -123,7 +123,7 @@ void NetworkDropdownButton::SetNetworkIconAndText() { string16 text; const SkBitmap bitmap = network_icon_->GetIconAndText(&text); SetIcon(bitmap); - SetText(UTF16ToWide(text)); + SetText(text); } } // namespace chromeos diff --git a/chrome/browser/chromeos/status/status_area_button.cc b/chrome/browser/chromeos/status/status_area_button.cc index 6e0e473..d05dbfa 100644 --- a/chrome/browser/chromeos/status/status_area_button.cc +++ b/chrome/browser/chromeos/status/status_area_button.cc @@ -78,7 +78,7 @@ void StatusAreaButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { } } -void StatusAreaButton::SetText(const std::wstring& text) { +void StatusAreaButton::SetText(const string16& text) { // TextButtons normally remember the max text size, so the button's preferred // size will always be as large as the largest text ever put in it. // We clear that max text size, so we can adjust the size to fit the text. @@ -90,11 +90,10 @@ void StatusAreaButton::SetText(const std::wstring& text) { } bool StatusAreaButton::Activate() { - if (active_) { + if (active_) return views::MenuButton::Activate(); - } else { + else return true; - } } gfx::Size StatusAreaButton::GetPreferredSize() { diff --git a/chrome/browser/chromeos/status/status_area_button.h b/chrome/browser/chromeos/status/status_area_button.h index 2d5c9fb..1aee800 100644 --- a/chrome/browser/chromeos/status/status_area_button.h +++ b/chrome/browser/chromeos/status/status_area_button.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ #pragma once +#include "base/string16.h" #include "chrome/browser/chromeos/status/status_area_host.h" #include "views/controls/button/menu_button.h" #include "views/controls/menu/view_menu_delegate.h" @@ -23,7 +24,7 @@ class StatusAreaButton : public views::MenuButton { // Overrides TextButton's SetText to clear max text size before seting new // text content so that the button size would fit the new text size. - virtual void SetText(const std::wstring& text); + virtual void SetText(const string16& text); void set_use_menu_button_paint(bool use_menu_button_paint) { use_menu_button_paint_ = use_menu_button_paint; diff --git a/chrome/browser/chromeos/views/dropdown_button.cc b/chrome/browser/chromeos/views/dropdown_button.cc index 7d37f9e..f29e0c3 100644 --- a/chrome/browser/chromeos/views/dropdown_button.cc +++ b/chrome/browser/chromeos/views/dropdown_button.cc @@ -4,7 +4,6 @@ #include "chrome/browser/chromeos/views/dropdown_button.h" -#include "base/utf_string_conversions.h" #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas_skia.h" @@ -78,8 +77,8 @@ void DropDownButton::OnPaintFocusBorder(gfx::Canvas* canvas) { height() - kFocusFrameBottomOffset); } -void DropDownButton::SetText(const std::wstring& text) { - text_ = WideToUTF16Hack(text); +void DropDownButton::SetText(const string16& text) { + text_ = text; UpdateTextSize(); } diff --git a/chrome/browser/chromeos/views/dropdown_button.h b/chrome/browser/chromeos/views/dropdown_button.h index 04c871c..ab33add 100644 --- a/chrome/browser/chromeos/views/dropdown_button.h +++ b/chrome/browser/chromeos/views/dropdown_button.h @@ -27,7 +27,7 @@ class DropDownButton : public views::MenuButton { // Override SetText to set the accessible value, rather than the // accessible name, since this acts more like a combo box than a // menu. - virtual void SetText(const std::wstring& text); + virtual void SetText(const string16& text); virtual string16 GetAccessibleValue(); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 214790e..2d3c10f 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -1276,7 +1276,7 @@ views::View* BookmarkBarView::CreateBookmarkButton(const BookmarkNode* node) { void BookmarkBarView::ConfigureButton(const BookmarkNode* node, views::TextButton* button) { - button->SetText(UTF16ToWide(node->GetTitle())); + button->SetText(node->GetTitle()); button->SetAccessibleName(node->GetTitle()); button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT); // We don't always have a theme provider (ui tests, for example). diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index e0b594e..85d7b73 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -1139,8 +1139,7 @@ void OpaqueBrowserFrameView::UpdateAvatarInfo() { size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); if (index != std::string::npos) { avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); - avatar_button_->SetText(UTF16ToWideHack( - cache.GetNameOfProfileAtIndex(index))); + avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); } } } diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc index 0e5b896..bfd704b 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc @@ -81,10 +81,10 @@ void TranslateInfoBarBase::UpdateLanguageButtonText( LanguagesMenuModel::LanguageType language_type) { DCHECK(button); TranslateInfoBarDelegate* delegate = GetDelegate(); - button->SetText(UTF16ToWideHack(delegate->GetLanguageDisplayableNameAt( - (language_type == LanguagesMenuModel::ORIGINAL) ? - delegate->original_language_index() : - delegate->target_language_index()))); + bool is_original = language_type == LanguagesMenuModel::ORIGINAL; + int index = is_original ? delegate->original_language_index() + : delegate->target_language_index(); + button->SetText(delegate->GetLanguageDisplayableNameAt(index)); // The button may have to grow to show the new text. Layout(); SchedulePaint(); |