Skip to content

Commit

Permalink
Copy code from #26099 and handle data, about, file, wss, etc schemes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Oct 19, 2024
1 parent 5bae8b7 commit a9889e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class CollapsedURLBarView: UIView {
Strings.PageSecurityView.signIntoWebsiteURLBarTitle
} else {
URLFormatter.formatURLOrigin(
forDisplayOmitSchemePathAndTrivialSubdomains: $0.scheme == "blob"
forDisplayOmitSchemePathAndTrivialSubdomains: $0.scheme != "http"
|| $0.scheme != "https"
? URLOrigin(url: $0).url?.absoluteString ?? $0.absoluteString : $0.absoluteString
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,24 +452,24 @@ class TabLocationView: UIView {
}

private func updateURLBarWithText() {
guard let url = url else {
urlDisplayLabel.text = ""
return
}

if let internalURL = InternalURL(url), internalURL.isBasicAuthURL {
urlDisplayLabel.text = Strings.PageSecurityView.signIntoWebsiteURLBarTitle
if let url = url {
if let internalURL = InternalURL(url), internalURL.isBasicAuthURL {
urlDisplayLabel.text = Strings.PageSecurityView.signIntoWebsiteURLBarTitle
} else {
// Matches LocationBarModelImpl::GetFormattedURL in Chromium (except for omitHTTP)
// components/omnibox/browser/location_bar_model_impl.cc
// TODO: Export omnibox related APIs and use directly
urlDisplayLabel.text = URLFormatter.formatURL(
url.scheme != "http" || url.scheme != "https"
? URLOrigin(url: url).url?.absoluteString ?? "" : url.absoluteString,
formatTypes: [
.trimAfterHost, .omitHTTP, .omitHTTPS, .omitTrivialSubdomains, .omitDefaults,
],
unescapeOptions: .normal
)
}
} else {
// Matches LocationBarModelImpl::GetFormattedURL in Chromium (except for omitHTTP)
// components/omnibox/browser/location_bar_model_impl.cc
// TODO: Export omnibox related APIs and use directly
urlDisplayLabel.text = URLFormatter.formatURL(
url.scheme == "blob" ? URLOrigin(url: url).url?.absoluteString ?? "" : url.absoluteString,
formatTypes: [
.trimAfterHost, .omitHTTP, .omitHTTPS, .omitTrivialSubdomains, .omitDefaults,
],
unescapeOptions: .normal
)
urlDisplayLabel.text = ""
}

reloadButton.isHidden = url == nil
Expand Down

0 comments on commit a9889e4

Please sign in to comment.