-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use brave://
for the virtual url and chrome://
for the internal u…
#1385
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,29 +61,52 @@ using extensions::ChromeContentBrowserClientExtensionsPart; | |
|
||
namespace { | ||
|
||
bool HandleURLRewrite(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
if (url->SchemeIs(content::kChromeUIScheme) && | ||
(url->host() == chrome::kChromeUIWelcomeHost || | ||
url->host() == chrome::kChromeUIWelcomeWin10Host)) { | ||
*url = GURL(kBraveUIWelcomeURL); | ||
bool HandleURLOverrideRewrite(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
// redirect sync-internals | ||
if (url->host() == chrome::kChromeUISyncInternalsHost || | ||
url->host() == chrome::kChromeUISyncHost) { | ||
GURL::Replacements replacements; | ||
replacements.SetHostStr(chrome::kChromeUISyncHost); | ||
*url = url->ReplaceComponents(replacements); | ||
return true; | ||
} | ||
if (url->SchemeIs(content::kChromeUIScheme) && | ||
(url->host() == kBraveUISyncHost)) { | ||
*url = GURL(kBraveUISyncURL); | ||
|
||
// no special win10 welcome page | ||
if (url->host() == chrome::kChromeUIWelcomeWin10Host || | ||
url->host() == chrome::kChromeUIWelcomeHost) { | ||
*url = GURL(chrome::kChromeUIWelcomeURL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q) Why do you make rest handler skip for these two hosts (sync and welcome) by returning true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! I saw upstream code tries to rewritten it. Ignore my above comment. |
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool HandleURLReverseRewrite(GURL* url, | ||
|
||
bool HandleURLReverseOverrideRewrite(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
if (url->spec() == kBraveUIWelcomeURL || | ||
url->spec() == kBraveUISyncURL) { | ||
if (url->host() == chrome::kChromeUIWelcomeHost || | ||
url->host() == chrome::kChromeUISyncHost) { | ||
GURL::Replacements replacements; | ||
replacements.SetSchemeStr(kBraveUIScheme); | ||
*url = url->ReplaceComponents(replacements); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool HandleURLRewrite(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
if (url->SchemeIs(kBraveUIScheme)) { | ||
GURL::Replacements replacements; | ||
replacements.SetSchemeStr(content::kChromeUIScheme); | ||
*url = url->ReplaceComponents(replacements); | ||
} | ||
|
||
if (HandleURLOverrideRewrite(url, browser_context)) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
|
@@ -110,8 +133,10 @@ void BraveContentBrowserClient::BrowserURLHandlerCreated( | |
handler->AddHandlerPair(&webtorrent::HandleTorrentURLRewrite, | ||
&webtorrent::HandleTorrentURLReverseRewrite); | ||
handler->AddHandlerPair(&HandleURLRewrite, | ||
&HandleURLReverseRewrite); | ||
&HandleURLReverseOverrideRewrite); | ||
ChromeContentBrowserClient::BrowserURLHandlerCreated(handler); | ||
handler->AddHandlerPair(&HandleURLOverrideRewrite, | ||
&HandleURLReverseOverrideRewrite); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add new pair after adding super class' handlers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, the order is critical because of rewriting that the superclass does |
||
} | ||
|
||
bool BraveContentBrowserClient::AllowAccessCookie(const GURL& url, const GURL& first_party, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,32 +3,33 @@ | |
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#define FixupBrowserAboutURL FixupBrowserAboutURL_ChromiumImpl | ||
#define WillHandleBrowserAboutURL WillHandleBrowserAboutURL_ChromiumImpl | ||
#include "../../../../chrome/browser/browser_about_handler.cc" | ||
#undef FixupBrowserAboutURL | ||
#undef WillHandleBrowserAboutURL | ||
|
||
#include "brave/common/url_constants.h" | ||
#include "brave/common/webui_url_constants.h" | ||
|
||
bool FixupBrowserAboutURLBraveImpl(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
if (url->SchemeIs(kBraveUIScheme)) { | ||
bool FixupBrowserAboutURL(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
bool result = FixupBrowserAboutURL_ChromiumImpl(url, browser_context); | ||
|
||
// no special win10 welcome page | ||
if (url->host() == chrome::kChromeUIWelcomeWin10Host) | ||
*url = GURL(chrome::kChromeUIWelcomeURL); | ||
|
||
// redirect sync-internals | ||
if (url->host() == chrome::kChromeUISyncInternalsHost) { | ||
GURL::Replacements replacements; | ||
replacements.SetSchemeStr(content::kChromeUIScheme); | ||
replacements.SetHostStr(chrome::kChromeUISyncHost); | ||
*url = url->ReplaceComponents(replacements); | ||
} | ||
return true; | ||
} | ||
|
||
|
||
bool FixupBrowserAboutURL(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
FixupBrowserAboutURLBraveImpl(url, browser_context); | ||
return FixupBrowserAboutURL_ChromiumImpl(url, browser_context); | ||
} | ||
if (url->SchemeIs(content::kChromeUIScheme) && | ||
url->host() != chrome::kChromeUINewTabHost) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curiosity, any particular reason about excluding newtab host? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it breaks the extension newtab override functionality |
||
GURL::Replacements replacements; | ||
replacements.SetSchemeStr(kBraveUIScheme); | ||
*url = url->ReplaceComponents(replacements); | ||
} | ||
|
||
bool WillHandleBrowserAboutURL(GURL* url, | ||
content::BrowserContext* browser_context) { | ||
FixupBrowserAboutURLBraveImpl(url, browser_context); | ||
return WillHandleBrowserAboutURL_ChromiumImpl(url, browser_context); | ||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this second condition in if clause can be removed.