[iOS] Add new favicon status to TabState (#34909)

This exposes the new favicon status method from WebState in TabState. In the future the `Favicon` value will be removed
This commit is contained in:
Kyle Hickinson
2026-03-24 09:59:06 -04:00
committed by GitHub
parent 6a07646ae0
commit a0877d1461
4 changed files with 23 additions and 0 deletions
@@ -79,6 +79,7 @@ public class AnyTabState: TabState {
set { tab.favicon = newValue }
}
public var faviconStatus: FaviconStatus? { tab.faviconStatus }
public var url: URL? { tab.url }
public var visibleURL: URL? { tab.visibleURL }
public var lastCommittedURL: URL? { tab.lastCommittedURL }
@@ -320,6 +320,10 @@ class ChromiumTabState: TabState, TabStateImpl {
return webView?.visibleSSLStatus?.certificate?.createServerTrust()
}
var favicon: Favicon?
var faviconStatus: FaviconStatus? {
guard let faviconStatus = webView?.faviconStatus else { return nil }
return .init(faviconStatus)
}
var url: URL? {
visibleURL
}
@@ -558,6 +562,12 @@ extension UserAgentType {
}
}
extension FaviconStatus {
init(_ faviconStatus: CWVFaviconStatus) {
self.init(url: faviconStatus.url, image: faviconStatus.image)
}
}
private struct ChromiumBackForwardList: BackForwardListProxy {
struct Item: BackForwardListItemProxy {
var item: CWVBackForwardListItem
+11
View File
@@ -63,6 +63,15 @@ public enum TabRestorationError: Error {
case invalidData
}
/// Favicon related information for a current navigation
public struct FaviconStatus {
/// The URL of the favicon which was used to load it off the web.
public var url: URL?
/// The favicon bitmap for the page. It is fetched asynchronously after the favicon URL is set,
/// so it is possible for `image` to be nil if the fetch hasn't completed
public var image: UIImage?
}
/// Core interface for interaction with the web
@dynamicMemberLookup
public protocol TabState: AnyObject {
@@ -129,6 +138,8 @@ public protocol TabState: AnyObject {
/// The current pages favicon
// TODO: Should be get only, make favicon fetch logic internal (brave/brave-browser#45095)
var favicon: Favicon? { get set }
/// The current cached favicon for the realized tab
var faviconStatus: FaviconStatus? { get }
/// The current URL loaded on the page, regardless of the navigation status or spoofing
@available(iOS, deprecated, message: "Use `visibleURL` or `lastCommittedURL` instead")
var url: URL? { get }
@@ -52,6 +52,7 @@ public final class FakeTabState: TabState {
public var visibleSecureContentState: SecureContentState { .unknown }
public var serverTrust: SecTrust? { nil }
public var favicon: Favicon?
public var faviconStatus: FaviconStatus? { nil }
public var url: URL? { visibleURL }
public var visibleURL: URL?
public var lastCommittedURL: URL?