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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « chrome/common/chrome_features.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sessions/content/content_serialized_navigation_driver.h" 5 #include "components/sessions/content/content_serialized_navigation_driver.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "components/sessions/core/serialized_navigation_entry.h" 9 #include "components/sessions/core/serialized_navigation_entry.h"
10 #include "content/public/common/page_state.h" 10 #include "content/public/common/page_state.h"
11 #include "content/public/common/referrer.h" 11 #include "content/public/common/referrer.h"
12 #include "content/public/common/url_constants.h" 12 #include "content/public/common/url_constants.h"
13 13
14 SESSIONS_EXPORT bool (*g_settingsFlagFunc)(void);
15
14 namespace sessions { 16 namespace sessions {
15 17
16 namespace { 18 namespace {
17 const int kObsoleteReferrerPolicyAlways = 0; 19 const int kObsoleteReferrerPolicyAlways = 0;
18 const int kObsoleteReferrerPolicyDefault = 1; 20 const int kObsoleteReferrerPolicyDefault = 1;
19 const int kObsoleteReferrerPolicyNever = 2; 21 const int kObsoleteReferrerPolicyNever = 2;
20 const int kObsoleteReferrerPolicyOrigin = 3; 22 const int kObsoleteReferrerPolicyOrigin = 3;
21 } // namespace 23 } // namespace
22 24
23 // static 25 // static
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // No need to compare the policy, as it doesn't change during 108 // No need to compare the policy, as it doesn't change during
107 // sanitization. If there has been a change, the referrer needs to be 109 // sanitization. If there has been a change, the referrer needs to be
108 // stripped from the page state as well. 110 // stripped from the page state as well.
109 if (navigation->referrer_url_ != new_referrer.url) { 111 if (navigation->referrer_url_ != new_referrer.url) {
110 navigation->referrer_url_ = GURL(); 112 navigation->referrer_url_ = GURL();
111 navigation->referrer_policy_ = GetDefaultReferrerPolicy(); 113 navigation->referrer_policy_ = GetDefaultReferrerPolicy();
112 navigation->encoded_page_state_ = 114 navigation->encoded_page_state_ =
113 StripReferrerFromPageState(navigation->encoded_page_state_); 115 StripReferrerFromPageState(navigation->encoded_page_state_);
114 } 116 }
115 117
118 if (g_settingsFlagFunc &&
Dan Beam 2016/07/21 23:36:18 can we plumb this through ContentBrowserClient? c
groby-ooo-7-16 2016/07/26 00:23:09 That was the plan, until I started digging deeper.
119 navigation->virtual_url_.SchemeIs(content::kChromeUIScheme)) {
120 if (g_settingsFlagFunc() &&
121 navigation->original_request_url().spec() ==
122 "chrome://chrome/settings/") {
123 navigation->original_request_url_ = GURL("chrome://settings/");
124 navigation->encoded_page_state_ =
125 content::PageState::CreateFromURL(navigation->original_request_url_)
126 .ToEncodedData();
127 }
128 if (!g_settingsFlagFunc() &&
129 navigation->original_request_url().spec() == "chrome://settings/") {
130 navigation->original_request_url_ = GURL("chrome://chrome/settings/");
131 navigation->encoded_page_state_ =
132 content::PageState::CreateFromURL(navigation->original_request_url_)
133 .ToEncodedData();
134 }
135 }
136
116 #if defined(OS_ANDROID) 137 #if defined(OS_ANDROID)
117 // Rewrite the old new tab and welcome page URLs to the new NTP URL. 138 // Rewrite the old new tab and welcome page URLs to the new NTP URL.
118 if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) && 139 if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) &&
119 (navigation->virtual_url_.host() == "welcome" || 140 (navigation->virtual_url_.host() == "welcome" ||
120 navigation->virtual_url_.host() == "newtab")) { 141 navigation->virtual_url_.host() == "newtab")) {
121 navigation->virtual_url_ = GURL("chrome-native://newtab/"); 142 navigation->virtual_url_ = GURL("chrome-native://newtab/");
122 navigation->original_request_url_ = navigation->virtual_url_; 143 navigation->original_request_url_ = navigation->virtual_url_;
123 navigation->encoded_page_state_ = content::PageState::CreateFromURL( 144 navigation->encoded_page_state_ = content::PageState::CreateFromURL(
124 navigation->virtual_url_).ToEncodedData(); 145 navigation->virtual_url_).ToEncodedData();
125 } 146 }
126 #endif // defined(OS_ANDROID) 147 #endif // defined(OS_ANDROID)
127 } 148 }
128 149
129 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState( 150 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState(
130 const std::string& page_state) const { 151 const std::string& page_state) const {
131 return content::PageState::CreateFromEncodedData(page_state) 152 return content::PageState::CreateFromEncodedData(page_state)
132 .RemoveReferrer() 153 .RemoveReferrer()
133 .ToEncodedData(); 154 .ToEncodedData();
134 } 155 }
135 156
136 } // namespace sessions 157 } // namespace sessions
OLDNEW
« no previous file with comments | « chrome/common/chrome_features.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698