Skip to content

Commit

Permalink
Remove wstring from l10n_util. Part 8, the last part.
Browse files Browse the repository at this point in the history
BUG=9911
TEST=no visible changes; all tests pass

Review URL: http://codereview.chromium.org/6156001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70769 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
avi@chromium.org committed Jan 7, 2011
1 parent a2a5727 commit 3abebda
Show file tree
Hide file tree
Showing 38 changed files with 254 additions and 350 deletions.
91 changes: 0 additions & 91 deletions app/l10n_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,6 @@ bool IsValidLocaleSyntax(const std::string& locale) {
return true;
}

#if CRBUG_9911_OBSOLETE_GOING_AWAY
std::wstring GetString(int message_id) {
return UTF16ToWide(GetStringUTF16(message_id));
}
#endif

std::string GetStringUTF8(int message_id) {
return UTF16ToUTF8(GetStringUTF16(message_id));
}
Expand Down Expand Up @@ -630,38 +624,6 @@ static string16 GetStringF(int message_id,
return formatted;
}

#if CRBUG_9911_OBSOLETE_GOING_AWAY
#if !defined(WCHAR_T_IS_UTF16)
std::wstring GetStringF(int message_id, const std::wstring& a) {
return UTF16ToWide(GetStringFUTF16(message_id, WideToUTF16(a)));
}

std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b) {
return UTF16ToWide(GetStringFUTF16(message_id, WideToUTF16(a),
WideToUTF16(b)));
}

std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
const std::wstring& c) {
return UTF16ToWide(GetStringFUTF16(message_id, WideToUTF16(a),
WideToUTF16(b), WideToUTF16(c)));
}

std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
const std::wstring& c,
const std::wstring& d) {
return UTF16ToWide(GetStringFUTF16(message_id, WideToUTF16(a), WideToUTF16(b),
WideToUTF16(c), WideToUTF16(d)));
}
#endif
#endif

std::string GetStringFUTF8(int message_id,
const string16& a) {
return UTF16ToUTF8(GetStringFUTF16(message_id, a));
Expand Down Expand Up @@ -725,29 +687,6 @@ string16 GetStringFUTF16(int message_id,
return GetStringF(message_id, replacements, NULL);
}

#if CRBUG_9911_OBSOLETE_GOING_AWAY
std::wstring GetStringF(int message_id, const std::wstring& a, size_t* offset) {
DCHECK(offset);
std::vector<size_t> offsets;
std::vector<string16> replacements;
replacements.push_back(WideToUTF16(a));
string16 result = GetStringF(message_id, replacements, &offsets);
DCHECK(offsets.size() == 1);
*offset = offsets[0];
return UTF16ToWide(result);
}

std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
std::vector<size_t>* offsets) {
std::vector<string16> replacements;
replacements.push_back(WideToUTF16(a));
replacements.push_back(WideToUTF16(b));
return UTF16ToWide(GetStringF(message_id, replacements, offsets));
}
#endif

string16 GetStringFUTF16(int message_id, const string16& a, size_t* offset) {
DCHECK(offset);
std::vector<size_t> offsets;
Expand All @@ -769,16 +708,6 @@ string16 GetStringFUTF16(int message_id,
return GetStringF(message_id, replacements, offsets);
}

#if CRBUG_9911_OBSOLETE_GOING_AWAY
std::wstring GetStringF(int message_id, int a) {
return GetStringF(message_id, UTF8ToWide(base::IntToString(a)));
}

std::wstring GetStringF(int message_id, int64 a) {
return GetStringF(message_id, UTF8ToWide(base::Int64ToString(a)));
}
#endif

string16 GetStringFUTF16Int(int message_id, int a) {
return GetStringFUTF16(message_id, UTF8ToUTF16(base::IntToString(a)));
}
Expand Down Expand Up @@ -883,26 +812,6 @@ UCollationResult CompareString16WithCollator(const icu::Collator* collator,
return result;
}

// Compares the character data stored in two different std:wstring strings by
// specified Collator instance.
UCollationResult CompareStringWithCollator(const icu::Collator* collator,
const std::wstring& lhs,
const std::wstring& rhs) {
DCHECK(collator);
UCollationResult result;
#if defined(WCHAR_T_IS_UTF32)
// Need to convert to UTF-16 to be compatible with UnicodeString's
// constructor.
string16 lhs_utf16 = WideToUTF16(lhs);
string16 rhs_utf16 = WideToUTF16(rhs);

result = CompareString16WithCollator(collator, lhs_utf16, rhs_utf16);
#else
result = CompareString16WithCollator(collator, lhs, rhs);
#endif
return result;
}

// Specialization of operator() method for string16 version.
template <>
bool StringComparator<string16>::operator()(const string16& lhs,
Expand Down
63 changes: 0 additions & 63 deletions app/l10n_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
#include "app/l10n_util_mac.h"
#endif // OS_MACOSX

// http://crbug.com/9911 . Any functions bracketed by this define are going
// away; this define exists to allow compiler assistance in removing their use.
#if defined(TOOLKIT_VIEWS)
#define CRBUG_9911_OBSOLETE_GOING_AWAY 1
#endif

namespace l10n_util {

// This method is responsible for determining the locale as defined below. In
Expand Down Expand Up @@ -86,9 +80,6 @@ bool IsValidLocaleSyntax(const std::string& locale);
//

// Pulls resource string from the string bundle and returns it.
#if CRBUG_9911_OBSOLETE_GOING_AWAY
std::wstring GetString(int message_id);
#endif
std::string GetStringUTF8(int message_id);
string16 GetStringUTF16(int message_id);

Expand All @@ -108,47 +99,6 @@ string16 GetStringFUTF16(int message_id,
const string16& b,
const string16& c,
const string16& d);
#if CRBUG_9911_OBSOLETE_GOING_AWAY
#if defined(WCHAR_T_IS_UTF16)
inline std::wstring GetStringF(int message_id,
const std::wstring& a) {
return GetStringFUTF16(message_id, a);
}
inline std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b) {
return GetStringFUTF16(message_id, a, b);
}
inline std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
const std::wstring& c) {
return GetStringFUTF16(message_id, a, b, c);
}
inline std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
const std::wstring& c,
const std::wstring& d) {
return GetStringFUTF16(message_id, a, b, c, d);
}
#else
std::wstring GetStringF(int message_id,
const std::wstring& a);
std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b);
std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
const std::wstring& c);
std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
const std::wstring& c,
const std::wstring& d);
#endif
#endif
std::string GetStringFUTF8(int message_id,
const string16& a);
std::string GetStringFUTF8(int message_id,
Expand All @@ -168,15 +118,6 @@ std::string GetStringFUTF8(int message_id,
// vector based version returns offsets ordered by parameter. For example if
// invoked with a and b offsets[0] gives the offset for a and offsets[1] the
// offset of b regardless of where the parameters end up in the string.
#if CRBUG_9911_OBSOLETE_GOING_AWAY
std::wstring GetStringF(int message_id,
const std::wstring& a,
size_t* offset);
std::wstring GetStringF(int message_id,
const std::wstring& a,
const std::wstring& b,
std::vector<size_t>* offsets);
#endif
string16 GetStringFUTF16(int message_id,
const string16& a,
size_t* offset);
Expand All @@ -186,10 +127,6 @@ string16 GetStringFUTF16(int message_id,
std::vector<size_t>* offsets);

// Convenience functions to get a string with a single number as a parameter.
#if CRBUG_9911_OBSOLETE_GOING_AWAY
std::wstring GetStringF(int message_id, int a);
std::wstring GetStringF(int message_id, int64 a);
#endif
string16 GetStringFUTF16Int(int message_id, int a);
string16 GetStringFUTF16Int(int message_id, int64 a);

Expand Down
3 changes: 0 additions & 3 deletions app/l10n_util_collator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
namespace l10n_util {

// Compares the two strings using the specified collator.
UCollationResult CompareStringWithCollator(const icu::Collator* collator,
const std::wstring& lhs,
const std::wstring& rhs);
UCollationResult CompareString16WithCollator(const icu::Collator* collator,
const string16& lhs,
const string16& rhs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
ASSERT_TRUE(NULL != acc_obj);

ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
std::wstring title =
l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT,
ASCIIToWide(chrome::kAboutBlankURL));
std::wstring title = UTF16ToWide(l10n_util::GetStringFUTF16(
IDS_BROWSER_WINDOW_TITLE_FORMAT,
ASCIIToUTF16(chrome::kAboutBlankURL)));
TestAccessibilityInfo(acc_obj, title, ROLE_SYSTEM_WINDOW);
}

Expand All @@ -142,7 +142,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestNonClientViewAccObj) {
GetBrowserView()->GetWindow()->GetNonClientView();

TestViewAccessibilityObject(non_client_view,
l10n_util::GetString(IDS_PRODUCT_NAME),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)),
ROLE_SYSTEM_WINDOW);
}

Expand All @@ -153,33 +153,37 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
views::View* browser_root_view =
GetBrowserView()->frame()->GetFrameView()->GetRootView();

TestViewAccessibilityObject(browser_root_view,
l10n_util::GetString(IDS_PRODUCT_NAME),
ROLE_SYSTEM_APPLICATION);
TestViewAccessibilityObject(
browser_root_view,
UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)),
ROLE_SYSTEM_APPLICATION);
}

// Retrieve accessibility object for browser view and verify accessibility info.
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestBrowserViewAccObj) {
// Verify root view MSAA name and role.
TestViewAccessibilityObject(GetBrowserView(),
l10n_util::GetString(IDS_PRODUCT_NAME),
ROLE_SYSTEM_CLIENT);
TestViewAccessibilityObject(
GetBrowserView(),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)),
ROLE_SYSTEM_CLIENT);
}

// Retrieve accessibility object for toolbar view and verify accessibility info.
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestToolbarViewAccObj) {
// Verify toolbar MSAA name and role.
TestViewAccessibilityObject(GetToolbarView(),
l10n_util::GetString(IDS_ACCNAME_TOOLBAR),
ROLE_SYSTEM_TOOLBAR);
TestViewAccessibilityObject(
GetToolbarView(),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR)),
ROLE_SYSTEM_TOOLBAR);
}

// Retrieve accessibility object for Back button and verify accessibility info.
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestBackButtonAccObj) {
// Verify Back button MSAA name and role.
TestViewAccessibilityObject(
GetToolbarView()->GetViewByID(VIEW_ID_BACK_BUTTON),
l10n_util::GetString(IDS_ACCNAME_BACK), ROLE_SYSTEM_BUTTONDROPDOWN);
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)),
ROLE_SYSTEM_BUTTONDROPDOWN);
}

// Retrieve accessibility object for Forward button and verify accessibility
Expand All @@ -188,7 +192,8 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestForwardButtonAccObj) {
// Verify Forward button MSAA name and role.
TestViewAccessibilityObject(
GetToolbarView()->GetViewByID(VIEW_ID_FORWARD_BUTTON),
l10n_util::GetString(IDS_ACCNAME_FORWARD), ROLE_SYSTEM_BUTTONDROPDOWN);
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)),
ROLE_SYSTEM_BUTTONDROPDOWN);
}

// Retrieve accessibility object for Reload button and verify accessibility
Expand All @@ -197,15 +202,17 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestReloadButtonAccObj) {
// Verify Reload button MSAA name and role.
TestViewAccessibilityObject(
GetToolbarView()->GetViewByID(VIEW_ID_RELOAD_BUTTON),
l10n_util::GetString(IDS_ACCNAME_RELOAD), ROLE_SYSTEM_PUSHBUTTON);
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)),
ROLE_SYSTEM_PUSHBUTTON);
}

// Retrieve accessibility object for Home button and verify accessibility info.
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestHomeButtonAccObj) {
// Verify Home button MSAA name and role.
TestViewAccessibilityObject(
GetToolbarView()->GetViewByID(VIEW_ID_HOME_BUTTON),
l10n_util::GetString(IDS_ACCNAME_HOME), ROLE_SYSTEM_PUSHBUTTON);
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_HOME)),
ROLE_SYSTEM_PUSHBUTTON);
}

// Retrieve accessibility object for Star button and verify accessibility info.
Expand All @@ -214,31 +221,35 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
// Verify Star button MSAA name and role.
TestViewAccessibilityObject(
GetToolbarView()->GetViewByID(VIEW_ID_STAR_BUTTON),
l10n_util::GetString(IDS_ACCNAME_STAR), ROLE_SYSTEM_PUSHBUTTON);
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_STAR)),
ROLE_SYSTEM_PUSHBUTTON);
}

// Retrieve accessibility object for App menu button and verify accessibility
// info.
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestAppMenuAccObj) {
// Verify App menu button MSAA name and role.
TestViewAccessibilityObject(GetToolbarView()->GetViewByID(VIEW_ID_APP_MENU),
l10n_util::GetString(IDS_ACCNAME_APP),
ROLE_SYSTEM_BUTTONMENU);
TestViewAccessibilityObject(
GetToolbarView()->GetViewByID(VIEW_ID_APP_MENU),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_APP)),
ROLE_SYSTEM_BUTTONMENU);
}

IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
TestBookmarkBarViewAccObj) {
TestViewAccessibilityObject(GetBookmarkBarView(),
l10n_util::GetString(IDS_ACCNAME_BOOKMARKS),
ROLE_SYSTEM_TOOLBAR);
TestViewAccessibilityObject(
GetBookmarkBarView(),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS)),
ROLE_SYSTEM_TOOLBAR);
}

IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
TestAboutChromeViewAccObj) {
// Firstly, test that the WindowDelegate got updated.
views::Window* aboutChromeWindow = GetBrowserView()->ShowAboutChromeDialog();
EXPECT_STREQ(aboutChromeWindow->GetDelegate()->GetWindowTitle().c_str(),
l10n_util::GetString(IDS_ABOUT_CHROME_TITLE).c_str());
EXPECT_STREQ(
aboutChromeWindow->GetDelegate()->GetWindowTitle().c_str(),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_TITLE)).c_str());
EXPECT_EQ(aboutChromeWindow->GetDelegate()->accessible_role(),
AccessibilityTypes::ROLE_DIALOG);

Expand All @@ -252,8 +263,10 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
ASSERT_EQ(S_OK, hr);
ASSERT_TRUE(NULL != acc_obj);

TestAccessibilityInfo(acc_obj, l10n_util::GetString(IDS_ABOUT_CHROME_TITLE),
ROLE_SYSTEM_DIALOG);
TestAccessibilityInfo(
acc_obj,
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_TITLE)),
ROLE_SYSTEM_DIALOG);

acc_obj->Release();
}
Expand Down
Loading

0 comments on commit 3abebda

Please sign in to comment.