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 // offline_page_info_ |
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 WriteStringToPickle(pickle, &bytes_written, max_size, offline_page_info_); |
260 } | 263 } |
261 | 264 |
262 bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) { | 265 bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) { |
263 *this = SerializedNavigationEntry(); | 266 *this = SerializedNavigationEntry(); |
264 std::string virtual_url_spec; | 267 std::string virtual_url_spec; |
265 int transition_type_int = 0; | 268 int transition_type_int = 0; |
266 if (!iterator->ReadInt(&index_) || | 269 if (!iterator->ReadInt(&index_) || |
267 !iterator->ReadString(&virtual_url_spec) || | 270 !iterator->ReadString(&virtual_url_spec) || |
268 !iterator->ReadString16(&title_) || | 271 !iterator->ReadString16(&title_) || |
269 !iterator->ReadString(&encoded_page_state_) || | 272 !iterator->ReadString(&encoded_page_state_) || |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 int mapped_referrer_policy; | 331 int mapped_referrer_policy; |
329 if (!SerializedNavigationDriver::Get()->MapReferrerPolicyToNewValues( | 332 if (!SerializedNavigationDriver::Get()->MapReferrerPolicyToNewValues( |
330 referrer_policy_, &mapped_referrer_policy)) { | 333 referrer_policy_, &mapped_referrer_policy)) { |
331 referrer_url_ = GURL(); | 334 referrer_url_ = GURL(); |
332 } | 335 } |
333 referrer_policy_ = mapped_referrer_policy; | 336 referrer_policy_ = mapped_referrer_policy; |
334 encoded_page_state_ = | 337 encoded_page_state_ = |
335 SerializedNavigationDriver::Get()->StripReferrerFromPageState( | 338 SerializedNavigationDriver::Get()->StripReferrerFromPageState( |
336 encoded_page_state_); | 339 encoded_page_state_); |
337 } | 340 } |
| 341 |
| 342 if (!iterator->ReadString(&offline_page_info_)) |
| 343 offline_page_info_ = std::string(); |
338 } | 344 } |
339 | 345 |
340 SerializedNavigationDriver::Get()->Sanitize(this); | 346 SerializedNavigationDriver::Get()->Sanitize(this); |
341 | 347 |
342 is_restored_ = true; | 348 is_restored_ = true; |
343 | 349 |
344 return true; | 350 return true; |
345 } | 351 } |
346 | 352 |
347 // TODO(zea): perhaps sync state (scroll position, form entries, etc.) as well? | 353 // 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()); | 482 redirect_chain_[last_entry].spec()); |
477 } | 483 } |
478 } | 484 } |
479 | 485 |
480 sync_data.set_is_restored(is_restored_); | 486 sync_data.set_is_restored(is_restored_); |
481 | 487 |
482 return sync_data; | 488 return sync_data; |
483 } | 489 } |
484 | 490 |
485 } // namespace sessions | 491 } // namespace sessions |
OLD | NEW |