diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-01 08:27:32 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-01 08:27:32 +0000 |
commit | f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392 (patch) | |
tree | bebb9be6f4b3a4a090917db063177fb5fb58f1dc /chrome/renderer/localized_error.cc | |
parent | 2cf57c8de64c62ec4f9c18ebf30b30961b208c3e (diff) | |
download | chromium_src-f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392.zip chromium_src-f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392.tar.gz chromium_src-f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392.tar.bz2 |
linux: use ICU direction for determining text direction in renderer
We use the GTK text direction in the browser process, but that
is not available in the renderer.
BUG=36624
TEST=Arabic error pages are properly RTL
Review URL: http://codereview.chromium.org/660176
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40260 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/localized_error.cc')
-rw-r--r-- | chrome/renderer/localized_error.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc index 2b49390..37dea28 100644 --- a/chrome/renderer/localized_error.cc +++ b/chrome/renderer/localized_error.cc @@ -90,10 +90,23 @@ WebErrorNetErrorMap net_error_options[] = { }, }; +bool LocaleIsRTL() { +#if defined(TOOLKIT_GTK) + // l10n_util::GetTextDirection uses the GTK text direction, which doesn't work + // within the renderer sandbox. + return l10n_util::GetICUTextDirection() == l10n_util::RIGHT_TO_LEFT; +#else + return l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; +#endif +} + } // namespace void GetLocalizedErrorValues(const WebURLError& error, DictionaryValue* error_strings) { + bool rtl = LocaleIsRTL(); + error_strings->SetString(L"textdirection", rtl ? L"rtl" : L"ltr"); + // Grab strings that are applicable to all error pages error_strings->SetString(L"detailsLink", l10n_util::GetString(IDS_ERRORPAGES_DETAILS_LINK)); @@ -128,7 +141,7 @@ void GetLocalizedErrorValues(const WebURLError& error, std::wstring failed_url( ASCIIToWide(std::string(error.unreachableURL.spec()))); // URLs are always LTR. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (rtl) l10n_util::WrapStringWithLTRFormatting(&failed_url); error_strings->SetString(L"title", l10n_util::GetStringF(options.title_resource_id, @@ -169,7 +182,7 @@ void GetLocalizedErrorValues(const WebURLError& error, l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HOMEPAGE)); std::wstring homepage(ASCIIToWide(failed_url.GetWithEmptyPath().spec())); // URLs are always LTR. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (rtl) l10n_util::WrapStringWithLTRFormatting(&homepage); suggest_home_page->SetString(L"homePage", homepage); // TODO(tc): we actually want the unicode hostname @@ -209,9 +222,12 @@ void GetLocalizedErrorValues(const WebURLError& error, void GetFormRepostErrorValues(const GURL& display_url, DictionaryValue* error_strings) { + bool rtl = LocaleIsRTL(); + error_strings->SetString(L"textdirection", rtl ? L"rtl" : L"ltr"); + std::wstring failed_url(ASCIIToWide(display_url.spec())); // URLs are always LTR. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + if (rtl) l10n_util::WrapStringWithLTRFormatting(&failed_url); error_strings->SetString( L"title", l10n_util::GetStringF(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |