Chromium Code Reviews| Index: base/i18n/rtl.cc |
| diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc |
| index 095d66c6d8af13a9846e70ddc4fdf650410d2d03..76a07730893514f579beacd2e8a0c42dcdb88dd8 100644 |
| --- a/base/i18n/rtl.cc |
| +++ b/base/i18n/rtl.cc |
| @@ -51,10 +51,26 @@ std::string GetLocaleString(const icu::Locale& locale) { |
| return result; |
| } |
| +bool HasForcedTextDirectionSwitch() { |
|
msw
2017/05/01 20:56:18
nit: "// Get the cached switch presence; avoids re
Kevin Bailey
2017/05/01 21:21:42
Done. Seemed like a bit much overhead for a whole
|
| + static bool value = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kForceTextDirection); |
| + return value; |
| +} |
| + |
| // Returns LEFT_TO_RIGHT or RIGHT_TO_LEFT if |character| has strong |
| // directionality, returns UNKNOWN_DIRECTION if it doesn't. Please refer to |
| // http://unicode.org/reports/tr9/ for more information. |
| base::i18n::TextDirection GetCharacterDirection(UChar32 character) { |
| + if (HasForcedTextDirectionSwitch()) { |
| + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| + std::string force_flag = |
| + command_line->GetSwitchValueASCII(switches::kForceTextDirection); |
| + |
| + if (force_flag == switches::kForceDirectionRTL) |
| + return base::i18n::RIGHT_TO_LEFT; |
| + if (force_flag == switches::kForceDirectionLTR) |
| + return base::i18n::LEFT_TO_RIGHT; |
| + } |
| // Now that we have the character, we use ICU in order to query for the |
| // appropriate Unicode BiDi character type. |
| int32_t property = u_getIntPropertyValue(character, UCHAR_BIDI_CLASS); |
| @@ -85,10 +101,10 @@ base::i18n::TextDirection GetForcedTextDirection() { |
| std::string force_flag = |
| command_line->GetSwitchValueASCII(switches::kForceUIDirection); |
| - if (force_flag == switches::kForceUIDirectionLTR) |
| + if (force_flag == switches::kForceDirectionLTR) |
| return base::i18n::LEFT_TO_RIGHT; |
| - if (force_flag == switches::kForceUIDirectionRTL) |
| + if (force_flag == switches::kForceDirectionRTL) |
| return base::i18n::RIGHT_TO_LEFT; |
| } |