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 #if !defined(OS_IOS) | |
263 pickle->WriteInt(extended_info_map_.size()); | |
264 for (const auto entry : extended_info_map_) { | |
265 WriteStringToPickle(pickle, &bytes_written, max_size, entry.first); | |
266 WriteStringToPickle(pickle, &bytes_written, max_size, entry.second); | |
267 } | |
268 #endif // !defined(OS_IOS) | |
260 } | 269 } |
261 | 270 |
262 bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) { | 271 bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) { |
263 *this = SerializedNavigationEntry(); | 272 *this = SerializedNavigationEntry(); |
264 std::string virtual_url_spec; | 273 std::string virtual_url_spec; |
265 int transition_type_int = 0; | 274 int transition_type_int = 0; |
266 if (!iterator->ReadInt(&index_) || | 275 if (!iterator->ReadInt(&index_) || |
267 !iterator->ReadString(&virtual_url_spec) || | 276 !iterator->ReadString(&virtual_url_spec) || |
268 !iterator->ReadString16(&title_) || | 277 !iterator->ReadString16(&title_) || |
269 !iterator->ReadString(&encoded_page_state_) || | 278 !iterator->ReadString(&encoded_page_state_) || |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 int mapped_referrer_policy; | 337 int mapped_referrer_policy; |
329 if (!SerializedNavigationDriver::Get()->MapReferrerPolicyToNewValues( | 338 if (!SerializedNavigationDriver::Get()->MapReferrerPolicyToNewValues( |
330 referrer_policy_, &mapped_referrer_policy)) { | 339 referrer_policy_, &mapped_referrer_policy)) { |
331 referrer_url_ = GURL(); | 340 referrer_url_ = GURL(); |
332 } | 341 } |
333 referrer_policy_ = mapped_referrer_policy; | 342 referrer_policy_ = mapped_referrer_policy; |
334 encoded_page_state_ = | 343 encoded_page_state_ = |
335 SerializedNavigationDriver::Get()->StripReferrerFromPageState( | 344 SerializedNavigationDriver::Get()->StripReferrerFromPageState( |
336 encoded_page_state_); | 345 encoded_page_state_); |
337 } | 346 } |
347 | |
348 #if !defined(OS_IOS) | |
349 int extended_info_map_size = 0; | |
350 if (iterator->ReadInt(&extended_info_map_size) && | |
351 extended_info_map_size >= 0) { | |
sky
2016/09/29 03:08:19
> 0?
jianli
2016/09/29 22:02:29
Done.
| |
352 for (int i = 0; i < extended_info_map_size; ++i) { | |
353 std::string key; | |
354 std::string value; | |
355 if (iterator->ReadString(&key) && iterator->ReadString(&value)) | |
356 extended_info_map_[key] = value; | |
357 } | |
358 } else { | |
sky
2016/09/29 03:08:19
I don't think you need the else case as everything
jianli
2016/09/29 22:02:29
Done.
| |
359 extended_info_map_.clear(); | |
360 } | |
361 #endif // !defined(OS_IOS) | |
338 } | 362 } |
339 | 363 |
340 SerializedNavigationDriver::Get()->Sanitize(this); | 364 SerializedNavigationDriver::Get()->Sanitize(this); |
341 | 365 |
342 is_restored_ = true; | 366 is_restored_ = true; |
343 | 367 |
344 return true; | 368 return true; |
345 } | 369 } |
346 | 370 |
347 // TODO(zea): perhaps sync state (scroll position, form entries, etc.) as well? | 371 // 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()); | 500 redirect_chain_[last_entry].spec()); |
477 } | 501 } |
478 } | 502 } |
479 | 503 |
480 sync_data.set_is_restored(is_restored_); | 504 sync_data.set_is_restored(is_restored_); |
481 | 505 |
482 return sync_data; | 506 return sync_data; |
483 } | 507 } |
484 | 508 |
485 } // namespace sessions | 509 } // namespace sessions |
OLD | NEW |