From 7a808f8849069f5ab342d3fae83e1d85d62a60be Mon Sep 17 00:00:00 2001 From: Pete Miller Date: Mon, 3 Oct 2022 14:45:34 -0700 Subject: [PATCH] Display brave:// protocol for internal urls when hovered Replaces chrome://. This is another unfortunate side effect of us still using chrome:// as the protocol which is neccessary as there are many checks for that string specifically and we're not at a point to change that at the moment. However, this is probably the most visible place remaining where Brave still shows chrome:// and so changing it to brave:// is helpful to avoid confusion --- browser/ui/brave_browser.cc | 11 +++++++++++ browser/ui/brave_browser.h | 1 + 2 files changed, 12 insertions(+) diff --git a/browser/ui/brave_browser.cc b/browser/ui/brave_browser.cc index 4ff1a6d49ca6..f89088af029f 100644 --- a/browser/ui/brave_browser.cc +++ b/browser/ui/brave_browser.cc @@ -163,6 +163,17 @@ void BraveBrowser::ResetTryToCloseWindow() { Browser::ResetTryToCloseWindow(); } +void BraveBrowser::UpdateTargetURL(content::WebContents* source, + const GURL& url) { + GURL target_url = url; + if (url.SchemeIs(content::kChromeUIScheme)) { + GURL::Replacements replacements; + replacements.SetSchemeStr(content::kBraveUIScheme); + target_url = target_url.ReplaceComponents(replacements); + } + Browser::UpdateTargetURL(source, target_url); +} + bool BraveBrowser::ShouldAskForBrowserClosingBeforeHandlers() { if (g_suppress_dialog_for_testing) return false; diff --git a/browser/ui/brave_browser.h b/browser/ui/brave_browser.h index b90d918d9076..cedaab6c36f1 100644 --- a/browser/ui/brave_browser.h +++ b/browser/ui/brave_browser.h @@ -46,6 +46,7 @@ class BraveBrowser : public Browser { bool TryToCloseWindow( bool skip_beforeunload, const base::RepeatingCallback& on_close_confirmed) override; + void UpdateTargetURL(content::WebContents* source, const GURL& url) override; void ResetTryToCloseWindow() override; void TabStripEmpty() override;