OLD | NEW |
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // 18: Add referrer policy. |
192 // 19: Remove target frame id, which was a bad idea, and original url string, | 192 // 19: Remove target frame id, which was a bad idea, and original url string, |
193 // which is no longer used. | 193 // which is no longer used. |
| 194 // 20: Add pinch viewport scroll offset, the offset of the pinched zoomed |
| 195 // viewport within the unzoomed main frame. |
194 // | 196 // |
195 // NOTE: If the version is -1, then the pickle contains only a URL string. | 197 // NOTE: If the version is -1, then the pickle contains only a URL string. |
196 // See ReadPageState. | 198 // See ReadPageState. |
197 // | 199 // |
198 const int kMinVersion = 11; | 200 const int kMinVersion = 11; |
199 const int kCurrentVersion = 19; | 201 const int kCurrentVersion = 20; |
200 | 202 |
201 // A bunch of convenience functions to read/write to SerializeObjects. The | 203 // A bunch of convenience functions to read/write to SerializeObjects. The |
202 // de-serializers assume the input data will be in the correct format and fall | 204 // de-serializers assume the input data will be in the correct format and fall |
203 // back to returning safe defaults when not. | 205 // back to returning safe defaults when not. |
204 | 206 |
205 void WriteData(const void* data, int length, SerializeObject* obj) { | 207 void WriteData(const void* data, int length, SerializeObject* obj) { |
206 obj->pickle.WriteData(static_cast<const char*>(data), length); | 208 obj->pickle.WriteData(static_cast<const char*>(data), length); |
207 } | 209 } |
208 | 210 |
209 void ReadData(SerializeObject* obj, const void** data, int* length) { | 211 void ReadData(SerializeObject* obj, const void** data, int* length) { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 WriteInteger(state.scroll_offset.x(), obj); | 505 WriteInteger(state.scroll_offset.x(), obj); |
504 WriteInteger(state.scroll_offset.y(), obj); | 506 WriteInteger(state.scroll_offset.y(), obj); |
505 WriteString(state.referrer, obj); | 507 WriteString(state.referrer, obj); |
506 | 508 |
507 WriteStringVector(state.document_state, obj); | 509 WriteStringVector(state.document_state, obj); |
508 | 510 |
509 WriteReal(state.page_scale_factor, obj); | 511 WriteReal(state.page_scale_factor, obj); |
510 WriteInteger64(state.item_sequence_number, obj); | 512 WriteInteger64(state.item_sequence_number, obj); |
511 WriteInteger64(state.document_sequence_number, obj); | 513 WriteInteger64(state.document_sequence_number, obj); |
512 WriteInteger(state.referrer_policy, obj); | 514 WriteInteger(state.referrer_policy, obj); |
| 515 WriteReal(state.pinch_viewport_scroll_offset.x(), obj); |
| 516 WriteReal(state.pinch_viewport_scroll_offset.y(), obj); |
513 | 517 |
514 bool has_state_object = !state.state_object.is_null(); | 518 bool has_state_object = !state.state_object.is_null(); |
515 WriteBoolean(has_state_object, obj); | 519 WriteBoolean(has_state_object, obj); |
516 if (has_state_object) | 520 if (has_state_object) |
517 WriteString(state.state_object, obj); | 521 WriteString(state.state_object, obj); |
518 | 522 |
519 WriteHttpBody(state.http_body, obj); | 523 WriteHttpBody(state.http_body, obj); |
520 | 524 |
521 // NOTE: It is a quirk of the format that we still have to write the | 525 // NOTE: It is a quirk of the format that we still have to write the |
522 // http_content_type field when the HTTP body is null. That's why this code | 526 // http_content_type field when the HTTP body is null. That's why this code |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 state->document_sequence_number = ReadInteger64(obj); | 569 state->document_sequence_number = ReadInteger64(obj); |
566 | 570 |
567 if (obj->version >= 17 && obj->version < 19) | 571 if (obj->version >= 17 && obj->version < 19) |
568 ConsumeInteger64(obj); // Skip obsolete target frame id number. | 572 ConsumeInteger64(obj); // Skip obsolete target frame id number. |
569 | 573 |
570 if (obj->version >= 18) { | 574 if (obj->version >= 18) { |
571 state->referrer_policy = | 575 state->referrer_policy = |
572 static_cast<blink::WebReferrerPolicy>(ReadInteger(obj)); | 576 static_cast<blink::WebReferrerPolicy>(ReadInteger(obj)); |
573 } | 577 } |
574 | 578 |
| 579 if (obj->version >= 20) { |
| 580 double x = ReadReal(obj); |
| 581 double y = ReadReal(obj); |
| 582 state->pinch_viewport_scroll_offset = gfx::PointF(x, y); |
| 583 } else { |
| 584 state->pinch_viewport_scroll_offset = gfx::PointF(-1, -1); |
| 585 } |
| 586 |
575 bool has_state_object = ReadBoolean(obj); | 587 bool has_state_object = ReadBoolean(obj); |
576 if (has_state_object) | 588 if (has_state_object) |
577 state->state_object = ReadString(obj); | 589 state->state_object = ReadString(obj); |
578 | 590 |
579 ReadHttpBody(obj, &state->http_body); | 591 ReadHttpBody(obj, &state->http_body); |
580 | 592 |
581 // NOTE: It is a quirk of the format that we still have to read the | 593 // NOTE: It is a quirk of the format that we still have to read the |
582 // http_content_type field when the HTTP body is null. That's why this code | 594 // http_content_type field when the HTTP body is null. That's why this code |
583 // is here instead of inside ReadHttpBody. | 595 // is here instead of inside ReadHttpBody. |
584 state->http_body.http_content_type = ReadString(obj); | 596 state->http_body.http_content_type = ReadString(obj); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 float device_scale_factor, | 730 float device_scale_factor, |
719 ExplodedPageState* exploded) { | 731 ExplodedPageState* exploded) { |
720 g_device_scale_factor_for_testing = device_scale_factor; | 732 g_device_scale_factor_for_testing = device_scale_factor; |
721 bool rv = DecodePageState(encoded, exploded); | 733 bool rv = DecodePageState(encoded, exploded); |
722 g_device_scale_factor_for_testing = 0.0; | 734 g_device_scale_factor_for_testing = 0.0; |
723 return rv; | 735 return rv; |
724 } | 736 } |
725 #endif | 737 #endif |
726 | 738 |
727 } // namespace content | 739 } // namespace content |
OLD | NEW |