summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 07:27:42 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 07:27:42 +0000
commitc32d31eab915dcff1f128bf744ced2ad8fa221ef (patch)
tree69a8fbf3b9360c6401bb4658893cafc4b2f209ed
parent6ee50a8d443f48e70921a8eed76f26a6e9844228 (diff)
downloadchromium_src-c32d31eab915dcff1f128bf744ced2ad8fa221ef.zip
chromium_src-c32d31eab915dcff1f128bf744ced2ad8fa221ef.tar.gz
chromium_src-c32d31eab915dcff1f128bf744ced2ad8fa221ef.tar.bz2
Cleanup AdjustStringForLocaleDirection() to modify input parameter in place.
As described in the bug, the current behavior is confusing and bug-prone. BUG=47194 TEST=Check that there are no visible regressions in RTL and LTR language UIs on Linux & Windows. Review URL: http://codereview.chromium.org/5154009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67237 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/win_util.cc16
-rw-r--r--base/i18n/rtl.cc21
-rw-r--r--base/i18n/rtl.h28
-rw-r--r--chrome/browser/browser_main_win.cc2
-rw-r--r--chrome/browser/chromeos/dom_ui/imageburner_ui.cc11
-rw-r--r--chrome/browser/chromeos/dom_ui/system_settings_provider.cc5
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc4
-rw-r--r--chrome/browser/download/download_util.cc18
-rw-r--r--chrome/browser/encoding_menu_controller.cc5
-rw-r--r--chrome/browser/language_combobox_model.cc18
-rw-r--r--chrome/browser/location_bar_util.cc2
-rw-r--r--chrome/browser/possible_url_model.cc6
-rw-r--r--chrome/browser/search_engines/template_url.cc8
-rw-r--r--chrome/browser/search_engines/template_url_table_model.cc3
-rw-r--r--chrome/browser/task_manager/task_manager.cc2
-rw-r--r--chrome/browser/task_manager/task_manager_resource_providers.cc5
-rw-r--r--chrome/browser/ui/views/bookmark_bar_view.cc5
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/ui/views/options/passwords_page_view.cc2
-rw-r--r--chrome/common/child_process_info.cc2
-rw-r--r--chrome/common/extensions/extension.cc2
-rw-r--r--chrome/common/extensions/extension_unittest.cc4
-rw-r--r--gfx/canvas_skia_win.cc15
-rw-r--r--views/controls/button/native_button.cc4
-rw-r--r--views/controls/combobox/native_combobox_win.cc6
-rw-r--r--views/controls/textfield/native_textfield_win.cc10
-rw-r--r--views/controls/tree/tree_view.cc4
-rw-r--r--views/widget/tooltip_manager_win.cc3
-rw-r--r--views/window/window_gtk.cc4
-rw-r--r--views/window/window_win.cc4
30 files changed, 77 insertions, 144 deletions
diff --git a/app/win_util.cc b/app/win_util.cc
index be267af..b3a0571 100644
--- a/app/win_util.cc
+++ b/app/win_util.cc
@@ -533,15 +533,13 @@ int MessageBox(HWND hwnd,
if (base::i18n::IsRTL())
actual_flags |= MB_RIGHT | MB_RTLREADING;
- std::wstring localized_text;
- const wchar_t* text_ptr = text.c_str();
- if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text))
- text_ptr = localized_text.c_str();
-
- std::wstring localized_caption;
- const wchar_t* caption_ptr = caption.c_str();
- if (base::i18n::AdjustStringForLocaleDirection(caption, &localized_caption))
- caption_ptr = localized_caption.c_str();
+ std::wstring localized_text = text;
+ base::i18n::AdjustStringForLocaleDirection(&localized_text);
+ const wchar_t* text_ptr = localized_text.c_str();
+
+ std::wstring localized_caption = caption;
+ base::i18n::AdjustStringForLocaleDirection(&localized_caption);
+ const wchar_t* caption_ptr = localized_caption.c_str();
return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags);
}
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc
index 0881fb7..6a5d293 100644
--- a/base/i18n/rtl.cc
+++ b/base/i18n/rtl.cc
@@ -163,30 +163,27 @@ TextDirection GetFirstStrongCharacterDirection(const std::wstring& text) {
}
#endif
-bool AdjustStringForLocaleDirection(const string16& text,
- string16* localized_text) {
- if (!IsRTL() || text.empty())
+bool AdjustStringForLocaleDirection(string16* text) {
+ if (!IsRTL() || text->empty())
return false;
// Marking the string as LTR if the locale is RTL and the string does not
// contain strong RTL characters. Otherwise, mark the string as RTL.
- *localized_text = text;
- bool has_rtl_chars = StringContainsStrongRTLChars(text);
+ bool has_rtl_chars = StringContainsStrongRTLChars(*text);
if (!has_rtl_chars)
- WrapStringWithLTRFormatting(localized_text);
+ WrapStringWithLTRFormatting(text);
else
- WrapStringWithRTLFormatting(localized_text);
+ WrapStringWithRTLFormatting(text);
return true;
}
#if defined(WCHAR_T_IS_UTF32)
-bool AdjustStringForLocaleDirection(const std::wstring& text,
- std::wstring* localized_text) {
- string16 out;
- if (AdjustStringForLocaleDirection(WideToUTF16(text), &out)) {
+bool AdjustStringForLocaleDirection(std::wstring* text) {
+ string16 temp = WideToUTF16(*text);
+ if (AdjustStringForLocaleDirection(&temp)) {
// We should only touch the output on success.
- *localized_text = UTF16ToWide(out);
+ *text = UTF16ToWide(temp);
return true;
}
return false;
diff --git a/base/i18n/rtl.h b/base/i18n/rtl.h
index ed0882f..82ac576 100644
--- a/base/i18n/rtl.h
+++ b/base/i18n/rtl.h
@@ -71,13 +71,12 @@ TextDirection GetFirstStrongCharacterDirection(const string16& text);
TextDirection GetFirstStrongCharacterDirection(const std::wstring& text);
#endif
-// Given the string in |text|, this function creates a copy of the string with
+// Given the string in |text|, this function modifies the string in place with
// the appropriate Unicode formatting marks that mark the string direction
-// (either left-to-right or right-to-left). The new string is returned in
-// |localized_text|. The function checks both the current locale and the
-// contents of the string in order to determine the direction of the returned
-// string. The function returns true if the string in |text| was properly
-// adjusted.
+// (either left-to-right or right-to-left). The function checks both the current
+// locale and the contents of the string in order to determine the direction of
+// the returned string. The function returns true if the string in |text| was
+// properly adjusted.
//
// Certain LTR strings are not rendered correctly when the context is RTL. For
// example, the string "Foo!" will appear as "!Foo" if it is rendered as is in
@@ -85,16 +84,7 @@ TextDirection GetFirstStrongCharacterDirection(const std::wstring& text);
// string is always treated as a right-to-left string. This is done by
// inserting certain Unicode formatting marks into the returned string.
//
-// TODO(brettw) bug 47194: This funciton is confusing. If it does no adjustment
-// becuase the current locale is not RTL, it will do nothing and return false.
-// This means you have to check the return value in many cases which doesn't
-// make sense. This should be cleaned up and probably just take a single
-// argument that's a pointer to a string that it modifies as necessary. In the
-// meantime, the recommended usage is to use the same arg as input & output,
-// which will work without extra checks:
-// AdjustStringForLocaleDirection(text, &text);
-//
-// TODO(idana) bug# 1206120: this function adjusts the string in question only
+// TODO(idana) bug 6806: this function adjusts the string in question only
// if the current locale is right-to-left. The function does not take care of
// the opposite case (an RTL string displayed in an LTR context) since
// adjusting the string involves inserting Unicode formatting characters that
@@ -102,11 +92,9 @@ TextDirection GetFirstStrongCharacterDirection(const std::wstring& text);
// installed. Since the English version of Windows doesn't have right-to-left
// language support installed by default, inserting the direction Unicode mark
// results in Windows displaying squares.
-bool AdjustStringForLocaleDirection(const string16& text,
- string16* localized_text);
+bool AdjustStringForLocaleDirection(string16* text);
#if defined(WCHAR_T_IS_UTF32)
-bool AdjustStringForLocaleDirection(const std::wstring& text,
- std::wstring* localized_text);
+bool AdjustStringForLocaleDirection(std::wstring* text);
#endif
// Returns true if the string contains at least one character with strong right
diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc
index de6f2f1..f4f9a59 100644
--- a/chrome/browser/browser_main_win.cc
+++ b/chrome/browser/browser_main_win.cc
@@ -134,7 +134,7 @@ void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) {
dlg_strings.push_back('|');
string16 adjusted_string(
l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_CONTENT));
- base::i18n::AdjustStringForLocaleDirection(adjusted_string, &adjusted_string);
+ base::i18n::AdjustStringForLocaleDirection(&adjusted_string);
dlg_strings.append(adjusted_string);
dlg_strings.push_back('|');
dlg_strings.append(ASCIIToUTF16(
diff --git a/chrome/browser/chromeos/dom_ui/imageburner_ui.cc b/chrome/browser/chromeos/dom_ui/imageburner_ui.cc
index 709a061..b827c93 100644
--- a/chrome/browser/chromeos/dom_ui/imageburner_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/imageburner_ui.cc
@@ -312,20 +312,13 @@ std::wstring ImageBurnHandler::GetBurnProgressText(int64 total_burnt,
std::wstring burnt_size =
UTF16ToWideHack(FormatBytes(total_burnt, amount_units, true));
- std::wstring burnt_size_localized;
- if (base::i18n::AdjustStringForLocaleDirection(burnt_size,
- &burnt_size_localized)) {
- burnt_size.assign(burnt_size_localized);
- }
+ base::i18n::AdjustStringForLocaleDirection(&burnt_size);
if (image_size) {
amount_units = GetByteDisplayUnits(image_size);
std::wstring total_text =
UTF16ToWideHack(FormatBytes(image_size, amount_units, true));
- std::wstring total_text_localized;
- if (base::i18n::AdjustStringForLocaleDirection(total_text,
- &total_text_localized))
- total_text.assign(total_text_localized);
+ base::i18n::AdjustStringForLocaleDirection(&total_text);
return l10n_util::GetStringF(IDS_IMAGEBURN_BURN_PROGRESS,
burnt_size,
diff --git a/chrome/browser/chromeos/dom_ui/system_settings_provider.cc b/chrome/browser/chromeos/dom_ui/system_settings_provider.cc
index 2c6fe6a..77350f4 100644
--- a/chrome/browser/chromeos/dom_ui/system_settings_provider.cc
+++ b/chrome/browser/chromeos/dom_ui/system_settings_provider.cc
@@ -272,9 +272,8 @@ string16 SystemSettingsProvider::GetTimezoneName(
string16 result(l10n_util::GetStringFUTF16(
IDS_OPTIONS_SETTINGS_TIMEZONE_DISPLAY_TEMPLATE, ASCIIToUTF16(offset_str),
string16(name.getBuffer(), name.length()), GetExemplarCity(timezone)));
- string16 rtl_safe_result = result;
- base::i18n::AdjustStringForLocaleDirection(result, &rtl_safe_result);
- return rtl_safe_result;
+ base::i18n::AdjustStringForLocaleDirection(&result);
+ return result;
}
string16 SystemSettingsProvider::GetTimezoneID(
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index e6481b6..06c7d2d 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -179,9 +179,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
if (using_url_as_the_title) {
base::i18n::WrapStringWithLTRFormatting(&title_to_set);
} else {
- bool success =
- base::i18n::AdjustStringForLocaleDirection(title, &title_to_set);
- DCHECK(success ? (title != title_to_set) : (title == title_to_set));
+ base::i18n::AdjustStringForLocaleDirection(&title_to_set);
}
}
dictionary->SetString("title", title_to_set);
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index c7a261f..2c856be 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -544,21 +544,15 @@ std::wstring GetProgressStatusText(DownloadItem* download) {
// Adjust both strings for the locale direction since we don't yet know which
// string we'll end up using for constructing the final progress string.
- std::wstring amount_localized;
- if (base::i18n::AdjustStringForLocaleDirection(amount, &amount_localized)) {
- amount.assign(amount_localized);
- received_size.assign(amount_localized);
- }
+ base::i18n::AdjustStringForLocaleDirection(&amount);
if (total) {
amount_units = GetByteDisplayUnits(total);
std::wstring total_text =
UTF16ToWideHack(FormatBytes(total, amount_units, true));
- std::wstring total_text_localized;
- if (base::i18n::AdjustStringForLocaleDirection(total_text,
- &total_text_localized))
- total_text.assign(total_text_localized);
+ base::i18n::AdjustStringForLocaleDirection(&total_text);
+ base::i18n::AdjustStringForLocaleDirection(&received_size);
amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE,
received_size,
total_text);
@@ -569,10 +563,7 @@ std::wstring GetProgressStatusText(DownloadItem* download) {
amount_units = GetByteDisplayUnits(current_speed);
std::wstring speed_text = UTF16ToWideHack(FormatSpeed(current_speed,
amount_units, true));
- std::wstring speed_text_localized;
- if (base::i18n::AdjustStringForLocaleDirection(speed_text,
- &speed_text_localized))
- speed_text.assign(speed_text_localized);
+ base::i18n::AdjustStringForLocaleDirection(&speed_text);
base::TimeDelta remaining;
string16 time_remaining;
@@ -582,6 +573,7 @@ std::wstring GetProgressStatusText(DownloadItem* download) {
time_remaining = TimeFormat::TimeRemaining(remaining);
if (time_remaining.empty()) {
+ base::i18n::AdjustStringForLocaleDirection(&amount);
return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN,
speed_text, amount);
}
diff --git a/chrome/browser/encoding_menu_controller.cc b/chrome/browser/encoding_menu_controller.cc
index d53536d..7d3a89e 100644
--- a/chrome/browser/encoding_menu_controller.cc
+++ b/chrome/browser/encoding_menu_controller.cc
@@ -131,10 +131,7 @@ void EncodingMenuController::GetEncodingMenuItems(Profile* profile,
for (it = encodings->begin(); it != encodings->end(); ++it) {
if (it->encoding_id) {
std::wstring encoding = it->encoding_display_name;
- std::wstring bidi_safe_encoding;
- if (base::i18n::AdjustStringForLocaleDirection(encoding,
- &bidi_safe_encoding))
- encoding.swap(bidi_safe_encoding);
+ base::i18n::AdjustStringForLocaleDirection(&encoding);
menuItems->push_back(EncodingMenuItem(it->encoding_id,
WideToUTF16(encoding)));
} else {
diff --git a/chrome/browser/language_combobox_model.cc b/chrome/browser/language_combobox_model.cc
index 55b98d4..c2787b8 100644
--- a/chrome/browser/language_combobox_model.cc
+++ b/chrome/browser/language_combobox_model.cc
@@ -90,21 +90,11 @@ std::wstring LanguageList::GetLanguageNameAt(int index) const {
// We must add directionality formatting to both the native name and the
// locale name in order to avoid text rendering problems such as misplaced
// parentheses or languages appearing in the wrong order.
- std::wstring locale_name_localized;
- std::wstring locale_name;
- if (base::i18n::AdjustStringForLocaleDirection(locale_names_[index],
- &locale_name_localized))
- locale_name.assign(locale_name_localized);
- else
- locale_name.assign(locale_names_[index]);
+ std::wstring locale_name = locale_names_[index];
+ base::i18n::AdjustStringForLocaleDirection(&locale_name);
- std::wstring native_name_localized;
- std::wstring native_name;
- if (base::i18n::AdjustStringForLocaleDirection(it->second.native_name,
- &native_name_localized))
- native_name.assign(native_name_localized);
- else
- native_name.assign(it->second.native_name);
+ std::wstring native_name = it->second.native_name;
+ base::i18n::AdjustStringForLocaleDirection(&native_name);
// We used to have a localizable template here, but none of translators
// changed the format. We also want to switch the order of locale_name
diff --git a/chrome/browser/location_bar_util.cc b/chrome/browser/location_bar_util.cc
index 3542070d..a398ada 100644
--- a/chrome/browser/location_bar_util.cc
+++ b/chrome/browser/location_bar_util.cc
@@ -35,7 +35,7 @@ std::wstring CalculateMinString(const std::wstring& description) {
} else {
min_string = description.substr(0, chop_index);
}
- base::i18n::AdjustStringForLocaleDirection(min_string, &min_string);
+ base::i18n::AdjustStringForLocaleDirection(&min_string);
return min_string;
}
diff --git a/chrome/browser/possible_url_model.cc b/chrome/browser/possible_url_model.cc
index f419762..d84c54f 100644
--- a/chrome/browser/possible_url_model.cc
+++ b/chrome/browser/possible_url_model.cc
@@ -132,13 +132,11 @@ std::wstring PossibleURLModel::GetText(int row, int col_id) {
}
if (col_id == IDS_ASI_PAGE_COLUMN) {
- const std::wstring& title = GetTitle(row);
+ std::wstring title = GetTitle(row);
// TODO(xji): Consider adding a special case if the title text is a URL,
// since those should always have LTR directionality. Please refer to
// http://crbug.com/6726 for more information.
- std::wstring localized_title;
- if (base::i18n::AdjustStringForLocaleDirection(title, &localized_title))
- return localized_title;
+ base::i18n::AdjustStringForLocaleDirection(&title);
return title;
}
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index 48f5d7d..c1ebf517 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -578,11 +578,9 @@ TemplateURL::~TemplateURL() {
}
std::wstring TemplateURL::AdjustedShortNameForLocaleDirection() const {
- std::wstring bidi_safe_short_name;
- if (base::i18n::AdjustStringForLocaleDirection(short_name_,
- &bidi_safe_short_name))
- return bidi_safe_short_name;
- return short_name_;
+ std::wstring bidi_safe_short_name = short_name_;
+ base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name);
+ return bidi_safe_short_name;
}
void TemplateURL::SetSuggestionsURL(const std::string& suggestions_url,
diff --git a/chrome/browser/search_engines/template_url_table_model.cc b/chrome/browser/search_engines/template_url_table_model.cc
index 4570b25..f335ba3 100644
--- a/chrome/browser/search_engines/template_url_table_model.cc
+++ b/chrome/browser/search_engines/template_url_table_model.cc
@@ -187,8 +187,7 @@ std::wstring TemplateURLTableModel::GetText(int row, int col_id) {
// TODO(xji): Consider adding a special case if the short name is a URL,
// since those should always be displayed LTR. Please refer to
// http://crbug.com/6726 for more information.
- base::i18n::AdjustStringForLocaleDirection(url_short_name,
- &url_short_name);
+ base::i18n::AdjustStringForLocaleDirection(&url_short_name);
return (template_url_model_->GetDefaultSearchProvider() == &url) ?
l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE,
url_short_name) : url_short_name;
diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc
index c6500fa..5673741 100644
--- a/chrome/browser/task_manager/task_manager.cc
+++ b/chrome/browser/task_manager/task_manager.cc
@@ -500,7 +500,7 @@ string16 TaskManagerModel::GetMemCellText(int64 number) const {
string16 str = base::FormatNumber(number / 1024);
// Adjust number string if necessary.
- base::i18n::AdjustStringForLocaleDirection(str, &str);
+ base::i18n::AdjustStringForLocaleDirection(&str);
return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_MEM_CELL_TEXT, str);
#else
// System expectation is to show "100 KB", "200 MB", etc.
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc
index 73476c9..2b339fa 100644
--- a/chrome/browser/task_manager/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager/task_manager_resource_providers.cc
@@ -149,7 +149,7 @@ std::wstring TaskManagerTabContentsResource::GetTitle() const {
// as LTR format, the concatenated result will be "!Yahoo! Mail: The best
// web-based Email :BAT", in which the capital letters "BAT" stands for
// the Hebrew word for "tab".
- base::i18n::AdjustStringForLocaleDirection(tab_title, &tab_title);
+ base::i18n::AdjustStringForLocaleDirection(&tab_title);
}
return l10n_util::GetStringF(IDS_TASK_MANAGER_TAB_PREFIX, tab_title);
@@ -357,8 +357,7 @@ TaskManagerBackgroundContentsResource::TaskManagerBackgroundContentsResource(
}
// Ensure that the string has the appropriate direction markers (see comment
// in TaskManagerTabContentsResource::GetTitle()).
- base::i18n::AdjustStringForLocaleDirection(application_name_,
- &application_name_);
+ base::i18n::AdjustStringForLocaleDirection(&application_name_);
}
TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource(
diff --git a/chrome/browser/ui/views/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmark_bar_view.cc
index 439df1d..6226524 100644
--- a/chrome/browser/ui/views/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmark_bar_view.cc
@@ -143,9 +143,8 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
// First the title.
if (!title.empty()) {
- std::wstring localized_title;
- if (!base::i18n::AdjustStringForLocaleDirection(title, &localized_title))
- localized_title = title;
+ std::wstring localized_title = title;
+ base::i18n::AdjustStringForLocaleDirection(&localized_title);
result.append(UTF16ToWideHack(gfx::ElideText(WideToUTF16Hack(
localized_title), tt_font, max_width, false)));
}
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index 3482380..b50debf 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -97,7 +97,7 @@ std::wstring HungPagesTableModel::GetText(int row, int column_id) {
// TODO(xji): Consider adding a special case if the title text is a URL,
// since those should always have LTR directionality. Please refer to
// http://crbug.com/6726 for more information.
- base::i18n::AdjustStringForLocaleDirection(title, &title);
+ base::i18n::AdjustStringForLocaleDirection(&title);
return title;
}
diff --git a/chrome/browser/ui/views/options/passwords_page_view.cc b/chrome/browser/ui/views/options/passwords_page_view.cc
index 6d22d5e..e33b0b6 100644
--- a/chrome/browser/ui/views/options/passwords_page_view.cc
+++ b/chrome/browser/ui/views/options/passwords_page_view.cc
@@ -82,7 +82,7 @@ std::wstring PasswordsTableModel::GetText(int row,
}
case IDS_PASSWORDS_PAGE_VIEW_USERNAME_COLUMN: { // Username.
std::wstring username = GetPasswordFormAt(row)->username_value;
- base::i18n::AdjustStringForLocaleDirection(username, &username);
+ base::i18n::AdjustStringForLocaleDirection(&username);
return username;
}
default:
diff --git a/chrome/common/child_process_info.cc b/chrome/common/child_process_info.cc
index 1af0cdb..8774578 100644
--- a/chrome/common/child_process_info.cc
+++ b/chrome/common/child_process_info.cc
@@ -82,7 +82,7 @@ string16 ChildProcessInfo::GetLocalizedTitle() const {
// to avoid the wrong concatenation result similar to "!Yahoo! Mail: the
// best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew
// or Arabic word for "plugin".
- base::i18n::AdjustStringForLocaleDirection(title, &title);
+ base::i18n::AdjustStringForLocaleDirection(&title);
switch (type_) {
case ChildProcessInfo::UTILITY_PROCESS:
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 4d33822..ba316b8 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1234,7 +1234,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
*error = errors::kInvalidName;
return false;
}
- base::i18n::AdjustStringForLocaleDirection(localized_name, &localized_name);
+ base::i18n::AdjustStringForLocaleDirection(&localized_name);
name_ = UTF16ToUTF8(localized_name);
// Initialize description (if present).
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index 3f86bbd..013fce7 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -383,7 +383,7 @@ TEST(ExtensionTest, InitFromValueValidNameInRTL) {
EXPECT_TRUE(extension.InitFromValue(input_value, false, &error));
EXPECT_EQ("", error);
std::wstring localized_name(name);
- base::i18n::AdjustStringForLocaleDirection(localized_name, &localized_name);
+ base::i18n::AdjustStringForLocaleDirection(&localized_name);
EXPECT_EQ(localized_name, UTF8ToWide(extension.name()));
// Strong RTL characters in name.
@@ -392,7 +392,7 @@ TEST(ExtensionTest, InitFromValueValidNameInRTL) {
EXPECT_TRUE(extension.InitFromValue(input_value, false, &error));
EXPECT_EQ("", error);
localized_name = name;
- base::i18n::AdjustStringForLocaleDirection(localized_name, &localized_name);
+ base::i18n::AdjustStringForLocaleDirection(&localized_name);
EXPECT_EQ(localized_name, UTF8ToWide(extension.name()));
// Reset locale.
diff --git a/gfx/canvas_skia_win.cc b/gfx/canvas_skia_win.cc
index 1a65da0..dd8c96a 100644
--- a/gfx/canvas_skia_win.cc
+++ b/gfx/canvas_skia_win.cc
@@ -19,17 +19,18 @@ void DoDrawText(HDC hdc,
const std::wstring& text,
RECT* text_bounds,
int flags) {
- std::wstring localized_text;
- const wchar_t* string_ptr = text.c_str();
- int string_size = static_cast<int>(text.length());
// Only adjust string directionality if both of the following are true:
// 1. The current locale is RTL.
// 2. The string itself has RTL directionality.
+ const wchar_t* string_ptr = text.c_str();
+ int string_size = static_cast<int>(text.length());
+
+ std::wstring localized_text;
if (flags & DT_RTLREADING) {
- if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text)) {
- string_ptr = localized_text.c_str();
- string_size = static_cast<int>(localized_text.length());
- }
+ localized_text = text;
+ base::i18n::AdjustStringForLocaleDirection(&localized_text);
+ string_ptr = localized_text.c_str();
+ string_size = static_cast<int>(localized_text.length());
}
DrawText(hdc, string_ptr, string_size, text_bounds, flags);
diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc
index 89dae9c..e1693d3 100644
--- a/views/controls/button/native_button.cc
+++ b/views/controls/button/native_button.cc
@@ -74,9 +74,7 @@ void NativeButton::SetLabel(const std::wstring& label) {
// In order to overcome this problem, we mark the localized Hebrew strings as
// RTL strings explicitly (using the appropriate Unicode formatting) so that
// Windows displays the text correctly regardless of the HWND hierarchy.
- std::wstring localized_label;
- if (base::i18n::AdjustStringForLocaleDirection(label_, &localized_label))
- label_ = localized_label;
+ base::i18n::AdjustStringForLocaleDirection(&label_);
if (native_wrapper_)
native_wrapper_->UpdateLabel();
diff --git a/views/controls/combobox/native_combobox_win.cc b/views/controls/combobox/native_combobox_win.cc
index 720e51f..2134a75e 100644
--- a/views/controls/combobox/native_combobox_win.cc
+++ b/views/controls/combobox/native_combobox_win.cc
@@ -47,14 +47,12 @@ void NativeComboboxWin::UpdateFromModel() {
int max_width = 0;
int num_items = combobox_->model()->GetItemCount();
for (int i = 0; i < num_items; ++i) {
- const std::wstring& text = UTF16ToWide(combobox_->model()->GetItemAt(i));
+ std::wstring text = UTF16ToWide(combobox_->model()->GetItemAt(i));
// Inserting the Unicode formatting characters if necessary so that the
// text is displayed correctly in right-to-left UIs.
- std::wstring localized_text;
+ base::i18n::AdjustStringForLocaleDirection(&text);
const wchar_t* text_ptr = text.c_str();
- if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text))
- text_ptr = localized_text.c_str();
SendMessage(native_view(), CB_ADDSTRING, 0,
reinterpret_cast<LPARAM>(text_ptr));
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index 2109cb9..3f4b0eb 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -155,13 +155,11 @@ void NativeTextfieldWin::UpdateText() {
std::wstring text = textfield_->text();
// Adjusting the string direction before setting the text in order to make
// sure both RTL and LTR strings are displayed properly.
- std::wstring text_to_set;
- if (!base::i18n::AdjustStringForLocaleDirection(text, &text_to_set))
- text_to_set = text;
+ base::i18n::AdjustStringForLocaleDirection(&text);
if (textfield_->style() & Textfield::STYLE_LOWERCASE)
- text_to_set = l10n_util::ToLower(text_to_set);
- SetWindowText(text_to_set.c_str());
- UpdateAccessibleValue(text_to_set);
+ text = l10n_util::ToLower(text);
+ SetWindowText(text.c_str());
+ UpdateAccessibleValue(text);
}
void NativeTextfieldWin::AppendText(const string16& text) {
diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc
index 6b02a62..bfdd454 100644
--- a/views/controls/tree/tree_view.cc
+++ b/views/controls/tree/tree_view.cc
@@ -370,9 +370,7 @@ LRESULT TreeView::OnNotify(int w_param, LPNMHDR l_param) {
DCHECK(info->item.cchTextMax);
// Adjust the string direction if such adjustment is required.
- std::wstring localized_text;
- if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text))
- text.swap(localized_text);
+ base::i18n::AdjustStringForLocaleDirection(&text);
wcsncpy_s(info->item.pszText, info->item.cchTextMax, text.c_str(),
_TRUNCATE);
diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc
index c7ad4ff..8e51e64 100644
--- a/views/widget/tooltip_manager_win.cc
+++ b/views/widget/tooltip_manager_win.cc
@@ -173,8 +173,7 @@ LRESULT TooltipManagerWin::OnNotify(int w_param,
TrimTooltipToFit(&clipped_text_, &tooltip_width_, &line_count_,
screen_loc.x(), screen_loc.y());
// Adjust the clipped tooltip text for locale direction.
- base::i18n::AdjustStringForLocaleDirection(clipped_text_,
- &clipped_text_);
+ base::i18n::AdjustStringForLocaleDirection(&clipped_text_);
tooltip_info->lpszText = const_cast<WCHAR*>(clipped_text_.c_str());
} else {
tooltip_text_.clear();
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index d59d7a5..4f8a251 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -207,9 +207,7 @@ void WindowGtk::UpdateWindowTitle() {
// Update the native frame's text. We do this regardless of whether or not
// the native frame is being used, since this also updates the taskbar, etc.
std::wstring window_title = window_delegate_->GetWindowTitle();
- std::wstring localized_text;
- if (base::i18n::AdjustStringForLocaleDirection(window_title, &localized_text))
- window_title.assign(localized_text);
+ base::i18n::AdjustStringForLocaleDirection(&window_title);
gtk_window_set_title(GetNativeWindow(), WideToUTF8(window_title).c_str());
}
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 03bf75f..e940fdd 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -417,9 +417,7 @@ void WindowWin::UpdateWindowTitle() {
window_title = window_delegate_->GetAccessibleWindowTitle();
else
window_title = window_delegate_->GetWindowTitle();
- std::wstring localized_text;
- if (base::i18n::AdjustStringForLocaleDirection(window_title, &localized_text))
- window_title.assign(localized_text);
+ base::i18n::AdjustStringForLocaleDirection(&window_title);
SetWindowText(GetNativeView(), window_title.c_str());
// Also update the accessibility name.