Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FXIOS-10205 [Swiftlint] Resolve 13 implicitly_unwrapped_optional violations in Client/TabManagement #23880

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions firefox-ios/Client/TabManagement/Legacy/LegacyTabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class LegacyTabManager: NSObject, FeatureFlaggable, TabManager, TabEventHandler
}

@discardableResult
func addTab(_ request: URLRequest! = nil,
func addTab(_ request: URLRequest? = nil,
afterTab: Tab? = nil,
zombie: Bool = false,
isPrivate: Bool = false
Expand All @@ -375,7 +375,7 @@ class LegacyTabManager: NSObject, FeatureFlaggable, TabManager, TabEventHandler
return
}

var tab: Tab!
var tab: Tab?
for url in urls {
tab = addTab(URLRequest(url: url), flushToDisk: false, zombie: zombie, isPrivate: isPrivate)
}
Expand Down Expand Up @@ -1017,23 +1017,23 @@ class LegacyTabManager: NSObject, FeatureFlaggable, TabManager, TabEventHandler
// MARK: - WKNavigationDelegate
extension LegacyTabManager: WKNavigationDelegate {
// Note the main frame JSContext (i.e. document, window) is not available yet.
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation?) {
if let tab = self[webView], let blocker = tab.contentBlocker {
blocker.clearPageStats()
}
}

// The main frame JSContext is available, and DOM parsing has begun.
// Do not execute JS at this point that requires running prior to DOM parsing.
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation?) {
guard let tab = self[webView] else { return }

if let tpHelper = tab.contentBlocker, !tpHelper.isEnabled {
webView.evaluateJavascriptInDefaultContentWorld("window.__firefox__.TrackingProtectionStats.setEnabled(false, \(UserScriptManager.appIdToken))")
}
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation?) {
// tab restore uses internal pages, so don't call storeChanges unnecessarily on startup
if let url = webView.url {
if InternalURL(url) != nil {
Expand Down
4 changes: 2 additions & 2 deletions firefox-ios/Client/TabManagement/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protocol TabManager: AnyObject {
func findRightOrLeftTab(forRemovedTab removedTab: Tab, withDeletedIndex deletedIndex: Int) -> Tab?

@discardableResult
func addTab(_ request: URLRequest!,
func addTab(_ request: URLRequest?,
afterTab: Tab?,
zombie: Bool,
isPrivate: Bool) -> Tab
Expand Down Expand Up @@ -130,7 +130,7 @@ extension TabManager {
}

@discardableResult
func addTab(_ request: URLRequest! = nil,
func addTab(_ request: URLRequest? = nil,
afterTab: Tab? = nil,
zombie: Bool = false,
isPrivate: Bool = false
Expand Down
12 changes: 6 additions & 6 deletions firefox-ios/Client/TabManagement/TabManagerNavDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class TabManagerNavDelegate: NSObject, WKNavigationDelegate {
delegates.insert(delegate)
}

func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation?) {
for delegate in delegates {
delegate.webView?(webView, didCommit: navigation)
}
}

func webView(
_ webView: WKWebView,
didFail navigation: WKNavigation!,
didFail navigation: WKNavigation?,
withError error: Error
) {
for delegate in delegates {
Expand All @@ -32,15 +32,15 @@ class TabManagerNavDelegate: NSObject, WKNavigationDelegate {

func webView(
_ webView: WKWebView,
didFailProvisionalNavigation navigation: WKNavigation!,
didFailProvisionalNavigation navigation: WKNavigation?,
withError error: Error
) {
for delegate in delegates {
delegate.webView?(webView, didFailProvisionalNavigation: navigation, withError: error)
}
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation?) {
for delegate in delegates {
delegate.webView?(webView, didFinish: navigation)
}
Expand Down Expand Up @@ -70,13 +70,13 @@ class TabManagerNavDelegate: NSObject, WKNavigationDelegate {
}
}

func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation?) {
for delegate in delegates {
delegate.webView?(webView, didReceiveServerRedirectForProvisionalNavigation: navigation)
}
}

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation?) {
for delegate in delegates {
delegate.webView?(webView, didStartProvisionalNavigation: navigation)
}
Expand Down