Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: content/common/page_state_serialization.cc

Issue 134813003: Add the referrer policy to the page state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/common/page_state_serialization.h" 5 #include "content/common/page_state_serialization.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 }; 181 };
182 182
183 // Version ID of serialized format. 183 // Version ID of serialized format.
184 // 11: Min version 184 // 11: Min version
185 // 12: Adds support for contains_passwords in HTTP body 185 // 12: Adds support for contains_passwords in HTTP body
186 // 13: Adds support for URL (FileSystem URL) 186 // 13: Adds support for URL (FileSystem URL)
187 // 14: Adds list of referenced files, version written only for first item. 187 // 14: Adds list of referenced files, version written only for first item.
188 // 15: Removes a bunch of values we defined but never used. 188 // 15: Removes a bunch of values we defined but never used.
189 // 16: Switched from blob urls to blob uuids. 189 // 16: Switched from blob urls to blob uuids.
190 // 17: Add a target frame id number. 190 // 17: Add a target frame id number.
191 // 18: Add referrer policy.
191 // 192 //
192 // NOTE: If the version is -1, then the pickle contains only a URL string. 193 // NOTE: If the version is -1, then the pickle contains only a URL string.
193 // See ReadPageState. 194 // See ReadPageState.
194 // 195 //
195 const int kMinVersion = 11; 196 const int kMinVersion = 11;
196 const int kCurrentVersion = 17; 197 const int kCurrentVersion = 18;
197 198
198 // A bunch of convenience functions to read/write to SerializeObjects. The 199 // A bunch of convenience functions to read/write to SerializeObjects. The
199 // de-serializers assume the input data will be in the correct format and fall 200 // de-serializers assume the input data will be in the correct format and fall
200 // back to returning safe defaults when not. 201 // back to returning safe defaults when not.
201 202
202 void WriteData(const void* data, int length, SerializeObject* obj) { 203 void WriteData(const void* data, int length, SerializeObject* obj) {
203 obj->pickle.WriteData(static_cast<const char*>(data), length); 204 obj->pickle.WriteData(static_cast<const char*>(data), length);
204 } 205 }
205 206
206 void ReadData(SerializeObject* obj, const void** data, int* length) { 207 void ReadData(SerializeObject* obj, const void** data, int* length) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 WriteInteger(state.scroll_offset.x(), obj); 498 WriteInteger(state.scroll_offset.x(), obj);
498 WriteInteger(state.scroll_offset.y(), obj); 499 WriteInteger(state.scroll_offset.y(), obj);
499 WriteString(state.referrer, obj); 500 WriteString(state.referrer, obj);
500 501
501 WriteStringVector(state.document_state, obj); 502 WriteStringVector(state.document_state, obj);
502 503
503 WriteReal(state.page_scale_factor, obj); 504 WriteReal(state.page_scale_factor, obj);
504 WriteInteger64(state.item_sequence_number, obj); 505 WriteInteger64(state.item_sequence_number, obj);
505 WriteInteger64(state.document_sequence_number, obj); 506 WriteInteger64(state.document_sequence_number, obj);
506 WriteInteger64(state.target_frame_id, obj); 507 WriteInteger64(state.target_frame_id, obj);
508 WriteInteger(state.referrer_policy, obj);
507 509
508 bool has_state_object = !state.state_object.is_null(); 510 bool has_state_object = !state.state_object.is_null();
509 WriteBoolean(has_state_object, obj); 511 WriteBoolean(has_state_object, obj);
510 if (has_state_object) 512 if (has_state_object)
511 WriteString(state.state_object, obj); 513 WriteString(state.state_object, obj);
512 514
513 WriteHttpBody(state.http_body, obj); 515 WriteHttpBody(state.http_body, obj);
514 516
515 // NOTE: It is a quirk of the format that we still have to write the 517 // NOTE: It is a quirk of the format that we still have to write the
516 // http_content_type field when the HTTP body is null. That's why this code 518 // http_content_type field when the HTTP body is null. That's why this code
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 551 }
550 state->referrer = ReadString(obj); 552 state->referrer = ReadString(obj);
551 553
552 ReadStringVector(obj, &state->document_state); 554 ReadStringVector(obj, &state->document_state);
553 555
554 state->page_scale_factor = ReadReal(obj); 556 state->page_scale_factor = ReadReal(obj);
555 state->item_sequence_number = ReadInteger64(obj); 557 state->item_sequence_number = ReadInteger64(obj);
556 state->document_sequence_number = ReadInteger64(obj); 558 state->document_sequence_number = ReadInteger64(obj);
557 if (obj->version >= 17) 559 if (obj->version >= 17)
558 state->target_frame_id = ReadInteger64(obj); 560 state->target_frame_id = ReadInteger64(obj);
561 if (obj->version >= 18) {
562 state->referrer_policy =
563 static_cast<blink::WebReferrerPolicy>(ReadInteger(obj));
564 }
559 565
560 bool has_state_object = ReadBoolean(obj); 566 bool has_state_object = ReadBoolean(obj);
561 if (has_state_object) 567 if (has_state_object)
562 state->state_object = ReadString(obj); 568 state->state_object = ReadString(obj);
563 569
564 ReadHttpBody(obj, &state->http_body); 570 ReadHttpBody(obj, &state->http_body);
565 571
566 // NOTE: It is a quirk of the format that we still have to read the 572 // NOTE: It is a quirk of the format that we still have to read the
567 // http_content_type field when the HTTP body is null. That's why this code 573 // http_content_type field when the HTTP body is null. That's why this code
568 // is here instead of inside ReadHttpBody. 574 // is here instead of inside ReadHttpBody.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 is_null(true) { 665 is_null(true) {
660 } 666 }
661 667
662 ExplodedHttpBody::~ExplodedHttpBody() { 668 ExplodedHttpBody::~ExplodedHttpBody() {
663 } 669 }
664 670
665 ExplodedFrameState::ExplodedFrameState() 671 ExplodedFrameState::ExplodedFrameState()
666 : item_sequence_number(0), 672 : item_sequence_number(0),
667 document_sequence_number(0), 673 document_sequence_number(0),
668 target_frame_id(0), 674 target_frame_id(0),
669 page_scale_factor(0.0) { 675 page_scale_factor(0.0),
676 referrer_policy(blink::WebReferrerPolicyDefault) {
670 } 677 }
671 678
672 ExplodedFrameState::~ExplodedFrameState() { 679 ExplodedFrameState::~ExplodedFrameState() {
673 } 680 }
674 681
675 ExplodedPageState::ExplodedPageState() { 682 ExplodedPageState::ExplodedPageState() {
676 } 683 }
677 684
678 ExplodedPageState::~ExplodedPageState() { 685 ExplodedPageState::~ExplodedPageState() {
679 } 686 }
(...skipping 23 matching lines...) Expand all
703 float device_scale_factor, 710 float device_scale_factor,
704 ExplodedPageState* exploded) { 711 ExplodedPageState* exploded) {
705 g_device_scale_factor_for_testing = device_scale_factor; 712 g_device_scale_factor_for_testing = device_scale_factor;
706 bool rv = DecodePageState(encoded, exploded); 713 bool rv = DecodePageState(encoded, exploded);
707 g_device_scale_factor_for_testing = 0.0; 714 g_device_scale_factor_for_testing = 0.0;
708 return rv; 715 return rv;
709 } 716 }
710 #endif 717 #endif
711 718
712 } // namespace content 719 } // namespace content
OLDNEW
« no previous file with comments | « content/common/page_state_serialization.h ('k') | content/common/page_state_serialization_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698