summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 19:36:17 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 19:36:17 +0000
commitca948a21e18cdac84a933ce9ebd72be4152d8a32 (patch)
tree2c4fa33bc742c0a9a5e144128a8e277f16620409 /webkit/glue
parentf8646f7f53d9f48139b37588953170c3a882509f (diff)
downloadchromium_src-ca948a21e18cdac84a933ce9ebd72be4152d8a32.zip
chromium_src-ca948a21e18cdac84a933ce9ebd72be4152d8a32.tar.gz
chromium_src-ca948a21e18cdac84a933ce9ebd72be4152d8a32.tar.bz2
Hook up WebHistoryItem and push HistoryItem serialization out of WebFrame.
WebHistoryItem is a copy-on-write wrapper for a WebCore::HistoryItem. Pushing history item serialization out of WebFrame allows us to avoid a dependency on base/pickle from WebFrame. This helps get us closer to being able to move WebFrame into the WebKit API. BUG=10043 TEST=none R=dglazkov,sky Review URL: http://codereview.chromium.org/146075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19275 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/glue_serialize.cc303
-rw-r--r--webkit/glue/glue_serialize.h31
-rw-r--r--webkit/glue/glue_serialize_unittest.cc223
-rw-r--r--webkit/glue/glue_util.cc16
-rw-r--r--webkit/glue/glue_util.h8
-rw-r--r--webkit/glue/webframe.h35
-rw-r--r--webkit/glue/webframe_impl.cc36
-rw-r--r--webkit/glue/webframe_impl.h7
-rw-r--r--webkit/glue/webkit_glue.cc45
9 files changed, 364 insertions, 340 deletions
diff --git a/webkit/glue/glue_serialize.cc b/webkit/glue/glue_serialize.cc
index 0850e1b..5db939a 100644
--- a/webkit/glue/glue_serialize.cc
+++ b/webkit/glue/glue_serialize.cc
@@ -1,27 +1,30 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "config.h"
-#include <string>
-
-#include "base/compiler_specific.h"
-
-MSVC_PUSH_WARNING_LEVEL(0);
-#include "HistoryItem.h"
-#include "PlatformString.h"
-#include "ResourceRequest.h"
-MSVC_POP_WARNING();
-#undef LOG
-
#include "webkit/glue/glue_serialize.h"
+#include <string>
+
#include "base/pickle.h"
#include "base/string_util.h"
+#include "googleurl/src/gurl.h"
+#include "webkit/api/public/WebData.h"
+#include "webkit/api/public/WebHistoryItem.h"
+#include "webkit/api/public/WebHTTPBody.h"
+#include "webkit/api/public/WebPoint.h"
+#include "webkit/api/public/WebString.h"
+#include "webkit/api/public/WebVector.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webkit_glue.h"
-using namespace WebCore;
+using WebKit::WebData;
+using WebKit::WebHistoryItem;
+using WebKit::WebHTTPBody;
+using WebKit::WebPoint;
+using WebKit::WebString;
+using WebKit::WebUChar;
+using WebKit::WebVector;
namespace webkit_glue {
@@ -43,7 +46,7 @@ struct SerializeObject {
// 1: Initial revision.
// 2: Added case for NULL string versus "". Version 2 code can read Version 1
// data, but not vice versa.
-// 3: Version 2 was broken, it stored number of UChars, not number of bytes.
+// 3: Version 2 was broken, it stored number of WebUChars, not number of bytes.
// This version checks and reads v1 and v2 correctly.
// 4: Adds support for storing FormData::identifier().
// 5: Adds support for empty FormData
@@ -114,67 +117,68 @@ inline bool ReadBoolean(const SerializeObject* obj) {
return tmp;
}
-// Read/WriteString pickle the String as <int length><UChar* data>.
-// If length == -1, then the String itself is NULL (String()).
-// Otherwise the length is the number of UChars (not bytes) in the String.
-inline void WriteString(const String& data, SerializeObject* obj) {
+// Read/WriteString pickle the WebString as <int length><WebUChar* data>.
+// If length == -1, then the WebString itself is NULL (WebString()).
+// Otherwise the length is the number of WebUChars (not bytes) in the WebString.
+inline void WriteString(const WebString& str, SerializeObject* obj) {
switch (kVersion) {
case 1:
// Version 1 writes <length in bytes><string data>.
- // It saves String() and "" as "".
- obj->pickle.WriteInt(data.length() * sizeof(UChar));
- obj->pickle.WriteBytes(data.characters(), data.length() * sizeof(UChar));
+ // It saves WebString() and "" as "".
+ obj->pickle.WriteInt(str.length() * sizeof(WebUChar));
+ obj->pickle.WriteBytes(str.data(), str.length() * sizeof(WebUChar));
break;
case 2:
- // Version 2 writes <length in UChars><string data>.
- // It uses -1 in the length field to mean String().
- if (data.isNull()) {
+ // Version 2 writes <length in WebUChar><string data>.
+ // It uses -1 in the length field to mean WebString().
+ if (str.isNull()) {
obj->pickle.WriteInt(-1);
} else {
- obj->pickle.WriteInt(data.length());
- obj->pickle.WriteBytes(data.characters(),
- data.length() * sizeof(UChar));
+ obj->pickle.WriteInt(str.length());
+ obj->pickle.WriteBytes(str.data(),
+ str.length() * sizeof(WebUChar));
}
break;
default:
// Version 3+ writes <length in bytes><string data>.
- // It uses -1 in the length field to mean String().
- if (data.isNull()) {
+ // It uses -1 in the length field to mean WebString().
+ if (str.isNull()) {
obj->pickle.WriteInt(-1);
} else {
- obj->pickle.WriteInt(data.length() * sizeof(UChar));
- obj->pickle.WriteBytes(data.characters(),
- data.length() * sizeof(UChar));
+ obj->pickle.WriteInt(str.length() * sizeof(WebUChar));
+ obj->pickle.WriteBytes(str.data(),
+ str.length() * sizeof(WebUChar));
}
break;
}
}
-// This reads a serialized String from obj. If a string can't be read,
-// String() is returned.
-inline String ReadString(const SerializeObject* obj) {
+// This reads a serialized WebString from obj. If a string can't be read,
+// WebString() is returned.
+inline WebString ReadString(const SerializeObject* obj) {
int length;
// Versions 1, 2, and 3 all start with an integer.
if (!obj->pickle.ReadInt(&obj->iter, &length))
- return String();
+ return WebString();
- // Starting with version 2, -1 means String().
+ // Starting with version 2, -1 means WebString().
if (length == -1)
- return String();
+ return WebString();
- // In version 2, the length field was the length in UChars.
+ // In version 2, the length field was the length in WebUChars.
// In version 1 and 3 it is the length in bytes.
- int bytes = ((obj->version == 2) ? length * sizeof(UChar) : length);
+ int bytes = ((obj->version == 2) ? length * sizeof(WebUChar) : length);
const void* data;
if (!ReadBytes(obj, &data, bytes))
- return String();
- return String(static_cast<const UChar*>(data), bytes / sizeof(UChar));
+ return WebString();
+ return WebString(static_cast<const WebUChar*>(data), bytes / sizeof(WebUChar));
}
// Writes a Vector of Strings into a SerializeObject for serialization.
-static void WriteStringVector(const Vector<String>& data, SerializeObject* obj) {
+static void WriteStringVector(
+ const WebVector<WebString>& data, SerializeObject* obj) {
WriteInteger(static_cast<int>(data.size()), obj);
for (size_t i = 0, c = data.size(); i < c; ++i) {
unsigned ui = static_cast<unsigned>(i); // sigh
@@ -182,185 +186,183 @@ static void WriteStringVector(const Vector<String>& data, SerializeObject* obj)
}
}
-static void ReadStringVector(const SerializeObject* obj, Vector<String>* data) {
+static WebVector<WebString> ReadStringVector(const SerializeObject* obj) {
int num_elements = ReadInteger(obj);
- data->reserveCapacity(num_elements);
- for (int i = 0; i < num_elements; ++i) {
- data->append(ReadString(obj));
- }
+ WebVector<WebString> result(static_cast<size_t>(num_elements));
+ for (int i = 0; i < num_elements; ++i)
+ result[i] = ReadString(obj);
+ return result;
}
// Writes a FormData object into a SerializeObject for serialization.
-static void WriteFormData(const FormData* form_data, SerializeObject* obj) {
- WriteBoolean(form_data != NULL, obj);
+static void WriteFormData(const WebHTTPBody& http_body, SerializeObject* obj) {
+ WriteBoolean(!http_body.isNull(), obj);
- if (!form_data)
+ if (http_body.isNull())
return;
- WriteInteger(static_cast<int>(form_data->elements().size()), obj);
- for (size_t i = 0, c = form_data->elements().size(); i < c; ++i) {
- const FormDataElement& e = form_data->elements().at(i);
- WriteInteger(e.m_type, obj);
-
- if (e.m_type == FormDataElement::data) {
- WriteData(e.m_data.data(), static_cast<int>(e.m_data.size()), obj);
+ WriteInteger(static_cast<int>(http_body.elementCount()), obj);
+ WebHTTPBody::Element element;
+ for (size_t i = 0; http_body.elementAt(i, element); ++i) {
+ WriteInteger(element.type, obj);
+ if (element.type == WebHTTPBody::Element::TypeData) {
+ WriteData(element.data.data(), static_cast<int>(element.data.size()),
+ obj);
} else {
- WriteString(e.m_filename, obj);
+ WriteString(element.filePath, obj);
}
}
- WriteInteger64(form_data->identifier(), obj);
+ WriteInteger64(http_body.identifier(), obj);
}
-static PassRefPtr<FormData> ReadFormData(const SerializeObject* obj) {
+static WebHTTPBody ReadFormData(const SerializeObject* obj) {
// In newer versions, an initial boolean indicates if we have form data.
if (obj->version >= 5 && !ReadBoolean(obj))
- return NULL;
+ return WebHTTPBody();
// In older versions, 0 elements implied no form data.
int num_elements = ReadInteger(obj);
if (num_elements == 0 && obj->version < 5)
- return NULL;
+ return WebHTTPBody();
- RefPtr<FormData> form_data = FormData::create();
+ WebHTTPBody http_body;
+ http_body.initialize();
for (int i = 0; i < num_elements; ++i) {
int type = ReadInteger(obj);
- if (type == FormDataElement::data) {
+ if (type == WebHTTPBody::Element::TypeData) {
const void* data;
int length;
ReadData(obj, &data, &length);
- form_data->appendData(static_cast<const char*>(data), length);
+ http_body.appendData(WebData(static_cast<const char*>(data), length));
} else {
- form_data->appendFile(ReadString(obj));
+ http_body.appendFile(ReadString(obj));
}
}
if (obj->version >= 4)
- form_data->setIdentifier(ReadInteger64(obj));
+ http_body.setIdentifier(ReadInteger64(obj));
- return form_data.release();
+ return http_body;
}
// Writes the HistoryItem data into the SerializeObject object for
// serialization.
-static void WriteHistoryItem(const HistoryItem* item, SerializeObject* obj) {
+static void WriteHistoryItem(
+ const WebHistoryItem& item, SerializeObject* obj) {
// WARNING: This data may be persisted for later use. As such, care must be
// taken when changing the serialized format. If a new field needs to be
// written, only adding at the end will make it easier to deal with loading
// older versions. Similarly, this should NOT save fields with sensitive
// data, such as password fields.
WriteInteger(kVersion, obj);
- WriteString(item->urlString(), obj);
- WriteString(item->originalURLString(), obj);
- WriteString(item->target(), obj);
- WriteString(item->parent(), obj);
- WriteString(item->title(), obj);
- WriteString(item->alternateTitle(), obj);
- WriteReal(item->lastVisitedTime(), obj);
- WriteInteger(item->scrollPoint().x(), obj);
- WriteInteger(item->scrollPoint().y(), obj);
- WriteBoolean(item->isTargetItem(), obj);
- WriteInteger(item->visitCount(), obj);
- WriteString(item->referrer(), obj);
-
- WriteStringVector(item->documentState(), obj);
-
- // No access to formData through a const HistoryItem = lame.
- WriteFormData(const_cast<HistoryItem*>(item)->formData(), obj);
- WriteString(item->formContentType(), obj);
- WriteString(item->referrer(), obj);
+ WriteString(item.urlString(), obj);
+ WriteString(item.originalURLString(), obj);
+ WriteString(item.target(), obj);
+ WriteString(item.parent(), obj);
+ WriteString(item.title(), obj);
+ WriteString(item.alternateTitle(), obj);
+ WriteReal(item.lastVisitedTime(), obj);
+ WriteInteger(item.scrollOffset().x, obj);
+ WriteInteger(item.scrollOffset().y, obj);
+ WriteBoolean(item.isTargetItem(), obj);
+ WriteInteger(item.visitCount(), obj);
+ WriteString(item.referrer(), obj);
+
+ WriteStringVector(item.documentState(), obj);
+
+ // Yes, the referrer is written twice. This is for backwards
+ // compatibility with the format.
+ WriteFormData(item.httpBody(), obj);
+ WriteString(item.httpContentType(), obj);
+ WriteString(item.referrer(), obj);
// Subitems
- WriteInteger(static_cast<int>(item->children().size()), obj);
- for (size_t i = 0, c = item->children().size(); i < c; ++i)
- WriteHistoryItem(item->children().at(i).get(), obj);
+ const WebVector<WebHistoryItem>& children = item.children();
+ WriteInteger(static_cast<int>(children.size()), obj);
+ for (size_t i = 0, c = children.size(); i < c; ++i)
+ WriteHistoryItem(children[i], obj);
}
// 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,
- bool include_form_data) {
+static WebHistoryItem ReadHistoryItem(
+ const SerializeObject* obj, bool include_form_data) {
// See note in WriteHistoryItem. on this.
obj->version = ReadInteger(obj);
if (obj->version > kVersion || obj->version < 1)
- return NULL;
-
- RefPtr<HistoryItem> item = HistoryItem::create();
-
- item->setURLString(ReadString(obj));
- item->setOriginalURLString(ReadString(obj));
- item->setTarget(ReadString(obj));
- item->setParent(ReadString(obj));
- item->setTitle(ReadString(obj));
- item->setAlternateTitle(ReadString(obj));
- item->setLastVisitedTime(ReadReal(obj));
+ return WebHistoryItem();
+
+ WebHistoryItem item;
+ item.initialize();
+
+ item.setURLString(ReadString(obj));
+ item.setOriginalURLString(ReadString(obj));
+ item.setTarget(ReadString(obj));
+ item.setParent(ReadString(obj));
+ item.setTitle(ReadString(obj));
+ item.setAlternateTitle(ReadString(obj));
+ item.setLastVisitedTime(ReadReal(obj));
int x = ReadInteger(obj);
int y = ReadInteger(obj);
- item->setScrollPoint(IntPoint(x, y));
- item->setIsTargetItem(ReadBoolean(obj));
- item->setVisitCount(ReadInteger(obj));
- item->setReferrer(ReadString(obj));
-
- Vector<String> document_state;
- ReadStringVector(obj, &document_state);
- item->setDocumentState(document_state);
-
- // Form data. If there is any form data, we assume POST, otherwise GET.
- // 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");
- if (include_form_data)
- item->setFormInfoFromRequest(dummy_request);
+ item.setScrollOffset(WebPoint(x, y));
+ item.setIsTargetItem(ReadBoolean(obj));
+ item.setVisitCount(ReadInteger(obj));
+ item.setReferrer(ReadString(obj));
+
+ item.setDocumentState(ReadStringVector(obj));
+
+ // The extra referrer string is read for backwards compat.
+ const WebHTTPBody& http_body = ReadFormData(obj);
+ const WebString& http_content_type = ReadString(obj);
+ const WebString& unused_referrer = ReadString(obj);
+ if (include_form_data) {
+ item.setHTTPBody(http_body);
+ item.setHTTPContentType(http_content_type);
+ }
// Subitems
int num_children = ReadInteger(obj);
for (int i = 0; i < num_children; ++i)
- item->addChildItem(ReadHistoryItem(obj, include_form_data));
+ item.appendToChildren(ReadHistoryItem(obj, include_form_data));
- return item.release();
+ return item;
}
// Serialize a HistoryItem to a string, using our JSON Value serializer.
-void HistoryItemToString(PassRefPtr<HistoryItem> item,
- std::string* serialized_item) {
- if (!item) {
- serialized_item->clear();
- return;
- }
+std::string HistoryItemToString(const WebHistoryItem& item) {
+ if (item.isNull())
+ return std::string();
SerializeObject obj;
- WriteHistoryItem(item.get(), &obj);
- *serialized_item = obj.GetAsString();
+ WriteHistoryItem(item, &obj);
+ return obj.GetAsString();
}
// 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. If |include_form_data| is true,
// the form data from a post is restored, otherwise the form data is empty.
-static PassRefPtr<HistoryItem> HistoryItemFromString(
+static WebHistoryItem HistoryItemFromString(
const std::string& serialized_item,
bool include_form_data) {
if (serialized_item.empty())
- return NULL;
+ return WebHistoryItem();
SerializeObject obj(serialized_item.data(),
static_cast<int>(serialized_item.length()));
return ReadHistoryItem(&obj, include_form_data);
}
-PassRefPtr<HistoryItem> HistoryItemFromString(
+WebHistoryItem HistoryItemFromString(
const std::string& serialized_item) {
return HistoryItemFromString(serialized_item, true);
}
// For testing purposes only.
-void HistoryItemToVersionedString(PassRefPtr<HistoryItem> item, int version,
+void HistoryItemToVersionedString(const WebHistoryItem& item, int version,
std::string* serialized_item) {
- if (!item) {
+ if (item.isNull()) {
serialized_item->clear();
return;
}
@@ -370,29 +372,28 @@ void HistoryItemToVersionedString(PassRefPtr<HistoryItem> item, int version,
kVersion = version;
SerializeObject obj;
- WriteHistoryItem(item.get(), &obj);
+ WriteHistoryItem(item, &obj);
*serialized_item = obj.GetAsString();
kVersion = real_version;
}
std::string CreateHistoryStateForURL(const GURL& url) {
- // TODO(eseide): We probably should be passing a list visit time other than 0
- RefPtr<HistoryItem> item(HistoryItem::create(GURLToKURL(url), String(), 0));
- std::string data;
- HistoryItemToString(item, &data);
- return data;
+ WebHistoryItem item;
+ item.initialize();
+ item.setURLString(UTF8ToUTF16(url.spec()));
+
+ return HistoryItemToString(item);
}
std::string RemoveFormDataFromHistoryState(const std::string& content_state) {
- RefPtr<HistoryItem> history_item(HistoryItemFromString(content_state, false));
- if (!history_item.get()) {
+ const WebHistoryItem& item = HistoryItemFromString(content_state, false);
+ if (item.isNull()) {
// Couldn't parse the string, return an empty string.
return std::string();
}
- std::string new_state;
- HistoryItemToString(history_item, &new_state);
- return new_state;
+
+ return HistoryItemToString(item);
}
} // namespace webkit_glue
diff --git a/webkit/glue/glue_serialize.h b/webkit/glue/glue_serialize.h
index eaa3f6d..ea73032 100644
--- a/webkit/glue/glue_serialize.h
+++ b/webkit/glue/glue_serialize.h
@@ -7,30 +7,25 @@
// In serialization, we write an object's state to a string in some opaque
// format. Deserialization reconstructs the object's state from such a string.
-#ifndef WEBKIT_GLUE_GLUE_SERIALIZE_H__
-#define WEBKIT_GLUE_GLUE_SERIALIZE_H__
+#ifndef WEBKIT_GLUE_GLUE_SERIALIZE_H_
+#define WEBKIT_GLUE_GLUE_SERIALIZE_H_
-namespace WebCore {
-class String;
-class HistoryItem;
-}
-namespace WTF {
-template<typename T> class PassRefPtr;
-}
+#include <string>
+#include "webkit/api/public/WebHistoryItem.h"
namespace webkit_glue {
-// HistoryItem serialization. The returned HistoryItem will have a ref count
-// of 0, so the first RefPtr it is assigned to will take ownership. The empty
-// string corresponds with a NULL HistoryItem.
-void HistoryItemToString(
- WTF::PassRefPtr<WebCore::HistoryItem> item, std::string* serialized_item);
-WTF::PassRefPtr<WebCore::HistoryItem> HistoryItemFromString(
+
+// HistoryItem serialization.
+std::string HistoryItemToString(
+ const WebKit::WebHistoryItem& item);
+WebKit::WebHistoryItem HistoryItemFromString(
const std::string& serialized_item);
// For testing purposes only.
void HistoryItemToVersionedString(
- WTF::PassRefPtr<WebCore::HistoryItem> item, int version,
+ const WebKit::WebHistoryItem& item, int version,
std::string* serialized_item);
-}
-#endif // #ifndef WEBKIT_GLUE_GLUE_SERIALIZE_H__
+} // namespace webkit_glue
+
+#endif // #ifndef WEBKIT_GLUE_GLUE_SERIALIZE_H_
diff --git a/webkit/glue/glue_serialize_unittest.cc b/webkit/glue/glue_serialize_unittest.cc
index 2a8dba3..1960fed 100644
--- a/webkit/glue/glue_serialize_unittest.cc
+++ b/webkit/glue/glue_serialize_unittest.cc
@@ -2,179 +2,194 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "config.h"
#include <string>
-#include "base/compiler_specific.h"
-
-MSVC_PUSH_WARNING_LEVEL(0);
-#include "CString.h"
-#include "FormData.h"
-#include "HistoryItem.h"
-#include "PlatformString.h"
-#include "ResourceRequest.h"
-MSVC_POP_WARNING();
-
-#undef LOG
-
+#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/api/public/WebHTTPBody.h"
+#include "webkit/api/public/WebPoint.h"
+#include "webkit/api/public/WebVector.h"
#include "webkit/glue/glue_serialize.h"
using namespace std;
-using namespace WebCore;
using namespace webkit_glue;
+using WebKit::WebData;
+using WebKit::WebHistoryItem;
+using WebKit::WebHTTPBody;
+using WebKit::WebPoint;
+using WebKit::WebString;
+using WebKit::WebUChar;
+using WebKit::WebVector;
+
// These exist only to support the gTest assertion macros, and
// shouldn't be used in normal program code.
-static std::ostream& operator<<(std::ostream& out, const String& str)
-{
- return out << str.latin1().data();
+static std::ostream& operator<<(std::ostream& out, const WebString& str) {
+ return out << UTF16ToUTF8(str);
}
-static std::ostream& operator<<(std::ostream& out, const FormDataElement& e)
-{
- return out << e.m_type << ": " <<
- e.m_data.size() <<
- " <" << string(e.m_data.data() ? e.m_data.data() : "", e.m_data.size()) << "> " <<
- e.m_filename;
+static std::ostream& operator<<(std::ostream& out,
+ const WebHTTPBody::Element& e) {
+ return out << e.type << ": " <<
+ e.data.size() <<
+ " <" << string(e.data.data() ? e.data.data() : "", e.data.size()) << "> " <<
+ e.filePath;
}
template<typename T>
-static std::ostream& operator<<(std::ostream& out, const Vector<T>& v)
-{
+static std::ostream& operator<<(std::ostream& out, const WebVector<T>& v) {
for (size_t i = 0; i < v.size(); ++i)
out << "[" << v[i] << "] ";
-
return out;
}
-static std::ostream& operator<<(std::ostream& out, const FormData& data)
-{
- return out << data.elements();
+static std::ostream& operator<<(std::ostream& out, const WebHTTPBody& data) {
+ WebHTTPBody::Element element;
+ for (size_t i = 0; data.elementAt(i, element); ++i)
+ out << "[" << element << "] ";
+ return out;
}
-static std::ostream& operator<<(std::ostream& out, const IntPoint& pt)
-{
- return out << "(" << pt.x() << "," << pt.y() << ")";
+static std::ostream& operator<<(std::ostream& out, const WebPoint& pt) {
+ return out << "(" << pt.x << "," << pt.y << ")";
}
namespace {
class GlueSerializeTest : public testing::Test {
public:
// Makes a FormData with some random data.
- PassRefPtr<FormData> MakeFormData() {
- RefPtr<FormData> form_data = FormData::create();
+ WebHTTPBody MakeFormData() {
+ WebHTTPBody http_body;
+ http_body.initialize();
- char d1[] = "first data block";
- form_data->appendData(d1, sizeof(d1)-1);
+ const char d1[] = "first data block";
+ http_body.appendData(WebData(d1, sizeof(d1)-1));
- form_data->appendFile("file.txt");
+ http_body.appendFile(WebString::fromUTF8("file.txt"));
- char d2[] = "data the second";
- form_data->appendData(d2, sizeof(d2)-1);
+ const char d2[] = "data the second";
+ http_body.appendData(WebData(d2, sizeof(d2)-1));
- return form_data.release();
+ return http_body;
}
// Constructs a HistoryItem with some random data and an optional child.
- PassRefPtr<HistoryItem> MakeHistoryItem(bool with_form_data, bool pregnant) {
- RefPtr<HistoryItem> item = HistoryItem::create();
-
- item->setURLString("urlString");
- item->setOriginalURLString("originalURLString");
- item->setTarget("target");
- item->setParent("parent");
- item->setTitle("title");
- item->setAlternateTitle("alternateTitle");
- item->setLastVisitedTime(13.37);
- item->setScrollPoint(IntPoint(42, -42));
- item->setIsTargetItem(true);
- item->setVisitCount(42*42);
-
- Vector<String> document_state;
- document_state.append("state1");
- document_state.append("state2");
- document_state.append("state AWESOME");
- item->setDocumentState(document_state);
+ WebHistoryItem MakeHistoryItem(bool with_form_data, bool pregnant) {
+ WebHistoryItem item;
+ item.initialize();
+
+ item.setURLString(WebString::fromUTF8("urlString"));
+ item.setOriginalURLString(WebString::fromUTF8("originalURLString"));
+ item.setTarget(WebString::fromUTF8("target"));
+ item.setParent(WebString::fromUTF8("parent"));
+ item.setTitle(WebString::fromUTF8("title"));
+ item.setAlternateTitle(WebString::fromUTF8("alternateTitle"));
+ item.setLastVisitedTime(13.37);
+ item.setScrollOffset(WebPoint(42, -42));
+ item.setIsTargetItem(true);
+ item.setVisitCount(42*42);
+
+ WebVector<WebString> document_state(3U);
+ document_state[0] = WebString::fromUTF8("state1");
+ document_state[1] = WebString::fromUTF8("state2");
+ document_state[2] = WebString::fromUTF8("state AWESOME");
+ item.setDocumentState(document_state);
// Form Data
- ResourceRequest dummy_request; // only way to initialize HistoryItem
if (with_form_data) {
- dummy_request.setHTTPBody(MakeFormData());
- dummy_request.setHTTPContentType("formContentType");
- dummy_request.setHTTPReferrer("referrer");
- dummy_request.setHTTPMethod("POST");
+ item.setHTTPBody(MakeFormData());
+ item.setHTTPContentType(WebString::fromUTF8("formContentType"));
}
- item->setFormInfoFromRequest(dummy_request);
// Setting the FormInfo causes the referrer to be set, so we set the
// referrer after setting the form info.
- item->setReferrer("referrer");
+ item.setReferrer(WebString::fromUTF8("referrer"));
// Children
if (pregnant)
- item->addChildItem(MakeHistoryItem(false, false));
+ item.appendToChildren(MakeHistoryItem(false, false));
- return item.release();
+ return item;
}
// Checks that a == b.
- void HistoryItemExpectEqual(HistoryItem* a, HistoryItem* b) {
- EXPECT_EQ(a->urlString(), b->urlString());
- EXPECT_EQ(a->originalURLString(), b->originalURLString());
- EXPECT_EQ(a->target(), b->target());
- EXPECT_EQ(a->parent(), b->parent());
- EXPECT_EQ(a->title(), b->title());
- EXPECT_EQ(a->alternateTitle(), b->alternateTitle());
- EXPECT_EQ(a->lastVisitedTime(), b->lastVisitedTime());
- EXPECT_EQ(a->scrollPoint(), b->scrollPoint());
- EXPECT_EQ(a->isTargetItem(), b->isTargetItem());
- EXPECT_EQ(a->visitCount(), b->visitCount());
- EXPECT_EQ(a->referrer(), b->referrer());
- EXPECT_EQ(a->documentState(), b->documentState());
+ void HistoryItemExpectEqual(const WebHistoryItem& a,
+ const WebHistoryItem& b) {
+ EXPECT_EQ(string16(a.urlString()), string16(b.urlString()));
+ EXPECT_EQ(string16(a.originalURLString()), string16(b.originalURLString()));
+ EXPECT_EQ(string16(a.target()), string16(b.target()));
+ EXPECT_EQ(string16(a.parent()), string16(b.parent()));
+ EXPECT_EQ(string16(a.title()), string16(b.title()));
+ EXPECT_EQ(string16(a.alternateTitle()), string16(b.alternateTitle()));
+ EXPECT_EQ(a.lastVisitedTime(), b.lastVisitedTime());
+ EXPECT_EQ(a.scrollOffset(), b.scrollOffset());
+ EXPECT_EQ(a.isTargetItem(), b.isTargetItem());
+ EXPECT_EQ(a.visitCount(), b.visitCount());
+ EXPECT_EQ(string16(a.referrer()), string16(b.referrer()));
+
+ const WebVector<WebString>& a_docstate = a.documentState();
+ const WebVector<WebString>& b_docstate = b.documentState();
+ EXPECT_EQ(a_docstate.size(), b_docstate.size());
+ for (size_t i = 0, c = a_docstate.size(); i < c; ++i)
+ EXPECT_EQ(string16(a_docstate[i]), string16(b_docstate[i]));
// Form Data
- EXPECT_EQ(a->formData() != NULL, b->formData() != NULL);
- if (a->formData() && b->formData())
- EXPECT_EQ(*a->formData(), *b->formData());
- EXPECT_EQ(a->formContentType(), b->formContentType());
+ const WebHTTPBody& a_body = a.httpBody();
+ const WebHTTPBody& b_body = b.httpBody();
+ EXPECT_EQ(!a_body.isNull(), !b_body.isNull());
+ if (!a_body.isNull() && !b_body.isNull()) {
+ EXPECT_EQ(a_body.elementCount(), b_body.elementCount());
+ WebHTTPBody::Element a_elem, b_elem;
+ for (size_t i = 0; a_body.elementAt(i, a_elem) &&
+ b_body.elementAt(i, b_elem); ++i) {
+ EXPECT_EQ(a_elem.type, b_elem.type);
+ if (a_elem.type == WebHTTPBody::Element::TypeData) {
+ EXPECT_EQ(string(a_elem.data.data(), a_elem.data.size()),
+ string(b_elem.data.data(), b_elem.data.size()));
+ } else {
+ EXPECT_EQ(string16(a_elem.filePath), string16(b_elem.filePath));
+ }
+ }
+ }
+ EXPECT_EQ(string16(a.httpContentType()), string16(b.httpContentType()));
// Children
- EXPECT_EQ(a->children().size(), b->children().size());
- for (size_t i = 0, c = a->children().size(); i < c; ++i) {
- HistoryItemExpectEqual(a->children().at(i).get(),
- b->children().at(i).get());
- }
+ const WebVector<WebHistoryItem>& a_children = a.children();
+ const WebVector<WebHistoryItem>& b_children = b.children();
+ EXPECT_EQ(a_children.size(), b_children.size());
+ for (size_t i = 0, c = a_children.size(); i < c; ++i)
+ HistoryItemExpectEqual(a_children[i], b_children[i]);
}
};
// Test old versions of serialized data to ensure that newer versions of code
// can still read history items written by previous versions.
TEST_F(GlueSerializeTest, BackwardsCompatibleTest) {
- RefPtr<HistoryItem> item = MakeHistoryItem(false, false);
+ const WebHistoryItem& item = MakeHistoryItem(false, false);
// Make sure version 3 (current version) can read versions 1 and 2.
for (int i = 1; i <= 2; i++) {
string serialized_item;
- HistoryItemToVersionedString(item.get(), i, &serialized_item);
- RefPtr<HistoryItem> deserialized_item = HistoryItemFromString(serialized_item);
- ASSERT_FALSE(item == NULL);
- ASSERT_FALSE(deserialized_item == NULL);
- HistoryItemExpectEqual(item.get(), deserialized_item.get());
+ HistoryItemToVersionedString(item, i, &serialized_item);
+ const WebHistoryItem& deserialized_item =
+ HistoryItemFromString(serialized_item);
+ ASSERT_FALSE(item.isNull());
+ ASSERT_FALSE(deserialized_item.isNull());
+ HistoryItemExpectEqual(item, deserialized_item);
}
}
// Makes sure that a HistoryItem remains intact after being serialized and
// deserialized.
TEST_F(GlueSerializeTest, HistoryItemSerializeTest) {
- RefPtr<HistoryItem> item = MakeHistoryItem(true, true);
- string serialized_item;
- HistoryItemToString(item, &serialized_item);
- RefPtr<HistoryItem> deserialized_item = HistoryItemFromString(serialized_item);
-
- ASSERT_FALSE(item == NULL);
- ASSERT_FALSE(deserialized_item == NULL);
- HistoryItemExpectEqual(item.get(), deserialized_item.get());
+ const WebHistoryItem& item = MakeHistoryItem(true, true);
+ const string& serialized_item = HistoryItemToString(item);
+ const WebHistoryItem& deserialized_item =
+ HistoryItemFromString(serialized_item);
+
+ ASSERT_FALSE(item.isNull());
+ ASSERT_FALSE(deserialized_item.isNull());
+ HistoryItemExpectEqual(item, deserialized_item);
}
diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc
index ffe9623..f80604b 100644
--- a/webkit/glue/glue_util.cc
+++ b/webkit/glue/glue_util.cc
@@ -17,6 +17,7 @@
#include "ChromiumDataObject.h"
#include "CString.h"
+#include "HistoryItem.h"
#include "HTMLFormElement.h"
#include "IntPoint.h"
#include "IntRect.h"
@@ -33,6 +34,7 @@
#include "googleurl/src/gurl.h"
#include "webkit/api/public/WebDragData.h"
#include "webkit/api/public/WebForm.h"
+#include "webkit/api/public/WebHistoryItem.h"
#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebSize.h"
@@ -230,7 +232,7 @@ PassRefPtr<WebCore::ChromiumDataObject> WebDragDataToChromiumDataObject(
return data;
}
-// FormElement conversions -----------------------------------------------------
+// WebForm conversions ---------------------------------------------------------
WebKit::WebForm HTMLFormElementToWebForm(
const WTF::PassRefPtr<WebCore::HTMLFormElement>& form) {
@@ -242,6 +244,18 @@ WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormToHTMLFormElement(
return form;
}
+// WebHistoryItem conversions --------------------------------------------------
+
+WebKit::WebHistoryItem HistoryItemToWebHistoryItem(
+ const WTF::PassRefPtr<WebCore::HistoryItem>& item) {
+ return item;
+}
+
+WTF::PassRefPtr<WebCore::HistoryItem> WebHistoryItemToHistoryItem(
+ const WebKit::WebHistoryItem& item) {
+ return item;
+}
+
// WebURLError conversions -----------------------------------------------------
WebKit::WebURLError ResourceErrorToWebURLError(
diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h
index 8d2f5cd..b22a610 100644
--- a/webkit/glue/glue_util.h
+++ b/webkit/glue/glue_util.h
@@ -13,6 +13,7 @@ class GURL;
namespace WebCore {
class ChromiumDataObject;
class CString;
+class HistoryItem;
class HTMLFormElement;
class IntPoint;
class IntRect;
@@ -28,6 +29,7 @@ namespace WebKit {
class WebCString;
class WebDragData;
class WebForm;
+class WebHistoryItem;
class WebString;
class WebURL;
class WebURLRequest;
@@ -117,6 +119,12 @@ WebKit::WebForm HTMLFormElementToWebForm(
WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormToHTMLFormElement(
const WebKit::WebForm&);
+// WebHistoryItem <-> HistoryItem
+WebKit::WebHistoryItem HistoryItemToWebHistoryItem(
+ const WTF::PassRefPtr<WebCore::HistoryItem>&);
+WTF::PassRefPtr<WebCore::HistoryItem> WebHistoryItemToHistoryItem(
+ const WebKit::WebHistoryItem&);
+
// WebURLError <-> ResourceError
WebKit::WebURLError ResourceErrorToWebURLError(
const WebCore::ResourceError& error);
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index 053c9dc..1a6ae34 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -21,6 +21,7 @@ struct NPObject;
namespace WebKit {
class WebDataSource;
class WebForm;
+class WebHistoryItem;
class WebURLRequest;
struct WebConsoleMessage;
struct WebFindOptions;
@@ -72,9 +73,9 @@ class WebFrame {
// Loads the given WebURLRequest.
virtual void LoadRequest(const WebKit::WebURLRequest& request) = 0;
- // Loads the given history state. This corresponds to a back/forward
+ // Loads the given WebHistoryItem. This corresponds to a back/forward
// navigation.
- virtual void LoadHistoryState(const std::string& history_state) = 0;
+ virtual void LoadHistoryItem(const WebKit::WebHistoryItem& item) = 0;
// This method is short-hand for calling LoadAlternateHTMLString with a dummy
// request for the given base_url.
@@ -124,26 +125,22 @@ class WebFrame {
// Inserts the given CSS styles at the beginning of the document.
virtual bool InsertCSSStyles(const std::string& css) = 0;
- // Returns a string representing the state of the previous page load for
- // later use when loading. The previous page is the page that was loaded
- // before DidCommitLoadForFrame was received.
+ // Returns the WebHistoryItem representing the state of the previous page
+ // load for later use when loading. The previous page is the page that was
+ // loaded before DidCommitLoadForFrame was received.
//
- // Returns false if there is no valid state to return (for example, there is
- // no previous item). Returns true if the previous item's state was retrieved,
- // even if that state may be empty.
- virtual bool GetPreviousHistoryState(std::string* history_state) const = 0;
+ // Returns a null item if there is no valid state to return (for example,
+ // there is no previous item). Returns true if the previous item's state was
+ // retrieved, even if that state may be empty.
+ virtual WebKit::WebHistoryItem GetPreviousHistoryItem() const = 0;
- // Returns a string representing the state of the current page load for later
- // use when loading as well as the url and title of the page.
+ // Returns the WebHistoryItem representing the state of the current page load
+ // for later use when loading.
//
- // Returns false if there is no valid state to return (for example, there is
- // no previous item). Returns true if the current item's state was retrieved,
- // even if that state may be empty.
- virtual bool GetCurrentHistoryState(std::string* history_state) const = 0;
-
- // Returns true if there is a current history item. A newly created WebFrame
- // lacks a history item. Otherwise, this will always be true.
- virtual bool HasCurrentHistoryState() const = 0;
+ // Returns a null item if there is no valid state to return (for example,
+ // there is no previous item). Returns true if the current item's state was
+ // retrieved, even if that state may be empty.
+ virtual WebKit::WebHistoryItem GetCurrentHistoryItem() const = 0;
// Returns the current URL of the frame, or an empty GURL if there is no
// URL to retrieve (for example, the frame may never have had any content).
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index 98c9b16..3e418e7 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -145,6 +145,7 @@ MSVC_POP_WARNING();
#include "webkit/api/public/WebConsoleMessage.h"
#include "webkit/api/public/WebFindOptions.h"
#include "webkit/api/public/WebForm.h"
+#include "webkit/api/public/WebHistoryItem.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebScriptSource.h"
#include "webkit/api/public/WebSize.h"
@@ -152,7 +153,6 @@ MSVC_POP_WARNING();
#include "webkit/glue/chrome_client_impl.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/dom_operations_private.h"
-#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webappcachecontext.h"
#include "webkit/glue/webdatasource_impl.h"
@@ -207,6 +207,7 @@ using WebCore::XPathResult;
using WebKit::WebConsoleMessage;
using WebKit::WebDataSource;
using WebKit::WebFindOptions;
+using WebKit::WebHistoryItem;
using WebKit::WebForm;
using WebKit::WebRect;
using WebKit::WebScriptSource;
@@ -419,9 +420,9 @@ void WebFrameImpl::LoadRequest(const WebURLRequest& request) {
InternalLoadRequest(request, SubstituteData(), false);
}
-void WebFrameImpl::LoadHistoryState(const std::string& history_state) {
+void WebFrameImpl::LoadHistoryItem(const WebHistoryItem& item) {
RefPtr<HistoryItem> history_item =
- webkit_glue::HistoryItemFromString(history_state);
+ webkit_glue::WebHistoryItemToHistoryItem(item);
DCHECK(history_item.get());
StopLoading(); // make sure existing activity stops
@@ -566,35 +567,20 @@ int WebFrameImpl::GetContentsPreferredWidth() const {
}
}
-bool WebFrameImpl::GetPreviousHistoryState(std::string* history_state) const {
+WebHistoryItem WebFrameImpl::GetPreviousHistoryItem() const {
// We use the previous item here because documentState (filled-out forms)
// only get saved to history when it becomes the previous item. The caller
- // is expected to query the history state after a navigation occurs, after
+ // is expected to query the history item after a navigation occurs, after
// the desired history item has become the previous entry.
- RefPtr<HistoryItem> item = GetWebViewImpl()->GetPreviousHistoryItem();
- if (!item)
- return false;
-
- static StatsCounterTimer history_timer("GetHistoryTimer");
- StatsScope<StatsCounterTimer> history_scope(history_timer);
-
- webkit_glue::HistoryItemToString(item, history_state);
- return true;
+ return webkit_glue::HistoryItemToWebHistoryItem(
+ GetWebViewImpl()->GetPreviousHistoryItem());
}
-bool WebFrameImpl::GetCurrentHistoryState(std::string* state) const {
+WebHistoryItem WebFrameImpl::GetCurrentHistoryItem() const {
frame_->loader()->saveDocumentAndScrollState();
- RefPtr<HistoryItem> item = frame_->page()->backForwardList()->currentItem();
- if (!item)
- return false;
-
- webkit_glue::HistoryItemToString(item, state);
- return true;
-}
-
-bool WebFrameImpl::HasCurrentHistoryState() const {
- return frame_->page()->backForwardList()->currentItem() != NULL;
+ return webkit_glue::HistoryItemToWebHistoryItem(
+ frame_->page()->backForwardList()->currentItem());
}
void WebFrameImpl::LoadDocumentData(const KURL& base_url,
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index dfce74a..f91c06c 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -77,7 +77,7 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
// WebFrame
virtual void LoadRequest(const WebKit::WebURLRequest& request);
- virtual void LoadHistoryState(const std::string& history_state);
+ virtual void LoadHistoryItem(const WebKit::WebHistoryItem& item);
virtual void LoadHTMLString(const std::string& html_text,
const GURL& base_url);
virtual void LoadAlternateHTMLString(const WebKit::WebURLRequest& request,
@@ -93,9 +93,8 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
virtual void ExecuteScriptInNewContext(
const WebKit::WebScriptSource* sources, int num_sources);
virtual bool InsertCSSStyles(const std::string& css);
- virtual bool GetPreviousHistoryState(std::string* history_state) const;
- virtual bool GetCurrentHistoryState(std::string* history_state) const;
- virtual bool HasCurrentHistoryState() const;
+ virtual WebKit::WebHistoryItem GetPreviousHistoryItem() const;
+ virtual WebKit::WebHistoryItem GetCurrentHistoryItem() const;
virtual GURL GetURL() const;
virtual GURL GetFavIconURL() const;
virtual GURL GetOSDDURL() const;
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 80e97f8..8ffb59f 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -35,7 +35,9 @@
#include "base/sys_info.h"
#include "base/sys_string_conversions.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "webkit/api/public/WebHistoryItem.h"
#include "webkit/api/public/WebString.h"
+#include "webkit/api/public/WebVector.h"
#if defined(OS_WIN)
#include "webkit/api/public/win/WebInputEventFactory.h"
#endif
@@ -47,6 +49,10 @@
#include "webkit_version.h" // Generated
+using WebKit::WebHistoryItem;
+using WebKit::WebString;
+using WebKit::WebVector;
+
//------------------------------------------------------------------------------
// webkit_glue impl:
@@ -140,17 +146,17 @@ std::wstring DumpFrameScrollPosition(WebFrame* web_frame, bool recursive) {
}
// Returns True if item1 < item2.
-static bool HistoryItemCompareLess(PassRefPtr<WebCore::HistoryItem> item1,
- PassRefPtr<WebCore::HistoryItem> item2) {
- std::wstring target1 = StringToStdWString(item1->target());
- std::wstring target2 = StringToStdWString(item2->target());
+static bool HistoryItemCompareLess(const WebHistoryItem& item1,
+ const WebHistoryItem& item2) {
+ string16 target1 = item1.target();
+ string16 target2 = item2.target();
std::transform(target1.begin(), target1.end(), target1.begin(), tolower);
std::transform(target2.begin(), target2.end(), target2.begin(), tolower);
return target1 < target2;
}
// Writes out a HistoryItem into a string in a readable format.
-static std::wstring DumpHistoryItem(PassRefPtr<WebCore::HistoryItem> item,
+static std::wstring DumpHistoryItem(const WebHistoryItem& item,
int indent, bool is_current) {
std::wstring result;
@@ -161,22 +167,25 @@ static std::wstring DumpHistoryItem(PassRefPtr<WebCore::HistoryItem> item,
result.append(indent, L' ');
}
- result.append(StringToStdWString(item->urlString()));
- if (!item->target().isEmpty()) {
- result.append(L" (in frame \"" + StringToStdWString(item->target()) +
- L"\")");
- }
- if (item->isTargetItem())
+ result.append(UTF16ToWideHack(item.urlString()));
+ if (!item.target().isEmpty())
+ result.append(L" (in frame \"" + UTF16ToWide(item.target()) + L"\")");
+ if (item.isTargetItem())
result.append(L" **nav target**");
result.append(L"\n");
- if (item->hasChildren()) {
- WebCore::HistoryItemVector children = item->children();
+ const WebVector<WebHistoryItem>& children = item.children();
+ if (!children.isEmpty()) {
// Must sort to eliminate arbitrary result ordering which defeats
// reproducible testing.
- std::sort(children.begin(), children.end(), HistoryItemCompareLess);
- for (unsigned i = 0; i < children.size(); i++)
- result += DumpHistoryItem(children[i].get(), indent+4, false);
+ // TODO(darin): WebVector should probably just be a std::vector!!
+ std::vector<WebHistoryItem> sorted_children;
+ for (size_t i = 0; i < children.size(); ++i)
+ sorted_children.push_back(children[i]);
+ std::sort(sorted_children.begin(), sorted_children.end(),
+ HistoryItemCompareLess);
+ for (size_t i = 0; i < sorted_children.size(); i++)
+ result += DumpHistoryItem(sorted_children[i], indent+4, false);
}
return result;
@@ -246,7 +255,7 @@ bool DecodeImage(const std::string& image_data, SkBitmap* image) {
// remain as the concept of a file-path specific character encoding string type
// will most likely not make its way into WebKit.
-FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str) {
+FilePath::StringType WebStringToFilePathString(const WebString& str) {
#if defined(OS_POSIX)
return base::SysWideToNativeMB(UTF16ToWideHack(str));
#elif defined(OS_WIN)
@@ -254,7 +263,7 @@ FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str) {
#endif
}
-WebKit::WebString FilePathStringToWebString(const FilePath::StringType& str) {
+WebString FilePathStringToWebString(const FilePath::StringType& str) {
#if defined(OS_POSIX)
return WideToUTF16Hack(base::SysNativeMBToWide(str));
#elif defined(OS_WIN)