From 4bc85545342d73537c28b27ddcdf6978ecce13d6 Mon Sep 17 00:00:00 2001 From: Zakhar Voit Date: Thu, 29 Feb 2024 15:36:56 +0800 Subject: [PATCH] [Chromium] Fix YouTube navigation Fix back/forward navigation from YouTube pages by marking mobile URLs of YouTube as skippable so that only desktop URLs are used in navigation. --- .../wolvic/browser/api/impl/TabWebContentsDelegate.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/common/chromium/com/igalia/wolvic/browser/api/impl/TabWebContentsDelegate.java b/app/src/common/chromium/com/igalia/wolvic/browser/api/impl/TabWebContentsDelegate.java index aa693b62e6..d058049008 100644 --- a/app/src/common/chromium/com/igalia/wolvic/browser/api/impl/TabWebContentsDelegate.java +++ b/app/src/common/chromium/com/igalia/wolvic/browser/api/impl/TabWebContentsDelegate.java @@ -14,6 +14,7 @@ import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.WebContents; import org.chromium.url.GURL; +import org.chromium.wolvic.Tab; import org.chromium.wolvic.WolvicWebContentsDelegate; public class TabWebContentsDelegate extends WolvicWebContentsDelegate { @@ -110,6 +111,10 @@ public void onUpdateUrl(GURL url) { // If mobile Youtube URL is detected, redirect to the desktop version. if (!url.getSpec().equals(newUrl)) { LoadUrlParams params = new LoadUrlParams(newUrl); + mWebContents.getNavigationController().setEntryExtraData( + mWebContents.getNavigationController().getLastCommittedEntryIndex(), + Tab.NAVIGATION_ENTRY_MARKED_AS_SKIPPED_KEY, + Tab.NAVIGATION_ENTRY_MARKED_AS_SKIPPED_VALUE); mWebContents.getNavigationController().loadUrl(params); return; }