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

Commit

Permalink
Fix #8489: Follow Safari's behaviour for Desktop-UA (#8490)
Browse files Browse the repository at this point in the history
Follow Safari's behaviour for Desktop-UA when in compact horizontal size class.
  • Loading branch information
Brandon-T committed Nov 28, 2023
1 parent ed3ad28 commit 16f651e
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit 16f651e

Please sign in to comment.