| Index: components/sessions/content/content_serialized_navigation_driver.cc
|
| diff --git a/components/sessions/content/content_serialized_navigation_driver.cc b/components/sessions/content/content_serialized_navigation_driver.cc
|
| index a3305a8695311157429112f3677d91fa124daac5..82b7d98cda8bcdcba166bfc5e943927ca9d9fe22 100644
|
| --- a/components/sessions/content/content_serialized_navigation_driver.cc
|
| +++ b/components/sessions/content/content_serialized_navigation_driver.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/memory/singleton.h"
|
| #include "build/build_config.h"
|
| #include "components/sessions/core/serialized_navigation_entry.h"
|
| +#include "content/public/browser/browser_url_handler.h"
|
| #include "content/public/common/page_state.h"
|
| #include "content/public/common/referrer.h"
|
| #include "content/public/common/url_constants.h"
|
| @@ -113,6 +114,27 @@ void ContentSerializedNavigationDriver::Sanitize(
|
| StripReferrerFromPageState(navigation->encoded_page_state_);
|
| }
|
|
|
| + // Rewrite any WebUI links that do not have an appropriate handler any more.
|
| + if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme)) {
|
| + // I'd like to check for "is handled by WebUI" here, so we don't
|
| + // unnecessarily rewrite - but oh well. It's not accessible.
|
| + // content::WebUI::TypeID type_id =
|
| + // content::WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType(
|
| + // nullptr, navigation->original_request_url_);
|
| + // if (type_id != content::WebUI::kNoWebUI) {
|
| + // in place of that, let's check if the original URL is a chrome:// URL as
|
| + // well.
|
| + if (navigation->original_request_url_.SchemeIs(content::kChromeUIScheme)) {
|
| + bool reverse_on_redirect;
|
| + navigation->original_request_url_ = navigation->virtual_url_;
|
| + content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
|
| + &navigation->original_request_url_, nullptr, &reverse_on_redirect);
|
| + navigation->encoded_page_state_ =
|
| + content::PageState::CreateFromURL(navigation->original_request_url_)
|
| + .ToEncodedData();
|
| + }
|
| + }
|
| +
|
| #if defined(OS_ANDROID)
|
| // Rewrite the old new tab and welcome page URLs to the new NTP URL.
|
| if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) &&
|
|
|