Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: components/sessions/content/content_serialized_navigation_driver.cc

Issue 2166693002: [MD Settings] PROOF OF CONCEPT - DO NOT LAND - URL rewrite (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use existing hooks Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) &&
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698