Commit cfd0445d authored by palmer's avatar palmer Committed by Commit bot

[android] Correct the URL scheme colors in the Omnibox.

Make the empahsized "https:" scheme text match the connection state indicator
icon color. (In the new design, the color changed.) Also, per the new design,
don't emphasize (color) the scheme for Incognito or theme colors.

BUG=626646
TBR=tedchoc

Review-Url: https://codereview.chromium.org/2144443002
Cr-Commit-Position: refs/heads/master@{#405258}
parent 47e6f464
...@@ -50,10 +50,6 @@ ...@@ -50,10 +50,6 @@
<color name="website_settings_popup_text_link">#4285f4</color> <color name="website_settings_popup_text_link">#4285f4</color>
<!-- URL Emphasizer colors --> <!-- URL Emphasizer colors -->
<color name="url_emphasis_start_scheme_security_warning">#ffb000</color>
<color name="url_emphasis_start_scheme_security_error">#db4437</color>
<color name="url_emphasis_start_scheme_ev_secure">#1ac222</color>
<color name="url_emphasis_start_scheme_secure">#1ac222</color>
<color name="url_emphasis_non_emphasized_text">#80333333</color> <color name="url_emphasis_non_emphasized_text">#80333333</color>
<color name="url_emphasis_light_non_emphasized_text">#80ffffff</color> <color name="url_emphasis_light_non_emphasized_text">#80ffffff</color>
<color name="url_emphasis_domain_and_registry">#333333</color> <color name="url_emphasis_domain_and_registry">#333333</color>
......
...@@ -1262,7 +1262,7 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener, ...@@ -1262,7 +1262,7 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
mSecurityIconType = securityLevel; mSecurityIconType = securityLevel;
updateSecurityButton(!(securityLevel == ConnectionSecurityLevel.NONE && isSmallDevice)); updateSecurityButton(!(securityLevel == ConnectionSecurityLevel.NONE && isSmallDevice));
// Since we emphasize the schema of the URL based on the security type, we need to // Since we emphasize the scheme of the URL based on the security type, we need to
// refresh the emphasis. // refresh the emphasis.
mUrlBar.deEmphasizeUrl(); mUrlBar.deEmphasizeUrl();
emphasizeUrl(); emphasizeUrl();
...@@ -1275,14 +1275,8 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener, ...@@ -1275,14 +1275,8 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
@Override @Override
public boolean shouldEmphasizeHttpsScheme() { public boolean shouldEmphasizeHttpsScheme() {
int securityLevel = getSecurityLevel(); ToolbarDataProvider provider = getToolbarDataProvider();
if (securityLevel == ConnectionSecurityLevel.SECURITY_ERROR if (provider.isUsingBrandColor() || provider.isIncognito()) return false;
|| securityLevel == ConnectionSecurityLevel.SECURITY_WARNING
|| securityLevel == ConnectionSecurityLevel.SECURITY_POLICY_WARNING) {
return true;
}
if (getToolbarDataProvider().isUsingBrandColor()) return false;
if (getToolbarDataProvider().isIncognito()) return false;
return true; return true;
} }
......
...@@ -128,13 +128,9 @@ public class OmniboxUrlEmphasizer { ...@@ -128,13 +128,9 @@ public class OmniboxUrlEmphasizer {
public static void emphasizeUrl(Spannable url, Resources resources, Profile profile, public static void emphasizeUrl(Spannable url, Resources resources, Profile profile,
int securityLevel, boolean isInternalPage, int securityLevel, boolean isInternalPage,
boolean useDarkColors, boolean emphasizeHttpsScheme) { boolean useDarkColors, boolean emphasizeHttpsScheme) {
assert (securityLevel == ConnectionSecurityLevel.SECURITY_ERROR assert useDarkColors ? true : !emphasizeHttpsScheme;
|| securityLevel == ConnectionSecurityLevel.SECURITY_WARNING)
? emphasizeHttpsScheme
: true;
String urlString = url.toString(); String urlString = url.toString();
EmphasizeComponentsResponse emphasizeResponse = EmphasizeComponentsResponse emphasizeResponse =
parseForEmphasizeComponents(profile, urlString); parseForEmphasizeComponents(profile, urlString);
...@@ -149,29 +145,25 @@ public class OmniboxUrlEmphasizer { ...@@ -149,29 +145,25 @@ public class OmniboxUrlEmphasizer {
int startHostIndex = emphasizeResponse.hostStart; int startHostIndex = emphasizeResponse.hostStart;
int endHostIndex = emphasizeResponse.hostStart + emphasizeResponse.hostLength; int endHostIndex = emphasizeResponse.hostStart + emphasizeResponse.hostLength;
// Add the https scheme highlight // Color the HTTPS scheme.
ForegroundColorSpan span; ForegroundColorSpan span;
if (emphasizeResponse.hasScheme()) { if (emphasizeResponse.hasScheme()) {
int colorId = nonEmphasizedColorId; int colorId = nonEmphasizedColorId;
if (!isInternalPage && emphasizeHttpsScheme) { if (!isInternalPage) {
boolean strikeThroughScheme = false; boolean strikeThroughScheme = false;
switch (securityLevel) { switch (securityLevel) {
case ConnectionSecurityLevel.NONE: case ConnectionSecurityLevel.NONE:
colorId = nonEmphasizedColorId; // Intentional fall-through:
break;
case ConnectionSecurityLevel.SECURITY_WARNING: case ConnectionSecurityLevel.SECURITY_WARNING:
colorId = R.color.url_emphasis_start_scheme_security_warning;
strikeThroughScheme = true;
break; break;
case ConnectionSecurityLevel.SECURITY_ERROR: case ConnectionSecurityLevel.SECURITY_ERROR:
colorId = R.color.url_emphasis_start_scheme_security_error; if (emphasizeHttpsScheme) colorId = R.color.google_red_700;
strikeThroughScheme = true; strikeThroughScheme = true;
break; break;
case ConnectionSecurityLevel.EV_SECURE: case ConnectionSecurityLevel.EV_SECURE:
colorId = R.color.url_emphasis_start_scheme_ev_secure; // Intentional fall-through:
break;
case ConnectionSecurityLevel.SECURE: case ConnectionSecurityLevel.SECURE:
colorId = R.color.url_emphasis_start_scheme_secure; if (emphasizeHttpsScheme) colorId = R.color.google_green_700;
break; break;
default: default:
assert false; assert false;
......
...@@ -129,8 +129,8 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase { ...@@ -129,8 +129,8 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase {
EmphasizedUrlSpanHelper[] spans = EmphasizedUrlSpanHelper.getSpansForEmphasizedUrl(url); EmphasizedUrlSpanHelper[] spans = EmphasizedUrlSpanHelper.getSpansForEmphasizedUrl(url);
assertEquals("Unexpected number of spans:", 4, spans.length); assertEquals("Unexpected number of spans:", 4, spans.length);
spans[0].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources, spans[0].assertIsColoredSpan(
R.color.url_emphasis_start_scheme_secure)); "https", 0, ApiCompatibilityUtils.getColor(mResources, R.color.google_green_700));
spans[1].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources, spans[1].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_non_emphasized_text)); R.color.url_emphasis_non_emphasized_text));
spans[2].assertIsColoredSpan("www.google.com", 8, ApiCompatibilityUtils.getColor(mResources, spans[2].assertIsColoredSpan("www.google.com", 8, ApiCompatibilityUtils.getColor(mResources,
...@@ -179,8 +179,8 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase { ...@@ -179,8 +179,8 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase {
assertEquals("Unexpected number of spans:", 5, spans.length); assertEquals("Unexpected number of spans:", 5, spans.length);
spans[0].assertIsStrikethroughSpan("https", 0); spans[0].assertIsStrikethroughSpan("https", 0);
spans[1].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources, spans[1].assertIsColoredSpan(
R.color.url_emphasis_start_scheme_security_error)); "https", 0, ApiCompatibilityUtils.getColor(mResources, R.color.google_red_700));
spans[2].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources, spans[2].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_non_emphasized_text)); R.color.url_emphasis_non_emphasized_text));
spans[3].assertIsColoredSpan("www.google.com", 8, ApiCompatibilityUtils.getColor(mResources, spans[3].assertIsColoredSpan("www.google.com", 8, ApiCompatibilityUtils.getColor(mResources,
...@@ -203,13 +203,12 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase { ...@@ -203,13 +203,12 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase {
ConnectionSecurityLevel.SECURITY_WARNING, false, true, true); ConnectionSecurityLevel.SECURITY_WARNING, false, true, true);
EmphasizedUrlSpanHelper[] spans = EmphasizedUrlSpanHelper.getSpansForEmphasizedUrl(url); EmphasizedUrlSpanHelper[] spans = EmphasizedUrlSpanHelper.getSpansForEmphasizedUrl(url);
assertEquals("Unexpected number of spans:", 4, spans.length); assertEquals("Unexpected number of spans:", 3, spans.length);
spans[0].assertIsStrikethroughSpan("https", 0); spans[0].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources,
spans[1].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources, R.color.url_emphasis_non_emphasized_text));
R.color.url_emphasis_start_scheme_security_warning)); spans[1].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
spans[2].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_non_emphasized_text)); R.color.url_emphasis_non_emphasized_text));
spans[3].assertIsColoredSpan("www.dodgysite.com", 8, ApiCompatibilityUtils.getColor( spans[2].assertIsColoredSpan("www.dodgysite.com", 8, ApiCompatibilityUtils.getColor(
mResources, R.color.url_emphasis_domain_and_registry)); mResources, R.color.url_emphasis_domain_and_registry));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment