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/content_features.h" | |
10 #include "content/public/common/page_state.h" | 11 #include "content/public/common/page_state.h" |
11 #include "content/public/common/referrer.h" | 12 #include "content/public/common/referrer.h" |
12 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
13 | 14 |
14 namespace sessions { | 15 namespace sessions { |
15 | 16 |
16 namespace { | 17 namespace { |
17 const int kObsoleteReferrerPolicyAlways = 0; | 18 const int kObsoleteReferrerPolicyAlways = 0; |
18 const int kObsoleteReferrerPolicyDefault = 1; | 19 const int kObsoleteReferrerPolicyDefault = 1; |
19 const int kObsoleteReferrerPolicyNever = 2; | 20 const int kObsoleteReferrerPolicyNever = 2; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 #if defined(OS_ANDROID) | 132 #if defined(OS_ANDROID) |
132 // Rewrite the old new tab and welcome page URLs to the new NTP URL. | 133 // Rewrite the old new tab and welcome page URLs to the new NTP URL. |
133 if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) && | 134 if (navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) && |
134 (navigation->virtual_url_.host_piece() == "welcome" || | 135 (navigation->virtual_url_.host_piece() == "welcome" || |
135 navigation->virtual_url_.host_piece() == "newtab")) { | 136 navigation->virtual_url_.host_piece() == "newtab")) { |
136 navigation->virtual_url_ = GURL("chrome-native://newtab/"); | 137 navigation->virtual_url_ = GURL("chrome-native://newtab/"); |
137 navigation->original_request_url_ = navigation->virtual_url_; | 138 navigation->original_request_url_ = navigation->virtual_url_; |
138 navigation->encoded_page_state_ = content::PageState::CreateFromURL( | 139 navigation->encoded_page_state_ = content::PageState::CreateFromURL( |
139 navigation->virtual_url_).ToEncodedData(); | 140 navigation->virtual_url_).ToEncodedData(); |
140 } | 141 } |
142 | |
143 if (base::FeatureList::IsEnabled(features::kNativeAndroidHistoryManager) && | |
144 navigation->virtual_url_.SchemeIs(content::kChromeUIScheme) && | |
145 (navigation->virtual_url_.host_piece() == content::kChromeUIHistoryHost || | |
146 navigation->virtual_url_.host_piece() == "history-frame")) { | |
sky
2017/02/06 22:32:14
Is history-frame really not defined anywhere?
Theresa
2017/02/06 23:38:09
It wasn't defined anywhere that was accessible by
| |
147 // Rewrite the old history Web UI to the new android native history. | |
148 navigation->virtual_url_ = GURL("chrome-native://history/"); | |
sky
2017/02/06 22:32:14
Seems like this should be constants, right?
Theresa
2017/02/06 23:38:09
Done.
| |
149 navigation->original_request_url_ = navigation->virtual_url_; | |
150 navigation->encoded_page_state_ = content::PageState::CreateFromURL( | |
151 navigation->virtual_url_).ToEncodedData(); | |
152 } else if ( | |
153 !base::FeatureList::IsEnabled(features::kNativeAndroidHistoryManager) && | |
154 navigation->virtual_url_.SchemeIs("chrome-native") && | |
155 navigation->virtual_url_.host_piece() == content::kChromeUIHistoryHost) { | |
156 // If the android native history UI has been disabled, redirect | |
157 // chrome-native://history to the old web UI. | |
158 navigation->virtual_url_ = GURL("chrome://history/"); | |
159 navigation->original_request_url_ = navigation->virtual_url_; | |
160 navigation->encoded_page_state_ = std::string(); | |
161 } | |
141 #endif // defined(OS_ANDROID) | 162 #endif // defined(OS_ANDROID) |
142 } | 163 } |
143 | 164 |
144 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState( | 165 std::string ContentSerializedNavigationDriver::StripReferrerFromPageState( |
145 const std::string& page_state) const { | 166 const std::string& page_state) const { |
146 return content::PageState::CreateFromEncodedData(page_state) | 167 return content::PageState::CreateFromEncodedData(page_state) |
147 .RemoveReferrer() | 168 .RemoveReferrer() |
148 .ToEncodedData(); | 169 .ToEncodedData(); |
149 } | 170 } |
150 | 171 |
151 void ContentSerializedNavigationDriver::RegisterExtendedInfoHandler( | 172 void ContentSerializedNavigationDriver::RegisterExtendedInfoHandler( |
152 const std::string& key, | 173 const std::string& key, |
153 std::unique_ptr<ExtendedInfoHandler> handler) { | 174 std::unique_ptr<ExtendedInfoHandler> handler) { |
154 DCHECK(!key.empty()); | 175 DCHECK(!key.empty()); |
155 DCHECK(!extended_info_handler_map_.count(key)); | 176 DCHECK(!extended_info_handler_map_.count(key)); |
156 DCHECK(handler.get()); | 177 DCHECK(handler.get()); |
157 extended_info_handler_map_[key] = std::move(handler); | 178 extended_info_handler_map_[key] = std::move(handler); |
158 } | 179 } |
159 | 180 |
160 const ContentSerializedNavigationDriver::ExtendedInfoHandlerMap& | 181 const ContentSerializedNavigationDriver::ExtendedInfoHandlerMap& |
161 ContentSerializedNavigationDriver::GetAllExtendedInfoHandlers() const { | 182 ContentSerializedNavigationDriver::GetAllExtendedInfoHandlers() const { |
162 return extended_info_handler_map_; | 183 return extended_info_handler_map_; |
163 } | 184 } |
164 | 185 |
165 } // namespace sessions | 186 } // namespace sessions |
OLD | NEW |