OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/public/common/page_state.h" |
| 6 |
| 7 #include "third_party/WebKit/Source/Platform/chromium/public/WebHTTPBody.h" |
| 8 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
| 10 #include "webkit/base/file_path_string_conversions.h" |
| 11 #include "webkit/glue/glue_serialize_deprecated.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 // static |
| 16 PageState PageState::CreateFromURL(const GURL& url) { |
| 17 return PageState(webkit_glue::CreateHistoryStateForURL(url)); |
| 18 } |
| 19 |
| 20 // static |
| 21 PageState PageState::CreateForTesting( |
| 22 const GURL& url, |
| 23 bool body_contains_password_data, |
| 24 const char* optional_body_data, |
| 25 const base::FilePath* optional_body_file_path) { |
| 26 WebKit::WebHistoryItem history_item; |
| 27 history_item.initialize(); |
| 28 history_item.setURLString( |
| 29 WebKit::WebString::fromUTF8(url.possibly_invalid_spec())); |
| 30 if (optional_body_data || optional_body_file_path) { |
| 31 WebKit::WebHTTPBody http_body; |
| 32 http_body.initialize(); |
| 33 http_body.setContainsPasswordData(body_contains_password_data); |
| 34 if (optional_body_data) { |
| 35 http_body.appendData( |
| 36 WebKit::WebData(optional_body_data, strlen(optional_body_data))); |
| 37 } |
| 38 if (optional_body_file_path) { |
| 39 http_body.appendFile( |
| 40 webkit_base::FilePathToWebString(*optional_body_file_path)); |
| 41 } |
| 42 history_item.setHTTPBody(http_body); |
| 43 } |
| 44 return PageState(webkit_glue::HistoryItemToString(history_item)); |
| 45 } |
| 46 |
| 47 std::vector<base::FilePath> PageState::GetReferencedFiles() const { |
| 48 return webkit_glue::FilePathsFromHistoryState(data_); |
| 49 } |
| 50 |
| 51 PageState PageState::RemovePasswordData() const { |
| 52 return PageState(webkit_glue::RemovePasswordDataFromHistoryState(data_)); |
| 53 } |
| 54 |
| 55 PageState PageState::RemoveScrollOffset() const { |
| 56 return PageState(webkit_glue::RemoveScrollOffsetFromHistoryState(data_)); |
| 57 } |
| 58 |
| 59 } // namespace content |
OLD | NEW |