Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxUrlEmphasizer.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxUrlEmphasizer.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxUrlEmphasizer.java |
index c9bd8cbe990672862204e95f83e950864517a27a..69de2d7befe89c2f3fa36aafd67582fb9ed1aa2a 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxUrlEmphasizer.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxUrlEmphasizer.java |
@@ -108,6 +108,7 @@ public class OmniboxUrlEmphasizer { |
/** |
* Make the whole url greyed out (trailing url color). |
+ * TODO(sashab): Remove this method. For backwards compatibility only. |
* |
* @param url The URL spannable to grey out. This variable is modified. |
* @param resources Resources for the given application context. |
@@ -119,6 +120,20 @@ public class OmniboxUrlEmphasizer { |
} |
/** |
+ * Make the whole url greyed out (trailing url color). |
+ * |
+ * @param url The URL spannable to grey out. This variable is modified. |
+ * @param resources Resources for the given application context. |
+ * @param useDarkColors Whether the text colors should be dark (i.e. |
+ * appropriate for use on a light background). |
+ */ |
+ public static void greyOutUrl(Spannable url, Resources resources, boolean useDarkColors) { |
+ UrlEmphasisColorSpan span = new UrlEmphasisColorSpan( |
+ resources.getColor(R.color.url_emphasis_trailing_url)); |
+ url.setSpan(span, 0, url.toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
+ } |
+ |
+ /** |
* Modifies the given URL to emphasize the TLD and second domain. |
* |
* @param url The URL spannable to add emphasis to. This variable is |
@@ -138,6 +153,11 @@ public class OmniboxUrlEmphasizer { |
EmphasizeComponentsResponse emphasizeResponse = |
parseForEmphasizeComponents(profile, urlString); |
+ int nonEmphasizedColorId = R.color.url_emphasis_non_emphasized_text; |
+ if (!useDarkColors) { |
+ nonEmphasizedColorId = R.color.url_emphasis_light_non_emphasized_text; |
+ } |
+ |
int startSchemeIndex = emphasizeResponse.schemeStart; |
int endSchemeIndex = emphasizeResponse.schemeStart + emphasizeResponse.schemeLength; |
@@ -147,13 +167,11 @@ public class OmniboxUrlEmphasizer { |
// Add the https scheme highlight |
ForegroundColorSpan span; |
if (emphasizeResponse.hasScheme()) { |
- int colorId = R.color.url_emphasis_scheme_to_domain; |
- if (isInternalPage) { |
- colorId = R.color.url_emphasis_trailing_url; |
- } else { |
+ int colorId = nonEmphasizedColorId; |
+ if (!isInternalPage) { |
switch (securityLevel) { |
case ToolbarModelSecurityLevel.NONE: |
- colorId = R.color.url_emphasis_scheme_to_domain; |
+ colorId = nonEmphasizedColorId; |
break; |
case ToolbarModelSecurityLevel.SECURITY_WARNING: |
colorId = R.color.url_emphasis_start_scheme_security_warning; |
@@ -182,8 +200,7 @@ public class OmniboxUrlEmphasizer { |
// https, this will be ://. For normal pages, this will be empty as we trim off |
// http://. |
if (emphasizeResponse.hasHost()) { |
- span = new UrlEmphasisColorSpan( |
- resources.getColor(R.color.url_emphasis_scheme_to_domain)); |
+ span = new UrlEmphasisColorSpan(resources.getColor(nonEmphasizedColorId)); |
url.setSpan(span, endSchemeIndex, startHostIndex, |
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
} |
@@ -200,8 +217,7 @@ public class OmniboxUrlEmphasizer { |
// Highlight the remainder of the URL. |
if (endHostIndex < urlString.length()) { |
- span = new UrlEmphasisColorSpan( |
- resources.getColor(R.color.url_emphasis_trailing_url)); |
+ span = new UrlEmphasisColorSpan(resources.getColor(nonEmphasizedColorId)); |
url.setSpan(span, endHostIndex, urlString.length(), |
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
} |