Skip to content

Commit

Permalink
Prevent loading sync ui in private window
Browse files Browse the repository at this point in the history
Currently, brave sync ui isn't allowed to load in private window.
That only works properly in normal window.
  • Loading branch information
simonhong committed Jan 18, 2019
1 parent 3b244d2 commit 83b19b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions browser/brave_scheme_load_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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/"));
}
21 changes: 21 additions & 0 deletions patches/chrome-browser-ui-browser_navigator.cc.patch
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 83b19b3

Please sign in to comment.