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