Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: base/i18n/rtl.cc

Issue 1458043003: Added --force-ui-direction flag for developers to force LTR or RTL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/i18n/base_i18n_switches.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/rtl.cc
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc
index ac9589cb32531f551271c5817f9578daa801d250..adcf6deb01b934e1734b5ccac9d753d3c09c7b8a 100644
--- a/base/i18n/rtl.cc
+++ b/base/i18n/rtl.cc
@@ -6,7 +6,9 @@
#include <algorithm>
+#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/i18n/base_i18n_switches.h"
#include "base/logging.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -64,6 +66,30 @@ base::i18n::TextDirection GetCharacterDirection(UChar32 character) {
return base::i18n::UNKNOWN_DIRECTION;
}
+// Gets the explicitly forced text direction for debugging. If no forcing is
+// applied, returns UNKNOWN_DIRECTION.
+base::i18n::TextDirection GetForcedTextDirection() {
+ // On iOS, check for RTL forcing.
+#if defined(OS_IOS)
+ if (base::ios::IsInForcedRTL())
+ return base::i18n::RIGHT_TO_LEFT;
+#endif
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kForceUIDirection)) {
+ std::string force_flag =
+ command_line->GetSwitchValueASCII(switches::kForceUIDirection);
+
+ if (force_flag == switches::kForceUIDirectionLTR)
+ return base::i18n::LEFT_TO_RIGHT;
+
+ if (force_flag == switches::kForceUIDirectionRTL)
+ return base::i18n::RIGHT_TO_LEFT;
+ }
+
+ return base::i18n::UNKNOWN_DIRECTION;
+}
+
} // namespace
namespace base {
@@ -135,11 +161,10 @@ bool ICUIsRTL() {
}
TextDirection GetTextDirectionForLocaleInStartUp(const char* locale_name) {
-// On iOS, check for RTL forcing.
-#if defined(OS_IOS)
- if (ios::IsInForcedRTL())
- return RIGHT_TO_LEFT;
-#endif
+ // Check for direction forcing.
+ TextDirection forced_direction = GetForcedTextDirection();
+ if (forced_direction != UNKNOWN_DIRECTION)
+ return forced_direction;
// This list needs to be updated in alphabetical order if we add more RTL
// locales.
@@ -155,11 +180,10 @@ TextDirection GetTextDirectionForLocaleInStartUp(const char* locale_name) {
}
TextDirection GetTextDirectionForLocale(const char* locale_name) {
- // On iOS, check for RTL forcing.
-#if defined(OS_IOS)
- if (ios::IsInForcedRTL())
- return RIGHT_TO_LEFT;
-#endif
+ // Check for direction forcing.
+ TextDirection forced_direction = GetForcedTextDirection();
+ if (forced_direction != UNKNOWN_DIRECTION)
+ return forced_direction;
UErrorCode status = U_ZERO_ERROR;
ULayoutType layout_dir = uloc_getCharacterOrientation(locale_name, &status);
« no previous file with comments | « base/i18n/base_i18n_switches.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698