diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-20 06:37:01 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-20 06:37:01 +0000 |
commit | 7cf1b6ced3b14cce1d66ca0ddc713851f0d37536 (patch) | |
tree | 1c2fc9f4d52bf3046addf820d5eec03a2e150749 /chrome/browser | |
parent | f9f4841b14a9f309ce5ee613f0d4de6afad88767 (diff) | |
download | chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.zip chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.tar.gz chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.tar.bz2 |
Move RTL related functions from app/l10n_util to base/i18n/rtl
TBR=darin
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1073005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
61 files changed, 193 insertions, 165 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 03ef0f0..fa547d3 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -20,6 +20,7 @@ #include "base/base_drag_source.h" #include "base/base_drop_target.h" #include "base/basictypes.h" +#include "base/i18n/rtl.h" #include "base/iat_patch.h" #include "base/keyboard_codes.h" #include "base/lazy_instance.h" @@ -1993,7 +1994,7 @@ LONG AutocompleteEditViewWin::ClipXCoordToVisibleText( // paragraph. bool ltr_text_in_ltr_layout = true; if ((pf2.wEffects & PFE_RTLPARA) || - l10n_util::StringContainsStrongRTLChars(GetText())) { + base::i18n::StringContainsStrongRTLChars(GetText())) { ltr_text_in_ltr_layout = false; } const int length = GetTextLength(); diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc index da54e88..b94c3b0 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc @@ -10,9 +10,9 @@ #include <string> #include "app/gfx/font.h" -#include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/utf_string_conversions.h" #include "chrome/browser/autocomplete/autocomplete.h" @@ -397,7 +397,7 @@ gboolean AutocompletePopupViewGtk::HandleButtonRelease(GtkWidget* widget, gboolean AutocompletePopupViewGtk::HandleExpose(GtkWidget* widget, GdkEventExpose* event) { - bool ltr = (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT); + bool ltr = !base::i18n::IsRTL(); const AutocompleteResult& result = model_->result(); gfx::Rect window_rect = GetWindowRect(event->window); diff --git a/chrome/browser/bookmarks/bookmark_table_model.cc b/chrome/browser/bookmarks/bookmark_table_model.cc index 4d8b01a..f7848e4 100644 --- a/chrome/browser/bookmarks/bookmark_table_model.cc +++ b/chrome/browser/bookmarks/bookmark_table_model.cc @@ -9,6 +9,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/table_model_observer.h" +#include "base/i18n/rtl.h" #include "base/i18n/time_formatting.h" #include "base/string_util.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -314,7 +315,7 @@ std::wstring BookmarkTableModel::GetText(int row, int column_id) { // TODO(xji): Consider adding a special case if the title text is a URL, // since those should always be displayed LTR. Please refer to // http://crbug.com/6726 for more information. - l10n_util::AdjustStringForLocaleDirection(title, &title); + base::i18n::AdjustStringForLocaleDirection(title, &title); return title; } @@ -326,8 +327,8 @@ std::wstring BookmarkTableModel::GetText(int row, int column_id) { : std::wstring(); std::wstring url_text = net::FormatUrl(node->GetURL(), languages, false, UnescapeRule::SPACES, NULL, NULL, NULL); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&url_text); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&url_text); return url_text; } @@ -353,8 +354,8 @@ std::wstring BookmarkTableModel::GetText(int row, int column_id) { // Firefox, IE, Nautilus, gedit choose to format only the whole path as // LTR too. The point here is to display the path the same way as it's // displayed by other software. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&path); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&path); return path; } } diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index 2c9f6ee..5981a66 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -5,6 +5,7 @@ #include <string> #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/sys_info.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/app_modal_dialog.h" @@ -135,9 +136,9 @@ class BrowserTest : public ExtensionBrowserTest { std::wstring page_title = WindowCaptionFromPageTitle(expected_title); #if defined(OS_WIN) std::string locale = g_browser_process->GetApplicationLocale(); - if (l10n_util::GetTextDirectionForLocale(locale.c_str()) == - l10n_util::RIGHT_TO_LEFT) { - l10n_util::WrapStringWithLTRFormatting(&page_title); + if (base::i18n::GetTextDirectionForLocale(locale.c_str()) == + base::i18n::RIGHT_TO_LEFT) { + base::i18n::WrapStringWithLTRFormatting(&page_title); } return page_title; diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index 7138288..833807a 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -12,6 +12,7 @@ #include "app/message_box_flags.h" #include "app/win_util.h" #include "base/command_line.h" +#include "base/i18n/rtl.h" #include "base/path_service.h" #include "base/win_util.h" #include "chrome/browser/first_run.h" @@ -132,7 +133,7 @@ void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) { dlg_strings.append(L"|"); dlg_strings.append(l10n_util::GetString(IDS_CRASH_RECOVERY_CONTENT)); dlg_strings.append(L"|"); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) dlg_strings.append(env_vars::kRtlLocale); else dlg_strings.append(env_vars::kLtrLocale); diff --git a/chrome/browser/browser_theme_provider_gtk.cc b/chrome/browser/browser_theme_provider_gtk.cc index cd8d26e..8052086 100644 --- a/chrome/browser/browser_theme_provider_gtk.cc +++ b/chrome/browser/browser_theme_provider_gtk.cc @@ -6,7 +6,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> -#include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "gfx/gtk_util.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -34,8 +34,7 @@ GdkPixbuf* BrowserThemeProvider::GetPixbufImpl(int id, bool rtl_enabled) const { // We loaded successfully. Cache the pixbuf. if (pixbuf) { - if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && - rtl_enabled) { + if (base::i18n::IsRTL() && rtl_enabled) { GdkPixbuf* original_pixbuf = pixbuf; pixbuf = gdk_pixbuf_flip(pixbuf, TRUE); g_object_unref(original_pixbuf); diff --git a/chrome/browser/chromeos/compact_location_bar_host.cc b/chrome/browser/chromeos/compact_location_bar_host.cc index 328549d..a412cb6 100644 --- a/chrome/browser/chromeos/compact_location_bar_host.cc +++ b/chrome/browser/chromeos/compact_location_bar_host.cc @@ -6,8 +6,8 @@ #include <algorithm> -#include "app/l10n_util.h" #include "app/slide_animation.h" +#include "base/i18n/rtl.h" #include "base/keyboard_codes.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_process.h" @@ -217,9 +217,8 @@ gfx::Rect CompactLocationBarHost::GetBoundsUnderTab(int index) const { view()->GetPreferredSize()); // For RTL case x() defines tab right corner. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) navbar_bounds.set_x(navbar_bounds.x() + bounds.width()); - } navbar_bounds.set_x(navbar_bounds.x() + tabstrip->x()); navbar_bounds.set_y(navbar_bounds.y() + tabstrip->y()); diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm index 032443f..affcdfab 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar_view_mac.mm @@ -6,6 +6,7 @@ #include "app/l10n_util_mac.h" #include "app/resource_bundle.h" +#include "base/i18n/rtl.h" #include "base/nsimage_cache_mac.h" #include "base/stl_util-inl.h" #include "base/string_util.h" @@ -82,7 +83,7 @@ std::wstring CalculateMinString(const std::wstring& description) { } else { min_string = description.substr(0, chop_index); } - l10n_util::AdjustStringForLocaleDirection(min_string, &min_string); + base::i18n::AdjustStringForLocaleDirection(min_string, &min_string); return min_string; } diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index 3fd2fca..7fd0179 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -13,6 +13,7 @@ #include "app/table_model_observer.h" #include "app/tree_node_model.h" #include "base/callback.h" +#include "base/i18n/rtl.h" #include "base/linked_ptr.h" #include "base/string_util.h" #include "chrome/browser/extensions/extensions_service.h" @@ -590,7 +591,7 @@ std::wstring CookiesTreeModel::FormExtensionNodeName( // "Great Extension!" the concatenated result would be something like // "!Great Extension :NOISNETXE", in which capital letters "NOISNETXE" // stand for the Hebrew word for "extension". - l10n_util::AdjustStringForLocaleDirection(extension_name, &extension_name); + base::i18n::AdjustStringForLocaleDirection(extension_name, &extension_name); return l10n_util::GetStringF(IDS_TASK_MANAGER_EXTENSION_PREFIX, extension_name); } diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc index 0fa68d4..46a26f4 100644 --- a/chrome/browser/dom_ui/chrome_url_data_manager.cc +++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/file_util.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/singleton.h" @@ -299,8 +300,7 @@ void ChromeURLDataManager::DataSource::SetFontAndTextDirection( l10n_util::GetString(web_font_size_id)); localized_strings->SetString(L"textdirection", - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - L"rtl" : L"ltr"); + base::i18n::IsRTL() ? L"rtl" : L"ltr"); } URLRequestJob* ChromeURLDataManager::Factory(URLRequest* request, diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc index 9a1e614..8f83db1 100644 --- a/chrome/browser/dom_ui/dom_ui.cc +++ b/chrome/browser/dom_ui/dom_ui.cc @@ -4,9 +4,10 @@ #include "chrome/browser/dom_ui/dom_ui.h" -#include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/json/json_writer.h" #include "base/stl_util-inl.h" +#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/browser_theme_provider.h" @@ -129,12 +130,12 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary, // as the title, we mark the title as LTR since URLs are always treated as // left to right strings. std::wstring title_to_set(title); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { if (using_url_as_the_title) { - l10n_util::WrapStringWithLTRFormatting(&title_to_set); + base::i18n::WrapStringWithLTRFormatting(&title_to_set); } else { bool success = - l10n_util::AdjustStringForLocaleDirection(title, &title_to_set); + base::i18n::AdjustStringForLocaleDirection(title, &title_to_set); DCHECK(success ? (title != title_to_set) : (title == title_to_set)); } } diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 7b01684..ecf009a 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -12,6 +12,7 @@ #include "base/callback.h" #include "base/command_line.h" #include "base/histogram.h" +#include "base/i18n/rtl.h" #include "base/singleton.h" #include "base/thread.h" #include "chrome/browser/browser.h" @@ -643,15 +644,15 @@ void NewTabUI::SetURLTitleAndDirection(DictionaryValue* dictionary, // example, without LRE-PDF pair, the title "Yahoo!" will be rendered as // "!Yahoo" within the tooltip when the mouse is over the title link. std::wstring direction = kDefaultHtmlTextDirection; - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { if (using_url_as_the_title) { - l10n_util::WrapStringWithLTRFormatting(&title_to_set); + base::i18n::WrapStringWithLTRFormatting(&title_to_set); } else { - if (l10n_util::StringContainsStrongRTLChars(wstring_title)) { - l10n_util::WrapStringWithRTLFormatting(&title_to_set); + if (base::i18n::StringContainsStrongRTLChars(wstring_title)) { + base::i18n::WrapStringWithRTLFormatting(&title_to_set); direction = kRTLHtmlTextDirection; } else { - l10n_util::WrapStringWithLTRFormatting(&title_to_set); + base::i18n::WrapStringWithLTRFormatting(&title_to_set); } } } diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc index 7371c8c..b69d85f 100644 --- a/chrome/browser/download/download_item_model.cc +++ b/chrome/browser/download/download_item_model.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/i18n/number_formatting.h" +#include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/save_package.h" @@ -38,8 +39,8 @@ std::wstring DownloadItemModel::GetStatusText() { // we mark the total string as an LTR string if the UI layout is // right-to-left so that the string "456 MB" is treated as an LTR run. std::wstring simple_total = FormatBytes(total, amount_units, true); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&simple_total); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&simple_total); TimeDelta remaining; std::wstring simple_time; diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index b839074..b8619e4 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -15,6 +15,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/file_util.h" +#include "base/i18n/rtl.h" #include "base/i18n/time_formatting.h" #include "base/path_service.h" #include "base/singleton.h" @@ -366,8 +367,8 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) { file_value->SetString(L"file_path", download->full_path().ToWStringHack()); // Keep file names as LTR. std::wstring file_name = download->GetFileName().ToWStringHack(); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&file_name); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&file_name); file_value->SetString(L"file_name", file_name); file_value->SetString(L"url", download->url().spec()); file_value->SetBoolean(L"otr", download->is_otr()); @@ -414,7 +415,7 @@ 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 (l10n_util::AdjustStringForLocaleDirection(amount, &amount_localized)) { + if (base::i18n::AdjustStringForLocaleDirection(amount, &amount_localized)) { amount.assign(amount_localized); received_size.assign(amount_localized); } @@ -423,8 +424,8 @@ std::wstring GetProgressStatusText(DownloadItem* download) { amount_units = GetByteDisplayUnits(total); std::wstring total_text = FormatBytes(total, amount_units, true); std::wstring total_text_localized; - if (l10n_util::AdjustStringForLocaleDirection(total_text, - &total_text_localized)) + if (base::i18n::AdjustStringForLocaleDirection(total_text, + &total_text_localized)) total_text.assign(total_text_localized); amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, @@ -437,8 +438,8 @@ std::wstring GetProgressStatusText(DownloadItem* download) { std::wstring speed_text = FormatSpeed(download->CurrentSpeed(), amount_units, true); std::wstring speed_text_localized; - if (l10n_util::AdjustStringForLocaleDirection(speed_text, - &speed_text_localized)) + if (base::i18n::AdjustStringForLocaleDirection(speed_text, + &speed_text_localized)) speed_text.assign(speed_text_localized); base::TimeDelta remaining; diff --git a/chrome/browser/encoding_menu_controller.cc b/chrome/browser/encoding_menu_controller.cc index cfb59cf..9667f5f 100644 --- a/chrome/browser/encoding_menu_controller.cc +++ b/chrome/browser/encoding_menu_controller.cc @@ -5,6 +5,7 @@ #include "chrome/browser/encoding_menu_controller.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser_process.h" @@ -135,8 +136,8 @@ void EncodingMenuController::GetEncodingMenuItems(Profile* profile, if (it->encoding_id) { std::wstring encoding = it->encoding_display_name; std::wstring bidi_safe_encoding; - if (l10n_util::AdjustStringForLocaleDirection(encoding, - &bidi_safe_encoding)) + if (base::i18n::AdjustStringForLocaleDirection(encoding, + &bidi_safe_encoding)) encoding.swap(bidi_safe_encoding); menuItems->push_back(EncodingMenuItem(it->encoding_id, WideToUTF16(encoding))); diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 70ac7fc..e6d1211 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -6,8 +6,8 @@ #include <string> -#include "app/l10n_util.h" #include "app/win_util.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/win_util.h" #include "chrome/app/chrome_dll_resource.h" @@ -539,7 +539,7 @@ bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) { ipc_params.page_url = params.page_url; ipc_params.frame_url = params.frame_url; - bool rtl = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; + bool rtl = base::i18n::IsRTL(); automation_->Send( new AutomationMsg_ForwardContextMenuToExternalHost(0, tab_handle_, external_context_menu_->GetMenuHandle(), diff --git a/chrome/browser/find_bar_controller.cc b/chrome/browser/find_bar_controller.cc index b7ddf69..b56b929 100644 --- a/chrome/browser/find_bar_controller.cc +++ b/chrome/browser/find_bar_controller.cc @@ -4,7 +4,7 @@ #include "chrome/browser/find_bar_controller.h" -#include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "build/build_config.h" #include "chrome/browser/find_bar.h" #include "chrome/browser/tab_contents/navigation_entry.h" @@ -154,7 +154,7 @@ gfx::Rect FindBarController::GetLocationForFindbarView( gfx::Rect view_location, const gfx::Rect& dialog_bounds, const gfx::Rect& avoid_overlapping_rect) { - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { int boundary = dialog_bounds.width() - view_location.width(); view_location.set_x(std::min(view_location.x(), boundary)); } else { @@ -168,7 +168,7 @@ gfx::Rect FindBarController::GetLocationForFindbarView( // rectangle. if (!avoid_overlapping_rect.IsEmpty() && avoid_overlapping_rect.Intersects(new_pos)) { - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { new_pos.set_x(avoid_overlapping_rect.x() + avoid_overlapping_rect.width() + (2 * kMinFindWndDistanceFromSelection)); diff --git a/chrome/browser/gtk/bookmark_bubble_gtk.cc b/chrome/browser/gtk/bookmark_bubble_gtk.cc index 8c6e13a..3e09a4a 100644 --- a/chrome/browser/gtk/bookmark_bubble_gtk.cc +++ b/chrome/browser/gtk/bookmark_bubble_gtk.cc @@ -9,6 +9,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/message_loop.h" #include "chrome/browser/bookmarks/bookmark_editor.h" @@ -221,7 +222,7 @@ BookmarkBubbleGtk::BookmarkBubbleGtk(GtkWindow* toplevel_window, gtk_container_set_focus_child(GTK_CONTAINER(content), table); InfoBubbleGtk::ArrowLocationGtk arrow_location = - (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) ? + !base::i18n::IsRTL() ? InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT : InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT; bubble_ = InfoBubbleGtk::Show(toplevel_window_, diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index a3a5e5d..997d20d 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -13,6 +13,7 @@ #include "app/menus/accelerator_gtk.h" #include "app/resource_bundle.h" #include "base/base_paths.h" +#include "base/i18n/rtl.h" #include "base/keyboard_codes_posix.h" #include "base/logging.h" #include "base/path_service.h" @@ -449,7 +450,7 @@ gfx::Rect BrowserToolbarGtk::GetLocationStackBounds() const { GtkWidget* left; GtkWidget* right; - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { left = go_->widget(); right = star_->widget(); } else { diff --git a/chrome/browser/gtk/content_blocked_bubble_gtk.cc b/chrome/browser/gtk/content_blocked_bubble_gtk.cc index 956e014..5f083c21 100644 --- a/chrome/browser/gtk/content_blocked_bubble_gtk.cc +++ b/chrome/browser/gtk/content_blocked_bubble_gtk.cc @@ -5,6 +5,7 @@ #include "chrome/browser/gtk/content_blocked_bubble_gtk.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "chrome/browser/blocked_popup_container.h" #include "chrome/browser/content_setting_bubble_model.h" #include "chrome/browser/gtk/gtk_chrome_link_button.h" @@ -165,7 +166,7 @@ void ContentSettingBubbleGtk::BuildBubble() { gtk_box_pack_start(GTK_BOX(bubble_content), bottom_box, FALSE, FALSE, 0); InfoBubbleGtk::ArrowLocationGtk arrow_location = - (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) ? + !base::i18n::IsRTL() ? InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT : InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT; info_bubble_ = InfoBubbleGtk::Show( diff --git a/chrome/browser/gtk/edit_search_engine_dialog.cc b/chrome/browser/gtk/edit_search_engine_dialog.cc index f639f0c..1978862 100644 --- a/chrome/browser/gtk/edit_search_engine_dialog.cc +++ b/chrome/browser/gtk/edit_search_engine_dialog.cc @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" @@ -182,7 +183,7 @@ void EditSearchEngineDialog::Init(GtkWindow* parent_window, Profile* profile) { // is displayed correctly when rendered in an RTL context. std::string description = l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { const std::string reversed_percent("s%"); std::wstring::size_type percent_index = description.find("%s", static_cast<std::string::size_type>(0)); diff --git a/chrome/browser/gtk/extension_installed_bubble_gtk.cc b/chrome/browser/gtk/extension_installed_bubble_gtk.cc index 8cf8bb2..2ac515f 100644 --- a/chrome/browser/gtk/extension_installed_bubble_gtk.cc +++ b/chrome/browser/gtk/extension_installed_bubble_gtk.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "chrome/browser/browser.h" #include "chrome/browser/gtk/browser_actions_toolbar_gtk.h" @@ -202,7 +203,7 @@ void ExtensionInstalledBubbleGtk::ShowInternal() { FALSE, FALSE, 0); InfoBubbleGtk::ArrowLocationGtk arrow_location = - (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) ? + !base::i18n::IsRTL() ? InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT : InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT; info_bubble_ = InfoBubbleGtk::Show(browser_window->window(), diff --git a/chrome/browser/gtk/extension_popup_gtk.cc b/chrome/browser/gtk/extension_popup_gtk.cc index 2d25d96..878e6db 100644 --- a/chrome/browser/gtk/extension_popup_gtk.cc +++ b/chrome/browser/gtk/extension_popup_gtk.cc @@ -6,7 +6,7 @@ #include <gtk/gtk.h> -#include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/profile.h" @@ -74,7 +74,7 @@ void ExtensionPopupGtk::ShowPopup() { // want to put the arrow at the upper-right corner of the bubble to match the // page and app menus. InfoBubbleGtk::ArrowLocationGtk arrow_location = - (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) ? + !base::i18n::IsRTL() ? InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT : InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT; bubble_ = InfoBubbleGtk::Show(browser_->window()->GetNativeHandle(), diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 965dcf9..39b6511 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/i18n/rtl.h" #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/find_bar_controller.h" @@ -73,7 +74,7 @@ std::vector<GdkPoint> MakeFramePolygonPoints(int width, using gtk_util::MakeBidiGdkPoint; std::vector<GdkPoint> points; - bool ltr = l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT; + bool ltr = !base::i18n::IsRTL(); // If we have a stroke, we have to offset some of our points by 1 pixel. // We have to inset by 1 pixel when we draw horizontal lines that are on the // bottom or when we draw vertical lines that are closer to the end (end is @@ -404,7 +405,7 @@ void FindBarGtk::AudibleAlert() { } gfx::Rect FindBarGtk::GetDialogPosition(gfx::Rect avoid_overlapping_rect) { - bool ltr = l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT; + bool ltr = !base::i18n::IsRTL(); // 15 is the size of the scrollbar, copied from ScrollbarThemeChromium. // The height is not used. // At very low browser widths we can wind up with a negative |dialog_bounds| @@ -838,7 +839,7 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, GtkAllocation border_allocation = bar->border_bin_->allocation; // Blit the left part of the background image once on the left. - bool rtl = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; + bool rtl = base::i18n::IsRTL(); CairoCachedSurface* background_left = bar->theme_provider_->GetSurfaceNamed( rtl ? IDR_FIND_BOX_BACKGROUND_LEFT_RTL : IDR_FIND_BOX_BACKGROUND_LEFT, widget); diff --git a/chrome/browser/gtk/first_run_bubble.cc b/chrome/browser/gtk/first_run_bubble.cc index b2989d6..d70c94c 100644 --- a/chrome/browser/gtk/first_run_bubble.cc +++ b/chrome/browser/gtk/first_run_bubble.cc @@ -8,6 +8,7 @@ #include "app/gtk_util.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/options_window.h" @@ -148,7 +149,7 @@ FirstRunBubble::FirstRunBubble(Profile* profile, gtk_widget_grab_focus(keep_button); InfoBubbleGtk::ArrowLocationGtk arrow_location = - (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) ? + !base::i18n::IsRTL() ? InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT : InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT; bubble_ = InfoBubbleGtk::Show(parent_, diff --git a/chrome/browser/gtk/go_button_gtk.cc b/chrome/browser/gtk/go_button_gtk.cc index eba8f82..2df9932 100644 --- a/chrome/browser/gtk/go_button_gtk.cc +++ b/chrome/browser/gtk/go_button_gtk.cc @@ -5,6 +5,7 @@ #include "chrome/browser/gtk/go_button_gtk.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/message_loop.h" #include "chrome/app/chrome_dll_resource.h" @@ -175,8 +176,8 @@ gboolean GoButtonGtk::OnQueryTooltip(GtkTooltip* tooltip) { std::string text; if (visible_mode_ == MODE_GO) { std::wstring current_text_wstr(location_bar_->location_entry()->GetText()); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(¤t_text_wstr); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(¤t_text_wstr); string16 current_text = WideToUTF16Hack( l10n_util::TruncateString(current_text_wstr, kMaxTooltipTextLength)); diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc index ea46705..305a411 100644 --- a/chrome/browser/gtk/gtk_util.cc +++ b/chrome/browser/gtk/gtk_util.cc @@ -11,9 +11,9 @@ #include <map> #include "app/gtk_util.h" -#include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/x11_util.h" +#include "base/i18n/rtl.h" #include "base/linux_util.h" #include "base/logging.h" #include "chrome/browser/browser_list.h" @@ -504,16 +504,14 @@ void SetButtonTriggersNavigation(GtkWidget* button) { } int MirroredLeftPointForRect(GtkWidget* widget, const gfx::Rect& bounds) { - if (l10n_util::GetTextDirection() != l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) return bounds.x(); - } return widget->allocation.width - bounds.x() - bounds.width(); } int MirroredXCoordinate(GtkWidget* widget, int x) { - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) return widget->allocation.width - x; - } return x; } diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index 815bb2f..dabdf18 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -10,6 +10,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/string_util.h" #include "chrome/app/chrome_dll_resource.h" @@ -120,7 +121,7 @@ std::wstring CalculateMinString(const std::wstring& description) { } else { min_string = description.substr(0, chop_index); } - l10n_util::AdjustStringForLocaleDirection(min_string, &min_string); + base::i18n::AdjustStringForLocaleDirection(min_string, &min_string); return min_string; } @@ -841,7 +842,7 @@ void LocationBarViewGtk::ShowFirstRunBubbleInternal(bool use_OEM_bubble) { // of star button, so shift x and y co-ordinates. int y_offset = widget()->allocation.height + kFirstRunBubbleTopMargin; int x_offset = 0; - if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) + if (!base::i18n::IsRTL()) x_offset = kFirstRunBubbleLeftMargin; else x_offset = widget()->allocation.width - kFirstRunBubbleLeftMargin; diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc index acc325c..dd6945d 100644 --- a/chrome/browser/gtk/menu_gtk.cc +++ b/chrome/browser/gtk/menu_gtk.cc @@ -9,6 +9,7 @@ #include "app/l10n_util.h" #include "app/menus/accelerator_gtk.h" #include "app/menus/menu_model.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/stl_util-inl.h" @@ -459,7 +460,7 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu, bool start_align = !!g_object_get_data(G_OBJECT(widget), "left-align-popup"); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) start_align = !start_align; if (!start_align) diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc index a0f8f40..973d3c5 100644 --- a/chrome/browser/gtk/nine_box.cc +++ b/chrome/browser/gtk/nine_box.cc @@ -4,10 +4,10 @@ #include "chrome/browser/gtk/nine_box.h" -#include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" #include "base/basictypes.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "gfx/gtk_util.h" #include "gfx/point.h" @@ -132,7 +132,7 @@ void NineBox::RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const { cairo_translate(cr, dst->allocation.x, dst->allocation.y); } - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { cairo_translate(cr, dst_width, 0.0f); cairo_scale(cr, -1.0f, 1.0f); } @@ -224,7 +224,7 @@ void NineBox::ContourWidget(GtkWidget* widget) const { cairo_destroy(cr); // Mask the widget's window's shape. - if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) { + if (!base::i18n::IsRTL()) { gtk_widget_shape_combine_mask(widget, mask, 0, 0); } else { GdkBitmap* flipped_mask = gdk_pixmap_new(NULL, width, height, 1); diff --git a/chrome/browser/gtk/rounded_window.cc b/chrome/browser/gtk/rounded_window.cc index 06cae21..540a465 100644 --- a/chrome/browser/gtk/rounded_window.cc +++ b/chrome/browser/gtk/rounded_window.cc @@ -7,7 +7,7 @@ #include <gtk/gtk.h> #include <math.h> -#include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "chrome/browser/gtk/gtk_util.h" namespace gtk_util { @@ -60,7 +60,7 @@ std::vector<GdkPoint> MakeFramePolygonPoints(RoundedWindowData* data, std::vector<GdkPoint> points; - bool ltr = l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT; + bool ltr = !base::i18n::IsRTL(); // If we have a stroke, we have to offset some of our points by 1 pixel. // We have to inset by 1 pixel when we draw horizontal lines that are on the // bottom or when we draw vertical lines that are closer to the end (end is diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc index 076cff5..fa7742b3 100644 --- a/chrome/browser/gtk/status_bubble_gtk.cc +++ b/chrome/browser/gtk/status_bubble_gtk.cc @@ -8,8 +8,8 @@ #include <algorithm> -#include "app/l10n_util.h" #include "app/text_elider.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "chrome/browser/gtk/gtk_theme_provider.h" @@ -157,7 +157,7 @@ void StatusBubbleGtk::MouseMoved( if (!toplevel || !GTK_WIDGET_REALIZED(toplevel)) return; - bool ltr = (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT); + bool ltr = !base::i18n::IsRTL(); GtkRequisition requisition; gtk_widget_size_request(container_.get(), &requisition); @@ -219,7 +219,7 @@ void StatusBubbleGtk::Observe(NotificationType type, } void StatusBubbleGtk::InitWidgets() { - bool ltr = (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT); + bool ltr = !base::i18n::IsRTL(); label_ = gtk_label_new(NULL); @@ -275,7 +275,7 @@ void StatusBubbleGtk::SetFlipHorizontally(bool flip_horizontally) { flip_horizontally_ = flip_horizontally; - bool ltr = (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT); + bool ltr = !base::i18n::IsRTL(); bool on_left = (ltr && !flip_horizontally) || (!ltr && flip_horizontally); gtk_alignment_set_padding(GTK_ALIGNMENT(padding_), diff --git a/chrome/browser/gtk/tab_contents_container_gtk.cc b/chrome/browser/gtk/tab_contents_container_gtk.cc index 3760f86..af83a0e 100644 --- a/chrome/browser/gtk/tab_contents_container_gtk.cc +++ b/chrome/browser/gtk/tab_contents_container_gtk.cc @@ -4,7 +4,7 @@ #include "chrome/browser/gtk/tab_contents_container_gtk.h" -#include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "chrome/browser/gtk/gtk_expanded_container.h" #include "chrome/browser/gtk/gtk_floating_container.h" #include "chrome/browser/gtk/status_bubble_gtk.h" @@ -167,7 +167,7 @@ void TabContentsContainerGtk::OnSetFloatingPosition( GtkRequisition requisition; gtk_widget_size_request(status->widget(), &requisition); - bool ltr = (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT); + bool ltr = !base::i18n::IsRTL(); GValue value = { 0, }; g_value_init(&value, G_TYPE_INT); diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc index c11e3f4..2093fda 100644 --- a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc +++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc @@ -9,8 +9,8 @@ #include <algorithm> #include "app/gfx/canvas_paint.h" -#include "app/l10n_util.h" #include "app/x11_util.h" +#include "base/i18n/rtl.h" #include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h" @@ -160,7 +160,7 @@ void DraggedTabGtk::Layout() { renderer_->SetBounds(gfx::Rect(0, 0, prefsize.width(), prefsize.height())); } else { int left = 0; - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) left = GetPreferredSize().width() - attached_tab_size_.width(); // The renderer_'s width should be attached_tab_size_.width() in both LTR diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 11e4521..e7e2ac6 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -8,9 +8,9 @@ #include "app/gfx/canvas_paint.h" #include "app/gtk_dnd_util.h" -#include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/slide_animation.h" +#include "base/i18n/rtl.h" #include "base/string_util.h" #include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/browser_theme_provider.h" @@ -1239,7 +1239,7 @@ int TabStripGtk::GetMiniTabCount() const { } int TabStripGtk::GetAvailableWidthForTabs(TabGtk* last_tab) const { - if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) + if (!base::i18n::IsRTL()) return last_tab->x() - bounds_.x() + last_tab->width(); else return bounds_.width() - last_tab->x(); diff --git a/chrome/browser/language_combobox_model.cc b/chrome/browser/language_combobox_model.cc index 95d9598..9d256e7 100644 --- a/chrome/browser/language_combobox_model.cc +++ b/chrome/browser/language_combobox_model.cc @@ -5,6 +5,7 @@ #include "chrome/browser/language_combobox_model.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/metrics/user_metrics.h" @@ -86,16 +87,16 @@ std::wstring LanguageList::GetLanguageNameAt(int index) const { // parentheses or languages appearing in the wrong order. std::wstring locale_name_localized; std::wstring locale_name; - if (l10n_util::AdjustStringForLocaleDirection(locale_names_[index], - &locale_name_localized)) + 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 native_name_localized; std::wstring native_name; - if (l10n_util::AdjustStringForLocaleDirection(it->second.native_name, - &native_name_localized)) + 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); @@ -106,7 +107,7 @@ std::wstring LanguageList::GetLanguageNameAt(int index) const { std::wstring formatted_item; SStringPrintf(&formatted_item, L"%ls - %ls", locale_name.c_str(), native_name.c_str()); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) // Somehow combo box (even with LAYOUTRTL flag) doesn't get this // right so we add RTL BDO (U+202E) to set the direction // explicitly. diff --git a/chrome/browser/possible_url_model.cc b/chrome/browser/possible_url_model.cc index a8bc57b..2f4fdc8 100644 --- a/chrome/browser/possible_url_model.cc +++ b/chrome/browser/possible_url_model.cc @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "app/table_model_observer.h" #include "base/callback.h" +#include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/cancelable_request.h" #include "chrome/browser/favicon_service.h" @@ -113,7 +114,7 @@ std::wstring PossibleURLModel::GetText(int row, int col_id) { // since those should always have LTR directionality. Please refer to // http://crbug.com/6726 for more information. std::wstring localized_title; - if (l10n_util::AdjustStringForLocaleDirection(title, &localized_title)) + if (base::i18n::AdjustStringForLocaleDirection(title, &localized_title)) return localized_title; return title; } @@ -121,11 +122,11 @@ std::wstring PossibleURLModel::GetText(int row, int col_id) { // TODO(brettw): this should probably pass the GURL up so the URL elider // can be used at a higher level when we know the width. const string16& url = results_[row].display_url.display_url(); - if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) + if (!base::i18n::IsRTL()) return UTF16ToWideHack(url); // Force URL to be LTR. std::wstring localized_url = UTF16ToWideHack(url); - l10n_util::WrapStringWithLTRFormatting(&localized_url); + base::i18n::WrapStringWithLTRFormatting(&localized_url); return localized_url; } diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index f4e297c..ed12fda 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -8,8 +8,8 @@ #include <utility> #include <vector> -#include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/i18n/rtl.h" #include "base/json/json_reader.h" #include "base/stats_counters.h" #include "base/string_util.h" @@ -1297,13 +1297,13 @@ void RenderViewHost::OnMsgSetTooltipText( std::wstring wrapped_tooltip_text = tooltip_text; if (!tooltip_text.empty()) { if (text_direction_hint == WebKit::WebTextDirectionLeftToRight && - l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + base::i18n::IsRTL()) { // Force the tooltip to have LTR directionality. - l10n_util::WrapStringWithLTRFormatting(&wrapped_tooltip_text); + base::i18n::WrapStringWithLTRFormatting(&wrapped_tooltip_text); } else if (text_direction_hint == WebKit::WebTextDirectionRightToLeft && - l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) { + !base::i18n::IsRTL()) { // Force the tooltip to have RTL directionality. - l10n_util::WrapStringWithRTLFormatting(&wrapped_tooltip_text); + base::i18n::WrapStringWithRTLFormatting(&wrapped_tooltip_text); } } if (view()) diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 3996a8a..84e190f 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "base/command_line.h" #include "base/histogram.h" +#include "base/i18n/rtl.h" #include "base/process_util.h" #include "base/thread.h" #include "base/win_util.h" @@ -558,7 +559,7 @@ void RenderWidgetHostViewWin::UpdateCursorIfOverSelf() { BOOL result = ::ScreenToClient(m_hWnd, &pt); DCHECK(result); if (render_widget_host_->GetRootWindowResizerRect().Contains(pt.x, pt.y)) { - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) SetCursor(kCursorResizeLeft); else SetCursor(kCursorResizeRight); @@ -651,8 +652,7 @@ void RenderWidgetHostViewWin::DrawResizeCorner(const gfx::Rect& paint_rect, canvas.getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); int x = resize_corner_rect.x() + resize_corner_rect.width() - bitmap->width(); - bool rtl_dir = (l10n_util::GetTextDirection() == - l10n_util::RIGHT_TO_LEFT); + bool rtl_dir = base::i18n::IsRTL(); if (rtl_dir) { canvas.TranslateInt(bitmap->width(), 0); canvas.ScaleInt(-1, 1); @@ -1235,7 +1235,7 @@ LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam, render_widget_host_->GetRootWindowResizerRect(). Contains(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam))) { WPARAM wparam = HTBOTTOMRIGHT; - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) wparam = HTBOTTOMLEFT; HWND root_hwnd = ::GetAncestor(m_hWnd, GA_ROOT); if (SendMessage(root_hwnd, WM_NCLBUTTONDOWN, wparam, lparam) == 0) diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index d37c6ce..f5ef76e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -11,6 +11,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/histogram.h" +#include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/chrome_thread.h" @@ -238,9 +239,7 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON)); strings->SetString(L"back_button", l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); - strings->SetString(L"textdirection", - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - L"rtl" : L"ltr"); + strings->SetString(L"textdirection", base::i18n::IsRTL() ? L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( @@ -280,9 +279,7 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON)); strings->SetString(L"back_button", l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); - strings->SetString(L"textdirection", - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - L"rtl" : L"ltr"); + strings->SetString(L"textdirection", base::i18n::IsRTL() ? L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( @@ -303,9 +300,7 @@ void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON)); strings->SetString(L"report_error", l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR)); - strings->SetString(L"textdirection", - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - L"rtl" : L"ltr"); + strings->SetString(L"textdirection", base::i18n::IsRTL() ? L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) { diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index 09201d6..fe83561 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/i18n/icu_string_conversions.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" @@ -546,8 +547,8 @@ bool TemplateURL::SupportsReplacement(const TemplateURL* turl) { std::wstring TemplateURL::AdjustedShortNameForLocaleDirection() const { std::wstring bidi_safe_short_name; - if (l10n_util::AdjustStringForLocaleDirection(short_name_, - &bidi_safe_short_name)) + if (base::i18n::AdjustStringForLocaleDirection(short_name_, + &bidi_safe_short_name)) return bidi_safe_short_name; return short_name_; } diff --git a/chrome/browser/search_engines/template_url_table_model.cc b/chrome/browser/search_engines/template_url_table_model.cc index 84ce653..961506e 100644 --- a/chrome/browser/search_engines/template_url_table_model.cc +++ b/chrome/browser/search_engines/template_url_table_model.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "app/table_model_observer.h" #include "base/callback.h" +#include "base/i18n/rtl.h" #include "base/stl_util-inl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/favicon_service.h" @@ -180,8 +181,8 @@ 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. - l10n_util::AdjustStringForLocaleDirection(url_short_name, - &url_short_name); + base::i18n::AdjustStringForLocaleDirection(url_short_name, + &url_short_name); return (template_url_model_->GetDefaultSearchProvider() == &url) ? l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, url_short_name) : url_short_name; @@ -190,9 +191,9 @@ std::wstring TemplateURLTableModel::GetText(int row, int col_id) { case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { const std::wstring& keyword = url.keyword(); // Keyword should be domain name. Force it to have LTR directionality. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { std::wstring localized_keyword = keyword; - l10n_util::WrapStringWithLTRFormatting(&localized_keyword); + base::i18n::WrapStringWithLTRFormatting(&localized_keyword); return localized_keyword; } return keyword; diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc index 0746d61..904c083 100644 --- a/chrome/browser/ssl/ssl_blocking_page.cc +++ b/chrome/browser/ssl/ssl_blocking_page.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/histogram.h" +#include "base/i18n/rtl.h" #include "base/string_piece.h" #include "base/values.h" #include "chrome/browser/browser.h" @@ -78,9 +79,7 @@ std::string SSLBlockingPage::GetHTMLContents() { strings.SetString(L"exit", l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT)); - strings.SetString(L"textdirection", - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - L"rtl" : L"ltr"); + strings.SetString(L"textdirection", base::i18n::IsRTL() ? L"rtl" : L"ltr"); static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc index 0612558..2f21e5d 100644 --- a/chrome/browser/ssl/ssl_policy.cc +++ b/chrome/browser/ssl/ssl_policy.cc @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "base/base_switches.h" #include "base/command_line.h" +#include "base/i18n/rtl.h" #include "base/singleton.h" #include "base/string_piece.h" #include "base/string_util.h" @@ -218,9 +219,7 @@ void SSLPolicy::ShowErrorPage(SSLCertErrorHandler* handler) { strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK)); - strings.SetString(L"textdirection", - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - L"rtl" : L"ltr"); + strings.SetString(L"textdirection", base::i18n::IsRTL() ? L"rtl" : L"ltr"); static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 384cdd1..c8d3e95 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -9,6 +9,7 @@ #include "app/text_elider.h" #include "base/auto_reset.h" #include "base/file_version_info.h" +#include "base/i18n/rtl.h" #include "base/process_util.h" #include "base/string16.h" #include "base/string_util.h" @@ -2855,8 +2856,8 @@ std::wstring TabContents::GetMessageBoxTitle(const GURL& frame_url, std::wstring base_address = gfx::ElideUrl(clean_url, gfx::Font(), 0, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); // Force URL to have LTR directionality. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&base_address); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&base_address); return l10n_util::GetStringF( is_alert ? IDS_JAVASCRIPT_ALERT_TITLE : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index 6453663..533a696 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "base/compiler_specific.h" #include "base/i18n/number_formatting.h" +#include "base/i18n/rtl.h" #include "base/process_util.h" #include "base/stats_table.h" #include "base/string_util.h" @@ -122,8 +123,8 @@ std::wstring TaskManagerModel::GetResourceNetworkUsage(int index) const { std::wstring net_byte = FormatSpeed(net_usage, GetByteDisplayUnits(net_usage), true); // Force number string to have LTR directionality. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&net_byte); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&net_byte); return net_byte; } @@ -450,7 +451,7 @@ std::wstring TaskManagerModel::GetMemCellText(int64 number) const { std::wstring str = UTF16ToWide(base::FormatNumber(number / 1024)); // Adjust number string if necessary. - l10n_util::AdjustStringForLocaleDirection(str, &str); + base::i18n::AdjustStringForLocaleDirection(str, &str); return l10n_util::GetStringF(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_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc index f1ffefd..8d43db0 100644 --- a/chrome/browser/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager_resource_providers.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "base/basictypes.h" #include "base/file_version_info.h" +#include "base/i18n/rtl.h" #include "base/process_util.h" #include "base/stl_util-inl.h" #include "base/string_util.h" @@ -73,8 +74,8 @@ std::wstring TaskManagerTabContentsResource::GetTitle() const { if (tab_title.empty()) { tab_title = UTF8ToWide(tab_contents_->GetURL().spec()); // Force URL to be LTR. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&tab_title); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&tab_title); } else { // Since the tab_title will be concatenated with // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to @@ -85,7 +86,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". - l10n_util::AdjustStringForLocaleDirection(tab_title, &tab_title); + base::i18n::AdjustStringForLocaleDirection(tab_title, &tab_title); } return l10n_util::GetStringF(IDS_TASK_MANAGER_TAB_PREFIX, tab_title); @@ -532,7 +533,7 @@ TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( // "Great Extension!" the concatenated result would be something like // "!Great Extension :NOISNETXE", in which capital letters "NOISNETXE" // stand for the Hebrew word for "extension". - l10n_util::AdjustStringForLocaleDirection(extension_name, &extension_name); + base::i18n::AdjustStringForLocaleDirection(extension_name, &extension_name); title_ = l10n_util::GetStringF(IDS_TASK_MANAGER_EXTENSION_PREFIX, extension_name); } diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 443a86f..228e8e5 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "base/callback.h" #include "base/file_version_info.h" +#include "base/i18n/rtl.h" #include "base/i18n/word_iterator.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_list.h" @@ -127,8 +128,7 @@ AboutChromeView::~AboutChromeView() { } void AboutChromeView::Init() { - text_direction_is_rtl_ = - l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; + text_direction_is_rtl_ = base::i18n::IsRTL(); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); scoped_ptr<FileVersionInfo> version_info( @@ -871,9 +871,9 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, l10n_util::GetStringF(IDS_UPGRADE_ALREADY_UP_TO_DATE, l10n_util::GetString(IDS_PRODUCT_NAME), current_version_); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { update_label_text.push_back( - static_cast<wchar_t>(l10n_util::kLeftToRightMark)); + static_cast<wchar_t>(base::i18n::kLeftToRightMark)); } update_label_.SetText(update_label_text); show_success_indicator = true; diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc index 77c9ae3..5a2bdd8 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "app/theme_provider.h" #include "base/compiler_specific.h" +#include "base/i18n/rtl.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/bubble_positioner.h" @@ -484,7 +485,7 @@ int AutocompleteResultView::DrawString( const bool force_rtl_directionality = !(classifications[i].style & ACMatchClassification::URL) && (run_direction == UBIDI_RTL) && - (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT); + !base::i18n::IsRTL(); if (text_start < text_end) { x += DrawStringFragment(canvas, diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 5954725..f1fb348 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -14,6 +14,7 @@ #include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "app/text_elider.h" +#include "base/i18n/rtl.h" #include "base/string_util.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" @@ -140,7 +141,7 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc, // First the title. if (!title.empty()) { std::wstring localized_title; - if (l10n_util::AdjustStringForLocaleDirection(title, &localized_title)) + if (base::i18n::AdjustStringForLocaleDirection(title, &localized_title)) result.append(gfx::ElideText(localized_title, tt_font, max_width)); else result.append(gfx::ElideText(title, tt_font, max_width)); @@ -158,8 +159,8 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc, // the Unicode BiDi algorithm puts certain characters on the left by // default. std::wstring elided_url(gfx::ElideUrl(url, tt_font, max_width, languages)); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&elided_url); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&elided_url); result.append(elided_url); } return result; diff --git a/chrome/browser/views/bookmark_context_menu.cc b/chrome/browser/views/bookmark_context_menu.cc index fee7865..aef8070 100644 --- a/chrome/browser/views/bookmark_context_menu.cc +++ b/chrome/browser/views/bookmark_context_menu.cc @@ -5,6 +5,7 @@ #include "chrome/browser/views/bookmark_context_menu.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "chrome/browser/profile.h" #include "grit/generated_resources.h" #include "views/controls/menu/menu_item_view.h" @@ -35,8 +36,7 @@ BookmarkContextMenu::~BookmarkContextMenu() { void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) { // width/height don't matter here. - views::MenuItemView::AnchorPosition anchor = - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? + views::MenuItemView::AnchorPosition anchor = base::i18n::IsRTL() ? views::MenuItemView::TOPRIGHT : views::MenuItemView::TOPLEFT; menu_->RunMenuAt(parent_window_, NULL, gfx::Rect(point.x(), point.y(), 0, 0), anchor, true); diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index 66e6ca7..add4203 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -13,6 +13,7 @@ #include "app/theme_provider.h" #include "base/callback.h" #include "base/file_path.h" +#include "base/i18n/rtl.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/browser_process.h" @@ -90,7 +91,7 @@ class DownloadShelfContextMenuWin : public DownloadShelfContextMenu { // The menu's alignment is determined based on the UI layout. views::Menu2::Alignment alignment; - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) alignment = views::Menu2::ALIGN_TOPRIGHT; else alignment = views::Menu2::ALIGN_TOPLEFT; @@ -285,8 +286,8 @@ DownloadItemView::DownloadItemView(DownloadItem* download, } else { ElideString(rootname, kFileNameMaxLength - extension.length(), &rootname); std::wstring filename = rootname + L"." + extension; - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&filename); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(&filename); dangerous_download_label_ = new views::Label( l10n_util::GetStringF(IDS_PROMPT_DANGEROUS_DOWNLOAD, filename)); } diff --git a/chrome/browser/views/edit_search_engine_dialog.cc b/chrome/browser/views/edit_search_engine_dialog.cc index 1a58f3f..c32eaba 100644 --- a/chrome/browser/views/edit_search_engine_dialog.cc +++ b/chrome/browser/views/edit_search_engine_dialog.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/i18n/rtl.h" #include "base/string_util.h" #include "chrome/browser/search_engines/edit_search_engine_controller.h" #include "chrome/browser/search_engines/template_url.h" @@ -203,7 +204,7 @@ void EditSearchEngineDialog::Init() { layout->StartRowWithPadding(0, 2, 0, unrelated_y); std::wstring description = l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { const std::wstring reversed_percent(L"s%"); std::wstring::size_type percent_index = description.find(L"%s", static_cast<std::wstring::size_type>(0)); diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 3312812..1970be1 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -14,6 +14,7 @@ #include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/command_line.h" +#include "base/i18n/rtl.h" #include "base/keyboard_codes.h" #include "base/time.h" #include "build/build_config.h" @@ -211,7 +212,7 @@ class ResizeCorner : public views::View { SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_TEXTAREA_RESIZER); bitmap->buildMipMap(false); - bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); + bool rtl_dir = base::i18n::IsRTL(); if (rtl_dir) { canvas->TranslateInt(width(), 0); canvas->ScaleInt(-1, 1); @@ -930,7 +931,7 @@ gfx::Rect BrowserView::GetRootWindowResizerRect() const { gfx::Rect client_rect = contents_split_->bounds(); gfx::Size resize_corner_size = ResizeCorner::GetSize(); int x = client_rect.width() - resize_corner_size.width(); - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (base::i18n::IsRTL()) x = 0; return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), resize_corner_size.width(), resize_corner_size.height()); @@ -1548,7 +1549,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), client_rect.bottom - resize_corner_size.height(), resize_corner_size.width(), resize_corner_size.height()); - bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); + bool rtl_dir = base::i18n::IsRTL(); if (rtl_dir) resize_corner_rect.set_x(0); if (resize_corner_rect.Contains(point)) { diff --git a/chrome/browser/views/go_button.cc b/chrome/browser/views/go_button.cc index 29451c3..05fc1c4 100644 --- a/chrome/browser/views/go_button.cc +++ b/chrome/browser/views/go_button.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/compiler_specific.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" @@ -104,8 +105,8 @@ bool GoButton::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { // Note that we mark the URL's text as LTR (instead of examining the // characters and guessing the text directionality) since URLs are always // treated as left-to-right text, even when they contain RTL characters. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(¤t_text); + if (base::i18n::IsRTL()) + base::i18n::WrapStringWithLTRFormatting(¤t_text); AutocompleteEditModel* edit_model = location_bar_->location_entry()->model(); if (edit_model->CurrentTextIsURL()) { diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index 523e5cc..10f4a25 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -7,6 +7,7 @@ #include "app/gfx/canvas.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/i18n/rtl.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -95,7 +96,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. - l10n_util::AdjustStringForLocaleDirection(title, &title); + base::i18n::AdjustStringForLocaleDirection(title, &title); return title; } diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 6021532..d657c06 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -12,6 +12,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" +#include "base/i18n/rtl.h" #include "base/stl_util-inl.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/alternate_nav_url_fetcher.h" @@ -996,7 +997,7 @@ std::wstring LocationBarView::SelectedKeywordView::CalculateMinString( } else { min_string = description.substr(0, chop_index); } - l10n_util::AdjustStringForLocaleDirection(min_string, &min_string); + base::i18n::AdjustStringForLocaleDirection(min_string, &min_string); return min_string; } diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index ab09db9..e7dcfa8 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -17,6 +17,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/file_util.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/thread.h" @@ -146,9 +147,9 @@ FileDisplayArea::~FileDisplayArea() { void FileDisplayArea::SetFile(const FilePath& file_path) { // Force file path to have LTR directionality. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { string16 localized_file_path; - l10n_util::WrapPathWithLTRFormatting(file_path, &localized_file_path); + base::i18n::WrapPathWithLTRFormatting(file_path, &localized_file_path); text_field_->SetText(UTF16ToWide(localized_file_path)); } else { text_field_->SetText(file_path.ToWStringHack()); @@ -210,7 +211,7 @@ void FileDisplayArea::InitClass() { // We'd prefer to use UILayoutIsRightToLeft() to perform the RTL // environment check, but it's nonstatic, so, instead, we check whether the // locale is RTL. - bool ui_is_rtl = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; + bool ui_is_rtl = base::i18n::IsRTL(); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); default_folder_icon_ = *rb.GetBitmapNamed(ui_is_rtl ? IDR_FOLDER_CLOSED_RTL : @@ -756,7 +757,7 @@ void WebContentSection::ButtonPressed( void WebContentSection::InitControlLayout() { AdvancedSection::InitControlLayout(); - if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) { + if (!base::i18n::IsRTL()) { gears_label_ = new views::Label( l10n_util::GetString(IDS_OPTIONS_GEARSSETTINGS_GROUP_NAME)); } else { @@ -765,7 +766,7 @@ void WebContentSection::InitControlLayout() { std::wstring gearssetting_group_name = l10n_util::GetString(IDS_OPTIONS_GEARSSETTINGS_GROUP_NAME); gearssetting_group_name.push_back( - static_cast<wchar_t>(l10n_util::kRightToLeftMark)); + static_cast<wchar_t>(base::i18n::kRightToLeftMark)); gears_label_ = new views::Label(gearssetting_group_name); } gears_settings_button_ = new views::NativeButton( diff --git a/chrome/browser/views/options/passwords_page_view.cc b/chrome/browser/views/options/passwords_page_view.cc index 0cff819..c03700f 100644 --- a/chrome/browser/views/options/passwords_page_view.cc +++ b/chrome/browser/views/options/passwords_page_view.cc @@ -5,6 +5,7 @@ #include "chrome/browser/views/options/passwords_page_view.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/string_util.h" #include "chrome/browser/password_manager/password_store.h" #include "chrome/browser/pref_service.h" @@ -71,16 +72,16 @@ std::wstring PasswordsTableModel::GetText(int row, case IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN: { // Site. const std::wstring& url = saved_signons_[row]->display_url.display_url(); // Force URL to have LTR directionality. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { std::wstring localized_url = url; - l10n_util::WrapStringWithLTRFormatting(&localized_url); + base::i18n::WrapStringWithLTRFormatting(&localized_url); return localized_url; } return url; } case IDS_PASSWORDS_PAGE_VIEW_USERNAME_COLUMN: { // Username. std::wstring username = GetPasswordFormAt(row)->username_value; - l10n_util::AdjustStringForLocaleDirection(username, &username); + base::i18n::AdjustStringForLocaleDirection(username, &username); return username; } default: diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index ff6ebc2..b533729 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -11,6 +11,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/text_elider.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/string_util.h" #include "chrome/browser/browser_theme_provider.h" @@ -497,7 +498,7 @@ gfx::Size StatusBubbleViews::GetPreferredSize() { void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { // If the UI layout is RTL, we need to mirror the position of the bubble // relative to the parent. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { + if (base::i18n::IsRTL()) { gfx::Rect frame_bounds; frame_->GetBounds(&frame_bounds, false); int mirrored_x = frame_bounds.width() - x - w; @@ -558,9 +559,8 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { // An URL is always treated as a left-to-right string. On right-to-left UIs // we need to explicitly mark the URL as LTR to make sure it is displayed // correctly. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT && - !url_text_.empty()) - l10n_util::WrapStringWithLTRFormatting(&url_text_); + if (base::i18n::IsRTL() && !url_text_.empty()) + base::i18n::WrapStringWithLTRFormatting(&url_text_); if (IsFrameVisible()) view_->SetText(url_text_); diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index c8c055f..b953466 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -13,6 +13,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/callback.h" +#include "base/i18n/rtl.h" #include "base/keyboard_codes.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" @@ -83,7 +84,7 @@ class DockView : public views::View { SkBitmap* high_icon = rb.GetBitmapNamed(IDR_DOCK_HIGH); SkBitmap* wide_icon = rb.GetBitmapNamed(IDR_DOCK_WIDE); - bool rtl_ui = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; + bool rtl_ui = base::i18n::IsRTL(); if (rtl_ui) { // Flip canvas to draw the mirrored tab images for RTL UI. canvas->save(); @@ -1136,7 +1137,7 @@ bool DraggedTabController::CompleteDrag() { gfx::Size(browser_rect.width(), browser_rect.height())); // When modifying the following if statement, please make sure not to // introduce issue listed in http://crbug.com/6223 comment #11. - bool rtl_ui = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); + bool rtl_ui = base::i18n::IsRTL(); bool has_dock_position = (dock_info_.type() != DockInfo::NONE); if (rtl_ui && has_dock_position) { // Mirror X axis so the docked tab is aligned using the mouse click as |