diff options
-rw-r--r-- | base/i18n/case_conversion.cc | 8 | ||||
-rw-r--r-- | base/i18n/case_conversion.h | 2 | ||||
-rw-r--r-- | base/i18n/case_conversion_unittest.cc | 13 | ||||
-rw-r--r-- | chrome/browser/enumerate_modules_model_win.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/shell_dialogs_win.cc | 2 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.cc | 18 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.h | 6 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 12 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.h | 2 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_win.cc | 8 |
10 files changed, 25 insertions, 48 deletions
diff --git a/base/i18n/case_conversion.cc b/base/i18n/case_conversion.cc index 2dedade..2762505 100644 --- a/base/i18n/case_conversion.cc +++ b/base/i18n/case_conversion.cc @@ -16,19 +16,11 @@ string16 ToLower(const string16& string) { return string16(unicode_string.getBuffer(), unicode_string.length()); } -std::wstring WideToLower(const std::wstring& string) { - return UTF16ToWide(ToLower(WideToUTF16(string))); -} - string16 ToUpper(const string16& string) { icu::UnicodeString unicode_string(string.c_str(), string.size()); unicode_string.toUpper(); return string16(unicode_string.getBuffer(), unicode_string.length()); } -std::wstring WideToUpper(const std::wstring& string) { - return UTF16ToWide(ToUpper(WideToUTF16(string))); -} - } // namespace i18n } // namespace base diff --git a/base/i18n/case_conversion.h b/base/i18n/case_conversion.h index d834ede..cb62da1 100644 --- a/base/i18n/case_conversion.h +++ b/base/i18n/case_conversion.h @@ -15,11 +15,9 @@ namespace i18n { // Returns the lower case equivalent of string. Uses ICU's default locale. string16 ToLower(const string16& string); -std::wstring WideToLower(const std::wstring& string); // Returns the upper case equivalent of string. Uses ICU's default locale. string16 ToUpper(const string16& string); -std::wstring WideToUpper(const std::wstring& string); } // namespace i18n } // namespace base diff --git a/base/i18n/case_conversion_unittest.cc b/base/i18n/case_conversion_unittest.cc index 87a349e..63900ec 100644 --- a/base/i18n/case_conversion_unittest.cc +++ b/base/i18n/case_conversion_unittest.cc @@ -21,19 +21,6 @@ TEST(CaseConversionTest, UpperLower) { EXPECT_EQ(expected_upper, result); } -// Test upper and lower case string conversion. -TEST(CaseConversionTest, WideUpperLower) { - std::wstring mixed(L"Text with UPPer & lowER casE."); - const std::wstring expected_lower(L"text with upper & lower case."); - const std::wstring expected_upper(L"TEXT WITH UPPER & LOWER CASE."); - - std::wstring result = base::i18n::WideToLower(mixed); - EXPECT_EQ(expected_lower, result); - - result = base::i18n::WideToUpper(mixed); - EXPECT_EQ(expected_upper, result); -} - // TODO(jshin): More tests are needed, especially with non-ASCII characters. } // namespace diff --git a/chrome/browser/enumerate_modules_model_win.cc b/chrome/browser/enumerate_modules_model_win.cc index 78ea9d1..cf6f697 100644 --- a/chrome/browser/enumerate_modules_model_win.cc +++ b/chrome/browser/enumerate_modules_model_win.cc @@ -587,7 +587,7 @@ void ModuleEnumerator::PreparePathMappings() { std::string path; if (environment->GetVar(WideToASCII(*variable).c_str(), &path)) { path_mapping_.push_back( - std::make_pair(base::i18n::WideToLower(UTF8ToWide(path)) + L"\\", + std::make_pair(base::i18n::ToLower(UTF8ToUTF16(path)) + L"\\", L"%" + base::i18n::ToLower(*variable) + L"%")); } } diff --git a/chrome/browser/ui/views/shell_dialogs_win.cc b/chrome/browser/ui/views/shell_dialogs_win.cc index 691f050..ff7b794 100644 --- a/chrome/browser/ui/views/shell_dialogs_win.cc +++ b/chrome/browser/ui/views/shell_dialogs_win.cc @@ -144,7 +144,7 @@ std::wstring FormatFilterForExtensions( // the we create a description "QQQ File (.qqq)"). include_all_files = true; desc = l10n_util::GetStringFUTF16(IDS_APP_SAVEAS_EXTENSION_FORMAT, - base::i18n::WideToUpper(ext_name), + base::i18n::ToUpper(ext_name), ext_name); } if (desc.empty()) diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 5a0ed2d..1af598f 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -52,17 +52,17 @@ namespace views { namespace { // Returns true if the mnemonic of |menu| matches key. -bool MatchesMnemonic(MenuItemView* menu, wchar_t key) { +bool MatchesMnemonic(MenuItemView* menu, char16 key) { return menu->GetMnemonic() == key; } // Returns true if |menu| doesn't have a mnemonic and first character of the its // title is |key|. -bool TitleMatchesMnemonic(MenuItemView* menu, wchar_t key) { +bool TitleMatchesMnemonic(MenuItemView* menu, char16 key) { if (menu->GetMnemonic()) return false; - std::wstring lower_title = base::i18n::WideToLower(menu->GetTitle()); + string16 lower_title = base::i18n::ToLower(WideToUTF16(menu->GetTitle())); return !lower_title.empty() && lower_title[0] == key; } @@ -827,7 +827,7 @@ bool MenuController::Dispatch(const MSG& msg) { return OnKeyDown(msg.wParam, msg); case WM_CHAR: - return !SelectByChar(static_cast<wchar_t>(msg.wParam)); + return !SelectByChar(static_cast<char16>(msg.wParam)); case WM_KEYUP: return true; @@ -1607,8 +1607,8 @@ void MenuController::CloseSubmenu() { MenuController::SelectByCharDetails MenuController::FindChildForMnemonic( MenuItemView* parent, - wchar_t key, - bool (*match_function)(MenuItemView* menu, wchar_t mnemonic)) { + char16 key, + bool (*match_function)(MenuItemView* menu, char16 mnemonic)) { SubmenuView* submenu = parent->GetSubmenu(); DCHECK(submenu); SelectByCharDetails details; @@ -1659,9 +1659,9 @@ bool MenuController::AcceptOrSelect(MenuItemView* parent, return false; } -bool MenuController::SelectByChar(wchar_t character) { - wchar_t char_array[1] = { character }; - wchar_t key = base::i18n::WideToLower(char_array)[0]; +bool MenuController::SelectByChar(char16 character) { + char16 char_array[] = { character, 0 }; + char16 key = base::i18n::ToLower(char_array)[0]; MenuItemView* item = pending_state_.item; if (!item->HasSubmenu() || !item->GetSubmenu()->IsShowing()) item = item->GetParentMenuItem(); diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h index 17a5dc0..9524497 100644 --- a/views/controls/menu/menu_controller.h +++ b/views/controls/menu/menu_controller.h @@ -357,8 +357,8 @@ class MenuController : public MessageLoopForUI::Dispatcher { // |match_function| is used to determine which menus match. SelectByCharDetails FindChildForMnemonic( MenuItemView* parent, - wchar_t key, - bool (*match_function)(MenuItemView* menu, wchar_t mnemonic)); + char16 key, + bool (*match_function)(MenuItemView* menu, char16 mnemonic)); // Selects or accepts the appropriate menu item based on |details|. Returns // true if |Accept| was invoked (which happens if there aren't multiple item @@ -367,7 +367,7 @@ class MenuController : public MessageLoopForUI::Dispatcher { // Selects by mnemonic, and if that doesn't work tries the first character of // the title. Returns true if a match was selected and the menu should exit. - bool SelectByChar(wchar_t key); + bool SelectByChar(char16 key); #if defined(OS_WIN) // If there is a window at the location of the event, a new mouse event is diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index 2d49c8f..c2c266b8 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -383,26 +383,26 @@ MenuItemView* MenuItemView::GetRootMenuItem() { return NULL; } -wchar_t MenuItemView::GetMnemonic() { +char16 MenuItemView::GetMnemonic() { if (!GetRootMenuItem()->has_mnemonics_) return 0; - const std::wstring& title = GetTitle(); + string16 title = WideToUTF16(GetTitle()); size_t index = 0; do { index = title.find('&', index); - if (index != std::wstring::npos) { + if (index != string16::npos) { if (index + 1 != title.size() && title[index + 1] != '&') { - wchar_t char_array[1] = { title[index + 1] }; + char16 char_array[] = { title[index + 1], 0 }; // TODO(jshin): What about Turkish locale? See http://crbug.com/81719. // If the mnemonic is capital I and the UI language is Turkish, // lowercasing it results in 'small dotless i', which is different // from a 'dotted i'. Similar issues may exist for az and lt locales. - return base::i18n::WideToLower(char_array)[0]; + return base::i18n::ToLower(char_array)[0]; } index++; } - } while (index != std::wstring::npos); + } while (index != string16::npos); return 0; } diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index 980f2d6..308c3e2 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -261,7 +261,7 @@ class MenuItemView : public View { // Returns the mnemonic for this MenuItemView, or 0 if this MenuItemView // doesn't have a mnemonic. - wchar_t GetMnemonic(); + char16 GetMnemonic(); // Do we have icons? This only has effect on the top menu. Turning this on // makes the menus slightly wider and taller. diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index 5811cf9..b59e168 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -189,12 +189,12 @@ string16 NativeTextfieldWin::GetText() const { } void NativeTextfieldWin::UpdateText() { - std::wstring text = textfield_->text(); + string16 text = textfield_->text(); // Adjusting the string direction before setting the text in order to make // sure both RTL and LTR strings are displayed properly. base::i18n::AdjustStringForLocaleDirection(&text); if (textfield_->style() & Textfield::STYLE_LOWERCASE) - text = base::i18n::WideToLower(text); + text = base::i18n::ToLower(text); SetWindowText(text.c_str()); UpdateAccessibleValue(text); } @@ -905,9 +905,9 @@ void NativeTextfieldWin::OnPaste() { std::wstring clipboard_str; clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_str); if (!clipboard_str.empty()) { - std::wstring collapsed(CollapseWhitespace(clipboard_str, false)); + string16 collapsed(CollapseWhitespace(clipboard_str, false)); if (textfield_->style() & Textfield::STYLE_LOWERCASE) - collapsed = base::i18n::WideToLower(collapsed); + collapsed = base::i18n::ToLower(collapsed); // Force a Paste operation to trigger ContentsChanged, even if identical // contents are pasted into the text box. See http://crbug.com/79002 ReplaceSel(L"", false); |