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 @@
<color name="website_settings_popup_text_link">#4285f4</color>
<!-- 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_light_non_emphasized_text">#80ffffff</color>
<color name="url_emphasis_domain_and_registry">#333333</color>
......
......@@ -1262,7 +1262,7 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
mSecurityIconType = securityLevel;
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.
mUrlBar.deEmphasizeUrl();
emphasizeUrl();
......@@ -1275,14 +1275,8 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
@Override
public boolean shouldEmphasizeHttpsScheme() {
int securityLevel = getSecurityLevel();
if (securityLevel == ConnectionSecurityLevel.SECURITY_ERROR
|| securityLevel == ConnectionSecurityLevel.SECURITY_WARNING
|| securityLevel == ConnectionSecurityLevel.SECURITY_POLICY_WARNING) {
return true;
}
if (getToolbarDataProvider().isUsingBrandColor()) return false;
if (getToolbarDataProvider().isIncognito()) return false;
ToolbarDataProvider provider = getToolbarDataProvider();
if (provider.isUsingBrandColor() || provider.isIncognito()) return false;
return true;
}
......
......@@ -128,13 +128,9 @@ public class OmniboxUrlEmphasizer {
public static void emphasizeUrl(Spannable url, Resources resources, Profile profile,
int securityLevel, boolean isInternalPage,
boolean useDarkColors, boolean emphasizeHttpsScheme) {
assert (securityLevel == ConnectionSecurityLevel.SECURITY_ERROR
|| securityLevel == ConnectionSecurityLevel.SECURITY_WARNING)
? emphasizeHttpsScheme
: true;
assert useDarkColors ? true : !emphasizeHttpsScheme;
String urlString = url.toString();
EmphasizeComponentsResponse emphasizeResponse =
parseForEmphasizeComponents(profile, urlString);
......@@ -149,29 +145,25 @@ public class OmniboxUrlEmphasizer {
int startHostIndex = emphasizeResponse.hostStart;
int endHostIndex = emphasizeResponse.hostStart + emphasizeResponse.hostLength;
// Add the https scheme highlight
// Color the HTTPS scheme.
ForegroundColorSpan span;
if (emphasizeResponse.hasScheme()) {
int colorId = nonEmphasizedColorId;
if (!isInternalPage && emphasizeHttpsScheme) {
if (!isInternalPage) {
boolean strikeThroughScheme = false;
switch (securityLevel) {
case ConnectionSecurityLevel.NONE:
colorId = nonEmphasizedColorId;
break;
// Intentional fall-through:
case ConnectionSecurityLevel.SECURITY_WARNING:
colorId = R.color.url_emphasis_start_scheme_security_warning;
strikeThroughScheme = true;
break;
case ConnectionSecurityLevel.SECURITY_ERROR:
colorId = R.color.url_emphasis_start_scheme_security_error;
if (emphasizeHttpsScheme) colorId = R.color.google_red_700;
strikeThroughScheme = true;
break;
case ConnectionSecurityLevel.EV_SECURE:
colorId = R.color.url_emphasis_start_scheme_ev_secure;
break;
// Intentional fall-through:
case ConnectionSecurityLevel.SECURE:
colorId = R.color.url_emphasis_start_scheme_secure;
if (emphasizeHttpsScheme) colorId = R.color.google_green_700;
break;
default:
assert false;
......
......@@ -129,8 +129,8 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase {
EmphasizedUrlSpanHelper[] spans = EmphasizedUrlSpanHelper.getSpansForEmphasizedUrl(url);
assertEquals("Unexpected number of spans:", 4, spans.length);
spans[0].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_start_scheme_secure));
spans[0].assertIsColoredSpan(
"https", 0, ApiCompatibilityUtils.getColor(mResources, R.color.google_green_700));
spans[1].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_non_emphasized_text));
spans[2].assertIsColoredSpan("www.google.com", 8, ApiCompatibilityUtils.getColor(mResources,
......@@ -179,8 +179,8 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase {
assertEquals("Unexpected number of spans:", 5, spans.length);
spans[0].assertIsStrikethroughSpan("https", 0);
spans[1].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_start_scheme_security_error));
spans[1].assertIsColoredSpan(
"https", 0, ApiCompatibilityUtils.getColor(mResources, R.color.google_red_700));
spans[2].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_non_emphasized_text));
spans[3].assertIsColoredSpan("www.google.com", 8, ApiCompatibilityUtils.getColor(mResources,
......@@ -203,13 +203,12 @@ public class OmniboxUrlEmphasizerTest extends NativeLibraryTestBase {
ConnectionSecurityLevel.SECURITY_WARNING, false, true, true);
EmphasizedUrlSpanHelper[] spans = EmphasizedUrlSpanHelper.getSpansForEmphasizedUrl(url);
assertEquals("Unexpected number of spans:", 4, spans.length);
spans[0].assertIsStrikethroughSpan("https", 0);
spans[1].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_start_scheme_security_warning));
spans[2].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
assertEquals("Unexpected number of spans:", 3, spans.length);
spans[0].assertIsColoredSpan("https", 0, ApiCompatibilityUtils.getColor(mResources,
R.color.url_emphasis_non_emphasized_text));
spans[1].assertIsColoredSpan("://", 5, ApiCompatibilityUtils.getColor(mResources,
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));
}
......
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