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 {
// 15: Removes a bunch of values we defined but never used.
// 16: Switched from blob urls to blob uuids.
// 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.
// See ReadPageState.
//
const int kMinVersion = 11;
const int kCurrentVersion = 17;
const int kCurrentVersion = 18;
// 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
......@@ -504,6 +505,7 @@ void WriteFrameState(
WriteInteger64(state.item_sequence_number, obj);
WriteInteger64(state.document_sequence_number, obj);
WriteInteger64(state.target_frame_id, obj);
WriteInteger(state.referrer_policy, obj);
bool has_state_object = !state.state_object.is_null();
WriteBoolean(has_state_object, obj);
......@@ -556,6 +558,10 @@ void ReadFrameState(SerializeObject* obj, bool is_top,
state->document_sequence_number = ReadInteger64(obj);
if (obj->version >= 17)
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);
if (has_state_object)
......@@ -666,7 +672,8 @@ ExplodedFrameState::ExplodedFrameState()
: item_sequence_number(0),
document_sequence_number(0),
target_frame_id(0),
page_scale_factor(0.0) {
page_scale_factor(0.0),
referrer_policy(blink::WebReferrerPolicyDefault) {
}
ExplodedFrameState::~ExplodedFrameState() {
......
......@@ -10,6 +10,7 @@
#include "base/strings/nullable_string16.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebHTTPBody.h"
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
#include "ui/gfx/point.h"
#include "url/gurl.h"
......@@ -52,6 +53,7 @@ struct CONTENT_EXPORT ExplodedFrameState {
int64 document_sequence_number;
int64 target_frame_id;
double page_scale_factor;
blink::WebReferrerPolicy referrer_policy;
ExplodedHttpBody http_body;
std::vector<ExplodedFrameState> children;
......
......@@ -69,6 +69,7 @@ void ExpectEquality(const ExplodedFrameState& a, const ExplodedFrameState& b) {
EXPECT_EQ(a.url_string, b.url_string);
EXPECT_EQ(a.original_url_string, b.original_url_string);
EXPECT_EQ(a.referrer, b.referrer);
EXPECT_EQ(a.referrer_policy, b.referrer_policy);
EXPECT_EQ(a.target, b.target);
EXPECT_EQ(a.state_object, b.state_object);
ExpectEquality(a.document_state, b.document_state);
......@@ -95,6 +96,7 @@ class PageStateSerializationTest : public testing::Test {
frame_state->url_string = NS16("http://dev.chromium.org/");
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_policy = blink::WebReferrerPolicyAlways;
frame_state->target = NS16("foo");
frame_state->state_object = NS16(NULL);
frame_state->document_state.push_back(NS16("1"));
......@@ -137,6 +139,7 @@ class PageStateSerializationTest : public testing::Test {
frame_state->url_string = NS16("http://chromium.org/");
frame_state->original_url_string = frame_state->url_string;
frame_state->referrer = NS16("http://google.com/");
frame_state->referrer_policy = blink::WebReferrerPolicyDefault;
if (!is_child)
frame_state->target = NS16("target");
frame_state->scroll_offset = gfx::Point(42, -42);
......
......@@ -46,6 +46,7 @@ void RecursivelyRemoveScrollOffset(ExplodedFrameState* state) {
void RecursivelyRemoveReferrer(ExplodedFrameState* state) {
state->referrer = base::NullableString16();
state->referrer_policy = blink::WebReferrerPolicyDefault;
for (std::vector<ExplodedFrameState>::iterator it = state->children.begin();
it != state->children.end();
++it) {
......
......@@ -84,6 +84,7 @@ bool RecursivelyGenerateFrameState(const WebHistoryItem& item,
state->url_string = item.urlString();
state->original_url_string = item.originalURLString();
state->referrer = item.referrer();
state->referrer_policy = item.referrerPolicy();
state->target = item.target();
if (!item.stateObject().isNull())
state->state_object = item.stateObject().toString();
......@@ -122,7 +123,7 @@ bool RecursivelyGenerateHistoryItem(const ExplodedFrameState& state,
WebHistoryItem* item) {
item->setURLString(state.url_string);
item->setOriginalURLString(state.original_url_string);
item->setReferrer(state.referrer);
item->setReferrer(state.referrer, state.referrer_policy);
item->setTarget(state.target);
if (!state.state_object.is_null()) {
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