Commit f26dc9e5 authored by Lei Tian's avatar Lei Tian Committed by Commit Bot

Fix CCT does not strikethrough scheme on broken https.

When CCT opens url like https://expired.badssl.com, the strikethrough
scheme sometimes does not display. This is because in CustomTabToolbar,
updateSecurityIcon does not demphasize the url before emphasize it and
this causes OmniboxUrlEmphasizer.hasEmphasisSpans() sometimes returns true
and prevents the emphasis. To fix the problem, remove the
hasEmphasisSpans check and always deEmphasizeUrl before emphasizeUrl the
url.

BUG=754985

Change-Id: I16143c4237d71ce9d5b860597f523942d314ba25
Reviewed-on: https://chromium-review.googlesource.com/675769
Commit-Queue: Lei Tian <ltian@google.com>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504469}
parent 57989437
...@@ -1392,9 +1392,7 @@ public class LocationBarLayout extends FrameLayout ...@@ -1392,9 +1392,7 @@ public class LocationBarLayout extends FrameLayout
changeLocationBarIcon(); changeLocationBarIcon();
updateLocationBarIconContainerVisibility(); updateLocationBarIconContainerVisibility();
// Since we emphasize the scheme of the URL based on the security type, we need to
// refresh the emphasis.
mUrlBar.deEmphasizeUrl();
emphasizeUrl(); emphasizeUrl();
mIsEmphasizingHttpsScheme = shouldEmphasizeHttpsScheme; mIsEmphasizingHttpsScheme = shouldEmphasizeHttpsScheme;
} }
...@@ -2147,7 +2145,6 @@ public class LocationBarLayout extends FrameLayout ...@@ -2147,7 +2145,6 @@ public class LocationBarLayout extends FrameLayout
setUrlBarText("", null); setUrlBarText("", null);
} else { } else {
if (setUrlBarText(url, displayText)) { if (setUrlBarText(url, displayText)) {
mUrlBar.deEmphasizeUrl();
emphasizeUrl(); emphasizeUrl();
} }
} }
......
...@@ -275,7 +275,6 @@ public class UrlBar extends AutocompleteEditText { ...@@ -275,7 +275,6 @@ public class UrlBar extends AutocompleteEditText {
} }
if (!hasFocus()) { if (!hasFocus()) {
deEmphasizeUrl();
emphasizeUrl(); emphasizeUrl();
} }
} }
...@@ -800,7 +799,7 @@ public class UrlBar extends AutocompleteEditText { ...@@ -800,7 +799,7 @@ public class UrlBar extends AutocompleteEditText {
*/ */
public void emphasizeUrl() { public void emphasizeUrl() {
Editable url = getText(); Editable url = getText();
if (OmniboxUrlEmphasizer.hasEmphasisSpans(url) || hasFocus()) { if (hasFocus()) {
return; return;
} }
...@@ -819,6 +818,9 @@ public class UrlBar extends AutocompleteEditText { ...@@ -819,6 +818,9 @@ public class UrlBar extends AutocompleteEditText {
// Ignore as this only is for applying color // Ignore as this only is for applying color
} }
// Since we emphasize the scheme of the URL based on the security type, we need to
// deEmphasize first to refresh.
deEmphasizeUrl();
OmniboxUrlEmphasizer.emphasizeUrl(url, getResources(), currentTab.getProfile(), OmniboxUrlEmphasizer.emphasizeUrl(url, getResources(), currentTab.getProfile(),
currentTab.getSecurityLevel(), isInternalPage, currentTab.getSecurityLevel(), isInternalPage,
mUseDarkColors, mUrlBarDelegate.shouldEmphasizeHttpsScheme()); mUseDarkColors, mUrlBarDelegate.shouldEmphasizeHttpsScheme());
......
...@@ -388,7 +388,6 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar, ...@@ -388,7 +388,6 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
} }
if (mUrlBar.setUrl(url, displayText)) { if (mUrlBar.setUrl(url, displayText)) {
mUrlBar.deEmphasizeUrl();
mUrlBar.emphasizeUrl(); mUrlBar.emphasizeUrl();
} }
} }
......
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