OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/public/common/page_state.h" | 5 #include "content/public/common/page_state.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/strings/nullable_string16.h" | 10 #include "base/strings/nullable_string16.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "content/common/page_state_serialization.h" | 12 #include "content/common/page_state_serialization.h" |
| 13 #include "content/public/common/resource_request_body.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 namespace { | 16 namespace { |
16 | 17 |
17 base::NullableString16 ToNullableString16(const std::string& utf8) { | 18 base::NullableString16 ToNullableString16(const std::string& utf8) { |
18 return base::NullableString16(base::UTF8ToUTF16(utf8), false); | 19 return base::NullableString16(base::UTF8ToUTF16(utf8), false); |
19 } | 20 } |
20 | 21 |
21 base::FilePath ToFilePath(const base::NullableString16& s) { | 22 base::FilePath ToFilePath(const base::NullableString16& s) { |
22 return base::FilePath::FromUTF16Unsafe(s.string()); | 23 return base::FilePath::FromUTF16Unsafe(s.string()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool body_contains_password_data, | 79 bool body_contains_password_data, |
79 const char* optional_body_data, | 80 const char* optional_body_data, |
80 const base::FilePath* optional_body_file_path) { | 81 const base::FilePath* optional_body_file_path) { |
81 ExplodedPageState state; | 82 ExplodedPageState state; |
82 | 83 |
83 state.top.url_string = ToNullableString16(url.possibly_invalid_spec()); | 84 state.top.url_string = ToNullableString16(url.possibly_invalid_spec()); |
84 | 85 |
85 if (optional_body_data || optional_body_file_path) { | 86 if (optional_body_data || optional_body_file_path) { |
86 if (optional_body_data) { | 87 if (optional_body_data) { |
87 std::string body_data(optional_body_data); | 88 std::string body_data(optional_body_data); |
88 state.top.http_body.request_body = new ResourceRequestBodyImpl(); | 89 state.top.http_body.request_body = new ResourceRequestBody(); |
89 state.top.http_body.request_body->AppendBytes(body_data.data(), | 90 state.top.http_body.request_body->AppendBytes(body_data.data(), |
90 body_data.size()); | 91 body_data.size()); |
91 } | 92 } |
92 if (optional_body_file_path) { | 93 if (optional_body_file_path) { |
93 state.top.http_body.request_body = new ResourceRequestBodyImpl(); | 94 state.top.http_body.request_body = new ResourceRequestBody(); |
94 state.top.http_body.request_body->AppendFileRange( | 95 state.top.http_body.request_body->AppendFileRange( |
95 *optional_body_file_path, | 96 *optional_body_file_path, |
96 0, std::numeric_limits<uint64_t>::max(), | 97 0, std::numeric_limits<uint64_t>::max(), |
97 base::Time()); | 98 base::Time()); |
98 state.referenced_files.push_back(base::NullableString16( | 99 state.referenced_files.push_back(base::NullableString16( |
99 optional_body_file_path->AsUTF16Unsafe(), false)); | 100 optional_body_file_path->AsUTF16Unsafe(), false)); |
100 } | 101 } |
101 state.top.http_body.contains_passwords = | 102 state.top.http_body.contains_passwords = |
102 body_contains_password_data; | 103 body_contains_password_data; |
103 } | 104 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 180 } |
180 | 181 |
181 PageState::PageState(const std::string& data) | 182 PageState::PageState(const std::string& data) |
182 : data_(data) { | 183 : data_(data) { |
183 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass | 184 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass |
184 // bogus encoded data to CreateFromEncodedData. | 185 // bogus encoded data to CreateFromEncodedData. |
185 //DCHECK(IsValid()); | 186 //DCHECK(IsValid()); |
186 } | 187 } |
187 | 188 |
188 } // namespace content | 189 } // namespace content |
OLD | NEW |