brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.96k stars 2.35k forks source link

[ads] Fix iOS single-page application/same document navigations #38662

Open aseren opened 6 months ago

aseren commented 6 months ago

Description

The current implementation of same document navigations detecting/handling on iOS is not perfect and fires a lots of false positives: https://github.com/brave/brave-core/blob/master/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift#L1979

Need to find a way of implementing same document navigation detection properly. See desktop implementation https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/navigation_handle.h;l=335

tmancey commented 4 months ago

@aseren https://github.com/brave/brave-browser/issues/39506 should also be fixed as part of this issue on iOS.

aseren commented 4 months ago

Closing the issue, as per discussion with ios-team, this is not possible to be properly implemented for now. The reason is that we don't get actual navigation events for these, so we can only rely on the URL changing

Eventually, when iOS is switched to WebState, this can be properly done by using tab helpers: https://source.chromium.org/chromium/chromium/src/+/main:ios/web/public/web_state_observer.h;l=77?q=webstateobserver

tmancey commented 4 months ago

Reopening issue as can be resolved after https://github.com/brave/roadmap/issues/1381. Thanks

tmancey commented 4 months ago

@aseren unblocked as we can use https://github.com/brave/brave-core/blob/master/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Paged/ReadyStateScript.js#L35