| 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" | |
| 11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 12 #include "content/common/page_state_serialization.h" | 11 #include "content/common/page_state_serialization.h" |
| 13 | 12 |
| 14 namespace content { | 13 namespace content { |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 base::NullableString16 ToNullableString16(const std::string& utf8) { | 16 base::NullableString16 ToNullableString16(const std::string& utf8) { |
| 18 return base::NullableString16(base::UTF8ToUTF16(utf8), false); | 17 return base::NullableString16(base::UTF8ToUTF16(utf8), false); |
| 19 } | 18 } |
| 20 | 19 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const char* optional_body_data, | 80 const char* optional_body_data, |
| 82 const base::FilePath* optional_body_file_path) { | 81 const base::FilePath* optional_body_file_path) { |
| 83 ExplodedPageState state; | 82 ExplodedPageState state; |
| 84 | 83 |
| 85 state.top.url_string = ToNullableString16(url.possibly_invalid_spec()); | 84 state.top.url_string = ToNullableString16(url.possibly_invalid_spec()); |
| 86 | 85 |
| 87 if (optional_body_data || optional_body_file_path) { | 86 if (optional_body_data || optional_body_file_path) { |
| 88 state.top.http_body.is_null = false; | 87 state.top.http_body.is_null = false; |
| 89 if (optional_body_data) { | 88 if (optional_body_data) { |
| 90 ExplodedHttpBodyElement element; | 89 ExplodedHttpBodyElement element; |
| 91 std::string body_data(optional_body_data); | 90 element.type = blink::WebHTTPBody::Element::TypeData; |
| 92 element.SetToBytes(body_data.data(), body_data.size()); | 91 element.data = optional_body_data; |
| 93 state.top.http_body.elements.push_back(element); | 92 state.top.http_body.elements.push_back(element); |
| 94 } | 93 } |
| 95 if (optional_body_file_path) { | 94 if (optional_body_file_path) { |
| 96 ExplodedHttpBodyElement element; | 95 ExplodedHttpBodyElement element; |
| 97 element.SetToFilePath(*optional_body_file_path); | 96 element.type = blink::WebHTTPBody::Element::TypeFile; |
| 98 state.referenced_files.push_back(base::NullableString16( | 97 element.file_path = |
| 99 optional_body_file_path->AsUTF16Unsafe(), false)); | 98 ToNullableString16(optional_body_file_path->AsUTF8Unsafe()); |
| 99 state.top.http_body.elements.push_back(element); |
| 100 state.referenced_files.push_back(element.file_path); |
| 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 } |
| 104 | 105 |
| 105 return ToPageState(state); | 106 return ToPageState(state); |
| 106 } | 107 } |
| 107 | 108 |
| 108 PageState::PageState() { | 109 PageState::PageState() { |
| 109 } | 110 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 165 } |
| 165 | 166 |
| 166 PageState::PageState(const std::string& data) | 167 PageState::PageState(const std::string& data) |
| 167 : data_(data) { | 168 : data_(data) { |
| 168 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass | 169 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass |
| 169 // bogus encoded data to CreateFromEncodedData. | 170 // bogus encoded data to CreateFromEncodedData. |
| 170 //DCHECK(IsValid()); | 171 //DCHECK(IsValid()); |
| 171 } | 172 } |
| 172 | 173 |
| 173 } // namespace content | 174 } // namespace content |
| OLD | NEW |