-
Notifications
You must be signed in to change notification settings - Fork 885
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
Conversation
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.
nice cleanup
It would be good to have a test that checks virtual url is brave url for chrome or brave webui navigation. |
yep, I'm going to look to see what tests already exist and see what others make sense. It looks like some tests are broken now, but haven't looked at them yet so not sure if it's a code or test issue |
I think only fixup handler should be executed when original url is chrome. This PR adds unnecessary mapping from brave to chrome url in URLHandler when |original_url| is chrome url. When |original_url| is chrome url, we just want to set brave url as a virtual url and original chrome url should be passed to |load_to_url|. In the near future, we want to delete mapping code in URLHandler because we want to move mapping timing from URLHandler to more earlier. So, URLHandler should not be executed when chrome url is original url.
|
@simonhong what unnecessary mapping is happening? We are mapping the virtual url to brave:// and the url_to_load to chrome:// |
@bridiver Yep, that's the result of URLHandler. |
@@ -109,9 +123,9 @@ void BraveContentBrowserClient::BrowserURLHandlerCreated( | |||
content::BrowserURLHandler::null_handler()); | |||
handler->AddHandlerPair(&webtorrent::HandleTorrentURLRewrite, | |||
&webtorrent::HandleTorrentURLReverseRewrite); | |||
ChromeContentBrowserClient::BrowserURLHandlerCreated(handler); |
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.
This point is what I worried.
When user types chrome url, load to url is initialized with brave url.
Then, I think brave url is the input of URLHandler before it is re-written our handler by below.
If so, that could cause skipping upstream URLHandler that checks chrome scheme.
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.
I see your point, but we may need to add two handers then because we have to run after ChromeContentBrowserClient to fix kChromeUISyncInternalsHost. I'll look at the upstream code to try to find something it breaks and update either way to convert back to chrome before the superclass method
content::BrowserContext* browser_context) { | ||
// redirect sync-internals | ||
if (url->host() == chrome::kChromeUISyncInternalsHost || | ||
url->host() == chrome::kChromeUISyncHost) { |
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.
// 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 comment
The 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?
Do you think upstream url handler doesn't need to handle them?
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.
Ah! I saw upstream code tries to rewritten it. Ignore my above comment.
ChromeContentBrowserClient::BrowserURLHandlerCreated(handler); | ||
handler->AddHandlerPair(&HandleURLOverrideRewrite, | ||
&HandleURLReverseOverrideRewrite); |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the order is critical because of rewriting that the superclass does
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it breaks the extension newtab override functionality
This comment was marked as abuse.
This comment was marked as abuse.
I'm going to remove myself from the list of reviewers since I don't think I'll have much useful feedback to provide here. |
…rl to load
fix brave/brave-browser#1616
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) ongit rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist: