OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.res.Resources; | 7 import android.content.res.Resources; |
8 import android.text.Spannable; | 8 import android.text.Spannable; |
9 import android.text.style.ForegroundColorSpan; | 9 import android.text.style.ForegroundColorSpan; |
10 import android.text.style.StrikethroughSpan; | 10 import android.text.style.StrikethroughSpan; |
11 | 11 |
12 import org.chromium.base.VisibleForTesting; | 12 import org.chromium.base.VisibleForTesting; |
13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
14 import org.chromium.chrome.browser.profiles.Profile; | 14 import org.chromium.chrome.browser.profiles.Profile; |
15 import org.chromium.chrome.browser.ui.toolbar.ToolbarModelSecurityLevel; | 15 import org.chromium.chrome.browser.ui.toolbar.ToolbarModelSecurityLevel; |
16 | 16 |
17 import java.util.Locale; | |
18 | |
17 /** | 19 /** |
18 * A helper class that emphasizes the various components of a URL. Useful in the | 20 * A helper class that emphasizes the various components of a URL. Useful in the |
19 * Omnibox and Origin Info dialog where different parts of the URL should appear | 21 * Omnibox and Origin Info dialog where different parts of the URL should appear |
20 * in different colours depending on the scheme, host and connection. | 22 * in different colours depending on the scheme, host and connection. |
21 */ | 23 */ |
22 public class OmniboxUrlEmphasizer { | 24 public class OmniboxUrlEmphasizer { |
23 | 25 |
24 /** | 26 /** |
25 * Describes the components of a URL that should be emphasized. | 27 * Describes the components of a URL that should be emphasized. |
26 */ | 28 */ |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 * @param profile The profile visiting this URL (used for parsing the URL). | 282 * @param profile The profile visiting this URL (used for parsing the URL). |
281 * @return The index of the last character containing origin information. | 283 * @return The index of the last character containing origin information. |
282 */ | 284 */ |
283 public static int getOriginEndIndex(String url, Profile profile) { | 285 public static int getOriginEndIndex(String url, Profile profile) { |
284 EmphasizeComponentsResponse emphasizeResponse = | 286 EmphasizeComponentsResponse emphasizeResponse = |
285 parseForEmphasizeComponents(profile, url.toString()); | 287 parseForEmphasizeComponents(profile, url.toString()); |
286 if (!emphasizeResponse.hasScheme()) return url.length(); | 288 if (!emphasizeResponse.hasScheme()) return url.length(); |
287 | 289 |
288 int startSchemeIndex = emphasizeResponse.schemeStart; | 290 int startSchemeIndex = emphasizeResponse.schemeStart; |
289 int endSchemeIndex = emphasizeResponse.schemeStart + emphasizeResponse.s chemeLength; | 291 int endSchemeIndex = emphasizeResponse.schemeStart + emphasizeResponse.s chemeLength; |
290 String scheme = url.subSequence(startSchemeIndex, endSchemeIndex).toStri ng().toLowerCase(); | 292 String scheme = url.subSequence(startSchemeIndex, endSchemeIndex).toStri ng().toLowerCase( |
293 Locale.ENGLISH); | |
newt (away)
2015/01/05 18:23:37
Actually, this should be "Locale.US" (to be consis
wajahat
2015/01/06 08:41:43
Done.
| |
291 | 294 |
292 if (scheme.equals("http") || scheme.equals("https")) { | 295 if (scheme.equals("http") || scheme.equals("https")) { |
293 return emphasizeResponse.hostStart + emphasizeResponse.hostLength; | 296 return emphasizeResponse.hostStart + emphasizeResponse.hostLength; |
294 } else if (scheme.equals("data")) { | 297 } else if (scheme.equals("data")) { |
295 return 0; | 298 return 0; |
296 } else { | 299 } else { |
297 return url.length(); | 300 return url.length(); |
298 } | 301 } |
299 } | 302 } |
300 | 303 |
301 private static native int[] nativeParseForEmphasizeComponents(Profile profil e, String text); | 304 private static native int[] nativeParseForEmphasizeComponents(Profile profil e, String text); |
302 } | 305 } |
OLD | NEW |