diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 18:34:56 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 18:34:56 +0000 |
commit | 001f08ab3184a370fdd1e8cf4cef05fa15174bd9 (patch) | |
tree | 2d808b05a8f8294af7346c0e7f8af472266023e1 /views | |
parent | 6784252af99d1da6c63871374d9409998c64ef5b (diff) | |
download | chromium_src-001f08ab3184a370fdd1e8cf4cef05fa15174bd9.zip chromium_src-001f08ab3184a370fdd1e8cf4cef05fa15174bd9.tar.gz chromium_src-001f08ab3184a370fdd1e8cf4cef05fa15174bd9.tar.bz2 |
Remove wstring from views. Part 3: Switch accessibility strings to string16.
BUG=68267
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/6192007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71461 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
25 files changed, 66 insertions, 63 deletions
diff --git a/views/accessibility/view_accessibility.cc b/views/accessibility/view_accessibility.cc index 5d51d814..1364157 100644 --- a/views/accessibility/view_accessibility.cc +++ b/views/accessibility/view_accessibility.cc @@ -282,7 +282,7 @@ STDMETHODIMP ViewAccessibility::get_accDefaultAction( if (!view_) return E_FAIL; - std::wstring temp_action = view_->GetAccessibleDefaultAction(); + string16 temp_action = view_->GetAccessibleDefaultAction(); if (!temp_action.empty()) { *def_action = SysAllocString(temp_action.c_str()); @@ -347,7 +347,7 @@ STDMETHODIMP ViewAccessibility::get_accKeyboardShortcut( if (!view_) return E_FAIL; - std::wstring temp_key = view_->GetAccessibleKeyboardShortcut(); + string16 temp_key = view_->GetAccessibleKeyboardShortcut(); if (!temp_key.empty()) { *acc_key = SysAllocString(temp_key.c_str()); @@ -365,7 +365,7 @@ STDMETHODIMP ViewAccessibility::get_accName(VARIANT var_id, BSTR* name) { if (!view_) return E_FAIL; - std::wstring temp_name; + string16 temp_name; // Retrieve the current view's name. view_->GetAccessibleName(&temp_name); @@ -457,7 +457,7 @@ STDMETHODIMP ViewAccessibility::get_accValue(VARIANT var_id, BSTR* value) { return E_FAIL; // Retrieve the current view's value. - std::wstring temp_value = view_->GetAccessibleValue(); + string16 temp_value = view_->GetAccessibleValue(); if (!temp_value.empty()) { // Return value retrieved. diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc index a80902d..b59fd89 100644 --- a/views/controls/button/button.cc +++ b/views/controls/button/button.cc @@ -33,8 +33,8 @@ bool Button::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { return true; } -std::wstring Button::GetAccessibleKeyboardShortcut() { - return UTF16ToWideHack(accessible_shortcut_); +string16 Button::GetAccessibleKeyboardShortcut() { + return accessible_shortcut_; } AccessibilityTypes::Role Button::GetAccessibleRole() { diff --git a/views/controls/button/button.h b/views/controls/button/button.h index 0f9eb9d..263e45f 100644 --- a/views/controls/button/button.h +++ b/views/controls/button/button.h @@ -39,9 +39,10 @@ class Button : public View { void SetAccessibleKeyboardShortcut(const std::wstring& shortcut); // Overridden from View: - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); - virtual std::wstring GetAccessibleKeyboardShortcut(); - virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual bool GetTooltipText(const gfx::Point& p, + std::wstring* tooltip) OVERRIDE; + virtual string16 GetAccessibleKeyboardShortcut() OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; protected: // Construct the Button with a Listener. The listener can be NULL. This can be diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc index d8625d9..74e598e 100644 --- a/views/controls/button/button_dropdown.cc +++ b/views/controls/button/button_dropdown.cc @@ -165,8 +165,8 @@ void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) { // //////////////////////////////////////////////////////////////////////////////// -std::wstring ButtonDropDown::GetAccessibleDefaultAction() { - return UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS)); +string16 ButtonDropDown::GetAccessibleDefaultAction() { + return l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); } AccessibilityTypes::Role ButtonDropDown::GetAccessibleRole() { diff --git a/views/controls/button/button_dropdown.h b/views/controls/button/button_dropdown.h index e2c372e04..07b8276 100644 --- a/views/controls/button/button_dropdown.h +++ b/views/controls/button/button_dropdown.h @@ -26,9 +26,9 @@ class ButtonDropDown : public ImageButton { virtual ~ButtonDropDown(); // Accessibility accessors, overridden from View. - virtual std::wstring GetAccessibleDefaultAction(); - virtual AccessibilityTypes::Role GetAccessibleRole(); - virtual AccessibilityTypes::State GetAccessibleState(); + virtual string16 GetAccessibleDefaultAction() OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; private: // Overridden from CustomButton diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index ad51681..1f2ca9f 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -256,8 +256,8 @@ void MenuButton::OnMouseExited(const MouseEvent& event) { // //////////////////////////////////////////////////////////////////////////////// -std::wstring MenuButton::GetAccessibleDefaultAction() { - return UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS)); +string16 MenuButton::GetAccessibleDefaultAction() { + return l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); } AccessibilityTypes::Role MenuButton::GetAccessibleRole() { diff --git a/views/controls/button/menu_button.h b/views/controls/button/menu_button.h index 1e78a9c..75489f6 100644 --- a/views/controls/button/menu_button.h +++ b/views/controls/button/menu_button.h @@ -58,9 +58,9 @@ class MenuButton : public TextButton { virtual bool OnKeyReleased(const KeyEvent& e); // Accessibility accessors, overridden from View. - virtual std::wstring GetAccessibleDefaultAction(); - virtual AccessibilityTypes::Role GetAccessibleRole(); - virtual AccessibilityTypes::State GetAccessibleState(); + virtual string16 GetAccessibleDefaultAction() OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; // Returns views/MenuButton. virtual std::string GetClassName() const; diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc index 71a6b5a4..0b8da4f 100644 --- a/views/controls/button/native_button.cc +++ b/views/controls/button/native_button.cc @@ -80,7 +80,7 @@ void NativeButton::SetLabel(const std::wstring& label) { native_wrapper_->UpdateLabel(); // Update the accessible name whenever the label changes. - SetAccessibleName(label); + SetAccessibleName(WideToUTF16Hack(label)); PreferredSizeChanged(); } diff --git a/views/controls/button/native_button_win.cc b/views/controls/button/native_button_win.cc index f0b1b36..c0b2681 100644 --- a/views/controls/button/native_button_win.cc +++ b/views/controls/button/native_button_win.cc @@ -71,7 +71,7 @@ void NativeButtonWin::UpdateDefault() { } void NativeButtonWin::UpdateAccessibleName() { - std::wstring name; + string16 name; if (native_button_->GetAccessibleName(&name)) { base::win::ScopedComPtr<IAccPropServices> pAccPropServices; HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc index 470d97c..1216be0 100644 --- a/views/controls/button/text_button.cc +++ b/views/controls/button/text_button.cc @@ -211,7 +211,7 @@ TextButton::~TextButton() { void TextButton::SetText(const std::wstring& text) { text_ = WideToUTF16Hack(text); - SetAccessibleName(text); + SetAccessibleName(WideToUTF16Hack(text)); UpdateTextSize(); } diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc index 6eb32ba..0c7f293 100644 --- a/views/controls/combobox/combobox.cc +++ b/views/controls/combobox/combobox.cc @@ -93,8 +93,8 @@ AccessibilityTypes::Role Combobox::GetAccessibleRole() { return AccessibilityTypes::ROLE_COMBOBOX; } -std::wstring Combobox::GetAccessibleValue() { - return UTF16ToWideHack(model_->GetItemAt(selected_item_)); +string16 Combobox::GetAccessibleValue() { + return model_->GetItemAt(selected_item_); } void Combobox::Focus() { diff --git a/views/controls/combobox/combobox.h b/views/controls/combobox/combobox.h index d306761..4d48ec1 100644 --- a/views/controls/combobox/combobox.h +++ b/views/controls/combobox/combobox.h @@ -64,8 +64,8 @@ class Combobox : public View { virtual void SetEnabled(bool enabled); virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); virtual void PaintFocusBorder(gfx::Canvas* canvas); - virtual AccessibilityTypes::Role GetAccessibleRole(); - virtual std::wstring GetAccessibleValue(); + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual string16 GetAccessibleValue() OVERRIDE; protected: virtual void Focus(); diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc index 68b7b9d..e3fe5a3c 100644 --- a/views/controls/image_view.cc +++ b/views/controls/image_view.cc @@ -154,7 +154,7 @@ ImageView::Alignment ImageView::GetVerticalAlignment() { void ImageView::SetTooltipText(const std::wstring& tooltip) { tooltip_text_ = WideToUTF16Hack(tooltip); - SetAccessibleName(tooltip); + SetAccessibleName(WideToUTF16Hack(tooltip)); } std::wstring ImageView::GetTooltipText() { diff --git a/views/controls/label.cc b/views/controls/label.cc index 8692622..62a9198 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -107,7 +107,7 @@ void Label::SetText(const std::wstring& text) { text_ = WideToUTF16Hack(text); url_set_ = false; text_size_valid_ = false; - SetAccessibleName(text); + SetAccessibleName(WideToUTF16Hack(text)); PreferredSizeChanged(); SchedulePaint(); } diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc index 504861e..44d101b 100644 --- a/views/controls/label_unittest.cc +++ b/views/controls/label_unittest.cc @@ -156,12 +156,12 @@ TEST(LabelTest, TooltipProperty) { TEST(LabelTest, Accessibility) { Label label; - std::wstring test_text(L"My special text."); - label.SetText(test_text); + string16 test_text(ASCIIToUTF16("My special text.")); + label.SetText(UTF16ToWideHack(test_text)); EXPECT_EQ(AccessibilityTypes::ROLE_STATICTEXT, label.GetAccessibleRole()); - std::wstring name; + string16 name; EXPECT_TRUE(label.GetAccessibleName(&name)); EXPECT_EQ(test_text, name); diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index ee60c79..b5c1ced 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -306,8 +306,7 @@ SubmenuView* MenuItemView::CreateSubmenu() { void MenuItemView::SetTitle(const std::wstring& title) { title_ = WideToUTF16Hack(title); - SetAccessibleName(UTF16ToWideHack( - GetAccessibleNameForMenuItem(title_, GetAcceleratorText()))); + SetAccessibleName(GetAccessibleNameForMenuItem(title_, GetAcceleratorText())); } void MenuItemView::SetSelected(bool selected) { diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index 053b804..63a4613 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -312,7 +312,7 @@ MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() { scroll_view_container_->set_parent_owned(false); // Use the parent menu item accessible name for the menu view. - std::wstring accessible_name; + string16 accessible_name; GetMenuItem()->GetAccessibleName(&accessible_name); scroll_view_container_->SetAccessibleName(accessible_name); SetAccessibleName(accessible_name); diff --git a/views/controls/progress_bar_unittest.cc b/views/controls/progress_bar_unittest.cc index 362f48f..55acfd4 100644 --- a/views/controls/progress_bar_unittest.cc +++ b/views/controls/progress_bar_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "views/controls/progress_bar.h" @@ -49,10 +50,10 @@ TEST(ProgressBarTest, Accessibility) { EXPECT_EQ(AccessibilityTypes::ROLE_PROGRESSBAR, bar.GetAccessibleRole()); - std::wstring name; + string16 name; EXPECT_FALSE(bar.GetAccessibleName(&name)); - EXPECT_EQ(std::wstring(), name); - std::wstring accessible_name = L"My progress bar"; + EXPECT_EQ(string16(), name); + string16 accessible_name = ASCIIToUTF16("My progress bar"); bar.SetAccessibleName(accessible_name); EXPECT_TRUE(bar.GetAccessibleName(&name)); EXPECT_EQ(accessible_name, name); diff --git a/views/controls/tabbed_pane/tabbed_pane.cc b/views/controls/tabbed_pane/tabbed_pane.cc index 6fb07ea..07a2d8d 100644 --- a/views/controls/tabbed_pane/tabbed_pane.cc +++ b/views/controls/tabbed_pane/tabbed_pane.cc @@ -5,6 +5,8 @@ #include "views/controls/tabbed_pane/tabbed_pane.h" #include "base/logging.h" +// TODO(avi): remove when not needed +#include "base/utf_string_conversions.h" #include "ui/base/keycodes/keyboard_codes.h" #include "views/controls/native/native_view_host.h" #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" @@ -36,7 +38,7 @@ void TabbedPane::AddTabAtIndex(int index, bool select_if_first_tab) { native_tabbed_pane_->AddTabAtIndex(index, title, contents, select_if_first_tab); - contents->SetAccessibleName(title); + contents->SetAccessibleName(WideToUTF16Hack(title)); PreferredSizeChanged(); } diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index 63e3082..9b5595b 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -395,13 +395,13 @@ void NativeTextfieldWin::InitializeAccessibilityInfo() { // Set the accessible name by getting the label text. View* parent = textfield_->GetParent(); int label_index = parent->GetChildIndex(textfield_) - 1; - if (label_index >= 0) { + if (label_index >= 0) { // Try to find the name of this text field. // We expect it to be a Label preceeding this view (if it exists). - std::wstring name; - View* label_view = parent->GetChildViewAt(label_index ); - if (label_view ->GetClassName() == Label::kViewClassName && - label_view ->GetAccessibleName(&name)) { + string16 name; + View* label_view = parent->GetChildViewAt(label_index); + if (label_view->GetClassName() == Label::kViewClassName && + label_view->GetAccessibleName(&name)) { hr = pAccPropServices->SetHwndPropStr(m_hWnd, OBJID_CLIENT, CHILDID_SELF, PROPID_ACC_NAME, name.c_str()); } diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 66f7489..50e6b94 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -327,10 +327,10 @@ AccessibilityTypes::State Textfield::GetAccessibleState() { return state; } -std::wstring Textfield::GetAccessibleValue() { +string16 Textfield::GetAccessibleValue() { if (!text_.empty()) - return UTF16ToWide(text_); - return std::wstring(); + return text_; + return string16(); } void Textfield::SetEnabled(bool enabled) { diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index afcc441..3d7ce38 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -209,9 +209,9 @@ class Textfield : public View { virtual void WillLoseFocus(); // Accessibility accessors, overridden from View: - virtual AccessibilityTypes::Role GetAccessibleRole(); - virtual AccessibilityTypes::State GetAccessibleState(); - virtual std::wstring GetAccessibleValue(); + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; + virtual string16 GetAccessibleValue() OVERRIDE; protected: virtual void Focus(); diff --git a/views/view.cc b/views/view.cc index fa8f1a4..d70e48b 100644 --- a/views/view.cc +++ b/views/view.cc @@ -1160,12 +1160,12 @@ bool View::InDrag() { return root_view ? (root_view->GetDragView() == this) : false; } -bool View::GetAccessibleName(std::wstring* name) { +bool View::GetAccessibleName(string16* name) { DCHECK(name); if (accessible_name_.empty()) return false; - *name = UTF16ToWideHack(accessible_name_); + *name = accessible_name_; return true; } @@ -1173,8 +1173,8 @@ AccessibilityTypes::Role View::GetAccessibleRole() { return AccessibilityTypes::ROLE_CLIENT; } -void View::SetAccessibleName(const std::wstring& name) { - accessible_name_ = WideToUTF16Hack(name); +void View::SetAccessibleName(const string16& name) { + accessible_name_ = name; } // static diff --git a/views/view.h b/views/view.h index 6b0f56c..3c77e03 100644 --- a/views/view.h +++ b/views/view.h @@ -571,18 +571,18 @@ class View : public AcceleratorTarget { // describes the default action that will occur when executing // IAccessible::DoDefaultAction. For instance, default action of a button is // 'Press'. - virtual std::wstring GetAccessibleDefaultAction() { return std::wstring(); } + virtual string16 GetAccessibleDefaultAction() { return string16(); } // Returns a string containing the mnemonic, or the keyboard shortcut, for a // given control. - virtual std::wstring GetAccessibleKeyboardShortcut() { - return std::wstring(); + virtual string16 GetAccessibleKeyboardShortcut() { + return string16(); } // Returns a brief, identifying string, containing a unique, readable name of // a given control. Sets the input string appropriately, and returns true if // successful. - bool GetAccessibleName(std::wstring* name); + bool GetAccessibleName(string16* name); // Returns the accessibility role of the current view. The role is what // assistive technologies (ATs) use to determine what behavior to expect from @@ -595,12 +595,12 @@ class View : public AcceleratorTarget { } // Returns the current value associated with a view. - virtual std::wstring GetAccessibleValue() { return std::wstring(); } + virtual string16 GetAccessibleValue() { return string16(); } // Assigns a string name to the given control. Needed as a View does not know // which name will be associated with it until it is created to be a // certain type. - void SetAccessibleName(const std::wstring& name); + void SetAccessibleName(const string16& name); // Returns an instance of the (platform-specific) accessibility interface for // the View. diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc index c2d8599..1b3351c 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -78,13 +78,13 @@ CustomFrameView::CustomFrameView(Window* frame) ResourceBundle& rb = ResourceBundle::GetSharedInstance(); close_button_->SetAccessibleName( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE))); + l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); // Close button images will be set in LayoutWindowControls(). AddChildView(close_button_); restore_button_->SetAccessibleName( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_RESTORE))); + l10n_util::GetStringUTF16(IDS_APP_ACCNAME_RESTORE)); restore_button_->SetImage(CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_RESTORE)); restore_button_->SetImage(CustomButton::BS_HOT, @@ -94,7 +94,7 @@ CustomFrameView::CustomFrameView(Window* frame) AddChildView(restore_button_); maximize_button_->SetAccessibleName( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE))); + l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE)); maximize_button_->SetImage(CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_MAXIMIZE)); maximize_button_->SetImage(CustomButton::BS_HOT, @@ -104,7 +104,7 @@ CustomFrameView::CustomFrameView(Window* frame) AddChildView(maximize_button_); minimize_button_->SetAccessibleName( - UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE))); + l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); minimize_button_->SetImage(CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_MINIMIZE)); minimize_button_->SetImage(CustomButton::BS_HOT, |