Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Remove unsupported protocol case, show unknown on origin change/nav s…
Browse files Browse the repository at this point in the history
…tart
  • Loading branch information
kylehickinson committed Nov 17, 2023
1 parent 6060ece commit b82c45d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ public class BrowserViewController: UIViewController {
updateTabsBarVisibility()
}

private func updateToolbarSecureContentState(_ secureContentState: TabSecureContentState) {
func updateToolbarSecureContentState(_ secureContentState: TabSecureContentState) {
topToolbar.secureContentState = secureContentState
collapsedURLBarView.secureContentState = secureContentState
}
Expand Down Expand Up @@ -1835,7 +1835,7 @@ public class BrowserViewController: UIViewController {

guard let scheme = tab.webView?.url?.scheme,
let host = tab.webView?.url?.host else {
tab.secureContentState = .unsupportedProtocol
tab.secureContentState = .unknown
self.updateURLBar()
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ extension BrowserViewController: WKNavigationDelegate {
}
toolbarVisibilityViewModel.toolbarState = .expanded

// check if web view is loading a different origin than the one currently loaded
if let selectedTab = tabManager.selectedTab,
selectedTab.url?.origin != webView.url?.origin {
// reset secure content state to unknown until page can be evaluated
selectedTab.secureContentState = .unknown
updateToolbarSecureContentState(.unknown)
// new site has a different origin, hide wallet icon.
tabManager.selectedTab?.isWalletIconVisible = false
// new site, reset connected addresses
Expand Down
5 changes: 2 additions & 3 deletions Sources/Brave/Frontend/Browser/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ enum TabSecureContentState {
case invalidCert
case missingSSL
case mixedContent
case unsupportedProtocol

var shouldDisplayWarning: Bool {
switch self {
case .invalidCert, .missingSSL, .mixedContent, .unsupportedProtocol:
case .unknown, .invalidCert, .missingSSL, .mixedContent:
return true
case .unknown, .localhost, .secure:
case .localhost, .secure:
return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ struct PageSecurityView: View {

private var warningTitle: String {
switch secureState {
case .unknown, .secure, .localhost:
case .secure, .localhost:
return ""
case .invalidCert, .missingSSL, .unsupportedProtocol:
case .unknown, .invalidCert, .missingSSL:
return Strings.PageSecurityView.pageNotSecureTitle
case .mixedContent:
return Strings.PageSecurityView.pageNotFullySecureTitle
Expand Down Expand Up @@ -71,7 +71,7 @@ struct PageSecurityView: View {
}
}
.background(Color(.braveBackground))
.frame(maxWidth: BraveUX.baseDimensionValue)
.frame(maxWidth: BraveUX.baseDimensionValue, alignment: .leading)
#if DEBUG
.onAppear {
assert(secureState.shouldDisplayWarning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CollapsedURLBarView: UIView {
let isTitleVisible = !traitCollection.preferredContentSizeCategory.isAccessibilityCategory

switch secureContentState {
case .unknown, .localhost, .secure:
case .localhost, .secure:
break
case .invalidCert:
configuration.baseForegroundColor = UIColor(braveSystemName: .systemfeedbackErrorIcon)
Expand All @@ -79,7 +79,7 @@ class CollapsedURLBarView: UIView {
configuration.attributedTitle = title
}
configuration.image = UIImage(braveSystemNamed: "leo.warning.triangle-filled")
case .unsupportedProtocol:
case .unknown:
configuration.baseForegroundColor = UIColor(braveSystemName: .iconDefault)
configuration.image = UIImage(braveSystemNamed: "leo.warning.circle-filled")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class TabLocationView: UIView {
let isTitleVisible = !traitCollection.preferredContentSizeCategory.isAccessibilityCategory

switch secureContentState {
case .unknown, .localhost, .secure:
case .localhost, .secure:
break
case .invalidCert:
configuration.baseForegroundColor = UIColor(braveSystemName: .systemfeedbackErrorIcon)
Expand All @@ -96,7 +96,7 @@ class TabLocationView: UIView {
configuration.attributedTitle = title
}
configuration.image = UIImage(braveSystemNamed: "leo.warning.triangle-filled")
case .unsupportedProtocol:
case .unknown:
configuration.baseForegroundColor = UIColor(braveSystemName: .iconDefault)
configuration.image = UIImage(braveSystemNamed: "leo.warning.circle-filled")
}
Expand Down Expand Up @@ -426,6 +426,7 @@ class TabLocationView: UIView {
voiceSearchButton.isHidden = (url != nil) || !isVoiceSearchAvailable
placeholderLabel.isHidden = url != nil
urlDisplayLabel.isHidden = url == nil
leadingItemContainerView.isHidden = url == nil
}

// MARK: Tap Actions
Expand Down

0 comments on commit b82c45d

Please sign in to comment.