diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 18:01:01 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 18:01:01 +0000 |
commit | 8d37b11e3db0bf4ef7bfb76ae0148d2420eb7cd4 (patch) | |
tree | 2340c444189431df19b1685ecf9ecbe21efc5fb1 | |
parent | 6417f0b7a24856edba82bd8385a55e940af875c9 (diff) | |
download | chromium_src-8d37b11e3db0bf4ef7bfb76ae0148d2420eb7cd4.zip chromium_src-8d37b11e3db0bf4ef7bfb76ae0148d2420eb7cd4.tar.gz chromium_src-8d37b11e3db0bf4ef7bfb76ae0148d2420eb7cd4.tar.bz2 |
wstring: remove wstrings from all tooltip-related code
This is a nearly-mechanical translation of wstring to string16.
Removes a *ton* of string conversions.
Review URL: http://codereview.chromium.org/7886023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101329 0039d316-1c4b-4281-b951-d872f2087c98
93 files changed, 226 insertions, 250 deletions
diff --git a/chrome/browser/chromeos/frame/layout_mode_button.cc b/chrome/browser/chromeos/frame/layout_mode_button.cc index 734eda2..c4381dc 100644 --- a/chrome/browser/chromeos/frame/layout_mode_button.cc +++ b/chrome/browser/chromeos/frame/layout_mode_button.cc @@ -85,13 +85,13 @@ void LayoutModeButton::UpdateForCurrentLayoutMode() { switch (mode) { case WM_IPC_LAYOUT_MAXIMIZED: SetImage(BS_NORMAL, rb.GetBitmapNamed(IDR_STATUSBAR_WINDOW_RESTORE)); - SetTooltipText(UTF16ToWide( - l10n_util::GetStringUTF16(IDS_STATUSBAR_WINDOW_RESTORE_TOOLTIP))); + SetTooltipText( + l10n_util::GetStringUTF16(IDS_STATUSBAR_WINDOW_RESTORE_TOOLTIP)); break; case WM_IPC_LAYOUT_OVERLAPPING: SetImage(BS_NORMAL, rb.GetBitmapNamed(IDR_STATUSBAR_WINDOW_MAXIMIZE)); - SetTooltipText(UTF16ToWide( - l10n_util::GetStringUTF16(IDS_STATUSBAR_WINDOW_MAXIMIZE_TOOLTIP))); + SetTooltipText( + l10n_util::GetStringUTF16(IDS_STATUSBAR_WINDOW_MAXIMIZE_TOOLTIP)); break; default: DLOG(WARNING) << "Unknown layout mode " << mode; diff --git a/chrome/browser/chromeos/login/default_images_view.cc b/chrome/browser/chromeos/login/default_images_view.cc index c050b17..a4d49da 100644 --- a/chrome/browser/chromeos/login/default_images_view.cc +++ b/chrome/browser/chromeos/login/default_images_view.cc @@ -93,8 +93,8 @@ DefaultImagesView::~DefaultImagesView() {} void DefaultImagesView::Init() { UserImageButton* capture_button = new UserImageButton(this); capture_button->set_id(kCaptureButtonId); - capture_button->SetTooltipText(UTF16ToWide( - l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO))); + capture_button->SetTooltipText( + l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO)); InitButton(IDR_BUTTON_USER_IMAGE_TAKE_PHOTO, capture_button); default_images_.push_back(capture_button); for (int i = 0; i < kDefaultImagesCount; ++i) { diff --git a/chrome/browser/chromeos/login/eula_view.cc b/chrome/browser/chromeos/login/eula_view.cc index dbf6522..b28640e 100644 --- a/chrome/browser/chromeos/login/eula_view.cc +++ b/chrome/browser/chromeos/login/eula_view.cc @@ -372,13 +372,13 @@ void EulaView::UpdateLocalizedStrings() { // Set tooltip for usage statistics checkbox if the metric is unmanaged. if (!usage_statistics_checkbox_->IsEnabled()) { usage_statistics_checkbox_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_OPTION_DISABLED_BY_POLICY))); + l10n_util::GetStringUTF16(IDS_OPTION_DISABLED_BY_POLICY)); } // Set tooltip for system security settings link if TPM is disabled. if (!system_security_settings_link_->IsEnabled()) { system_security_settings_link_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_EULA_TPM_DISABLED))); + l10n_util::GetStringUTF16(IDS_EULA_TPM_DISABLED)); } // Load other labels from resources. diff --git a/chrome/browser/chromeos/login/keyboard_switch_menu.cc b/chrome/browser/chromeos/login/keyboard_switch_menu.cc index 47ac9fe..ef9be17 100644 --- a/chrome/browser/chromeos/login/keyboard_switch_menu.cc +++ b/chrome/browser/chromeos/login/keyboard_switch_menu.cc @@ -26,7 +26,7 @@ KeyboardSwitchMenu::KeyboardSwitchMenu() // InputMethodMenu::InputMethodMenuHost implementation. void KeyboardSwitchMenu::UpdateUI(const std::string& input_method_id, const std::wstring& name, - const std::wstring& tooltip, + const string16& tooltip, size_t num_active_input_methods) { // Update all view hierarchies so that the new input method name is shown in // the menu button. diff --git a/chrome/browser/chromeos/login/keyboard_switch_menu.h b/chrome/browser/chromeos/login/keyboard_switch_menu.h index c103198..0f4ffc2 100644 --- a/chrome/browser/chromeos/login/keyboard_switch_menu.h +++ b/chrome/browser/chromeos/login/keyboard_switch_menu.h @@ -25,10 +25,10 @@ class KeyboardSwitchMenu : public InputMethodMenu { // InputMethodMenu::InputMethodMenuHost implementation. virtual void UpdateUI(const std::string& input_method_id, const std::wstring& name, - const std::wstring& tooltip, - size_t num_active_input_methods); - virtual bool ShouldSupportConfigUI(); - virtual void OpenConfigUI() {} + const string16& tooltip, + size_t num_active_input_methods) OVERRIDE; + virtual bool ShouldSupportConfigUI() OVERRIDE; + virtual void OpenConfigUI() OVERRIDE {} // views::ViewMenuDelegate implementation which overrides the implementation // in InputMethodMenu. diff --git a/chrome/browser/chromeos/login/screen_lock_view.cc b/chrome/browser/chromeos/login/screen_lock_view.cc index 57f0f89..00f88e8 100644 --- a/chrome/browser/chromeos/login/screen_lock_view.cc +++ b/chrome/browser/chromeos/login/screen_lock_view.cc @@ -160,8 +160,7 @@ void ScreenLockView::Init() { // Add tooltip if screen name is not unique. if (user.NeedsNameTooltip()) { - const std::wstring tooltip_text = UTF8ToWide(user.GetNameTooltip()); - + string16 tooltip_text = UTF8ToUTF16(user.GetNameTooltip()); user_view_->SetTooltipText(tooltip_text); username->SetTooltipText(tooltip_text); } diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc index 4e6645a..069cdc9 100644 --- a/chrome/browser/chromeos/login/user_controller.cc +++ b/chrome/browser/chromeos/login/user_controller.cc @@ -190,7 +190,7 @@ void UserController::ClearAndEnablePassword() { void UserController::EnableNameTooltip(bool enable) { name_tooltip_enabled_ = enable; - std::wstring tooltip_text; + string16 tooltip_text; if (enable) tooltip_text = GetNameTooltip(); @@ -519,14 +519,13 @@ gfx::Font UserController::GetUnselectedLabelFont() { kUnselectedUsernameFontDelta, gfx::Font::BOLD); } - -std::wstring UserController::GetNameTooltip() const { +string16 UserController::GetNameTooltip() const { if (is_new_user_) - return UTF16ToWide(l10n_util::GetStringUTF16(IDS_ADD_USER)); + return l10n_util::GetStringUTF16(IDS_ADD_USER); else if (is_guest_) - return UTF16ToWide(l10n_util::GetStringUTF16(IDS_GO_INCOGNITO_BUTTON)); + return l10n_util::GetStringUTF16(IDS_GO_INCOGNITO_BUTTON); else - return UTF8ToWide(user_.GetNameTooltip()); + return UTF8ToUTF16(user_.GetNameTooltip()); } } // namespace chromeos diff --git a/chrome/browser/chromeos/login/user_controller.h b/chrome/browser/chromeos/login/user_controller.h index 0278d78..9bfe948 100644 --- a/chrome/browser/chromeos/login/user_controller.h +++ b/chrome/browser/chromeos/login/user_controller.h @@ -167,7 +167,7 @@ class UserController : public views::WidgetDelegate, int controls_width, int controls_height); // Returns tooltip text for user name. - std::wstring GetNameTooltip() const; + string16 GetNameTooltip() const; // Creates the widget that holds the controls. Caller owns the returned // widget. diff --git a/chrome/browser/chromeos/login/user_controller_unittest.cc b/chrome/browser/chromeos/login/user_controller_unittest.cc index 74642fc2..6b8ce18 100644 --- a/chrome/browser/chromeos/login/user_controller_unittest.cc +++ b/chrome/browser/chromeos/login/user_controller_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -15,13 +15,13 @@ namespace chromeos { TEST(UserControllerTest, GetNameTooltipAddUser) { UserController guest_user_controller(NULL, false); - EXPECT_EQ(UTF16ToWide(l10n_util::GetStringUTF16(IDS_ADD_USER)), + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ADD_USER), guest_user_controller.GetNameTooltip()); } TEST(UserControllerTest, GetNameTooltipIncognitoUser) { UserController new_user_controller(NULL, true); - EXPECT_EQ(UTF16ToWide(l10n_util::GetStringUTF16(IDS_GO_INCOGNITO_BUTTON)), + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_GO_INCOGNITO_BUTTON), new_user_controller.GetNameTooltip()); } @@ -32,7 +32,7 @@ TEST(UserControllerTest, GetNameTooltipExistingUser) { UserManager::User existing_user; existing_user.set_email("someordinaryuser@domain.com"); UserController existing_user_controller(NULL, existing_user); - EXPECT_EQ(L"someordinaryuser (domain.com)", + EXPECT_EQ(ASCIIToUTF16("someordinaryuser (domain.com)"), existing_user_controller.GetNameTooltip()); } diff --git a/chrome/browser/chromeos/login/user_view.cc b/chrome/browser/chromeos/login/user_view.cc index 352a42a..c2d72f7 100644 --- a/chrome/browser/chromeos/login/user_view.cc +++ b/chrome/browser/chromeos/login/user_view.cc @@ -301,7 +301,7 @@ void UserView::SetImage(const SkBitmap& image, const SkBitmap& image_hot) { image_view_->SetImage(image, image_hot); } -void UserView::SetTooltipText(const std::wstring& text) { +void UserView::SetTooltipText(const string16& text) { DCHECK(image_view_); image_view_->SetTooltipText(text); } diff --git a/chrome/browser/chromeos/login/user_view.h b/chrome/browser/chromeos/login/user_view.h index b33e359..8b67a90 100644 --- a/chrome/browser/chromeos/login/user_view.h +++ b/chrome/browser/chromeos/login/user_view.h @@ -63,7 +63,7 @@ class UserView : public views::View, void SetImage(const SkBitmap& image, const SkBitmap& image_hot); // Sets tooltip over the image. - void SetTooltipText(const std::wstring& text); + void SetTooltipText(const string16& text); // Show/Hide remove button. void SetRemoveButtonVisible(bool flag); diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index d1c8e99..fa1199e 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -877,11 +877,11 @@ void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) { // Password visible button. passphrase_visible_button_ = new views::ToggleImageButton(this); passphrase_visible_button_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE_SHOW))); + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE_SHOW)); passphrase_visible_button_->SetToggledTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE_HIDE))); + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE_HIDE)); passphrase_visible_button_->SetImage( views::ImageButton::BS_NORMAL, ResourceBundle::GetSharedInstance(). diff --git a/chrome/browser/chromeos/status/accessibility_menu_button.cc b/chrome/browser/chromeos/status/accessibility_menu_button.cc index 867f758..4ffbb5e 100644 --- a/chrome/browser/chromeos/status/accessibility_menu_button.cc +++ b/chrome/browser/chromeos/status/accessibility_menu_button.cc @@ -86,7 +86,7 @@ void AccessibilityMenuButton::Update() { // Update tooltip and accessibile name. string16 message = l10n_util::GetStringUTF16(IDS_STATUSBAR_ACCESSIBILITY_ENABLED); - SetTooltipText(UTF16ToWide(message)); + SetTooltipText(message); SetAccessibleName(message); // Update visibility. SetVisible(accessibility_enabled_.GetValue()); diff --git a/chrome/browser/chromeos/status/caps_lock_menu_button.cc b/chrome/browser/chromeos/status/caps_lock_menu_button.cc index 50db80c..7509d8a 100644 --- a/chrome/browser/chromeos/status/caps_lock_menu_button.cc +++ b/chrome/browser/chromeos/status/caps_lock_menu_button.cc @@ -86,7 +86,7 @@ void CapsLockMenuButton::UpdateTooltip() { int id = IDS_STATUSBAR_CAPS_LOCK_ENABLED; if (prefs_ && (remap_search_key_to_.GetValue() == input_method::kCapsLockKey)) id = IDS_STATUSBAR_CAPS_LOCK_ENABLED_PRESS_SEARCH; - SetTooltipText(UTF16ToWide(l10n_util::GetStringUTF16(id))); + SetTooltipText(l10n_util::GetStringUTF16(id)); SetAccessibleName(l10n_util::GetStringUTF16(id)); } diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc index 94f309c..dd3f3cf 100644 --- a/chrome/browser/chromeos/status/clock_menu_button.cc +++ b/chrome/browser/chromeos/status/clock_menu_button.cc @@ -95,7 +95,7 @@ void ClockMenuButton::UpdateText() { time, use_24hour_clock ? base::k24HourClock : base::k12HourClock, base::kDropAmPm))); - SetTooltipText(UTF16ToWide(base::TimeFormatFriendlyDateAndTime(time))); + SetTooltipText(base::TimeFormatFriendlyDateAndTime(time)); SetAccessibleName(base::TimeFormatFriendlyDateAndTime(time)); SchedulePaint(); } diff --git a/chrome/browser/chromeos/status/input_method_menu.cc b/chrome/browser/chromeos/status/input_method_menu.cc index ff42f3e..da7c7f6 100644 --- a/chrome/browser/chromeos/status/input_method_menu.cc +++ b/chrome/browser/chromeos/status/input_method_menu.cc @@ -498,7 +498,7 @@ void InputMethodMenu::UpdateUIFromInputMethod( const input_method::InputMethodDescriptor& input_method, size_t num_active_input_methods) { const std::wstring name = GetTextForIndicator(input_method); - const std::wstring tooltip = GetTextForMenu(input_method); + const string16 tooltip = WideToUTF16Hack(GetTextForMenu(input_method)); UpdateUI(input_method.id(), name, tooltip, num_active_input_methods); } diff --git a/chrome/browser/chromeos/status/input_method_menu.h b/chrome/browser/chromeos/status/input_method_menu.h index 0382380..c2ae9ac 100644 --- a/chrome/browser/chromeos/status/input_method_menu.h +++ b/chrome/browser/chromeos/status/input_method_menu.h @@ -127,7 +127,7 @@ class InputMethodMenu : public views::ViewMenuDelegate, // status area). Sub classes have to implement the interface for their own UI. virtual void UpdateUI(const std::string& input_method_id, // e.g. "mozc" const std::wstring& name, // e.g. "US", "INTL" - const std::wstring& tooltip, + const string16& tooltip, size_t num_active_input_methods) = 0; // Sub classes have to implement the interface. This interface should return diff --git a/chrome/browser/chromeos/status/input_method_menu_button.cc b/chrome/browser/chromeos/status/input_method_menu_button.cc index 1a45e4a..f4c124e 100644 --- a/chrome/browser/chromeos/status/input_method_menu_button.cc +++ b/chrome/browser/chromeos/status/input_method_menu_button.cc @@ -41,7 +41,7 @@ class MenuImpl : public chromeos::InputMethodMenu { // InputMethodMenu implementation. virtual void UpdateUI(const std::string& input_method_id, const std::wstring& name, - const std::wstring& tooltip, + const string16& tooltip, size_t num_active_input_methods) { button_->UpdateUI(input_method_id, name, tooltip, num_active_input_methods); } @@ -107,7 +107,7 @@ bool InputMethodMenuButton::WindowIsActive() { void InputMethodMenuButton::UpdateUI(const std::string& input_method_id, const std::wstring& name, - const std::wstring& tooltip, + const string16& tooltip, size_t num_active_input_methods) { // Hide the button only if there is only one input method, and the input // method is a XKB keyboard layout. We don't hide the button for other @@ -120,7 +120,7 @@ void InputMethodMenuButton::UpdateUI(const std::string& input_method_id, SetVisible(!hide_button); SetText(name); SetTooltipText(tooltip); - SetAccessibleName(WideToUTF16(tooltip)); + SetAccessibleName(tooltip); if (WindowIsActive()) { // We don't call these functions if the |current_window| is not active since @@ -150,7 +150,8 @@ void InputMethodMenuButton::UpdateUIFromCurrentInputMethod() { const input_method::InputMethodDescriptor& input_method = input_method_manager->current_input_method(); const std::wstring name = InputMethodMenu::GetTextForIndicator(input_method); - const std::wstring tooltip = InputMethodMenu::GetTextForMenu(input_method); + const string16 tooltip = WideToUTF16Hack( + InputMethodMenu::GetTextForMenu(input_method)); const size_t num_active_input_methods = input_method_manager->GetNumActiveInputMethods(); UpdateUI(input_method.id(), name, tooltip, num_active_input_methods); diff --git a/chrome/browser/chromeos/status/input_method_menu_button.h b/chrome/browser/chromeos/status/input_method_menu_button.h index eff624d3..3c14f7b 100644 --- a/chrome/browser/chromeos/status/input_method_menu_button.h +++ b/chrome/browser/chromeos/status/input_method_menu_button.h @@ -8,6 +8,7 @@ #include <string> +#include "base/compiler_specific.h" #include "chrome/browser/chromeos/status/input_method_menu.h" #include "chrome/browser/chromeos/status/status_area_button.h" #include "views/controls/menu/view_menu_delegate.h" @@ -33,10 +34,10 @@ class InputMethodMenuButton : public StatusAreaButton, // InputMethodMenu implementation. virtual void UpdateUI(const std::string& input_method_id, const std::wstring& name, - const std::wstring& tooltip, - size_t num_active_input_methods); - virtual bool ShouldSupportConfigUI(); - virtual void OpenConfigUI(); + const string16& tooltip, + size_t num_active_input_methods) OVERRIDE; + virtual bool ShouldSupportConfigUI() OVERRIDE; + virtual void OpenConfigUI() OVERRIDE; // Updates the UI from the current input method. void UpdateUIFromCurrentInputMethod(); diff --git a/chrome/browser/chromeos/status/memory_menu_button.cc b/chrome/browser/chromeos/status/memory_menu_button.cc index cda69ff..6720965 100644 --- a/chrome/browser/chromeos/status/memory_menu_button.cc +++ b/chrome/browser/chromeos/status/memory_menu_button.cc @@ -81,12 +81,12 @@ void MemoryMenuButton::UpdateText() { anon_kb / 1024, renderer_kills_); SetText(label); - std::wstring tooltip = base::StringPrintf( - L"%d MB allocated (anonymous)\n" - L"%d renderer kill(s)", + std::string tooltip = base::StringPrintf( + "%d MB allocated (anonymous)\n" + "%d renderer kill(s)", anon_kb / 1024, renderer_kills_); - SetTooltipText(tooltip); + SetTooltipText(ASCIIToUTF16(tooltip)); SchedulePaint(); } diff --git a/chrome/browser/chromeos/status/network_menu_button.cc b/chrome/browser/chromeos/status/network_menu_button.cc index 5bac069..adc891f 100644 --- a/chrome/browser/chromeos/status/network_menu_button.cc +++ b/chrome/browser/chromeos/status/network_menu_button.cc @@ -435,7 +435,7 @@ void NetworkMenuButton::ShowOptionalMobileDataPromoNotification( } void NetworkMenuButton::SetTooltipAndAccessibleName(const string16& label) { - SetTooltipText(UTF16ToWide(label)); + SetTooltipText(label); SetAccessibleName(label); } diff --git a/chrome/browser/chromeos/status/power_menu_button.cc b/chrome/browser/chromeos/status/power_menu_button.cc index 555f67d..88ca658 100644 --- a/chrome/browser/chromeos/status/power_menu_button.cc +++ b/chrome/browser/chromeos/status/power_menu_button.cc @@ -397,7 +397,7 @@ void PowerMenuButton::UpdateIconAndLabelInfo() { } percentage_text_ = GetBatteryPercentageText(); - SetTooltipText(UTF16ToWide(percentage_text_)); + SetTooltipText(percentage_text_); SetAccessibleName(percentage_text_); SchedulePaint(); if (status_) diff --git a/chrome/browser/extensions/browser_action_test_util_views.cc b/chrome/browser/extensions/browser_action_test_util_views.cc index 1924c37..6e1aa74 100644 --- a/chrome/browser/extensions/browser_action_test_util_views.cc +++ b/chrome/browser/extensions/browser_action_test_util_views.cc @@ -56,10 +56,10 @@ std::string BrowserActionTestUtil::GetExtensionId(int index) { } std::string BrowserActionTestUtil::GetTooltip(int index) { - std::wstring text; + string16 text; GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> GetTooltipText(gfx::Point(), &text); - return WideToUTF8(text); + return UTF16ToUTF8(text); } bool BrowserActionTestUtil::HasPopup() { diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index 71e1c53..4dcd88b 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -230,7 +230,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual void RenderViewGone(base::TerminationStatus status, int error_code) OVERRIDE; virtual void Destroy() OVERRIDE; - virtual void SetTooltipText(const std::wstring& tooltip_text) OVERRIDE; + virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; virtual void SelectionChanged(const std::string& text, const ui::Range& range, const gfx::Point& start, @@ -412,7 +412,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { bool is_showing_context_menu_; // The text to be shown in the tooltip, supplied by the renderer. - std::wstring tooltip_text_; + string16 tooltip_text_; // Factory used to safely scope delayed calls to ShutdownHost(). ScopedRunnableMethodFactory<RenderWidgetHostViewMac> shutdown_factory_; diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index dcc3988..46fad6e 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -681,7 +681,7 @@ void RenderWidgetHostViewMac::Destroy() { // Called from the renderer to tell us what the tooltip text should be. It // calls us frequently so we need to cache the value to prevent doing a lot // of repeat work. -void RenderWidgetHostViewMac::SetTooltipText(const std::wstring& tooltip_text) { +void RenderWidgetHostViewMac::SetTooltipText(const string16& tooltip_text) { if (tooltip_text != tooltip_text_ && [[cocoa_view_ window] isKeyWindow]) { tooltip_text_ = tooltip_text; @@ -689,11 +689,11 @@ void RenderWidgetHostViewMac::SetTooltipText(const std::wstring& tooltip_text) { // Windows; we're just trying to be polite. Don't persist the trimmed // string, as then the comparison above will always fail and we'll try to // set it again every single time the mouse moves. - std::wstring display_text = tooltip_text_; + string16 display_text = tooltip_text_; if (tooltip_text_.length() > kMaxTooltipLength) display_text = tooltip_text_.substr(0, kMaxTooltipLength); - NSString* tooltip_nsstring = base::SysWideToNSString(display_text); + NSString* tooltip_nsstring = base::SysUTF16ToNSString(display_text); [cocoa_view_ setToolTipAtMousePoint:tooltip_nsstring]; } } diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc index 6396c4b..6608f22 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc @@ -328,12 +328,11 @@ void RenderWidgetHostViewViews::Destroy() { MessageLoop::current()->DeleteSoon(FROM_HERE, this); } -void RenderWidgetHostViewViews::SetTooltipText(const std::wstring& tip) { +void RenderWidgetHostViewViews::SetTooltipText(const string16& tip) { const int kMaxTooltipLength = 8 << 10; // Clamp the tooltip length to kMaxTooltipLength so that we don't // accidentally DOS the user with a mega tooltip. - tooltip_text_ = - ui::TruncateString(WideToUTF16Hack(tip), kMaxTooltipLength); + tooltip_text_ = ui::TruncateString(tip, kMaxTooltipLength); if (GetWidget()) GetWidget()->TooltipTextChanged(this); } @@ -577,10 +576,10 @@ views::TextInputClient* RenderWidgetHostViewViews::GetTextInputClient() { } bool RenderWidgetHostViewViews::GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) { + string16* tooltip) { if (tooltip_text_.length() == 0) return false; - *tooltip = UTF16ToWide(tooltip_text_); + *tooltip = tooltip_text_; return true; } diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h index e81b48d..0e923c3 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.h +++ b/chrome/browser/renderer_host/render_widget_host_view_views.h @@ -79,7 +79,7 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView, virtual void RenderViewGone(base::TerminationStatus status, int error_code) OVERRIDE; virtual void Destroy() OVERRIDE; - virtual void SetTooltipText(const std::wstring& tooltip_text) OVERRIDE; + virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; virtual void SelectionChanged(const std::string& text, const ui::Range& range, const gfx::Point& start, @@ -140,8 +140,7 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView, virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE; virtual bool OnMouseWheel(const views::MouseWheelEvent& event) OVERRIDE; virtual views::TextInputClient* GetTextInputClient() OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) - OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; // Overridden from TextInputClient: virtual void SetCompositionText( diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc index d713dff..b27e96e 100644 --- a/chrome/browser/ui/panels/panel_browser_frame_view.cc +++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc @@ -223,7 +223,7 @@ PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame, settings_button_->set_alignment(views::TextButton::ALIGN_CENTER); settings_button_->set_border(NULL); settings_button_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_SETTINGS))); + l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_SETTINGS)); settings_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_SETTINGS)); settings_button_->SetVisible(is_settings_button_visible_); @@ -237,7 +237,7 @@ PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame, close_button_->SetImage(views::CustomButton::BS_PUSHED, close_button_resources.pushed_image); close_button_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB))); + l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB)); close_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); AddChildView(close_button_); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 2722199..22c4bf7 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -148,11 +148,11 @@ class BookmarkButton : public views::TextButton { } virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE { + string16* tooltip) OVERRIDE { gfx::Point location(p); ConvertPointToScreen(this, &location); - *tooltip = BookmarkBarView::CreateToolTipForURLAndTitle(location, url_, - text(), profile_); + *tooltip = WideToUTF16Hack(BookmarkBarView::CreateToolTipForURLAndTitle( + location, url_, text(), profile_)); return !tooltip->empty(); } @@ -198,9 +198,9 @@ class BookmarkFolderButton : public views::MenuButton { } virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE { + string16* tooltip) OVERRIDE { if (text_size_.width() > GetTextBounds().width()) - *tooltip = UTF16ToWide(text_); + *tooltip = text_; return !tooltip->empty(); } @@ -1250,7 +1250,7 @@ views::TextButton* BookmarkBarView::CreateSyncErrorButton() { // The tooltip is the only way we have to display text explaining the error // to the user. sync_error_button->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC))); + l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)); sync_error_button->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON)); sync_error_button->SetIcon( diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc index 5658705..6832c7e 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc @@ -83,8 +83,7 @@ void BookmarkMenuController::SetPageNavigator(PageNavigator* navigator) { menu_delegate_->SetPageNavigator(navigator); } -std::wstring BookmarkMenuController::GetTooltipText(int id, - const gfx::Point& p) { +string16 BookmarkMenuController::GetTooltipText(int id, const gfx::Point& p) { return menu_delegate_->GetTooltipText(id, p); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h index 4cfda5c..3f0591f 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h @@ -77,7 +77,7 @@ class BookmarkMenuController : public BaseBookmarkModelObserver, void set_observer(Observer* observer) { observer_ = observer; } // MenuDelegate methods. - virtual std::wstring GetTooltipText(int id, const gfx::Point& p); + virtual string16 GetTooltipText(int id, const gfx::Point& p) OVERRIDE; virtual bool IsTriggerableEvent(views::MenuItemView* view, const views::MouseEvent& e); virtual void ExecuteCommand(int id, int mouse_event_flags); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc index 35073ff..1ec41f4 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc @@ -95,16 +95,17 @@ void BookmarkMenuDelegate::SetActiveMenu(const BookmarkNode* node, menu_ = node_to_menu_map_[node]; } -std::wstring BookmarkMenuDelegate::GetTooltipText( - int id, - const gfx::Point& screen_loc) { +string16 BookmarkMenuDelegate::GetTooltipText(int id, + const gfx::Point& screen_loc) { DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end()); const BookmarkNode* node = menu_id_to_node_map_[id]; - if (node->is_url()) - return BookmarkBarView::CreateToolTipForURLAndTitle( - screen_loc, node->url(), UTF16ToWide(node->GetTitle()), profile_); - return std::wstring(); + if (node->is_url()) { + return WideToUTF16Hack(BookmarkBarView::CreateToolTipForURLAndTitle( + screen_loc, node->url(), + UTF16ToWide(node->GetTitle()), profile_)); + } + return string16(); } bool BookmarkMenuDelegate::IsTriggerableEvent(views::MenuItemView* menu, diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h index 134cf29..ef4330d 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h @@ -85,7 +85,7 @@ class BookmarkMenuDelegate : public BaseBookmarkModelObserver, bool is_mutating_model() const { return is_mutating_model_; } // MenuDelegate like methods (see class description for details). - std::wstring GetTooltipText(int id, const gfx::Point& p); + string16 GetTooltipText(int id, const gfx::Point& p); bool IsTriggerableEvent(views::MenuItemView* menu, const views::MouseEvent& e); void ExecuteCommand(int id, int mouse_event_flags); diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index f49cb4c..db456de 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -172,7 +172,7 @@ void BrowserActionButton::UpdateState() { string16 name = UTF8ToUTF16(browser_action()->GetTitle(tab_id)); if (name.empty()) name = UTF8ToUTF16(extension()->name()); - SetTooltipText(UTF16ToWideHack(name)); + SetTooltipText(name); SetAccessibleName(name); parent()->SchedulePaint(); } diff --git a/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc b/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc index 98185e8..31aca7f 100644 --- a/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc +++ b/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc @@ -120,8 +120,7 @@ void CompactLocationBarView::Init() { reload_button_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN); reload_button_->set_tag(IDC_RELOAD); - reload_button_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD))); + reload_button_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD)); reload_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)); reload_button_->set_id(VIEW_ID_RELOAD_BUTTON); diff --git a/chrome/browser/ui/views/compact_nav/compact_navigation_bar.cc b/chrome/browser/ui/views/compact_nav/compact_navigation_bar.cc index b161300..adec663 100644 --- a/chrome/browser/ui/views/compact_nav/compact_navigation_bar.cc +++ b/chrome/browser/ui/views/compact_nav/compact_navigation_bar.cc @@ -79,8 +79,7 @@ void CompactNavigationBar::Init() { back_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN); back_->set_tag(IDC_BACK); - back_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK))); + back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)); back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); back_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); @@ -95,8 +94,7 @@ void CompactNavigationBar::Init() { forward_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN); forward_->set_tag(IDC_FORWARD); - forward_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD))); + forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); forward_->SetAccessibleName(l10n_util::GetStringUTF16((IDS_ACCNAME_FORWARD))); forward_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); diff --git a/chrome/browser/ui/views/compact_nav/compact_options_bar.cc b/chrome/browser/ui/views/compact_nav/compact_options_bar.cc index 5ba008f..1e2548b 100644 --- a/chrome/browser/ui/views/compact_nav/compact_options_bar.cc +++ b/chrome/browser/ui/views/compact_nav/compact_options_bar.cc @@ -46,9 +46,9 @@ void CompactOptionsBar::Init() { app_menu_->set_border(NULL); app_menu_->EnableCanvasFlippingForRTLUI(true); app_menu_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_APP)); - app_menu_->SetTooltipText(UTF16ToWide(l10n_util::GetStringFUTF16( + app_menu_->SetTooltipText(l10n_util::GetStringFUTF16( IDS_APPMENU_TOOLTIP, - l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)))); + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); app_menu_->set_id(VIEW_ID_APP_MENU); AddChildView(app_menu_); diff --git a/chrome/browser/ui/views/default_search_view.cc b/chrome/browser/ui/views/default_search_view.cc index e54c10d..6f7e30c 100644 --- a/chrome/browser/ui/views/default_search_view.cc +++ b/chrome/browser/ui/views/default_search_view.cc @@ -83,7 +83,7 @@ views::View* CreateProviderLogo( SkBitmap* logo_bmp = ResourceBundle::GetSharedInstance().GetBitmapNamed(logo_id); logo_image->SetImage(logo_bmp); - logo_image->SetTooltipText(short_name); + logo_image->SetTooltipText(WideToUTF16Hack(short_name)); logo_view = logo_image; } else { // No logo -- show a text label. @@ -92,7 +92,7 @@ views::View* CreateProviderLogo( logo_label->SetFont(logo_label->font().DeriveFont(3, gfx::Font::BOLD)); logo_label->SetHorizontalAlignment(views::Label::ALIGN_CENTER); // Tooltip text provides accessibility for low-vision users. - logo_label->SetTooltipText(short_name); + logo_label->SetTooltipText(WideToUTF16Hack(short_name)); logo_view = logo_label; } diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index 58c42d3..02010f7 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc @@ -180,8 +180,7 @@ DownloadItemView::DownloadItemView(DownloadItem* download, dangerous_mode_body_image_set_ = dangerous_mode_body_image_set; LoadIcon(); - tooltip_text_ = - UTF16ToWide(download_->GetFileNameToReportUser().LossyDisplayName()); + tooltip_text_ = download_->GetFileNameToReportUser().LossyDisplayName(); font_ = ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); box_height_ = std::max<int>(2 * kVerticalPadding + font_.GetHeight() + @@ -581,7 +580,7 @@ bool DownloadItemView::OnKeyPressed(const views::KeyEvent& event) { } bool DownloadItemView::GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) { + string16* tooltip) { if (tooltip_text_.empty()) return false; @@ -997,8 +996,7 @@ void DownloadItemView::ClearDangerousMode() { // We need to load the icon now that the download_ has the real path. LoadIcon(); - tooltip_text_ = - UTF16ToWide(download_->GetFileNameToReportUser().LossyDisplayName()); + tooltip_text_ = download_->GetFileNameToReportUser().LossyDisplayName(); // Force the shelf to layout again as our size has changed. parent_->Layout(); diff --git a/chrome/browser/ui/views/download/download_item_view.h b/chrome/browser/ui/views/download/download_item_view.h index f518b12..43c999c 100644 --- a/chrome/browser/ui/views/download/download_item_view.h +++ b/chrome/browser/ui/views/download/download_item_view.h @@ -87,8 +87,7 @@ class DownloadItemView : public views::ButtonListener, virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; @@ -204,7 +203,7 @@ class DownloadItemView : public views::ButtonListener, gfx::Font font_; // The tooltip. - std::wstring tooltip_text_; + string16 tooltip_text_; // The current state (normal, hot or pushed) of the body and drop-down. State body_state_; diff --git a/chrome/browser/ui/views/edit_search_engine_dialog.cc b/chrome/browser/ui/views/edit_search_engine_dialog.cc index 81cdeb2cf..13e596c 100644 --- a/chrome/browser/ui/views/edit_search_engine_dialog.cc +++ b/chrome/browser/ui/views/edit_search_engine_dialog.cc @@ -255,13 +255,12 @@ void EditSearchEngineDialog::UpdateImageView(ImageView* image_view, bool is_valid, int invalid_message_id) { if (is_valid) { - image_view->SetTooltipText(std::wstring()); + image_view->SetTooltipText(string16()); image_view->SetImage( ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_INPUT_GOOD)); } else { - image_view->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(invalid_message_id))); + image_view->SetTooltipText(l10n_util::GetStringUTF16(invalid_message_id)) ; image_view->SetImage( ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_INPUT_ALERT)); diff --git a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc index b1472cf..3cd1a56 100644 --- a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc +++ b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc @@ -45,7 +45,7 @@ BrowserActionOverflowMenuController::BrowserActionOverflowMenuController( canvas->AsCanvasSkia()->ExtractBitmap()); // Set the tooltip for this item. - std::wstring tooltip = UTF8ToWide( + string16 tooltip = UTF8ToUTF16( view->button()->extension()->browser_action()->GetTitle( owner_->GetCurrentTabId())); menu_->SetTooltip(tooltip, command_id); diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc index 150b218..aba1533 100644 --- a/chrome/browser/ui/views/find_bar_view.cc +++ b/chrome/browser/ui/views/find_bar_view.cc @@ -106,8 +106,8 @@ FindBarView::FindBarView(FindBarHost* host) rb.GetBitmapNamed(IDR_FINDINPAGE_PREV_H)); find_previous_button_->SetImage(views::CustomButton::BS_DISABLED, rb.GetBitmapNamed(IDR_FINDINPAGE_PREV_P)); - find_previous_button_->SetTooltipText(UTF16ToWide( - l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP))); + find_previous_button_->SetTooltipText( + l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); find_previous_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); AddChildView(find_previous_button_); @@ -122,7 +122,7 @@ FindBarView::FindBarView(FindBarHost* host) find_next_button_->SetImage(views::CustomButton::BS_DISABLED, rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT_P)); find_next_button_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP))); + l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); find_next_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); AddChildView(find_next_button_); @@ -137,7 +137,7 @@ FindBarView::FindBarView(FindBarHost* host) close_button_->SetImage(views::CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); close_button_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP))); + l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); close_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); AddChildView(close_button_); diff --git a/chrome/browser/ui/views/first_run_search_engine_view.cc b/chrome/browser/ui/views/first_run_search_engine_view.cc index 7163e67..7112f4b 100644 --- a/chrome/browser/ui/views/first_run_search_engine_view.cc +++ b/chrome/browser/ui/views/first_run_search_engine_view.cc @@ -100,7 +100,7 @@ SearchEngineChoice::SearchEngineChoice(views::ButtonListener* listener, if (use_small_logos) logo_image->SetImageSize(gfx::Size(kSmallLogoWidth, kSmallLogoHeight)); // Tooltip text provides accessibility for low-vision users. - logo_image->SetTooltipText(search_engine_->short_name()); + logo_image->SetTooltipText(WideToUTF16Hack(search_engine_->short_name())); choice_view_ = logo_image; } else { // No logo -- we must show a text label. @@ -108,7 +108,7 @@ SearchEngineChoice::SearchEngineChoice(views::ButtonListener* listener, logo_label->SetColor(SK_ColorDKGRAY); logo_label->SetFont(logo_label->font().DeriveFont(3, gfx::Font::BOLD)); logo_label->SetHorizontalAlignment(views::Label::ALIGN_CENTER); - logo_label->SetTooltipText(search_engine_->short_name()); + logo_label->SetTooltipText(WideToUTF16Hack(search_engine_->short_name())); logo_label->SetMultiLine(true); logo_label->SizeToFit(kSmallLogoWidth); choice_view_ = logo_label; 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 990323f..4eca62a 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 @@ -72,7 +72,7 @@ void ContentSettingImageView::UpdateFromTabContents(TabContents* tab_contents) { } SetImage(ResourceBundle::GetSharedInstance().GetBitmapNamed( content_setting_image_model_->get_icon())); - SetTooltipText(UTF8ToWide(content_setting_image_model_->get_tooltip())); + SetTooltipText(UTF8ToUTF16(content_setting_image_model_->get_tooltip())); SetVisible(true); TabSpecificContentSettings* content_settings = NULL; diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.cc b/chrome/browser/ui/views/location_bar/location_icon_view.cc index 2846337..2755501 100644 --- a/chrome/browser/ui/views/location_bar/location_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/location_icon_view.cc @@ -10,8 +10,7 @@ LocationIconView::LocationIconView(LocationBarView* location_bar) : ALLOW_THIS_IN_INITIALIZER_LIST(click_handler_(this, location_bar)) { - SetTooltipText(UTF16ToWide(l10n_util::GetStringUTF16( - IDS_TOOLTIP_LOCATION_ICON))); + SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); } LocationIconView::~LocationIconView() { @@ -29,9 +28,8 @@ void LocationIconView::OnMouseReleased(const views::MouseEvent& event) { void LocationIconView::ShowTooltip(bool show) { if (show) { - SetTooltipText(UTF16ToWide(l10n_util::GetStringUTF16( - IDS_TOOLTIP_LOCATION_ICON))); + SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); } else { - SetTooltipText(L""); + SetTooltipText(string16()); } } diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc index 0638fa6..a7fa6f0 100644 --- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc @@ -193,7 +193,7 @@ void PageActionImageView::UpdateVisibility(TabContents* contents, // Set the tooltip. tooltip_ = page_action_->GetTitle(current_tab_id_); - SetTooltipText(UTF8ToWide(tooltip_)); + SetTooltipText(UTF8ToUTF16(tooltip_)); // Set the image. // It can come from three places. In descending order of priority: diff --git a/chrome/browser/ui/views/location_bar/star_view.cc b/chrome/browser/ui/views/location_bar/star_view.cc index 6e1b91e..8d4c0c0 100644 --- a/chrome/browser/ui/views/location_bar/star_view.cc +++ b/chrome/browser/ui/views/location_bar/star_view.cc @@ -27,8 +27,8 @@ StarView::~StarView() { } void StarView::SetToggled(bool on) { - SetTooltipText(UTF16ToWide(l10n_util::GetStringUTF16( - on ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR))); + SetTooltipText(l10n_util::GetStringUTF16( + on ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR)); SetImage(ResourceBundle::GetSharedInstance().GetBitmapNamed( on ? IDR_STAR_LIT : IDR_STAR)); } @@ -38,7 +38,7 @@ void StarView::GetAccessibleState(ui::AccessibleViewState* state) { state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; } -bool StarView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool StarView::GetTooltipText(const gfx::Point& p, string16* tooltip) { // Don't show tooltip to distract user if BookmarkBubbleView is showing. if (browser::IsBookmarkBubbleViewShowing()) return false; diff --git a/chrome/browser/ui/views/location_bar/star_view.h b/chrome/browser/ui/views/location_bar/star_view.h index 0ef704d..319936e 100644 --- a/chrome/browser/ui/views/location_bar/star_view.h +++ b/chrome/browser/ui/views/location_bar/star_view.h @@ -28,8 +28,7 @@ class StarView : public views::ImageView, public BubbleDelegate { private: // views::ImageView overrides: virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc index 6067b42..62f3f31 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.cc +++ b/chrome/browser/ui/views/notifications/balloon_view.cc @@ -290,8 +290,8 @@ void BalloonViewImpl::Show(Balloon* balloon) { options_menu_button_ = new views::MenuButton(NULL, L"", this, false); AddChildView(options_menu_button_); close_button_ = new views::ImageButton(this); - close_button_->SetTooltipText(UTF16ToWide(l10n_util::GetStringUTF16( - IDS_NOTIFICATION_BALLOON_DISMISS_LABEL))); + close_button_->SetTooltipText(l10n_util::GetStringUTF16( + IDS_NOTIFICATION_BALLOON_DISMISS_LABEL)); AddChildView(close_button_); // We have to create two windows: one for the contents and one for the diff --git a/chrome/browser/ui/views/reload_button.cc b/chrome/browser/ui/views/reload_button.cc index db95490..1fb81f4 100644 --- a/chrome/browser/ui/views/reload_button.cc +++ b/chrome/browser/ui/views/reload_button.cc @@ -124,10 +124,10 @@ void ReloadButton::OnMouseExited(const views::MouseEvent& event) { SetState(BS_NORMAL); } -bool ReloadButton::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool ReloadButton::GetTooltipText(const gfx::Point& p, string16* tooltip) { int text_id = visible_mode_ == MODE_RELOAD ? IDS_TOOLTIP_RELOAD : IDS_TOOLTIP_STOP; - tooltip->assign(UTF16ToWide(l10n_util::GetStringUTF16(text_id))); + tooltip->assign(l10n_util::GetStringUTF16(text_id)); return true; } diff --git a/chrome/browser/ui/views/reload_button.h b/chrome/browser/ui/views/reload_button.h index e7cd856..4b0cdc2 100644 --- a/chrome/browser/ui/views/reload_button.h +++ b/chrome/browser/ui/views/reload_button.h @@ -46,8 +46,7 @@ class ReloadButton : public views::ToggleImageButton, // Overridden from views::View: virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; virtual std::string GetClassName() const OVERRIDE; private: diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc index cd5f249..4be5f54 100644 --- a/chrome/browser/ui/views/tabs/base_tab.cc +++ b/chrome/browser/ui/views/tabs/base_tab.cc @@ -165,7 +165,7 @@ BaseTab::BaseTab(TabController* controller) close_button_->SetImage(views::CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); close_button_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB))); + l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB)); close_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); // Disable animation so that the red danger sign shows up immediately @@ -370,13 +370,13 @@ void BaseTab::OnMouseExited(const views::MouseEvent& event) { hover_animation_->Hide(); } -bool BaseTab::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool BaseTab::GetTooltipText(const gfx::Point& p, string16* tooltip) { if (data_.title.empty()) return false; // Only show the tooltip if the title is truncated. if (font_->GetStringWidth(data_.title) > GetTitleBounds().width()) { - *tooltip = UTF16ToWide(data_.title); + *tooltip = data_.title; return true; } return false; diff --git a/chrome/browser/ui/views/tabs/base_tab.h b/chrome/browser/ui/views/tabs/base_tab.h index 42a00ad..5157eb6 100644 --- a/chrome/browser/ui/views/tabs/base_tab.h +++ b/chrome/browser/ui/views/tabs/base_tab.h @@ -91,8 +91,7 @@ class BaseTab : public ui::AnimationDelegate, virtual void OnMouseCaptureLost() OVERRIDE; virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; protected: diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index 2d62750..ba30929 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -132,8 +132,7 @@ void ToolbarView::Init() { back_->set_tag(IDC_BACK); back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, views::ImageButton::ALIGN_TOP); - back_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK))); + back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)); back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); back_->set_id(VIEW_ID_BACK_BUTTON); @@ -141,8 +140,7 @@ void ToolbarView::Init() { forward_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN); forward_->set_tag(IDC_FORWARD); - forward_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD))); + forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); forward_->set_id(VIEW_ID_FORWARD_BUTTON); @@ -155,8 +153,7 @@ void ToolbarView::Init() { reload_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN); reload_->set_tag(IDC_RELOAD); - reload_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD))); + reload_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD)); reload_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)); reload_->set_id(VIEW_ID_RELOAD_BUTTON); @@ -164,8 +161,7 @@ void ToolbarView::Init() { home_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN); home_->set_tag(IDC_HOME); - home_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_HOME))); + home_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_HOME)); home_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_HOME)); home_->set_id(VIEW_ID_HOME_BUTTON); @@ -179,9 +175,9 @@ void ToolbarView::Init() { app_menu_->set_border(NULL); app_menu_->EnableCanvasFlippingForRTLUI(true); app_menu_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_APP)); - app_menu_->SetTooltipText(UTF16ToWide(l10n_util::GetStringFUTF16( + app_menu_->SetTooltipText(l10n_util::GetStringFUTF16( IDS_APPMENU_TOOLTIP, - l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)))); + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); app_menu_->set_id(VIEW_ID_APP_MENU); // Add any necessary badges to the menu item based on the system state. @@ -207,9 +203,9 @@ void ToolbarView::Init() { // Accessibility specific tooltip text. if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { back_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK))); + l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); forward_->SetTooltipText( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD))); + l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); } } diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc index f688d40..3c3c20c 100644 --- a/chrome/browser/ui/views/wrench_menu.cc +++ b/chrome/browser/ui/views/wrench_menu.cc @@ -607,10 +607,10 @@ void WrenchMenu::RunMenu(views::MenuButton* host) { selected_menu_model_->ActivatedAt(selected_index_); } -std::wstring WrenchMenu::GetTooltipText(int id, +string16 WrenchMenu::GetTooltipText(int id, const gfx::Point& p) { return is_bookmark_command(id) ? - bookmark_menu_delegate_->GetTooltipText(id, p) : std::wstring(); + bookmark_menu_delegate_->GetTooltipText(id, p) : string16(); } bool WrenchMenu::IsTriggerableEvent(views::MenuItemView* menu, diff --git a/chrome/browser/ui/views/wrench_menu.h b/chrome/browser/ui/views/wrench_menu.h index c18c5f0..231f379 100644 --- a/chrome/browser/ui/views/wrench_menu.h +++ b/chrome/browser/ui/views/wrench_menu.h @@ -37,7 +37,7 @@ class WrenchMenu : public views::MenuDelegate, void RunMenu(views::MenuButton* host); // MenuDelegate overrides: - virtual std::wstring GetTooltipText(int id, const gfx::Point& p) OVERRIDE; + virtual string16 GetTooltipText(int id, const gfx::Point& p) OVERRIDE; virtual bool IsTriggerableEvent(views::MenuItemView* menu, const views::MouseEvent& e) OVERRIDE; virtual bool GetDropFormats( diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index e370fe4..add827a 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -854,7 +854,7 @@ void RenderWidgetHost::OnMsgSetTooltipText( } } if (view()) - view()->SetTooltipText(UTF16ToWide(wrapped_tooltip_text)); + view()->SetTooltipText(wrapped_tooltip_text); } void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) { diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index 08b500f..8fa8448 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -181,7 +181,7 @@ class RenderWidgetHostView { // Tells the View that the tooltip text for the current mouse position over // the page has changed. - virtual void SetTooltipText(const std::wstring& tooltip_text) = 0; + virtual void SetTooltipText(const string16& tooltip_text) = 0; // Notifies the View that the renderer text selection has changed. |start| // and |end| are the visual end points of the selection in the coordinate diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index 4c535f63..d258aac 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -819,7 +819,7 @@ void RenderWidgetHostViewGtk::Destroy() { MessageLoop::current()->DeleteSoon(FROM_HERE, this); } -void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) { +void RenderWidgetHostViewGtk::SetTooltipText(const string16& tooltip_text) { // Maximum number of characters we allow in a tooltip. const int kMaxTooltipLength = 8 << 10; // Clamp the tooltip length to kMaxTooltipLength so that we don't @@ -827,8 +827,7 @@ void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) { // this itself). // I filed https://bugzilla.gnome.org/show_bug.cgi?id=604641 upstream. const string16 clamped_tooltip = - ui::TruncateString(WideToUTF16Hack(tooltip_text), - kMaxTooltipLength); + ui::TruncateString(tooltip_text, kMaxTooltipLength); if (clamped_tooltip.empty()) { gtk_widget_set_has_tooltip(view_.get(), FALSE); @@ -836,7 +835,7 @@ void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) { gtk_widget_set_tooltip_text(view_.get(), UTF16ToUTF8(clamped_tooltip).c_str()); #if defined(OS_CHROMEOS) - tooltip_window_->SetTooltipText(UTF16ToWideHack(clamped_tooltip)); + tooltip_window_->SetTooltipText(clamped_tooltip); #endif // defined(OS_CHROMEOS) } } diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h index 43973f7..5eb9ed4 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -84,7 +84,7 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView, int error_code) OVERRIDE; virtual void Destroy() OVERRIDE; virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) {} - virtual void SetTooltipText(const std::wstring& tooltip_text) OVERRIDE; + virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; virtual void SelectionChanged(const std::string& text, const ui::Range& range, const gfx::Point& start, diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 5003006..f9da032 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -727,11 +727,11 @@ void RenderWidgetHostViewWin::Destroy() { DestroyWindow(); } -void RenderWidgetHostViewWin::SetTooltipText(const std::wstring& tooltip_text) { +void RenderWidgetHostViewWin::SetTooltipText(const string16& tooltip_text) { // Clamp the tooltip length to kMaxTooltipLength so that we don't // accidentally DOS the user with a mega tooltip (since Windows doesn't seem // to do this itself). - const std::wstring& new_tooltip_text = + const string16 new_tooltip_text = ui::TruncateString(tooltip_text, kMaxTooltipLength); if (new_tooltip_text != tooltip_text_) { @@ -1096,7 +1096,7 @@ LRESULT RenderWidgetHostViewWin::OnNotify(int w_param, NMHDR* header) { case TTN_GETDISPINFO: { NMTTDISPINFOW* tooltip_info = reinterpret_cast<NMTTDISPINFOW*>(header); tooltip_info->szText[0] = L'\0'; - tooltip_info->lpszText = const_cast<wchar_t*>(tooltip_text_.c_str()); + tooltip_info->lpszText = const_cast<WCHAR*>(tooltip_text_.c_str()); ::SendMessage( tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0, kTooltipMaxWidthPixels); SetMsgHandled(TRUE); diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index a1656a6..d2047f3 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -164,7 +164,7 @@ class RenderWidgetHostViewWin // called by TabContents before DestroyWindow virtual void WillWmDestroy() OVERRIDE; virtual void Destroy() OVERRIDE; - virtual void SetTooltipText(const std::wstring& tooltip_text) OVERRIDE; + virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void SetVisuallyDeemphasized(const SkColor* color, @@ -341,7 +341,7 @@ class RenderWidgetHostViewWin // Tooltips // The text to be shown in the tooltip, supplied by the renderer. - std::wstring tooltip_text_; + string16 tooltip_text_; // The tooltip control hwnd HWND tooltip_hwnd_; // Whether or not a tooltip is currently visible. We use this to track diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 8c66291..3fdcee1 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -87,7 +87,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { int error_code) OVERRIDE; virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) { } virtual void Destroy() OVERRIDE {} - virtual void SetTooltipText(const std::wstring& tooltip_text) OVERRIDE {} + virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE {} virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; #if defined(OS_MACOSX) virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE {} diff --git a/ui/base/gtk/tooltip_window_gtk.cc b/ui/base/gtk/tooltip_window_gtk.cc index 652b0ce..0a5900f 100644 --- a/ui/base/gtk/tooltip_window_gtk.cc +++ b/ui/base/gtk/tooltip_window_gtk.cc @@ -23,10 +23,8 @@ TooltipWindowGtk::~TooltipWindowGtk() { gtk_widget_destroy(window_); } -void TooltipWindowGtk::SetTooltipText(const std::wstring& text) { - const std::string& utf8 = WideToUTF8(text); - - gtk_label_set_text(label(), utf8.c_str()); +void TooltipWindowGtk::SetTooltipText(const string16& text) { + gtk_label_set_text(label(), UTF16ToUTF8(text).c_str()); } GtkLabel* TooltipWindowGtk::label() { diff --git a/ui/base/gtk/tooltip_window_gtk.h b/ui/base/gtk/tooltip_window_gtk.h index cffda40..52622a7 100644 --- a/ui/base/gtk/tooltip_window_gtk.h +++ b/ui/base/gtk/tooltip_window_gtk.h @@ -8,7 +8,7 @@ #include <string> -#include "base/basictypes.h" +#include "base/string16.h" #include "ui/base/gtk/gtk_integers.h" #include "ui/base/gtk/gtk_signal.h" #include "ui/base/ui_export.h" @@ -29,7 +29,7 @@ class UI_EXPORT TooltipWindowGtk { virtual ~TooltipWindowGtk(); // Sets tooltip text to display. - void SetTooltipText(const std::wstring& text); + void SetTooltipText(const string16& text); GtkLabel* label(); diff --git a/views/accessibility/native_view_accessibility_win.cc b/views/accessibility/native_view_accessibility_win.cc index 347c5e8..d9cdaac 100644 --- a/views/accessibility/native_view_accessibility_win.cc +++ b/views/accessibility/native_view_accessibility_win.cc @@ -280,7 +280,7 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accDescription( if (!view_) return E_FAIL; - std::wstring temp_desc; + string16 temp_desc; view_->GetTooltipText(gfx::Point(), &temp_desc); if (!temp_desc.empty()) { diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc index 6d18204..e9f7e2b 100644 --- a/views/controls/button/button.cc +++ b/views/controls/button/button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -15,8 +15,8 @@ namespace views { Button::~Button() { } -void Button::SetTooltipText(const std::wstring& tooltip_text) { - tooltip_text_ = WideToUTF16Hack(tooltip_text); +void Button::SetTooltipText(const string16& tooltip_text) { + tooltip_text_ = tooltip_text; TooltipTextChanged(); } @@ -31,11 +31,11 @@ void Button::SetAccessibleKeyboardShortcut(const string16& shortcut) { //////////////////////////////////////////////////////////////////////////////// // Button, View overrides: -bool Button::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool Button::GetTooltipText(const gfx::Point& p, string16* tooltip) { if (tooltip_text_.empty()) return false; - *tooltip = UTF16ToWideHack(tooltip_text_); + *tooltip = tooltip_text_; return true; } diff --git a/views/controls/button/button.h b/views/controls/button/button.h index dde56c1..f1f1a10 100644 --- a/views/controls/button/button.h +++ b/views/controls/button/button.h @@ -29,7 +29,7 @@ class VIEWS_EXPORT Button : public View { public: virtual ~Button(); - void SetTooltipText(const std::wstring& tooltip_text); + void SetTooltipText(const string16& tooltip_text); int tag() const { return tag_; } void set_tag(int tag) { tag_ = tag; } @@ -40,8 +40,7 @@ class VIEWS_EXPORT Button : public View { void SetAccessibleKeyboardShortcut(const string16& shortcut); // Overridden from View: - virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; protected: diff --git a/views/controls/button/image_button.cc b/views/controls/button/image_button.cc index 612ce88..76ed12c 100644 --- a/views/controls/button/image_button.cc +++ b/views/controls/button/image_button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -141,8 +141,8 @@ void ToggleImageButton::SetToggledImage(ButtonState state, } } -void ToggleImageButton::SetToggledTooltipText(const std::wstring& tooltip) { - toggled_tooltip_text_ = WideToUTF16Hack(tooltip); +void ToggleImageButton::SetToggledTooltipText(const string16& tooltip) { + toggled_tooltip_text_ = tooltip; } //////////////////////////////////////////////////////////////////////////////// @@ -163,11 +163,11 @@ void ToggleImageButton::SetImage(ButtonState state, const SkBitmap* image) { // ToggleImageButton, View overrides: bool ToggleImageButton::GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) { + string16* tooltip) { if (!toggled_ || toggled_tooltip_text_.empty()) return Button::GetTooltipText(p, tooltip); - *tooltip = UTF16ToWideHack(toggled_tooltip_text_); + *tooltip = toggled_tooltip_text_; return true; } diff --git a/views/controls/button/image_button.h b/views/controls/button/image_button.h index 95f4b47..0dc3ab4 100644 --- a/views/controls/button/image_button.h +++ b/views/controls/button/image_button.h @@ -93,13 +93,13 @@ class VIEWS_EXPORT ToggleImageButton : public ImageButton { void SetToggledImage(ButtonState state, const SkBitmap* image); // Set the tooltip text displayed when the button is toggled. - void SetToggledTooltipText(const std::wstring& tooltip); + void SetToggledTooltipText(const string16& tooltip); // Overridden from ImageButton: virtual void SetImage(ButtonState aState, const SkBitmap* anImage); // Overridden from View: - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip); private: // The parent class's images_ member is used for the current images, diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc index 67f9190b..c0dcad3 100644 --- a/views/controls/image_view.cc +++ b/views/controls/image_view.cc @@ -155,15 +155,15 @@ ImageView::Alignment ImageView::GetVerticalAlignment() { return vert_alignment_; } -void ImageView::SetTooltipText(const std::wstring& tooltip) { - tooltip_text_ = WideToUTF16Hack(tooltip); +void ImageView::SetTooltipText(const string16& tooltip) { + tooltip_text_ = tooltip; } -std::wstring ImageView::GetTooltipText() { - return UTF16ToWideHack(tooltip_text_); +string16 ImageView::GetTooltipText() { + return tooltip_text_; } -bool ImageView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool ImageView::GetTooltipText(const gfx::Point& p, string16* tooltip) { if (tooltip_text_.empty()) return false; diff --git a/views/controls/image_view.h b/views/controls/image_view.h index 7a346b3..2bd4a92 100644 --- a/views/controls/image_view.h +++ b/views/controls/image_view.h @@ -71,15 +71,14 @@ class VIEWS_EXPORT ImageView : public View { Alignment GetVerticalAlignment(); // Set / Get the tooltip text. - void SetTooltipText(const std::wstring& tooltip); - std::wstring GetTooltipText(); + void SetTooltipText(const string16& tooltip); + string16 GetTooltipText(); // Overriden from View virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) - OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; private: // Compute the image origin given the desired size and the receiver alignment diff --git a/views/controls/label.cc b/views/controls/label.cc index 54978ec..e61c6e1 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -129,8 +129,8 @@ void Label::SetElideInMiddle(bool elide_in_middle) { } } -void Label::SetTooltipText(const std::wstring& tooltip_text) { - tooltip_text_ = WideToUTF16Hack(tooltip_text); +void Label::SetTooltipText(const string16& tooltip_text) { + tooltip_text_ = tooltip_text; } void Label::SetMouseOverBackground(Background* background) { @@ -234,19 +234,19 @@ void Label::OnMouseExited(const MouseEvent& event) { SetContainsMouse(false); } -bool Label::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool Label::GetTooltipText(const gfx::Point& p, string16* tooltip) { DCHECK(tooltip); // If a tooltip has been explicitly set, use it. if (!tooltip_text_.empty()) { - tooltip->assign(UTF16ToWideHack(tooltip_text_)); + tooltip->assign(tooltip_text_); return true; } // Show the full text if the text does not fit. if (!is_multi_line_ && (font_.GetStringWidth(text_) > GetAvailableRect().width())) { - *tooltip = UTF16ToWideHack(text_); + *tooltip = text_; return true; } return false; diff --git a/views/controls/label.h b/views/controls/label.h index 51aa553..8bca9dd 100644 --- a/views/controls/label.h +++ b/views/controls/label.h @@ -124,7 +124,7 @@ class VIEWS_EXPORT Label : public View { // show the full text if it is wider than its bounds. Calling this overrides // the default behavior and lets you set a custom tooltip. To revert to // default behavior, call this with an empty string. - void SetTooltipText(const std::wstring& tooltip_text); + void SetTooltipText(const string16& tooltip_text); // The background color to use when the mouse is over the label. Label // takes ownership of the Background. @@ -171,12 +171,13 @@ class VIEWS_EXPORT Label : public View { virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + // Gets the tooltip text for labels that are wider than their bounds, except // when the label is multiline, in which case it just returns false (no // tooltip). If a custom tooltip has been specified with SetTooltipText() // it is returned instead. - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + bool GetTooltipText(const gfx::Point& p, string16* tooltip); protected: // Called by Paint to paint the text. Override this to change how diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc index d0a162f..db3d491 100644 --- a/views/controls/label_unittest.cc +++ b/views/controls/label_unittest.cc @@ -110,19 +110,19 @@ TEST(LabelTest, MultiLineProperty) { TEST(LabelTest, TooltipProperty) { Label label; - std::wstring test_text(L"My cool string."); - label.SetText(test_text); + string16 test_text(ASCIIToUTF16("My cool string.")); + label.SetText(UTF16ToWideHack(test_text)); - std::wstring tooltip; + string16 tooltip; EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); EXPECT_EQ(test_text, tooltip); - std::wstring tooltip_text(L"The tooltip!"); + string16 tooltip_text(ASCIIToUTF16("The tooltip!")); label.SetTooltipText(tooltip_text); EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); EXPECT_EQ(tooltip_text, tooltip); - std::wstring empty_text; + string16 empty_text; label.SetTooltipText(empty_text); EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); EXPECT_EQ(test_text, tooltip); diff --git a/views/controls/menu/menu_delegate.cc b/views/controls/menu/menu_delegate.cc index 9a3b177..eea9fd4 100644 --- a/views/controls/menu/menu_delegate.cc +++ b/views/controls/menu/menu_delegate.cc @@ -21,9 +21,8 @@ const gfx::Font& MenuDelegate::GetLabelFont(int id) const { return MenuConfig::instance().font; } -std::wstring MenuDelegate::GetTooltipText(int id, - const gfx::Point& screen_loc) { - return std::wstring(); +string16 MenuDelegate::GetTooltipText(int id, const gfx::Point& screen_loc) { + return string16(); } bool MenuDelegate::GetAccelerator(int id, Accelerator* accelerator) { diff --git a/views/controls/menu/menu_delegate.h b/views/controls/menu/menu_delegate.h index f76569e..9d7c8a2 100644 --- a/views/controls/menu/menu_delegate.h +++ b/views/controls/menu/menu_delegate.h @@ -66,7 +66,7 @@ class VIEWS_EXPORT MenuDelegate { // The tooltip shown for the menu item. This is invoked when the user // hovers over the item, and no tooltip text has been set for that item. - virtual std::wstring GetTooltipText(int id, const gfx::Point& screen_loc); + virtual string16 GetTooltipText(int id, const gfx::Point& screen_loc); // If there is an accelerator for the menu item with id |id| it is set in // |accelerator| and true is returned. diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index 86e6a70..ff9c0e3 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -40,7 +40,7 @@ class EmptyMenuMenuItem : public MenuItemView { SetEnabled(false); } - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE { // Empty menu items shouldn't have a tooltip. return false; } @@ -101,8 +101,8 @@ void MenuItemView::ChildPreferredSizeChanged(View* child) { PreferredSizeChanged(); } -bool MenuItemView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { - *tooltip = UTF16ToWideHack(tooltip_); +bool MenuItemView::GetTooltipText(const gfx::Point& p, string16* tooltip) { + *tooltip = tooltip_; if (!tooltip->empty()) return true; @@ -297,10 +297,10 @@ void MenuItemView::SetSelected(bool selected) { SchedulePaint(); } -void MenuItemView::SetTooltip(const std::wstring& tooltip, int item_id) { +void MenuItemView::SetTooltip(const string16& tooltip, int item_id) { MenuItemView* item = GetMenuItemByID(item_id); DCHECK(item); - item->tooltip_ = WideToUTF16Hack(tooltip); + item->tooltip_ = tooltip; } void MenuItemView::SetIcon(const SkBitmap& icon, int item_id) { diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index 6b91c8d..beb487b 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -111,8 +111,7 @@ class VIEWS_EXPORT MenuItemView : public View { explicit MenuItemView(MenuDelegate* delegate); // Overridden from View: - virtual bool GetTooltipText(const gfx::Point& p, - std::wstring* tooltip) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; // Returns the preferred height of menu items. This is only valid when the @@ -243,7 +242,7 @@ class VIEWS_EXPORT MenuItemView : public View { bool IsSelected() const { return selected_; } // Sets the |tooltip| for a menu item view with |item_id| identifier. - void SetTooltip(const std::wstring& tooltip, int item_id); + void SetTooltip(const string16& tooltip, int item_id); // Sets the icon for the descendant identified by item_id. void SetIcon(const SkBitmap& icon, int item_id); diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc index 7091500..f15f5dd 100644 --- a/views/controls/progress_bar.cc +++ b/views/controls/progress_bar.cc @@ -289,11 +289,11 @@ void ProgressBar::OnPaint(gfx::Canvas* canvas) { #endif } -bool ProgressBar::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool ProgressBar::GetTooltipText(const gfx::Point& p, string16* tooltip) { DCHECK(tooltip); if (tooltip == NULL) return false; - tooltip->assign(UTF16ToWideHack(tooltip_text_)); + tooltip->assign(tooltip_text_); return !tooltip_text_.empty(); } @@ -315,8 +315,8 @@ void ProgressBar::SetValue(double value) { } } -void ProgressBar::SetTooltipText(const std::wstring& tooltip_text) { - tooltip_text_ = WideToUTF16Hack(tooltip_text); +void ProgressBar::SetTooltipText(const string16& tooltip_text) { + tooltip_text_ = tooltip_text; } } // namespace views diff --git a/views/controls/progress_bar.h b/views/controls/progress_bar.h index 5156c8f..c4d3f24 100644 --- a/views/controls/progress_bar.h +++ b/views/controls/progress_bar.h @@ -39,8 +39,7 @@ class VIEWS_EXPORT ProgressBar : public View { virtual std::string GetClassName() const OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) - OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; // Sets the inclusive range of values to be displayed. Values outside of the // range will be capped when displayed. @@ -54,7 +53,7 @@ class VIEWS_EXPORT ProgressBar : public View { // Sets the tooltip text. Default behavior for a progress bar is to show no // tooltip on mouse hover. Calling this lets you set a custom tooltip. To // revert to default behavior, call this with an empty string. - virtual void SetTooltipText(const std::wstring& tooltip_text); + void SetTooltipText(const string16& tooltip_text); private: diff --git a/views/controls/progress_bar_unittest.cc b/views/controls/progress_bar_unittest.cc index 16f1581..7d62b99 100644 --- a/views/controls/progress_bar_unittest.cc +++ b/views/controls/progress_bar_unittest.cc @@ -12,10 +12,10 @@ namespace views { TEST(ProgressBarTest, TooltipTextProperty) { ProgressBar bar; - std::wstring tooltip = L"Some text"; + string16 tooltip = ASCIIToUTF16("Some text"); EXPECT_FALSE(bar.GetTooltipText(gfx::Point(), &tooltip)); - EXPECT_EQ(L"", tooltip); - std::wstring tooltip_text = L"My progress"; + EXPECT_EQ(string16(), tooltip); + string16 tooltip_text = ASCIIToUTF16("My progress"); bar.SetTooltipText(tooltip_text); EXPECT_TRUE(bar.GetTooltipText(gfx::Point(), &tooltip)); EXPECT_EQ(tooltip_text, tooltip); diff --git a/views/controls/table/native_table_win.cc b/views/controls/table/native_table_win.cc index 209959d..1a568cf 100644 --- a/views/controls/table/native_table_win.cc +++ b/views/controls/table/native_table_win.cc @@ -324,7 +324,7 @@ bool NativeTableWin::ProcessMessage(UINT message, WPARAM w_param, // be called when dwFlags would be LVGIT_UNFOLDED. Removing it entirely // will disable all of the above behavior. NMLVGETINFOTIP* info_tip = reinterpret_cast<NMLVGETINFOTIP*>(hdr); - std::wstring tooltip = table_->model()->GetTooltip(info_tip->iItem); + string16 tooltip = table_->model()->GetTooltip(info_tip->iItem); CHECK(info_tip->cchTextMax >= 2); if (tooltip.length() >= static_cast<size_t>(info_tip->cchTextMax)) { // Elide the tooltip if necessary. diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index c761bb6..b6b6bb5 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -1080,13 +1080,13 @@ LRESULT TableView::OnNotify(int w_param, LPNMHDR hdr) { // called when dwFlags would be LVGIT_UNFOLDED. Removing it entirely will // disable all of the above behavior. NMLVGETINFOTIP* info_tip = reinterpret_cast<NMLVGETINFOTIP*>(hdr); - std::wstring tooltip = + string16 tooltip = model_->GetTooltip(ViewToModel(info_tip->iItem)); CHECK(info_tip->cchTextMax >= 2); if (tooltip.length() >= static_cast<size_t>(info_tip->cchTextMax)) { tooltip.erase(info_tip->cchTextMax - 2); // Ellipsis + '\0' - const wchar_t kEllipsis = L'\x2026'; - tooltip += kEllipsis; + const char16 kEllipsis = 0x2026; + tooltip.push_back(kEllipsis); } if (!tooltip.empty()) wcscpy_s(info_tip->pszText, tooltip.length() + 1, tooltip.c_str()); diff --git a/views/view.cc b/views/view.cc index 7ea42bf..dfd8f2f 100644 --- a/views/view.cc +++ b/views/view.cc @@ -944,7 +944,7 @@ FocusTraversable* View::GetPaneFocusTraversable() { // Tooltips -------------------------------------------------------------------- -bool View::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { +bool View::GetTooltipText(const gfx::Point& p, string16* tooltip) { return false; } diff --git a/views/view.h b/views/view.h index 4cd9274..c12c2bd2 100644 --- a/views/view.h +++ b/views/view.h @@ -736,7 +736,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // Any time the tooltip text that a View is displaying changes, it must // invoke TooltipTextChanged. // |p| provides the coordinates of the mouse (relative to this view). - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); + virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip); // Returns the location (relative to this View) for the text on the tooltip // to display. If false is returned (the default), the tooltip is placed at diff --git a/views/widget/tooltip_manager.cc b/views/widget/tooltip_manager.cc index 1323318..db15c9e 100644 --- a/views/widget/tooltip_manager.cc +++ b/views/widget/tooltip_manager.cc @@ -13,17 +13,17 @@ namespace { // Maximum number of characters we allow in a tooltip. -static const size_t kMaxTooltipLength = 1024; +const size_t kMaxTooltipLength = 1024; // Maximum number of lines we allow in the tooltip. -static const size_t kMaxLines = 6; +const size_t kMaxLines = 6; } // anonymous namespace namespace views { // static -void TooltipManager::TrimTooltipToFit(std::wstring* text, +void TooltipManager::TrimTooltipToFit(string16* text, int* max_width, int* line_count, int x, @@ -41,7 +41,7 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text, // Split the string into at most kMaxLines lines. std::vector<string16> lines; - base::SplitString(WideToUTF16(*text), '\n', &lines); + base::SplitString(*text, '\n', &lines); if (lines.size() > kMaxLines) lines.resize(kMaxLines); *line_count = static_cast<int>(lines.size()); @@ -57,7 +57,7 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text, result.push_back('\n'); result.append(elided_text); } - *text = UTF16ToWideHack(result); + *text = result; } } // namespace views diff --git a/views/widget/tooltip_manager.h b/views/widget/tooltip_manager.h index e58f79c..6b4c8d9 100644 --- a/views/widget/tooltip_manager.h +++ b/views/widget/tooltip_manager.h @@ -9,6 +9,7 @@ #include <string> #include "base/basictypes.h" +#include "base/string16.h" #include "views/views_export.h" namespace gfx { @@ -55,7 +56,7 @@ class VIEWS_EXPORT TooltipManager { // |max_width| to the width (in pixels) of the clipped text and |line_count| // to the number of lines of text in the tooltip. |x| and |y| give the // location of the tooltip in screen coordinates. - static void TrimTooltipToFit(std::wstring* text, + static void TrimTooltipToFit(string16* text, int* max_width, int* line_count, int x, diff --git a/views/widget/tooltip_manager_gtk.cc b/views/widget/tooltip_manager_gtk.cc index eb5bf20..8515fa9 100644 --- a/views/widget/tooltip_manager_gtk.cc +++ b/views/widget/tooltip_manager_gtk.cc @@ -93,7 +93,7 @@ bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard, if (!view) return false; - std::wstring text; + string16 text; if (!view->GetTooltipText(view_loc, &text)) return false; @@ -138,7 +138,7 @@ void TooltipManagerGtk::ShowKeyboardTooltip(View* view) { // We have to hide the current tooltip, then show again. HideKeyboardTooltip(); - std::wstring tooltip_text; + string16 tooltip_text; if (!view->GetTooltipText(gfx::Point(), &tooltip_text)) return; // The view doesn't have a tooltip, nothing to do. diff --git a/views/widget/tooltip_manager_views.cc b/views/widget/tooltip_manager_views.cc index 15964d7..7156b57 100644 --- a/views/widget/tooltip_manager_views.cc +++ b/views/widget/tooltip_manager_views.cc @@ -158,7 +158,7 @@ View* TooltipManagerViews::GetViewForTooltip(int x, int y, bool for_keyboard) { void TooltipManagerViews::UpdateIfRequired(int x, int y, bool for_keyboard) { View* view = GetViewForTooltip(x, y, for_keyboard); - std::wstring tooltip_text; + string16 tooltip_text; if (view) view->GetTooltipText(gfx::Point(x, y), &tooltip_text); @@ -177,7 +177,7 @@ void TooltipManagerViews::Update() { tooltip_widget_->Hide(); } else { int max_width, line_count; - std::wstring tooltip_text(tooltip_text_); + string16 tooltip_text(tooltip_text_); TrimTooltipToFit(&tooltip_text, &max_width, &line_count, curr_mouse_pos_.x(), curr_mouse_pos_.y()); tooltip_label_.SetText(tooltip_text); diff --git a/views/widget/tooltip_manager_views.h b/views/widget/tooltip_manager_views.h index 3a154df..ced0ea2 100644 --- a/views/widget/tooltip_manager_views.h +++ b/views/widget/tooltip_manager_views.h @@ -80,7 +80,7 @@ class TooltipManagerViews : public TooltipManager, scoped_ptr<Widget> tooltip_widget_; internal::RootView* root_view_; View* tooltip_view_; - std::wstring tooltip_text_; + string16 tooltip_text_; Label tooltip_label_; gfx::Point curr_mouse_pos_; diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc index 061518c..b35e381 100644 --- a/views/widget/tooltip_manager_win.cc +++ b/views/widget/tooltip_manager_win.cc @@ -278,7 +278,7 @@ void TooltipManagerWin::UpdateTooltip(const gfx::Point& mouse_pos) { // text has changed. gfx::Point view_point = mouse_pos; View::ConvertPointToView(root_view, last_tooltip_view_, &view_point); - std::wstring new_tooltip_text; + string16 new_tooltip_text; bool has_tooltip_text = last_tooltip_view_->GetTooltipText(view_point, &new_tooltip_text); if (!has_tooltip_text || (new_tooltip_text != tooltip_text_)) { @@ -322,7 +322,7 @@ void TooltipManagerWin::ShowKeyboardTooltip(View* focused_view) { tooltip_text_.clear(); } HideKeyboardTooltip(); - std::wstring tooltip_text; + string16 tooltip_text; if (!focused_view->GetTooltipText(gfx::Point(), &tooltip_text)) return; gfx::Rect focused_bounds = focused_view->bounds(); |