| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/core/serialized_navigation_entry.h" | 5 #include "components/sessions/core/serialized_navigation_entry.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // | 206 // |
| 207 // type_mask (has_post_data_) | 207 // type_mask (has_post_data_) |
| 208 // referrer_url_ | 208 // referrer_url_ |
| 209 // referrer_policy_ (broken, crbug.com/450589) | 209 // referrer_policy_ (broken, crbug.com/450589) |
| 210 // original_request_url_ | 210 // original_request_url_ |
| 211 // is_overriding_user_agent_ | 211 // is_overriding_user_agent_ |
| 212 // timestamp_ | 212 // timestamp_ |
| 213 // search_terms_ | 213 // search_terms_ |
| 214 // http_status_code_ | 214 // http_status_code_ |
| 215 // referrer_policy_ | 215 // referrer_policy_ |
| 216 // extended_info_map_ |
| 216 | 217 |
| 217 void SerializedNavigationEntry::WriteToPickle(int max_size, | 218 void SerializedNavigationEntry::WriteToPickle(int max_size, |
| 218 base::Pickle* pickle) const { | 219 base::Pickle* pickle) const { |
| 219 pickle->WriteInt(index_); | 220 pickle->WriteInt(index_); |
| 220 | 221 |
| 221 int bytes_written = 0; | 222 int bytes_written = 0; |
| 222 | 223 |
| 223 WriteStringToPickle(pickle, &bytes_written, max_size, | 224 WriteStringToPickle(pickle, &bytes_written, max_size, |
| 224 virtual_url_.spec()); | 225 virtual_url_.spec()); |
| 225 | 226 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 250 original_request_url_.is_valid() ? | 251 original_request_url_.is_valid() ? |
| 251 original_request_url_.spec() : std::string()); | 252 original_request_url_.spec() : std::string()); |
| 252 pickle->WriteBool(is_overriding_user_agent_); | 253 pickle->WriteBool(is_overriding_user_agent_); |
| 253 pickle->WriteInt64(timestamp_.ToInternalValue()); | 254 pickle->WriteInt64(timestamp_.ToInternalValue()); |
| 254 | 255 |
| 255 WriteString16ToPickle(pickle, &bytes_written, max_size, search_terms_); | 256 WriteString16ToPickle(pickle, &bytes_written, max_size, search_terms_); |
| 256 | 257 |
| 257 pickle->WriteInt(http_status_code_); | 258 pickle->WriteInt(http_status_code_); |
| 258 | 259 |
| 259 pickle->WriteInt(referrer_policy_); | 260 pickle->WriteInt(referrer_policy_); |
| 261 |
| 262 pickle->WriteInt(extended_info_map_.size()); |
| 263 for (const auto entry : extended_info_map_) { |
| 264 WriteStringToPickle(pickle, &bytes_written, max_size, entry.first); |
| 265 WriteStringToPickle(pickle, &bytes_written, max_size, entry.second); |
| 266 } |
| 260 } | 267 } |
| 261 | 268 |
| 262 bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) { | 269 bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) { |
| 263 *this = SerializedNavigationEntry(); | 270 *this = SerializedNavigationEntry(); |
| 264 std::string virtual_url_spec; | 271 std::string virtual_url_spec; |
| 265 int transition_type_int = 0; | 272 int transition_type_int = 0; |
| 266 if (!iterator->ReadInt(&index_) || | 273 if (!iterator->ReadInt(&index_) || |
| 267 !iterator->ReadString(&virtual_url_spec) || | 274 !iterator->ReadString(&virtual_url_spec) || |
| 268 !iterator->ReadString16(&title_) || | 275 !iterator->ReadString16(&title_) || |
| 269 !iterator->ReadString(&encoded_page_state_) || | 276 !iterator->ReadString(&encoded_page_state_) || |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 int mapped_referrer_policy; | 335 int mapped_referrer_policy; |
| 329 if (!SerializedNavigationDriver::Get()->MapReferrerPolicyToNewValues( | 336 if (!SerializedNavigationDriver::Get()->MapReferrerPolicyToNewValues( |
| 330 referrer_policy_, &mapped_referrer_policy)) { | 337 referrer_policy_, &mapped_referrer_policy)) { |
| 331 referrer_url_ = GURL(); | 338 referrer_url_ = GURL(); |
| 332 } | 339 } |
| 333 referrer_policy_ = mapped_referrer_policy; | 340 referrer_policy_ = mapped_referrer_policy; |
| 334 encoded_page_state_ = | 341 encoded_page_state_ = |
| 335 SerializedNavigationDriver::Get()->StripReferrerFromPageState( | 342 SerializedNavigationDriver::Get()->StripReferrerFromPageState( |
| 336 encoded_page_state_); | 343 encoded_page_state_); |
| 337 } | 344 } |
| 345 |
| 346 int extended_info_map_size = 0; |
| 347 if (iterator->ReadInt(&extended_info_map_size) && |
| 348 extended_info_map_size > 0) { |
| 349 for (int i = 0; i < extended_info_map_size; ++i) { |
| 350 std::string key; |
| 351 std::string value; |
| 352 if (iterator->ReadString(&key) && iterator->ReadString(&value)) |
| 353 extended_info_map_[key] = value; |
| 354 } |
| 355 } |
| 338 } | 356 } |
| 339 | 357 |
| 340 SerializedNavigationDriver::Get()->Sanitize(this); | 358 SerializedNavigationDriver::Get()->Sanitize(this); |
| 341 | 359 |
| 342 is_restored_ = true; | 360 is_restored_ = true; |
| 343 | 361 |
| 344 return true; | 362 return true; |
| 345 } | 363 } |
| 346 | 364 |
| 347 // TODO(zea): perhaps sync state (scroll position, form entries, etc.) as well? | 365 // TODO(zea): perhaps sync state (scroll position, form entries, etc.) as well? |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 redirect_chain_[last_entry].spec()); | 494 redirect_chain_[last_entry].spec()); |
| 477 } | 495 } |
| 478 } | 496 } |
| 479 | 497 |
| 480 sync_data.set_is_restored(is_restored_); | 498 sync_data.set_is_restored(is_restored_); |
| 481 | 499 |
| 482 return sync_data; | 500 return sync_data; |
| 483 } | 501 } |
| 484 | 502 |
| 485 } // namespace sessions | 503 } // namespace sessions |
| OLD | NEW |