Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: webkit/glue/glue_serialize.cc

Issue 42619: Fixes bug where first login attempt to hotmail after session restore... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/tab_restore_service_unittest.cc ('k') | webkit/glue/webkit_glue.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/glue_serialize.cc
===================================================================
--- webkit/glue/glue_serialize.cc (revision 12517)
+++ webkit/glue/glue_serialize.cc (working copy)
@@ -271,7 +271,8 @@
// Creates a new HistoryItem tree based on the serialized string.
// Assumes the data is in the format returned by WriteHistoryItem.
-static PassRefPtr<HistoryItem> ReadHistoryItem(const SerializeObject* obj) {
+static PassRefPtr<HistoryItem> ReadHistoryItem(const SerializeObject* obj,
+ bool include_form_data) {
// See note in WriteHistoryItem. on this.
obj->version = ReadInteger(obj);
@@ -299,20 +300,20 @@
item->setDocumentState(document_state);
// Form data. If there is any form data, we assume POST, otherwise GET.
- // ResourceRequest takes ownership of the new FormData, then gives it to
- // HistoryItem.
+ // FormData is ref counted.
ResourceRequest dummy_request; // only way to initialize HistoryItem
dummy_request.setHTTPBody(ReadFormData(obj));
dummy_request.setHTTPContentType(ReadString(obj));
dummy_request.setHTTPReferrer(ReadString(obj));
if (dummy_request.httpBody())
dummy_request.setHTTPMethod("POST");
- item->setFormInfoFromRequest(dummy_request);
+ if (include_form_data)
+ item->setFormInfoFromRequest(dummy_request);
// Subitems
int num_children = ReadInteger(obj);
for (int i = 0; i < num_children; ++i)
- item->addChildItem(ReadHistoryItem(obj));
+ item->addChildItem(ReadHistoryItem(obj, include_form_data));
return item.release();
}
@@ -332,17 +333,24 @@
// Reconstruct a HistoryItem from a string, using our JSON Value deserializer.
// This assumes that the given serialized string has all the required key,value
-// pairs, and does minimal error checking.
+// pairs, and does minimal error checking. If |include_form_data| is true,
+// the form data from a post is restored, otherwise the form data is empty.
PassRefPtr<HistoryItem> HistoryItemFromString(
darin (slow to review) 2009/03/26 17:03:48 nit: since this function is only used in this file
- const std::string& serialized_item) {
+ const std::string& serialized_item,
+ bool include_form_data) {
if (serialized_item.empty())
return NULL;
SerializeObject obj(serialized_item.data(),
static_cast<int>(serialized_item.length()));
- return ReadHistoryItem(&obj);
+ return ReadHistoryItem(&obj, include_form_data);
}
+PassRefPtr<HistoryItem> HistoryItemFromString(
+ const std::string& serialized_item) {
+ return HistoryItemFromString(serialized_item, true);
+}
+
// For testing purposes only.
void HistoryItemToVersionedString(PassRefPtr<HistoryItem> item, int version,
std::string* serialized_item) {
@@ -370,4 +378,15 @@
return data;
}
+std::string RemoveFormDataFromHistoryState(const std::string& content_state) {
+ RefPtr<HistoryItem> history_item(HistoryItemFromString(content_state, false));
+ if (!history_item.get()) {
+ // Couldn't parse the string, return an empty string.
+ return std::string();
+ }
+ std::string new_state;
+ HistoryItemToString(history_item, &new_state);
+ return new_state;
+}
+
} // namespace webkit_glue
« no previous file with comments | « chrome/browser/sessions/tab_restore_service_unittest.cc ('k') | webkit/glue/webkit_glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698