chrome: Fix URL rewrite on new tab navigation (see issue #2969)

This fixes an `Unhandled chrome.send("getApps");` error when creating a new tab.

Creating a new tab initially loads chrome://newtab which should then be
rewritten to chrome://new-tab-page for normal profiles in
HandleNewTabURLRewrite. Failure to rewrite the URL results in the loading of
NewTabUI instead of the expected NewTabPageUI. NewTabUI loads different
resources for normal vs incognito/guest profiles (new_tab.js vs
incognito_tab.js), and new_tab.js calls chrome.send("getApps") via
page_list_view.js. This then fails in WebUIImpl::ProcessWebUIMessage because
the message is unhandled.
This commit is contained in:
Marshall Greenblatt
2021-02-27 14:25:46 -05:00
parent 1d39ff720e
commit a6a8c0e845
4 changed files with 38 additions and 8 deletions

View File

@ -632,11 +632,16 @@ class CefWebUIControllerFactory : public content::WebUIControllerFactory {
}
static void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) {
// Handler to rewrite chrome://about and chrome://sync URLs.
handler->AddHandlerPair(&HandleChromeAboutAndChromeSyncRewrite,
content::BrowserURLHandler::null_handler());
// For Chrome runtime this is registered in
// ChromeContentBrowserClient::BrowserURLHandlerCreated().
if (cef::IsAlloyRuntimeEnabled()) {
// Handler to rewrite chrome://about and chrome://sync URLs.
handler->AddHandlerPair(&HandleChromeAboutAndChromeSyncRewrite,
content::BrowserURLHandler::null_handler());
}
// chrome: & friends.
// chrome: & friends. For Chrome runtime the default registration is
// disabled is ChromeContentBrowserClient::BrowserURLHandlerCreated().
handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse);
}