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

Fix #8489: Follow Safari's behaviour for Desktop-UA #8490

Merged
merged 1 commit into from
Nov 28, 2023
Merged
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
7 changes: 7 additions & 0 deletions Sources/Brave/Frontend/Browser/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,13 @@ class Tab: NSObject {

func updateUserAgent(_ webView: WKWebView, newURL: URL) {
guard let baseDomain = newURL.baseDomain else { return }

let screenWidth = webView.currentScene?.screen.bounds.width ?? webView.bounds.size.width
if webView.traitCollection.horizontalSizeClass == .compact && (webView.bounds.size.width < screenWidth / 2.0) {
let desktopMode = userAgentOverrides[baseDomain] == true
webView.customUserAgent = desktopMode ? UserAgent.desktop : UserAgent.mobile
return
}

let desktopMode = userAgentOverrides[baseDomain] ?? UserAgent.shouldUseDesktopMode
webView.customUserAgent = desktopMode ? UserAgent.desktop : UserAgent.mobile
Expand Down