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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
11 | 11 |
12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/common/resource_request_body.h" |
17 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
18 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 namespace { | 22 namespace { |
22 | 23 |
23 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
24 float g_device_scale_factor_for_testing = 0.0; | 25 float g_device_scale_factor_for_testing = 0.0; |
25 #endif | 26 #endif |
26 | 27 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 } | 744 } |
744 | 745 |
745 bool EncodePageState(const ExplodedPageState& exploded, std::string* encoded) { | 746 bool EncodePageState(const ExplodedPageState& exploded, std::string* encoded) { |
746 SerializeObject obj; | 747 SerializeObject obj; |
747 obj.version = kCurrentVersion; | 748 obj.version = kCurrentVersion; |
748 WritePageState(exploded, &obj); | 749 WritePageState(exploded, &obj); |
749 *encoded = obj.GetAsString(); | 750 *encoded = obj.GetAsString(); |
750 return true; | 751 return true; |
751 } | 752 } |
752 | 753 |
| 754 bool GeneratePostData(const ExplodedHttpBody& exploded, |
| 755 ResourceRequestBody* http_body) { |
| 756 if (exploded.is_null) |
| 757 return false; |
| 758 |
| 759 http_body->set_identifier(exploded.identifier); |
| 760 for (auto element : exploded.elements) |
| 761 http_body->AppendExplodedHTTPBodyElement(element); |
| 762 |
| 763 return true; |
| 764 } |
| 765 |
753 #if defined(OS_ANDROID) | 766 #if defined(OS_ANDROID) |
754 bool DecodePageStateWithDeviceScaleFactorForTesting( | 767 bool DecodePageStateWithDeviceScaleFactorForTesting( |
755 const std::string& encoded, | 768 const std::string& encoded, |
756 float device_scale_factor, | 769 float device_scale_factor, |
757 ExplodedPageState* exploded) { | 770 ExplodedPageState* exploded) { |
758 g_device_scale_factor_for_testing = device_scale_factor; | 771 g_device_scale_factor_for_testing = device_scale_factor; |
759 bool rv = DecodePageState(encoded, exploded); | 772 bool rv = DecodePageState(encoded, exploded); |
760 g_device_scale_factor_for_testing = 0.0; | 773 g_device_scale_factor_for_testing = 0.0; |
761 return rv; | 774 return rv; |
762 } | 775 } |
763 #endif | 776 #endif |
764 | 777 |
765 } // namespace content | 778 } // namespace content |
OLD | NEW |