From 83b19b3e368997a4493d8ae6cf2d3188c60e7925 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Fri, 18 Jan 2019 18:07:19 +0900 Subject: [PATCH] Prevent loading sync ui in private window Currently, brave sync ui isn't allowed to load in private window. That only works properly in normal window. --- browser/brave_scheme_load_browsertest.cc | 7 +++++++ ...rome-browser-ui-browser_navigator.cc.patch | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 patches/chrome-browser-ui-browser_navigator.cc.patch diff --git a/browser/brave_scheme_load_browsertest.cc b/browser/brave_scheme_load_browsertest.cc index 1eb371f47773..d6953b561f66 100644 --- a/browser/brave_scheme_load_browsertest.cc +++ b/browser/brave_scheme_load_browsertest.cc @@ -237,3 +237,10 @@ IN_PROC_BROWSER_TEST_F(BraveSchemeLoadBrowserTest, NotAllowedInPrivateWindow) { TestURLIsNotLoadedInPrivateWindow(GURL("brave://settings/"), GURL("chrome://settings/")); } + +// Check brave sync page is also not loaded in private widnow. +IN_PROC_BROWSER_TEST_F(BraveSchemeLoadBrowserTest, + SyncUINotAllowedInPrivateWindow) { + TestURLIsNotLoadedInPrivateWindow(GURL("brave://sync/"), + GURL("chrome://sync/")); +} diff --git a/patches/chrome-browser-ui-browser_navigator.cc.patch b/patches/chrome-browser-ui-browser_navigator.cc.patch new file mode 100644 index 000000000000..127fc98e1762 --- /dev/null +++ b/patches/chrome-browser-ui-browser_navigator.cc.patch @@ -0,0 +1,21 @@ +diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc +index 57cc96c276c1106079828b5e359a3d88e1c901ce..81baaee0fdad10d4b1f4dc17889a44550083ee46 100644 +--- a/chrome/browser/ui/browser_navigator.cc ++++ b/chrome/browser/ui/browser_navigator.cc +@@ -707,6 +707,16 @@ bool IsHostAllowedInIncognito(const GURL& url) { + host != chrome::kChromeUISuggestionsHost; + } + ++#if defined(BRAVE_CHROMIUM_BUILD) ++ DCHECK(!url.SchemeIs(content::kBraveUIScheme)) ++ << "brave url should not be reached here. scheme mapping should be done " ++ "before. Use chrome scheme for this url: " ++ << url.spec(); ++ // sync page is not allowed in private window. ++ if (host == kBraveUISyncHost) ++ return false; ++#endif ++ + if (scheme != content::kChromeUIScheme) + return true; +