Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 | 96 |
| 97 void ContentSerializedNavigationDriver::Sanitize( | 97 void ContentSerializedNavigationDriver::Sanitize( |
| 98 SerializedNavigationEntry* navigation) const { | 98 SerializedNavigationEntry* navigation) const { |
| 99 content::Referrer old_referrer( | 99 content::Referrer old_referrer( |
| 100 navigation->referrer_url_, | 100 navigation->referrer_url_, |
| 101 static_cast<blink::WebReferrerPolicy>(navigation->referrer_policy_)); | 101 static_cast<blink::WebReferrerPolicy>(navigation->referrer_policy_)); |
| 102 content::Referrer new_referrer = | 102 content::Referrer new_referrer = |
| 103 content::Referrer::SanitizeForRequest(navigation->virtual_url_, | 103 content::Referrer::SanitizeForRequest(navigation->virtual_url_, |
| 104 old_referrer); | 104 old_referrer); |
| 105 | 105 |
| 106 // Clear any WebUI page state so that WebUI pages reloaded rather than | |
| 107 // restored from page state. This fixes session restore when WebUI URLs | |
| 108 // change. | |
| 109 if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) && | |
| 110 navigation->original_request_url_.SchemeIs(content::kChromeUIScheme)) { | |
|
Charlie Reis
2016/09/22 18:59:51
This seems like it affects too many cases. For UR
Dan Beam
2016/09/22 19:37:34
do those pages set different virtual URLs? could
calamity
2016/09/23 05:06:33
I don't think we can figure out if the page state
Charlie Reis
2016/09/23 06:33:53
Confirmed that chrome://settings and chrome://hist
| |
| 111 navigation->encoded_page_state_ = std::string(); | |
| 112 } | |
| 113 | |
| 106 // No need to compare the policy, as it doesn't change during | 114 // 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 | 115 // sanitization. If there has been a change, the referrer needs to be |
| 108 // stripped from the page state as well. | 116 // stripped from the page state as well. |
| 109 if (navigation->referrer_url_ != new_referrer.url) { | 117 if (navigation->referrer_url_ != new_referrer.url) { |
| 110 navigation->referrer_url_ = GURL(); | 118 navigation->referrer_url_ = GURL(); |
| 111 navigation->referrer_policy_ = GetDefaultReferrerPolicy(); | 119 navigation->referrer_policy_ = GetDefaultReferrerPolicy(); |
| 112 navigation->encoded_page_state_ = | 120 navigation->encoded_page_state_ = |
| 113 StripReferrerFromPageState(navigation->encoded_page_state_); | 121 StripReferrerFromPageState(navigation->encoded_page_state_); |
| 114 } | 122 } |
| 115 | 123 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 127 } | 135 } |
| 128 | 136 |
| 129 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState( | 137 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState( |
| 130 const std::string& page_state) const { | 138 const std::string& page_state) const { |
| 131 return content::PageState::CreateFromEncodedData(page_state) | 139 return content::PageState::CreateFromEncodedData(page_state) |
| 132 .RemoveReferrer() | 140 .RemoveReferrer() |
| 133 .ToEncodedData(); | 141 .ToEncodedData(); |
| 134 } | 142 } |
| 135 | 143 |
| 136 } // namespace sessions | 144 } // namespace sessions |
| OLD | NEW |