Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.components.url_formatter; | 5 package org.chromium.components.url_formatter; |
| 6 | 6 |
| 7 import android.text.Spannable; | |
| 8 import android.text.SpannableString; | |
| 7 import android.text.TextUtils; | 9 import android.text.TextUtils; |
| 10 import android.text.style.ForegroundColorSpan; | |
| 8 | 11 |
| 9 import org.chromium.base.annotations.JNINamespace; | 12 import org.chromium.base.annotations.JNINamespace; |
| 10 | 13 |
| 11 import java.net.URI; | 14 import java.net.URI; |
| 12 | 15 |
| 13 /** | 16 /** |
| 14 * Wrapper for utilities in url_formatter. | 17 * Wrapper for utilities in url_formatter. |
| 15 */ | 18 */ |
| 16 @JNINamespace("url_formatter::android") | 19 @JNINamespace("url_formatter::android") |
| 17 public final class UrlFormatter { | 20 public final class UrlFormatter { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 * it fails to parse it. | 79 * it fails to parse it. |
| 77 */ | 80 */ |
| 78 public static String formatUrlForSecurityDisplay(String uri, boolean showSch eme) { | 81 public static String formatUrlForSecurityDisplay(String uri, boolean showSch eme) { |
| 79 if (showScheme) { | 82 if (showScheme) { |
| 80 return nativeFormatUrlForSecurityDisplay(uri); | 83 return nativeFormatUrlForSecurityDisplay(uri); |
| 81 } else { | 84 } else { |
| 82 return nativeFormatUrlForSecurityDisplayOmitScheme(uri); | 85 return nativeFormatUrlForSecurityDisplayOmitScheme(uri); |
| 83 } | 86 } |
| 84 } | 87 } |
| 85 | 88 |
| 89 /** | |
| 90 * Tints the scheme of the URL to specific color for display. | |
| 91 * | |
| 92 * @param uri The URI. | |
|
please use gerrit instead
2017/02/15 21:45:02
Please align "The" together on these two lines.
gogerald1
2017/02/16 16:43:14
Done.
| |
| 93 * @param color The color used to tint the scheme. | |
| 94 * | |
| 95 * @return The URL with tinted scheme. | |
| 96 */ | |
| 97 public static CharSequence tintUrlSchemeForSecurityDisplay(String uri, int c olor) { | |
|
please use gerrit instead
2017/02/15 21:45:02
How does the omnibox tint the URL scheme? It would
please use gerrit instead
2017/02/15 21:45:02
Please pick either URL or URI and use that term th
gogerald1
2017/02/16 16:43:14
Done.
gogerald1
2017/02/16 16:43:14
They do the similar thing.
| |
| 98 SpannableString spannableUri = new SpannableString(uri); | |
| 99 spannableUri.setSpan(new ForegroundColorSpan(color), 0, | |
| 100 spannableUri.toString().indexOf(":"), Spannable.SPAN_EXCLUSIVE_E XCLUSIVE); | |
|
please use gerrit instead
2017/02/15 21:45:02
Please tint only "https:" scheme. Although "file:"
gogerald1
2017/02/16 16:43:14
Done.
| |
| 101 return spannableUri; | |
| 102 } | |
| 103 | |
| 86 private static native String nativeFixupUrl(String url); | 104 private static native String nativeFixupUrl(String url); |
| 87 private static native String nativeFormatUrlForDisplay(String url); | 105 private static native String nativeFormatUrlForDisplay(String url); |
| 88 private static native String nativeFormatUrlForSecurityDisplay(String url); | 106 private static native String nativeFormatUrlForSecurityDisplay(String url); |
| 89 private static native String nativeFormatUrlForSecurityDisplayOmitScheme(Str ing url); | 107 private static native String nativeFormatUrlForSecurityDisplayOmitScheme(Str ing url); |
| 90 } | 108 } |
| OLD | NEW |