Commit c84187c1 authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

Fix site settings button and detail link not shown on page info

Fix site settings and detail link not shown on page info under URL
with certain unescaped characters.

Bug: 874455
Change-Id: Icf31bee1b644136d285c5286938b16bc2b3de88c
Reviewed-on: https://chromium-review.googlesource.com/c/1278205
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599315}
parent 6072eb20
...@@ -56,6 +56,7 @@ import org.chromium.components.security_state.ConnectionSecurityLevel; ...@@ -56,6 +56,7 @@ import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.components.url_formatter.UrlFormatter; import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver; import org.chromium.content_public.browser.WebContentsObserver;
import org.chromium.net.GURLUtils;
import org.chromium.ui.base.DeviceFormFactor; import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
...@@ -119,9 +120,8 @@ public class PageInfoController ...@@ -119,9 +120,8 @@ public class PageInfoController
// URL'. // URL'.
private String mFullUrl; private String mFullUrl;
// A parsed version of mFullUrl. Is null if the URL is invalid/cannot be // The scheme of the URL of this page.
// parsed. private String mScheme;
private URI mParsedUrl;
// Whether or not this page is an internal chrome page (e.g. the // Whether or not this page is an internal chrome page (e.g. the
// chrome://settings page). // chrome://settings page).
...@@ -198,12 +198,11 @@ public class PageInfoController ...@@ -198,12 +198,11 @@ public class PageInfoController
// This can happen if an invalid chrome-distiller:// url was entered. // This can happen if an invalid chrome-distiller:// url was entered.
if (mFullUrl == null) mFullUrl = ""; if (mFullUrl == null) mFullUrl = "";
mScheme = GURLUtils.getScheme(mFullUrl);
try { try {
mParsedUrl = new URI(mFullUrl); mIsInternalPage = UrlUtilities.isInternalScheme(new URI(mFullUrl));
mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl);
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
mParsedUrl = null; // Ignore exception since this is for displaying some specific content on page info.
mIsInternalPage = false;
} }
String displayUrl = UrlFormatter.formatUrlForCopy(mFullUrl); String displayUrl = UrlFormatter.formatUrlForCopy(mFullUrl);
...@@ -227,7 +226,7 @@ public class PageInfoController ...@@ -227,7 +226,7 @@ public class PageInfoController
viewParams.urlOriginLength = OmniboxUrlEmphasizer.getOriginEndIndex( viewParams.urlOriginLength = OmniboxUrlEmphasizer.getOriginEndIndex(
displayUrlBuilder.toString(), mTab.getProfile()); displayUrlBuilder.toString(), mTab.getProfile());
if (shouldShowSiteSettingsButton(mParsedUrl)) { if (shouldShowSiteSettingsButton()) {
viewParams.siteSettingsButtonClickCallback = () -> { viewParams.siteSettingsButtonClickCallback = () -> {
// Delay while the dialog closes. // Delay while the dialog closes.
runAfterDismiss(() -> { runAfterDismiss(() -> {
...@@ -365,8 +364,7 @@ public class PageInfoController ...@@ -365,8 +364,7 @@ public class PageInfoController
*/ */
private boolean isConnectionDetailsLinkVisible() { private boolean isConnectionDetailsLinkVisible() {
return mContentPublisher == null && !isShowingOfflinePage() && !isShowingPreview() return mContentPublisher == null && !isShowingOfflinePage() && !isShowingPreview()
&& mParsedUrl != null && mParsedUrl.getScheme() != null && UrlConstants.HTTPS_SCHEME.equals(mScheme);
&& mParsedUrl.getScheme().equals(UrlConstants.HTTPS_SCHEME);
} }
/** /**
...@@ -517,21 +515,12 @@ public class PageInfoController ...@@ -517,21 +515,12 @@ public class PageInfoController
} }
/** /**
* Whether the site settings button should be displayed for the given URI. * Whether the site settings button should be displayed for the given URL.
*
* @param uri The URI used to determine if the site settings button should be displayed.
*/ */
private boolean shouldShowSiteSettingsButton(URI uri) { private boolean shouldShowSiteSettingsButton() {
if (uri == null || uri.getScheme() == null) { return !isShowingOfflinePage() && !isShowingPreview()
return false; && (UrlConstants.HTTP_SCHEME.equals(mScheme)
} || UrlConstants.HTTPS_SCHEME.equals(mScheme));
if (isShowingOfflinePage() || isShowingPreview()) {
return false;
}
return uri.getScheme().equals(UrlConstants.HTTP_SCHEME)
|| uri.getScheme().equals(UrlConstants.HTTPS_SCHEME);
} }
private boolean isSheet() { private boolean isSheet() {
......
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