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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java

Issue 2839843002: Android URL formatting: Disable RTL URLs for Android 4.2 and below. (Closed)
Patch Set: make constant Created 3 years, 8 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
index 9dc8a9860b4073bb498982825d4de174ba3cdef4..efd23fef541e9fe1c851c5f3ed2ca3042e61c6cb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
@@ -12,6 +12,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.net.Uri;
+import android.os.Build;
import android.os.StrictMode;
import android.os.SystemClock;
import android.text.Editable;
@@ -65,6 +66,9 @@ public class UrlBar extends VerticallyFixedEditText {
private static final int MAX_DISPLAYABLE_LENGTH = 4000;
private static final int MAX_DISPLAYABLE_LENGTH_LOW_END = 1000;
+ // Unicode "Left-To-Right Mark" (LRM) character.
+ private static final char LRM = '\u200E';
+
/** The contents of the URL that precede the path/query after being formatted. */
private String mFormattedUrlLocation;
@@ -758,6 +762,13 @@ public class UrlBar extends VerticallyFixedEditText {
*/
public boolean setUrl(String url, String formattedUrl) {
if (!TextUtils.isEmpty(formattedUrl)) {
+ // Because Android versions 4.2 and before lack proper RTL support,
+ // force the formatted URL to render as LTR using an LRM character.
+ // See: https://www.ietf.org/rfc/rfc3987.txt and crbug.com/709417
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ formattedUrl = LRM + formattedUrl;
+ }
+
try {
URL javaUrl = new URL(url);
mFormattedUrlLocation =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698