Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.omnibox; | 5 package org.chromium.chrome.browser.omnibox; |
| 6 | 6 |
| 7 import android.content.ClipData; | 7 import android.content.ClipData; |
| 8 import android.content.ClipboardManager; | 8 import android.content.ClipboardManager; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
| 11 import android.graphics.Canvas; | 11 import android.graphics.Canvas; |
| 12 import android.graphics.Paint; | 12 import android.graphics.Paint; |
| 13 import android.graphics.Rect; | 13 import android.graphics.Rect; |
| 14 import android.net.Uri; | 14 import android.net.Uri; |
| 15 import android.os.Build; | |
| 15 import android.os.StrictMode; | 16 import android.os.StrictMode; |
| 16 import android.os.SystemClock; | 17 import android.os.SystemClock; |
| 17 import android.text.Editable; | 18 import android.text.Editable; |
| 18 import android.text.Layout; | 19 import android.text.Layout; |
| 19 import android.text.Selection; | 20 import android.text.Selection; |
| 20 import android.text.Spanned; | 21 import android.text.Spanned; |
| 21 import android.text.TextUtils; | 22 import android.text.TextUtils; |
| 22 import android.text.style.ReplacementSpan; | 23 import android.text.style.ReplacementSpan; |
| 23 import android.util.AttributeSet; | 24 import android.util.AttributeSet; |
| 24 import android.util.Pair; | 25 import android.util.Pair; |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 | 752 |
| 752 /** | 753 /** |
| 753 * Sets the text content of the URL bar. | 754 * Sets the text content of the URL bar. |
| 754 * | 755 * |
| 755 * @param url The original URL (or generic text) that can be used for copy/c ut/paste. | 756 * @param url The original URL (or generic text) that can be used for copy/c ut/paste. |
| 756 * @param formattedUrl Formatted URL for user display. Null if there isn't o ne. | 757 * @param formattedUrl Formatted URL for user display. Null if there isn't o ne. |
| 757 * @return Whether the visible text has changed. | 758 * @return Whether the visible text has changed. |
| 758 */ | 759 */ |
| 759 public boolean setUrl(String url, String formattedUrl) { | 760 public boolean setUrl(String url, String formattedUrl) { |
| 760 if (!TextUtils.isEmpty(formattedUrl)) { | 761 if (!TextUtils.isEmpty(formattedUrl)) { |
| 762 // Because Android versions 4.2 and before lack proper RTL support, | |
| 763 // wrap the formatted URL with LTR control characters. | |
| 764 // This is quite hacky, but fixes a security bug. crbug.com/709417 | |
| 765 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
| 766 formattedUrl = '\u200E' + formattedUrl; | |
|
tommycli
2017/04/27 01:36:33
This I have confirmed does not negatively affect t
Matt Giuca
2017/04/27 03:33:07
Yeah this looks like exactly the right spot.
Ted C
2017/04/27 16:26:50
Agreed...I didn't even know what this was before r
tommycli
2017/04/27 17:23:14
Done. Great I made a constant at the top of the fi
| |
| 767 } | |
| 768 | |
| 761 try { | 769 try { |
| 762 URL javaUrl = new URL(url); | 770 URL javaUrl = new URL(url); |
| 763 mFormattedUrlLocation = | 771 mFormattedUrlLocation = |
| 764 getUrlContentsPrePath(formattedUrl, javaUrl.getHost()); | 772 getUrlContentsPrePath(formattedUrl, javaUrl.getHost()); |
| 765 mOriginalUrlLocation = | 773 mOriginalUrlLocation = |
| 766 getUrlContentsPrePath(url, javaUrl.getHost()); | 774 getUrlContentsPrePath(url, javaUrl.getHost()); |
| 767 } catch (MalformedURLException mue) { | 775 } catch (MalformedURLException mue) { |
| 768 mOriginalUrlLocation = null; | 776 mOriginalUrlLocation = null; |
| 769 mFormattedUrlLocation = null; | 777 mFormattedUrlLocation = null; |
| 770 } | 778 } |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 return (int) paint.measureText(ELLIPSIS); | 1242 return (int) paint.measureText(ELLIPSIS); |
| 1235 } | 1243 } |
| 1236 | 1244 |
| 1237 @Override | 1245 @Override |
| 1238 public void draw(Canvas canvas, CharSequence text, int start, int end, | 1246 public void draw(Canvas canvas, CharSequence text, int start, int end, |
| 1239 float x, int top, int y, int bottom, Paint paint) { | 1247 float x, int top, int y, int bottom, Paint paint) { |
| 1240 canvas.drawText(ELLIPSIS, x, y, paint); | 1248 canvas.drawText(ELLIPSIS, x, y, paint); |
| 1241 } | 1249 } |
| 1242 } | 1250 } |
| 1243 } | 1251 } |
| OLD | NEW |