| 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. |
| 107 if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) && |
| 108 navigation->original_request_url_.SchemeIs(content::kChromeUIScheme)) { |
| 109 navigation->encoded_page_state_ = std::string(); |
| 110 } |
| 111 |
| 106 // No need to compare the policy, as it doesn't change during | 112 // 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 | 113 // sanitization. If there has been a change, the referrer needs to be |
| 108 // stripped from the page state as well. | 114 // stripped from the page state as well. |
| 109 if (navigation->referrer_url_ != new_referrer.url) { | 115 if (navigation->referrer_url_ != new_referrer.url) { |
| 110 navigation->referrer_url_ = GURL(); | 116 navigation->referrer_url_ = GURL(); |
| 111 navigation->referrer_policy_ = GetDefaultReferrerPolicy(); | 117 navigation->referrer_policy_ = GetDefaultReferrerPolicy(); |
| 112 navigation->encoded_page_state_ = | 118 navigation->encoded_page_state_ = |
| 113 StripReferrerFromPageState(navigation->encoded_page_state_); | 119 StripReferrerFromPageState(navigation->encoded_page_state_); |
| 114 } | 120 } |
| 115 | 121 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 } | 133 } |
| 128 | 134 |
| 129 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState( | 135 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState( |
| 130 const std::string& page_state) const { | 136 const std::string& page_state) const { |
| 131 return content::PageState::CreateFromEncodedData(page_state) | 137 return content::PageState::CreateFromEncodedData(page_state) |
| 132 .RemoveReferrer() | 138 .RemoveReferrer() |
| 133 .ToEncodedData(); | 139 .ToEncodedData(); |
| 134 } | 140 } |
| 135 | 141 |
| 136 } // namespace sessions | 142 } // namespace sessions |
| OLD | NEW |