| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/nullable_string16.h" | 9 #include "base/strings/nullable_string16.h" |
| 10 #include "content/child/web_url_request_util.h" | 10 #include "content/child/web_url_request_util.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 item.SetStateObject(WebSerializedScriptValue::FromString( | 92 item.SetStateObject(WebSerializedScriptValue::FromString( |
| 93 WebString::FromUTF16(state.state_object))); | 93 WebString::FromUTF16(state.state_object))); |
| 94 } | 94 } |
| 95 WebVector<WebString> document_state(state.document_state.size()); | 95 WebVector<WebString> document_state(state.document_state.size()); |
| 96 std::transform(state.document_state.begin(), state.document_state.end(), | 96 std::transform(state.document_state.begin(), state.document_state.end(), |
| 97 document_state.begin(), [](const base::NullableString16& s) { | 97 document_state.begin(), [](const base::NullableString16& s) { |
| 98 return WebString::FromUTF16(s); | 98 return WebString::FromUTF16(s); |
| 99 }); | 99 }); |
| 100 item.SetDocumentState(document_state); | 100 item.SetDocumentState(document_state); |
| 101 item.SetScrollRestorationType(state.scroll_restoration_type); | 101 item.SetScrollRestorationType(state.scroll_restoration_type); |
| 102 item.SetVisualViewportScrollOffset(state.visual_viewport_scroll_offset); | 102 |
| 103 item.SetScrollOffset(state.scroll_offset); | 103 if (state.did_save_scroll_or_scale_state) { |
| 104 item.SetPageScaleFactor(state.page_scale_factor); | 104 item.SetVisualViewportScrollOffset(state.visual_viewport_scroll_offset); |
| 105 item.SetDidSaveScrollOrScaleState(state.did_save_scroll_or_scale_state); | 105 item.SetScrollOffset(state.scroll_offset); |
| 106 item.SetPageScaleFactor(state.page_scale_factor); |
| 107 } |
| 106 | 108 |
| 107 // These values are generated at WebHistoryItem construction time, and we | 109 // These values are generated at WebHistoryItem construction time, and we |
| 108 // only want to override those new values with old values if the old values | 110 // only want to override those new values with old values if the old values |
| 109 // are defined. A value of 0 means undefined in this context. | 111 // are defined. A value of 0 means undefined in this context. |
| 110 if (state.item_sequence_number) | 112 if (state.item_sequence_number) |
| 111 item.SetItemSequenceNumber(state.item_sequence_number); | 113 item.SetItemSequenceNumber(state.item_sequence_number); |
| 112 if (state.document_sequence_number) | 114 if (state.document_sequence_number) |
| 113 item.SetDocumentSequenceNumber(state.document_sequence_number); | 115 item.SetDocumentSequenceNumber(state.document_sequence_number); |
| 114 | 116 |
| 115 item.SetHTTPContentType( | 117 item.SetHTTPContentType( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (!DecodePageState(page_state.ToEncodedData(), &state)) | 155 if (!DecodePageState(page_state.ToEncodedData(), &state)) |
| 154 return std::unique_ptr<HistoryEntry>(); | 156 return std::unique_ptr<HistoryEntry>(); |
| 155 | 157 |
| 156 std::unique_ptr<HistoryEntry> entry(new HistoryEntry()); | 158 std::unique_ptr<HistoryEntry> entry(new HistoryEntry()); |
| 157 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node()); | 159 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node()); |
| 158 | 160 |
| 159 return entry; | 161 return entry; |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace content | 164 } // namespace content |
| OLD | NEW |