| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/glue/glue_serialize.h" | 5 #include "webkit/glue/glue_serialize.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 const std::string& content_state) { | 541 const std::string& content_state) { |
| 542 std::vector<FilePath> to_return; | 542 std::vector<FilePath> to_return; |
| 543 // TODO(darin): We should avoid using the WebKit API here, so that we do not | 543 // TODO(darin): We should avoid using the WebKit API here, so that we do not |
| 544 // need to have WebKit initialized before calling this method. | 544 // need to have WebKit initialized before calling this method. |
| 545 const WebHistoryItem& item = | 545 const WebHistoryItem& item = |
| 546 HistoryItemFromString(content_state, ALWAYS_INCLUDE_FORM_DATA, true); | 546 HistoryItemFromString(content_state, ALWAYS_INCLUDE_FORM_DATA, true); |
| 547 if (item.isNull()) { | 547 if (item.isNull()) { |
| 548 // Couldn't parse the string. | 548 // Couldn't parse the string. |
| 549 return to_return; | 549 return to_return; |
| 550 } | 550 } |
| 551 const WebHTTPBody& http_body = item.httpBody(); | 551 const WebVector<WebString> file_paths = item.getReferencedFilePaths(); |
| 552 if (!http_body.isNull()) { | 552 for (size_t i = 0; i < file_paths.size(); ++i) |
| 553 WebHTTPBody::Element element; | 553 to_return.push_back(WebStringToFilePath(file_paths[i])); |
| 554 for (size_t i = 0; i < http_body.elementCount(); ++i) { | |
| 555 http_body.elementAt(i, element); | |
| 556 if (element.type == WebHTTPBody::Element::TypeFile) | |
| 557 to_return.push_back(WebStringToFilePath(element.filePath)); | |
| 558 } | |
| 559 } | |
| 560 return to_return; | 554 return to_return; |
| 561 } | 555 } |
| 562 | 556 |
| 563 // For testing purposes only. | 557 // For testing purposes only. |
| 564 void HistoryItemToVersionedString(const WebHistoryItem& item, int version, | 558 void HistoryItemToVersionedString(const WebHistoryItem& item, int version, |
| 565 std::string* serialized_item) { | 559 std::string* serialized_item) { |
| 566 if (item.isNull()) { | 560 if (item.isNull()) { |
| 567 serialized_item->clear(); | 561 serialized_item->clear(); |
| 568 return; | 562 return; |
| 569 } | 563 } |
| 570 | 564 |
| 571 // Temporarily change the version. | 565 // Temporarily change the version. |
| 572 int real_version = kVersion; | 566 int real_version = kVersion; |
| 573 kVersion = version; | 567 kVersion = version; |
| 574 | 568 |
| 575 SerializeObject obj; | 569 SerializeObject obj; |
| 576 WriteHistoryItem(item, &obj); | 570 WriteHistoryItem(item, &obj); |
| 577 *serialized_item = obj.GetAsString(); | 571 *serialized_item = obj.GetAsString(); |
| 578 | 572 |
| 579 kVersion = real_version; | 573 kVersion = real_version; |
| 580 } | 574 } |
| 581 | 575 |
| 582 int HistoryItemCurrentVersion() { | 576 int HistoryItemCurrentVersion() { |
| 583 return kVersion; | 577 return kVersion; |
| 584 } | 578 } |
| 585 | 579 |
| 586 } // namespace webkit_glue | 580 } // namespace webkit_glue |
| OLD | NEW |