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

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

Issue 2676893002: [Android History] Fix chrome://history redirect (Closed)
Patch Set: [Android History] Fix chrome://history redirect Created 3 years, 10 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
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 7aa7de842ae547e4dd3a9187bfb839690088165e..d9e4b1c7b2169c1adc9b89b7d8bb9bf27ca71565 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/common/content_features.h"
#include "content/public/common/page_state.h"
#include "content/public/common/referrer.h"
#include "content/public/common/url_constants.h"
@@ -138,6 +139,27 @@ void ContentSerializedNavigationDriver::Sanitize(
navigation->encoded_page_state_ = content::PageState::CreateFromURL(
navigation->virtual_url_).ToEncodedData();
}
+
+ if (base::FeatureList::IsEnabled(features::kNativeAndroidHistoryManager) &&
+ navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) &&
+ (navigation->virtual_url_.host_piece() == content::kChromeUIHistoryHost ||
+ navigation->virtual_url_.host_piece() ==
+ content::kChromeUIHistoryFrameHost)) {
+ // Rewrite the old history Web UI to the new android native history.
+ navigation->virtual_url_ = GURL(content::kChromeUINativeHistoryURL);
+ navigation->original_request_url_ = navigation->virtual_url_;
+ navigation->encoded_page_state_ = content::PageState::CreateFromURL(
+ navigation->virtual_url_).ToEncodedData();
+ } else if (
+ !base::FeatureList::IsEnabled(features::kNativeAndroidHistoryManager) &&
+ navigation->virtual_url_.SchemeIs(content::kChromeNativeUIScheme) &&
+ navigation->virtual_url_.host_piece() == content::kChromeUIHistoryHost) {
+ // If the android native history UI has been disabled, redirect
+ // chrome-native://history to the old web UI.
+ navigation->virtual_url_ = GURL(content::kChromeUIHistoryURL);
+ navigation->original_request_url_ = navigation->virtual_url_;
+ navigation->encoded_page_state_ = std::string();
+ }
#endif // defined(OS_ANDROID)
}

Powered by Google App Engine
This is Rietveld 408576698