| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/history_serialization.h" | 5 #include "content/renderer/history_serialization.h" |
| 6 | 6 |
| 7 #include "content/common/page_state_serialization.h" | 7 #include "content/common/page_state_serialization.h" |
| 8 #include "content/public/common/page_state.h" | 8 #include "content/public/common/page_state.h" |
| 9 #include "content/renderer/history_entry.h" | 9 #include "content/renderer/history_entry.h" |
| 10 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 10 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 11 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
| 11 #include "third_party/WebKit/public/platform/WebPoint.h" | 12 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 13 #include "third_party/WebKit/public/platform/WebVector.h" | 14 #include "third_party/WebKit/public/platform/WebVector.h" |
| 14 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 15 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 15 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 16 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
| 16 | 17 |
| 17 using blink::WebHTTPBody; | 18 using blink::WebHTTPBody; |
| 18 using blink::WebHistoryItem; | 19 using blink::WebHistoryItem; |
| 19 using blink::WebSerializedScriptValue; | 20 using blink::WebSerializedScriptValue; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 82 } |
| 82 | 83 |
| 83 void GenerateFrameStateFromItem(const WebHistoryItem& item, | 84 void GenerateFrameStateFromItem(const WebHistoryItem& item, |
| 84 ExplodedFrameState* state) { | 85 ExplodedFrameState* state) { |
| 85 state->url_string = item.urlString(); | 86 state->url_string = item.urlString(); |
| 86 state->referrer = item.referrer(); | 87 state->referrer = item.referrer(); |
| 87 state->referrer_policy = item.referrerPolicy(); | 88 state->referrer_policy = item.referrerPolicy(); |
| 88 state->target = item.target(); | 89 state->target = item.target(); |
| 89 if (!item.stateObject().isNull()) | 90 if (!item.stateObject().isNull()) |
| 90 state->state_object = item.stateObject().toString(); | 91 state->state_object = item.stateObject().toString(); |
| 92 state->pinch_viewport_scroll_offset = item.pinchViewportScrollOffset(); |
| 91 state->scroll_offset = item.scrollOffset(); | 93 state->scroll_offset = item.scrollOffset(); |
| 92 state->item_sequence_number = item.itemSequenceNumber(); | 94 state->item_sequence_number = item.itemSequenceNumber(); |
| 93 state->document_sequence_number = | 95 state->document_sequence_number = |
| 94 item.documentSequenceNumber(); | 96 item.documentSequenceNumber(); |
| 95 state->page_scale_factor = item.pageScaleFactor(); | 97 state->page_scale_factor = item.pageScaleFactor(); |
| 96 ToNullableString16Vector(item.documentState(), &state->document_state); | 98 ToNullableString16Vector(item.documentState(), &state->document_state); |
| 97 | 99 |
| 98 state->http_body.http_content_type = item.httpContentType(); | 100 state->http_body.http_content_type = item.httpContentType(); |
| 99 const WebHTTPBody& http_body = item.httpBody(); | 101 const WebHTTPBody& http_body = item.httpBody(); |
| 100 if (!(state->http_body.is_null = http_body.isNull())) { | 102 if (!(state->http_body.is_null = http_body.isNull())) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 124 WebHistoryItem item; | 126 WebHistoryItem item; |
| 125 item.initialize(); | 127 item.initialize(); |
| 126 item.setURLString(state.url_string); | 128 item.setURLString(state.url_string); |
| 127 item.setReferrer(state.referrer, state.referrer_policy); | 129 item.setReferrer(state.referrer, state.referrer_policy); |
| 128 item.setTarget(state.target); | 130 item.setTarget(state.target); |
| 129 if (!state.state_object.is_null()) { | 131 if (!state.state_object.is_null()) { |
| 130 item.setStateObject( | 132 item.setStateObject( |
| 131 WebSerializedScriptValue::fromString(state.state_object)); | 133 WebSerializedScriptValue::fromString(state.state_object)); |
| 132 } | 134 } |
| 133 item.setDocumentState(state.document_state); | 135 item.setDocumentState(state.document_state); |
| 136 item.setPinchViewportScrollOffset(state.pinch_viewport_scroll_offset); |
| 134 item.setScrollOffset(state.scroll_offset); | 137 item.setScrollOffset(state.scroll_offset); |
| 135 item.setPageScaleFactor(state.page_scale_factor); | 138 item.setPageScaleFactor(state.page_scale_factor); |
| 136 | 139 |
| 137 // These values are generated at WebHistoryItem construction time, and we | 140 // These values are generated at WebHistoryItem construction time, and we |
| 138 // only want to override those new values with old values if the old values | 141 // only want to override those new values with old values if the old values |
| 139 // are defined. A value of 0 means undefined in this context. | 142 // are defined. A value of 0 means undefined in this context. |
| 140 if (state.item_sequence_number) | 143 if (state.item_sequence_number) |
| 141 item.setItemSequenceNumber(state.item_sequence_number); | 144 item.setItemSequenceNumber(state.item_sequence_number); |
| 142 if (state.document_sequence_number) | 145 if (state.document_sequence_number) |
| 143 item.setDocumentSequenceNumber(state.document_sequence_number); | 146 item.setDocumentSequenceNumber(state.document_sequence_number); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (!DecodePageState(page_state.ToEncodedData(), &state)) | 194 if (!DecodePageState(page_state.ToEncodedData(), &state)) |
| 192 return scoped_ptr<HistoryEntry>(); | 195 return scoped_ptr<HistoryEntry>(); |
| 193 | 196 |
| 194 scoped_ptr<HistoryEntry> entry(new HistoryEntry()); | 197 scoped_ptr<HistoryEntry> entry(new HistoryEntry()); |
| 195 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node()); | 198 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node()); |
| 196 | 199 |
| 197 return entry.Pass(); | 200 return entry.Pass(); |
| 198 } | 201 } |
| 199 | 202 |
| 200 } // namespace content | 203 } // namespace content |
| OLD | NEW |