Commit bd2979f3 authored by jochen@chromium.org's avatar jochen@chromium.org

Add the referrer policy to the page state

It's already part of history items, so we should persist it.

BUG=334125
R=marja@chromium.org

Review URL: https://codereview.chromium.org/134813003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247940 0039d316-1c4b-4281-b951-d872f2087c98
parent 1c8c27c1
...@@ -188,12 +188,13 @@ struct SerializeObject { ...@@ -188,12 +188,13 @@ struct SerializeObject {
// 15: Removes a bunch of values we defined but never used. // 15: Removes a bunch of values we defined but never used.
// 16: Switched from blob urls to blob uuids. // 16: Switched from blob urls to blob uuids.
// 17: Add a target frame id number. // 17: Add a target frame id number.
// 18: Add referrer policy.
// //
// NOTE: If the version is -1, then the pickle contains only a URL string. // NOTE: If the version is -1, then the pickle contains only a URL string.
// See ReadPageState. // See ReadPageState.
// //
const int kMinVersion = 11; const int kMinVersion = 11;
const int kCurrentVersion = 17; const int kCurrentVersion = 18;
// A bunch of convenience functions to read/write to SerializeObjects. The // A bunch of convenience functions to read/write to SerializeObjects. The
// de-serializers assume the input data will be in the correct format and fall // de-serializers assume the input data will be in the correct format and fall
...@@ -504,6 +505,7 @@ void WriteFrameState( ...@@ -504,6 +505,7 @@ void WriteFrameState(
WriteInteger64(state.item_sequence_number, obj); WriteInteger64(state.item_sequence_number, obj);
WriteInteger64(state.document_sequence_number, obj); WriteInteger64(state.document_sequence_number, obj);
WriteInteger64(state.target_frame_id, obj); WriteInteger64(state.target_frame_id, obj);
WriteInteger(state.referrer_policy, obj);
bool has_state_object = !state.state_object.is_null(); bool has_state_object = !state.state_object.is_null();
WriteBoolean(has_state_object, obj); WriteBoolean(has_state_object, obj);
...@@ -556,6 +558,10 @@ void ReadFrameState(SerializeObject* obj, bool is_top, ...@@ -556,6 +558,10 @@ void ReadFrameState(SerializeObject* obj, bool is_top,
state->document_sequence_number = ReadInteger64(obj); state->document_sequence_number = ReadInteger64(obj);
if (obj->version >= 17) if (obj->version >= 17)
state->target_frame_id = ReadInteger64(obj); state->target_frame_id = ReadInteger64(obj);
if (obj->version >= 18) {
state->referrer_policy =
static_cast<blink::WebReferrerPolicy>(ReadInteger(obj));
}
bool has_state_object = ReadBoolean(obj); bool has_state_object = ReadBoolean(obj);
if (has_state_object) if (has_state_object)
...@@ -666,7 +672,8 @@ ExplodedFrameState::ExplodedFrameState() ...@@ -666,7 +672,8 @@ ExplodedFrameState::ExplodedFrameState()
: item_sequence_number(0), : item_sequence_number(0),
document_sequence_number(0), document_sequence_number(0),
target_frame_id(0), target_frame_id(0),
page_scale_factor(0.0) { page_scale_factor(0.0),
referrer_policy(blink::WebReferrerPolicyDefault) {
} }
ExplodedFrameState::~ExplodedFrameState() { ExplodedFrameState::~ExplodedFrameState() {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/nullable_string16.h" #include "base/strings/nullable_string16.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebHTTPBody.h" #include "third_party/WebKit/public/platform/WebHTTPBody.h"
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -52,6 +53,7 @@ struct CONTENT_EXPORT ExplodedFrameState { ...@@ -52,6 +53,7 @@ struct CONTENT_EXPORT ExplodedFrameState {
int64 document_sequence_number; int64 document_sequence_number;
int64 target_frame_id; int64 target_frame_id;
double page_scale_factor; double page_scale_factor;
blink::WebReferrerPolicy referrer_policy;
ExplodedHttpBody http_body; ExplodedHttpBody http_body;
std::vector<ExplodedFrameState> children; std::vector<ExplodedFrameState> children;
......
...@@ -69,6 +69,7 @@ void ExpectEquality(const ExplodedFrameState& a, const ExplodedFrameState& b) { ...@@ -69,6 +69,7 @@ void ExpectEquality(const ExplodedFrameState& a, const ExplodedFrameState& b) {
EXPECT_EQ(a.url_string, b.url_string); EXPECT_EQ(a.url_string, b.url_string);
EXPECT_EQ(a.original_url_string, b.original_url_string); EXPECT_EQ(a.original_url_string, b.original_url_string);
EXPECT_EQ(a.referrer, b.referrer); EXPECT_EQ(a.referrer, b.referrer);
EXPECT_EQ(a.referrer_policy, b.referrer_policy);
EXPECT_EQ(a.target, b.target); EXPECT_EQ(a.target, b.target);
EXPECT_EQ(a.state_object, b.state_object); EXPECT_EQ(a.state_object, b.state_object);
ExpectEquality(a.document_state, b.document_state); ExpectEquality(a.document_state, b.document_state);
...@@ -95,6 +96,7 @@ class PageStateSerializationTest : public testing::Test { ...@@ -95,6 +96,7 @@ class PageStateSerializationTest : public testing::Test {
frame_state->url_string = NS16("http://dev.chromium.org/"); frame_state->url_string = NS16("http://dev.chromium.org/");
frame_state->original_url_string = frame_state->url_string; frame_state->original_url_string = frame_state->url_string;
frame_state->referrer = NS16("https://www.google.com/search?q=dev.chromium.org"); frame_state->referrer = NS16("https://www.google.com/search?q=dev.chromium.org");
frame_state->referrer_policy = blink::WebReferrerPolicyAlways;
frame_state->target = NS16("foo"); frame_state->target = NS16("foo");
frame_state->state_object = NS16(NULL); frame_state->state_object = NS16(NULL);
frame_state->document_state.push_back(NS16("1")); frame_state->document_state.push_back(NS16("1"));
...@@ -137,6 +139,7 @@ class PageStateSerializationTest : public testing::Test { ...@@ -137,6 +139,7 @@ class PageStateSerializationTest : public testing::Test {
frame_state->url_string = NS16("http://chromium.org/"); frame_state->url_string = NS16("http://chromium.org/");
frame_state->original_url_string = frame_state->url_string; frame_state->original_url_string = frame_state->url_string;
frame_state->referrer = NS16("http://google.com/"); frame_state->referrer = NS16("http://google.com/");
frame_state->referrer_policy = blink::WebReferrerPolicyDefault;
if (!is_child) if (!is_child)
frame_state->target = NS16("target"); frame_state->target = NS16("target");
frame_state->scroll_offset = gfx::Point(42, -42); frame_state->scroll_offset = gfx::Point(42, -42);
......
...@@ -46,6 +46,7 @@ void RecursivelyRemoveScrollOffset(ExplodedFrameState* state) { ...@@ -46,6 +46,7 @@ void RecursivelyRemoveScrollOffset(ExplodedFrameState* state) {
void RecursivelyRemoveReferrer(ExplodedFrameState* state) { void RecursivelyRemoveReferrer(ExplodedFrameState* state) {
state->referrer = base::NullableString16(); state->referrer = base::NullableString16();
state->referrer_policy = blink::WebReferrerPolicyDefault;
for (std::vector<ExplodedFrameState>::iterator it = state->children.begin(); for (std::vector<ExplodedFrameState>::iterator it = state->children.begin();
it != state->children.end(); it != state->children.end();
++it) { ++it) {
......
...@@ -84,6 +84,7 @@ bool RecursivelyGenerateFrameState(const WebHistoryItem& item, ...@@ -84,6 +84,7 @@ bool RecursivelyGenerateFrameState(const WebHistoryItem& item,
state->url_string = item.urlString(); state->url_string = item.urlString();
state->original_url_string = item.originalURLString(); state->original_url_string = item.originalURLString();
state->referrer = item.referrer(); state->referrer = item.referrer();
state->referrer_policy = item.referrerPolicy();
state->target = item.target(); state->target = item.target();
if (!item.stateObject().isNull()) if (!item.stateObject().isNull())
state->state_object = item.stateObject().toString(); state->state_object = item.stateObject().toString();
...@@ -122,7 +123,7 @@ bool RecursivelyGenerateHistoryItem(const ExplodedFrameState& state, ...@@ -122,7 +123,7 @@ bool RecursivelyGenerateHistoryItem(const ExplodedFrameState& state,
WebHistoryItem* item) { WebHistoryItem* item) {
item->setURLString(state.url_string); item->setURLString(state.url_string);
item->setOriginalURLString(state.original_url_string); item->setOriginalURLString(state.original_url_string);
item->setReferrer(state.referrer); item->setReferrer(state.referrer, state.referrer_policy);
item->setTarget(state.target); item->setTarget(state.target);
if (!state.state_object.is_null()) { if (!state.state_object.is_null()) {
item->setStateObject( item->setStateObject(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment