summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/webkit
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-10-08 17:19:54 +0100
committerSteve Block <steveblock@google.com>2009-10-20 00:41:58 +0100
commit231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch)
treea6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebKit/gtk/webkit
parente196732677050bd463301566a68a643b6d14b907 (diff)
downloadexternal_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebKit/gtk/webkit')
-rw-r--r--WebKit/gtk/webkit/webkit.h6
-rw-r--r--WebKit/gtk/webkit/webkitdefines.h22
-rw-r--r--WebKit/gtk/webkit/webkitdownload.cpp36
-rw-r--r--WebKit/gtk/webkit/webkitdownload.h4
-rw-r--r--WebKit/gtk/webkit/webkiterror.h4
-rw-r--r--WebKit/gtk/webkit/webkithittestresult.cpp193
-rw-r--r--WebKit/gtk/webkit/webkithittestresult.h83
-rw-r--r--WebKit/gtk/webkit/webkitnetworkrequest.cpp41
-rw-r--r--WebKit/gtk/webkit/webkitnetworkrequest.h4
-rw-r--r--WebKit/gtk/webkit/webkitnetworkresponse.cpp261
-rw-r--r--WebKit/gtk/webkit/webkitnetworkresponse.h74
-rw-r--r--WebKit/gtk/webkit/webkitprivate.cpp90
-rw-r--r--WebKit/gtk/webkit/webkitprivate.h114
-rw-r--r--WebKit/gtk/webkit/webkitsecurityorigin.cpp423
-rw-r--r--WebKit/gtk/webkit/webkitsecurityorigin.h80
-rw-r--r--WebKit/gtk/webkit/webkitsoupauthdialog.c176
-rw-r--r--WebKit/gtk/webkit/webkitsoupauthdialog.h6
-rw-r--r--WebKit/gtk/webkit/webkitversion.h.in4
-rw-r--r--WebKit/gtk/webkit/webkitwebbackforwardlist.h6
-rw-r--r--WebKit/gtk/webkit/webkitwebdatabase.cpp533
-rw-r--r--WebKit/gtk/webkit/webkitwebdatabase.h96
-rw-r--r--WebKit/gtk/webkit/webkitwebdatasource.cpp436
-rw-r--r--WebKit/gtk/webkit/webkitwebdatasource.h96
-rw-r--r--WebKit/gtk/webkit/webkitwebframe.cpp225
-rw-r--r--WebKit/gtk/webkit/webkitwebframe.h32
-rw-r--r--WebKit/gtk/webkit/webkitwebhistoryitem.cpp5
-rw-r--r--WebKit/gtk/webkit/webkitwebhistoryitem.h6
-rw-r--r--WebKit/gtk/webkit/webkitwebinspector.h6
-rw-r--r--WebKit/gtk/webkit/webkitwebnavigationaction.h4
-rw-r--r--WebKit/gtk/webkit/webkitwebpolicydecision.cpp6
-rw-r--r--WebKit/gtk/webkit/webkitwebpolicydecision.h4
-rw-r--r--WebKit/gtk/webkit/webkitwebresource.cpp401
-rw-r--r--WebKit/gtk/webkit/webkitwebresource.h84
-rw-r--r--WebKit/gtk/webkit/webkitwebsettings.cpp84
-rw-r--r--WebKit/gtk/webkit/webkitwebsettings.h11
-rw-r--r--WebKit/gtk/webkit/webkitwebview.cpp558
-rw-r--r--WebKit/gtk/webkit/webkitwebview.h37
-rw-r--r--WebKit/gtk/webkit/webkitwebwindowfeatures.cpp4
-rw-r--r--WebKit/gtk/webkit/webkitwebwindowfeatures.h6
-rw-r--r--WebKit/gtk/webkit/webkitworkers.cpp45
40 files changed, 4080 insertions, 226 deletions
diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h
index c22165e..4cd0709 100644
--- a/WebKit/gtk/webkit/webkit.h
+++ b/WebKit/gtk/webkit/webkit.h
@@ -24,8 +24,11 @@
#include <webkit/webkitversion.h>
#include <webkit/webkitdefines.h>
#include <webkit/webkitdownload.h>
+#include <webkit/webkithittestresult.h>
#include <webkit/webkitnetworkrequest.h>
+#include <webkit/webkitnetworkresponse.h>
#include <webkit/webkitsoupauthdialog.h>
+#include <webkit/webkitwebdatasource.h>
#include <webkit/webkitwebframe.h>
#include <webkit/webkitwebsettings.h>
#include <webkit/webkitwebinspector.h>
@@ -35,6 +38,9 @@
#include <webkit/webkitwebhistoryitem.h>
#include <webkit/webkitwebpolicydecision.h>
#include <webkit/webkitwebnavigationaction.h>
+#include <webkit/webkitwebresource.h>
+#include <webkit/webkitwebdatabase.h>
+#include <webkit/webkitsecurityorigin.h>
#include <webkit/webkitenumtypes.h>
#endif /* __WEBKIT_H__ */
diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h
index b0ab5e9..a5884f3 100644
--- a/WebKit/gtk/webkit/webkitdefines.h
+++ b/WebKit/gtk/webkit/webkitdefines.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_DEFINES_H
-#define WEBKIT_DEFINES_H
+#ifndef webkitdefines_h
+#define webkitdefines_h
#include <glib.h>
@@ -44,6 +44,9 @@ G_BEGIN_DECLS
typedef struct _WebKitNetworkRequest WebKitNetworkRequest;
typedef struct _WebKitNetworkRequestClass WebKitNetworkRequestClass;
+typedef struct _WebKitNetworkResponse WebKitNetworkResponse;
+typedef struct _WebKitNetworkResponseClass WebKitNetworkResponseClass;
+
typedef struct _WebKitWebBackForwardList WebKitWebBackForwardList;
typedef struct _WebKitWebBackForwardListClass WebKitWebBackForwardListClass;
@@ -71,6 +74,21 @@ typedef struct _WebKitWebViewClass WebKitWebViewClass;
typedef struct _WebKitDownload WebKitDownload;
typedef struct _WebKitDownloadClass WebKitDownloadClass;
+typedef struct _WebKitWebResource WebKitWebResource;
+typedef struct _WebKitWebResourceClass WebKitWebResourceClass;
+
+typedef struct _WebKitWebDataSource WebKitWebDataSource;
+typedef struct _WebKitWebDataSourceClass WebKitWebDataSourceClass;
+
+typedef struct _WebKitWebDatabase WebKitWebDatabase;
+typedef struct _WebKitWebDatabaseClass WebKitWebDatabaseClass;
+
+typedef struct _WebKitSecurityOrigin WebKitSecurityOrigin;
+typedef struct _WebKitSecurityOriginClass WebKitSecurityOriginClass;
+
+typedef struct _WebKitHitTestResult WebKitHitTestResult;
+typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass;
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitdownload.cpp b/WebKit/gtk/webkit/webkitdownload.cpp
index c0c6ea7..568378c 100644
--- a/WebKit/gtk/webkit/webkitdownload.cpp
+++ b/WebKit/gtk/webkit/webkitdownload.cpp
@@ -25,6 +25,7 @@
#include "Noncopyable.h"
#include "NotImplemented.h"
#include "ResourceHandleClient.h"
+#include "ResourceHandleInternal.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "webkitdownload.h"
@@ -100,6 +101,7 @@ enum {
G_DEFINE_TYPE(WebKitDownload, webkit_download, G_TYPE_OBJECT);
+static void webkit_download_set_response(WebKitDownload* download, const ResourceResponse& response);
static void webkit_download_set_status(WebKitDownload* download, WebKitDownloadStatus status);
static void webkit_download_dispose(GObject* object)
@@ -373,6 +375,25 @@ WebKitDownload* webkit_download_new(WebKitNetworkRequest* request)
return WEBKIT_DOWNLOAD(g_object_new(WEBKIT_TYPE_DOWNLOAD, "network-request", request, NULL));
}
+// Internal usage only
+WebKitDownload* webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response)
+{
+ g_return_val_if_fail(request, NULL);
+
+ ResourceHandleInternal* d = handle->getInternal();
+ soup_session_pause_message(webkit_get_default_session(), d->m_msg);
+
+ WebKitDownload* download = WEBKIT_DOWNLOAD(g_object_new(WEBKIT_TYPE_DOWNLOAD, "network-request", request, NULL));
+ WebKitDownloadPrivate* priv = download->priv;
+
+ handle->ref();
+ priv->resourceHandle = handle;
+
+ webkit_download_set_response(download, response);
+
+ return download;
+}
+
static gboolean webkit_download_open_stream_for_uri(WebKitDownload* download, const gchar* uri, gboolean append=FALSE)
{
g_return_val_if_fail(uri, FALSE);
@@ -425,10 +446,14 @@ void webkit_download_start(WebKitDownload* download)
g_return_if_fail(priv->status == WEBKIT_DOWNLOAD_STATUS_CREATED);
g_return_if_fail(priv->timer == NULL);
- if (priv->resourceHandle)
- priv->resourceHandle->setClient(priv->downloadClient);
- else
+ if (!priv->resourceHandle)
priv->resourceHandle = ResourceHandle::create(core(priv->networkRequest), priv->downloadClient, 0, false, false, false);
+ else {
+ priv->resourceHandle->setClient(priv->downloadClient);
+
+ ResourceHandleInternal* d = priv->resourceHandle->getInternal();
+ soup_session_unpause_message(webkit_get_default_session(), d->m_msg);
+ }
priv->timer = g_timer_new();
webkit_download_open_stream_for_uri(download, priv->destinationURI);
@@ -510,6 +535,9 @@ static void webkit_download_set_response(WebKitDownload* download, const Resourc
// FIXME Use WebKitNetworkResponse when it's merged.
WebKitDownloadPrivate* priv = download->priv;
priv->networkResponse = new ResourceResponse(response);
+
+ if (!response.isNull() && !response.suggestedFilename().isEmpty())
+ webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data());
}
/**
@@ -544,6 +572,8 @@ void webkit_download_set_suggested_filename(WebKitDownload* download, const gcha
WebKitDownloadPrivate* priv = download->priv;
g_free(priv->suggestedFilename);
priv->suggestedFilename = g_strdup(suggestedFilename);
+
+ g_object_notify(G_OBJECT(download), "suggested-filename");
}
diff --git a/WebKit/gtk/webkit/webkitdownload.h b/WebKit/gtk/webkit/webkitdownload.h
index 7c86c65..6e7f38b 100644
--- a/WebKit/gtk/webkit/webkitdownload.h
+++ b/WebKit/gtk/webkit/webkitdownload.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_DOWNLOAD_H
-#define WEBKIT_DOWNLOAD_H
+#ifndef webkitdownload_h
+#define webkitdownload_h
#include <webkit/webkitdefines.h>
diff --git a/WebKit/gtk/webkit/webkiterror.h b/WebKit/gtk/webkit/webkiterror.h
index 512bc7d..8fec949 100644
--- a/WebKit/gtk/webkit/webkiterror.h
+++ b/WebKit/gtk/webkit/webkiterror.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_ERROR_H
-#define WEBKIT_ERROR_H
+#ifndef webkiterror_h
+#define webkiterror_h
#include <glib.h>
diff --git a/WebKit/gtk/webkit/webkithittestresult.cpp b/WebKit/gtk/webkit/webkithittestresult.cpp
new file mode 100644
index 0000000..be97933
--- /dev/null
+++ b/WebKit/gtk/webkit/webkithittestresult.cpp
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ * Copyright (C) 2009 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkithittestresult.h"
+
+#include "CString.h"
+#include "GOwnPtr.h"
+#include "webkitenumtypes.h"
+#include "webkitprivate.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkithittestresult
+ * @short_description: The target of a mouse event
+ *
+ * This class holds context information about the coordinates
+ * specified by a GDK event.
+ */
+
+G_DEFINE_TYPE(WebKitHitTestResult, webkit_hit_test_result, G_TYPE_OBJECT)
+
+struct _WebKitHitTestResultPrivate {
+ guint context;
+ char* linkURI;
+ char* imageURI;
+ char* mediaURI;
+};
+
+#define WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultPrivate))
+
+enum {
+ PROP_0,
+
+ PROP_CONTEXT,
+ PROP_LINK_URI,
+ PROP_IMAGE_URI,
+ PROP_MEDIA_URI
+};
+
+static void webkit_hit_test_result_finalize(GObject* object)
+{
+ WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
+ WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
+
+ g_free(priv->linkURI);
+ g_free(priv->imageURI);
+ g_free(priv->mediaURI);
+
+ G_OBJECT_CLASS(webkit_hit_test_result_parent_class)->finalize(object);
+}
+
+static void webkit_hit_test_result_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* pspec)
+{
+ WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
+ WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
+
+ switch(propertyID) {
+ case PROP_CONTEXT:
+ g_value_set_flags(value, priv->context);
+ break;
+ case PROP_LINK_URI:
+ g_value_set_string(value, priv->linkURI);
+ break;
+ case PROP_IMAGE_URI:
+ g_value_set_string(value, priv->imageURI);
+ break;
+ case PROP_MEDIA_URI:
+ g_value_set_string(value, priv->mediaURI);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_hit_test_result_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* pspec)
+{
+ WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
+ WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
+
+ switch(propertyID) {
+ case PROP_CONTEXT:
+ priv->context = g_value_get_flags(value);
+ break;
+ case PROP_LINK_URI:
+ g_free (priv->linkURI);
+ priv->linkURI = g_value_dup_string(value);
+ break;
+ case PROP_IMAGE_URI:
+ g_free (priv->imageURI);
+ priv->imageURI = g_value_dup_string(value);
+ break;
+ case PROP_MEDIA_URI:
+ g_free (priv->mediaURI);
+ priv->mediaURI = g_value_dup_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_hit_test_result_class_init(WebKitHitTestResultClass* webHitTestResultClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(webHitTestResultClass);
+
+ objectClass->finalize = webkit_hit_test_result_finalize;
+ objectClass->get_property = webkit_hit_test_result_get_property;
+ objectClass->set_property = webkit_hit_test_result_set_property;
+
+ webkit_init();
+
+ /**
+ * WebKitHitTestResult:context:
+ *
+ * Flags indicating the kind of target that received the event.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_CONTEXT,
+ g_param_spec_flags("context",
+ _("Context"),
+ _("Flags indicating the kind of target that received the event."),
+ WEBKIT_TYPE_HIT_TEST_RESULT_CONTEXT,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
+ static_cast<GParamFlags>((WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY))));
+
+ /**
+ * WebKitHitTestResult:link-uri:
+ *
+ * The URI to which the target that received the event points, if any.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_LINK_URI,
+ g_param_spec_string("link-uri",
+ _("Link URI"),
+ _("The URI to which the target that received the event points, if any."),
+ NULL,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitHitTestResult:image-uri:
+ *
+ * The URI of the image that is part of the target that received the event, if any.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_IMAGE_URI,
+ g_param_spec_string("image-uri",
+ _("Image URI"),
+ _("The URI of the image that is part of the target that received the event, if any."),
+ NULL,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitHitTestResult:media-uri:
+ *
+ * The URI of the media that is part of the target that received the event, if any.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_MEDIA_URI,
+ g_param_spec_string("media-uri",
+ _("Media URI"),
+ _("The URI of the media that is part of the target that received the event, if any."),
+ NULL,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ g_type_class_add_private(webHitTestResultClass, sizeof(WebKitHitTestResultPrivate));
+}
+
+static void webkit_hit_test_result_init(WebKitHitTestResult* web_hit_test_result)
+{
+ web_hit_test_result->priv = WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(web_hit_test_result);
+}
diff --git a/WebKit/gtk/webkit/webkithittestresult.h b/WebKit/gtk/webkit/webkithittestresult.h
new file mode 100644
index 0000000..6caa84e
--- /dev/null
+++ b/WebKit/gtk/webkit/webkithittestresult.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ * Copyright (C) 2009 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkithittestresult_h
+#define webkithittestresult_h
+
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_HIT_TEST_RESULT (webkit_hit_test_result_get_type())
+#define WEBKIT_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResult))
+#define WEBKIT_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultClass))
+#define WEBKIT_IS_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_HIT_TEST_RESULT))
+#define WEBKIT_IS_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_HIT_TEST_RESULT))
+#define WEBKIT_HIT_TEST_RESULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_HIT_TEST_RESULT, WebKitHitTestResultClass))
+
+typedef struct _WebKitHitTestResultPrivate WebKitHitTestResultPrivate;
+
+struct _WebKitHitTestResult {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitHitTestResultPrivate *priv;
+};
+
+struct _WebKitHitTestResultClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+/**
+ * WebKitHitTestResultContext
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT: anywhere in the document.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK: a hyperlink element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE: an image element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA: a video or audio element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION: the area is selected by
+ * the user.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE: the area is
+ * editable by the user.
+ */
+typedef enum
+{
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT = 1 << 1,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK = 1 << 2,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE = 1 << 3,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION = 1 << 5,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 6,
+} WebKitHitTestResultContext;
+
+WEBKIT_API GType
+webkit_hit_test_result_get_type (void);
+
+G_END_DECLS
+
+#endif
+
diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp
index e8a225c..be6d5ff 100644
--- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp
+++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp
@@ -28,26 +28,17 @@
#include <glib/gi18n-lib.h>
-namespace WTF {
-
-template <> void freeOwnedGPtr<SoupMessage>(SoupMessage* soupMessage)
-{
- if (soupMessage)
- g_object_unref(soupMessage);
-}
-
-}
-
/**
* SECTION:webkitnetworkrequest
* @short_description: The target of a navigation request
- * @see_also: #WebKitWebView::navigation-requested
+ * @see_also: #WebKitWebView::navigation-policy-decision-requested
*
* This class represents the network related aspects of a navigation
- * request. Currently this is only the uri of the target. In the future
- * the state of the web form might be added.
- * Currently this object is only used along with the
- * #WebKitWebView::navigation-requested signal.
+ * request. It is used whenever WebKit wants to provide information
+ * about a request that will be sent, or has been sent. Inside it you
+ * can find the URI of the request, and, for valid URIs, a
+ * #SoupMessage object, which provides access to further information
+ * such as headers.
*
*/
@@ -67,18 +58,26 @@ enum {
PROP_MESSAGE,
};
-static void webkit_network_request_finalize(GObject* object)
+static void webkit_network_request_dispose(GObject* object)
{
WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(object);
WebKitNetworkRequestPrivate* priv = request->priv;
- g_free(priv->uri);
-
if (priv->message) {
g_object_unref(priv->message);
priv->message = NULL;
}
+ G_OBJECT_CLASS(webkit_network_request_parent_class)->dispose(object);
+}
+
+static void webkit_network_request_finalize(GObject* object)
+{
+ WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(object);
+ WebKitNetworkRequestPrivate* priv = request->priv;
+
+ g_free(priv->uri);
+
G_OBJECT_CLASS(webkit_network_request_parent_class)->finalize(object);
}
@@ -119,6 +118,7 @@ static void webkit_network_request_class_init(WebKitNetworkRequestClass* request
{
GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+ objectClass->dispose = webkit_network_request_dispose;
objectClass->finalize = webkit_network_request_finalize;
objectClass->get_property = webkit_network_request_get_property;
objectClass->set_property = webkit_network_request_set_property;
@@ -213,10 +213,7 @@ void webkit_network_request_set_uri(WebKitNetworkRequest* request, const gchar*
return;
SoupURI* soupURI = soup_uri_new(uri);
- if (!soupURI) {
- g_warning("Invalid URI: %s", uri);
- return;
- }
+ g_return_if_fail(soupURI);
soup_message_set_uri(priv->message, soupURI);
soup_uri_free(soupURI);
diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.h b/WebKit/gtk/webkit/webkitnetworkrequest.h
index 78e04a1..825ca9e 100644
--- a/WebKit/gtk/webkit/webkitnetworkrequest.h
+++ b/WebKit/gtk/webkit/webkitnetworkrequest.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_NETWORK_REQUEST_H
-#define WEBKIT_NETWORK_REQUEST_H
+#ifndef webkitnetworkrequest_h
+#define webkitnetworkrequest_h
#include <glib-object.h>
#include <libsoup/soup.h>
diff --git a/WebKit/gtk/webkit/webkitnetworkresponse.cpp b/WebKit/gtk/webkit/webkitnetworkresponse.cpp
new file mode 100644
index 0000000..33bcd28
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitnetworkresponse.cpp
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2007, 2008 Holger Hans Peter Freyther
+ * Copyright (C) 2009 Gustavo Noronha Silva
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitnetworkresponse.h"
+
+#include "GOwnPtr.h"
+#include "ResourceResponse.h"
+#include "webkitprivate.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitnetworkresponse
+ * @short_description: the response given to a network request
+ * @see_also: #WebKitNetworkRequest
+ *
+ * This class represents the network related aspects of a navigation
+ * response.
+ *
+ * Since: 1.1.14
+ */
+
+G_DEFINE_TYPE(WebKitNetworkResponse, webkit_network_response, G_TYPE_OBJECT);
+
+struct _WebKitNetworkResponsePrivate {
+ gchar* uri;
+ SoupMessage* message;
+};
+
+#define WEBKIT_NETWORK_RESPONSE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponsePrivate))
+
+enum {
+ PROP_0,
+
+ PROP_URI,
+ PROP_MESSAGE,
+};
+
+static void webkit_network_response_dispose(GObject* object)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ if (priv->message) {
+ g_object_unref(priv->message);
+ priv->message = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_network_response_parent_class)->dispose(object);
+}
+
+static void webkit_network_response_finalize(GObject* object)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ g_free(priv->uri);
+
+ G_OBJECT_CLASS(webkit_network_response_parent_class)->finalize(object);
+}
+
+static void webkit_network_response_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* pspec)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+
+ switch(propertyID) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_network_response_get_uri(response));
+ break;
+ case PROP_MESSAGE:
+ g_value_set_object(value, webkit_network_response_get_message(response));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_network_response_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* pspec)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ switch(propertyID) {
+ case PROP_URI:
+ webkit_network_response_set_uri(response, g_value_get_string(value));
+ break;
+ case PROP_MESSAGE:
+ priv->message = SOUP_MESSAGE(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_network_response_class_init(WebKitNetworkResponseClass* responseClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(responseClass);
+
+ objectClass->dispose = webkit_network_response_dispose;
+ objectClass->finalize = webkit_network_response_finalize;
+ objectClass->get_property = webkit_network_response_get_property;
+ objectClass->set_property = webkit_network_response_set_property;
+
+ webkit_init();
+
+ /**
+ * WebKitNetworkResponse:uri:
+ *
+ * The URI to which the response will be made.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_URI,
+ g_param_spec_string("uri",
+ _("URI"),
+ _("The URI to which the response will be made."),
+ NULL,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE)));
+
+ /**
+ * WebKitNetworkResponse:message:
+ *
+ * The #SoupMessage that backs the response.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_MESSAGE,
+ g_param_spec_object("message",
+ _("Message"),
+ _("The SoupMessage that backs the response."),
+ SOUP_TYPE_MESSAGE,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ g_type_class_add_private(responseClass, sizeof(WebKitNetworkResponsePrivate));
+}
+
+static void webkit_network_response_init(WebKitNetworkResponse* response)
+{
+ response->priv = WEBKIT_NETWORK_RESPONSE_GET_PRIVATE(response);
+}
+
+// for internal use only
+WebKitNetworkResponse* webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse)
+{
+ GOwnPtr<SoupMessage> soupMessage(resourceResponse.toSoupMessage());
+ if (soupMessage)
+ return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", soupMessage.get(), NULL));
+
+ return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", resourceResponse.url().string().utf8().data(), NULL));
+}
+
+/**
+ * webkit_network_response_new:
+ * @uri: an URI
+ *
+ * Creates a new #WebKitNetworkResponse initialized with an URI.
+ *
+ * Returns: a new #WebKitNetworkResponse, or %NULL if the URI is
+ * invalid.
+ *
+ * Since: 1.1.14
+ */
+WebKitNetworkResponse* webkit_network_response_new(const gchar* uri)
+{
+ g_return_val_if_fail(uri, NULL);
+
+ return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", uri, NULL));
+}
+
+/**
+ * webkit_network_response_set_uri:
+ * @response: a #WebKitNetworkResponse
+ * @uri: an URI
+ *
+ * Sets the URI held and used by the given response. When the response
+ * has an associated #SoupMessage, its URI will also be set by this
+ * call.
+ *
+ * Since: 1.1.14
+ */
+void webkit_network_response_set_uri(WebKitNetworkResponse* response, const gchar* uri)
+{
+ g_return_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response));
+ g_return_if_fail(uri);
+
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ if (priv->uri)
+ g_free(priv->uri);
+ priv->uri = g_strdup(uri);
+
+ if (!priv->message)
+ return;
+
+ SoupURI* soupURI = soup_uri_new(uri);
+ g_return_if_fail(soupURI);
+
+ soup_message_set_uri(priv->message, soupURI);
+ soup_uri_free(soupURI);
+}
+
+/**
+ * webkit_network_response_get_uri:
+ * @response: a #WebKitNetworkResponse
+ *
+ * Returns: the uri of the #WebKitNetworkResponse
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_network_response_get_uri(WebKitNetworkResponse* response)
+{
+ g_return_val_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response), NULL);
+
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ if (priv->uri)
+ return priv->uri;
+
+ SoupURI* soupURI = soup_message_get_uri(priv->message);
+ priv->uri = soup_uri_to_string(soupURI, FALSE);
+ return priv->uri;
+}
+
+/**
+ * webkit_network_response_get_soup_message:
+ * @response: a #WebKitNetworkResponse
+ *
+ * Obtains the #SoupMessage that represents the given response. Notice
+ * that only the response side of the HTTP conversation is
+ * represented.
+ *
+ * Returns: the #SoupMessage
+ * Since: 1.1.14
+ */
+SoupMessage* webkit_network_response_get_message(WebKitNetworkResponse* response)
+{
+ g_return_val_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response), NULL);
+
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ return priv->message;
+}
diff --git a/WebKit/gtk/webkit/webkitnetworkresponse.h b/WebKit/gtk/webkit/webkitnetworkresponse.h
new file mode 100644
index 0000000..a00308d
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitnetworkresponse.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitnewtorkresponse_h
+#define webkitnewtorkresponse_h
+
+#include <glib-object.h>
+#include <libsoup/soup.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_NETWORK_RESPONSE (webkit_network_response_get_type())
+#define WEBKIT_NETWORK_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponse))
+#define WEBKIT_NETWORK_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponseClass))
+#define WEBKIT_IS_NETWORK_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_NETWORK_RESPONSE))
+#define WEBKIT_IS_NETWORK_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_NETWORK_RESPONSE))
+#define WEBKIT_NETWORK_RESPONSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponseClass))
+
+typedef struct _WebKitNetworkResponsePrivate WebKitNetworkResponsePrivate;
+
+struct _WebKitNetworkResponse {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitNetworkResponsePrivate *priv;
+};
+
+struct _WebKitNetworkResponseClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_network_response_get_type (void);
+
+WEBKIT_API WebKitNetworkResponse *
+webkit_network_response_new (const gchar *uri);
+
+WEBKIT_API void
+webkit_network_response_set_uri (WebKitNetworkResponse *response,
+ const gchar* uri);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_network_response_get_uri (WebKitNetworkResponse *response);
+
+WEBKIT_API SoupMessage *
+webkit_network_response_get_message(WebKitNetworkResponse* response);
+
+G_END_DECLS
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp
index 755b4d3..4425dcd 100644
--- a/WebKit/gtk/webkit/webkitprivate.cpp
+++ b/WebKit/gtk/webkit/webkitprivate.cpp
@@ -27,6 +27,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClientGtk.h"
+#include "HitTestResult.h"
#include <libintl.h>
#include "Logging.h"
#include "PageCache.h"
@@ -37,6 +38,7 @@
#include "ResourceHandleClient.h"
#include "ResourceHandleInternal.h"
#include <runtime/InitializeThreading.h>
+#include "SecurityOrigin.h"
#if ENABLE(DATABASE)
#include "DatabaseTracker.h"
@@ -97,7 +99,7 @@ WebKitWebNavigationReason kit(WebCore::NavigationType type)
WebCore::NavigationType core(WebKitWebNavigationReason type)
{
- return (WebCore::NavigationType)type;
+ return static_cast<WebCore::NavigationType>(type);
}
WebCore::ResourceRequest core(WebKitNetworkRequest* request)
@@ -110,8 +112,77 @@ WebCore::ResourceRequest core(WebKitNetworkRequest* request)
return ResourceRequest(url);
}
+WebCore::EditingBehavior core(WebKitEditingBehavior type)
+{
+ return (WebCore::EditingBehavior)type;
+}
+
+WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
+{
+ guint context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
+ GOwnPtr<char> linkURI(0);
+ GOwnPtr<char> imageURI(0);
+ GOwnPtr<char> mediaURI(0);
+
+ if (!result.absoluteLinkURL().isEmpty()) {
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
+ linkURI.set(g_strdup(result.absoluteLinkURL().string().utf8().data()));
+ }
+
+ if (!result.absoluteImageURL().isEmpty()) {
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
+ imageURI.set(g_strdup(result.absoluteImageURL().string().utf8().data()));
+ }
+
+ if (!result.absoluteMediaURL().isEmpty()) {
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
+ mediaURI.set(g_strdup(result.absoluteMediaURL().string().utf8().data()));
+ }
+
+ if (result.isSelected())
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION;
+
+ if (result.isContentEditable())
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
+
+ return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
+ "link-uri", linkURI.get(),
+ "image-uri", imageURI.get(),
+ "media-uri", mediaURI.get(),
+ "context", context,
+ NULL));
+}
+
} /** end namespace WebKit */
+namespace WTF {
+
+template <> void freeOwnedGPtr<SoupMessage>(SoupMessage* soupMessage)
+{
+ if (soupMessage)
+ g_object_unref(soupMessage);
+}
+
+template <> void freeOwnedGPtr<WebKitNetworkRequest>(WebKitNetworkRequest* request)
+{
+ if (request)
+ g_object_unref(request);
+}
+
+template <> void freeOwnedGPtr<WebKitNetworkResponse>(WebKitNetworkResponse* response)
+{
+ if (response)
+ g_object_unref(response);
+}
+
+template <> void freeOwnedGPtr<WebKitWebResource>(WebKitWebResource* resource)
+{
+ if (resource)
+ g_object_unref(resource);
+}
+
+}
+
static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMessage* message, gpointer userData)
{
gpointer messageData = g_object_get_data(G_OBJECT(message), "resourceHandle");
@@ -130,7 +201,7 @@ static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMes
if (!frame)
return NULL;
- GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(frame->page()->chrome()->platformWindow()));
+ GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(frame->page()->chrome()->platformPageClient()));
if (GTK_WIDGET_TOPLEVEL(toplevel))
return toplevel;
else
@@ -156,9 +227,10 @@ void webkit_init()
WebCore::pageCache()->setCapacity(3);
#if ENABLE(DATABASE)
- // FIXME: It should be possible for client applications to override this default location
gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);
- WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(databaseDirectory);
+ webkit_set_web_database_directory_path(databaseDirectory);
+
+ // FIXME: It should be possible for client applications to override the default appcache location
WebCore::cacheStorage().setCacheDirectory(databaseDirectory);
g_free(databaseDirectory);
#endif
@@ -178,3 +250,13 @@ void webkit_init()
soup_session_add_feature(session, sniffer);
g_object_unref(sniffer);
}
+
+void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains)
+{
+ SecurityOrigin::whiteListAccessFromOrigin(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains);
+}
+
+void webkit_reset_origin_access_white_lists()
+{
+ SecurityOrigin::resetOriginAccessWhiteLists();
+}
diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h
index 0c3fbd3..44dac04 100644
--- a/WebKit/gtk/webkit/webkitprivate.h
+++ b/WebKit/gtk/webkit/webkitprivate.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_PRIVATE_H
-#define WEBKIT_PRIVATE_H
+#ifndef webkitprivate_h
+#define webkitprivate_h
/*
* This file knows the shared secret of WebKitWebView, WebKitWebFrame,
@@ -30,18 +30,25 @@
#include <webkit/webkitdefines.h>
#include <webkit/webkitdownload.h>
+#include <webkit/webkithittestresult.h>
#include <webkit/webkitnetworkrequest.h>
#include <webkit/webkitwebview.h>
+#include <webkit/webkitwebdatasource.h>
#include <webkit/webkitwebframe.h>
#include <webkit/webkitwebpolicydecision.h>
#include <webkit/webkitwebnavigationaction.h>
+#include <webkit/webkitwebresource.h>
#include <webkit/webkitwebsettings.h>
#include <webkit/webkitwebwindowfeatures.h>
#include <webkit/webkitwebbackforwardlist.h>
#include <webkit/webkitnetworkrequest.h>
+#include <webkit/webkitsecurityorigin.h>
+#include "ArchiveResource.h"
#include "BackForwardList.h"
+#include "CString.h"
#include <enchant.h>
+#include "GOwnPtr.h"
#include "HistoryItem.h"
#include "Settings.h"
#include "Page.h"
@@ -52,6 +59,7 @@
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "WindowFeatures.h"
+#include "SecurityOrigin.h"
#include <atk/atk.h>
#include <glib.h>
@@ -60,6 +68,9 @@
class DownloadClient;
namespace WebKit {
+
+ class DocumentLoader;
+
WebKitWebView* getViewFromFrame(WebKitWebFrame*);
WebCore::Frame* core(WebKitWebFrame*);
@@ -77,6 +88,15 @@ namespace WebKit {
WebCore::NavigationType core(WebKitWebNavigationReason reason);
WebCore::ResourceRequest core(WebKitNetworkRequest* request);
+
+ WebCore::ResourceResponse core(WebKitNetworkResponse* response);
+
+ WebCore::EditingBehavior core(WebKitEditingBehavior type);
+
+ WebKitSecurityOrigin* kit(WebCore::SecurityOrigin*);
+ WebCore::SecurityOrigin* core(WebKitSecurityOrigin*);
+
+ WebKitHitTestResult* kit(const WebCore::HitTestResult&);
}
typedef struct {
@@ -101,6 +121,7 @@ extern "C" {
WebKitWebFrame* mainFrame;
WebKitWebBackForwardList* backForwardList;
+ GtkMenu* currentMenu;
gint lastPopupXPosition;
gint lastPopupYPosition;
@@ -123,6 +144,12 @@ extern "C" {
gboolean disposing;
gboolean usePrimaryForPaste;
+
+ // These are hosted here because the DataSource object is
+ // created too late in the frame loading process.
+ WebKitWebResource* mainResource;
+ char* mainResourceIdentifier;
+ GHashTable* subResources;
};
#define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate))
@@ -135,6 +162,17 @@ extern "C" {
gchar* title;
gchar* uri;
WebKitLoadStatus loadStatus;
+ WebKitSecurityOrigin* origin;
+ };
+
+#define WEBKIT_SECURITY_ORIGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginPrivate))
+ struct _WebKitSecurityOriginPrivate {
+ RefPtr<WebCore::SecurityOrigin> coreOrigin;
+ gchar* protocol;
+ gchar* host;
+ GHashTable* webDatabases;
+
+ gboolean disposed;
};
PassRefPtr<WebCore::Frame>
@@ -157,6 +195,26 @@ extern "C" {
webkit_web_history_item_get_children(WebKitWebHistoryItem*);
// end WebKitWebHistoryItem private
+ // WebKitWebResource private
+ #define WEBKIT_WEB_RESOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourcePrivate))
+ struct _WebKitWebResourcePrivate {
+ WebCore::ArchiveResource* resource;
+
+ gchar* uri;
+ gchar* mimeType;
+ gchar* textEncoding;
+ gchar* frameName;
+
+ GString* data;
+ };
+ WebKitWebResource*
+ webkit_web_resource_new_with_core_resource(PassRefPtr<WebCore::ArchiveResource>);
+
+ void
+ webkit_web_resource_init_with_core_resource(WebKitWebResource*, PassRefPtr<WebCore::ArchiveResource>);
+
+ // end WebKitWebResource private
+
void
webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebCore::Page*);
@@ -173,7 +231,25 @@ extern "C" {
webkit_web_view_notify_ready (WebKitWebView* web_view);
void
- webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse());
+ webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse(), WebCore::ResourceHandle* handle = 0);
+
+ void
+ webkit_web_view_add_resource(WebKitWebView*, char*, WebKitWebResource*);
+
+ WebKitWebResource*
+ webkit_web_view_get_resource(WebKitWebView*, char*);
+
+ WebKitWebResource*
+ webkit_web_view_get_main_resource(WebKitWebView*);
+
+ void
+ webkit_web_view_clear_resources(WebKitWebView*);
+
+ GList*
+ webkit_web_view_get_subresources(WebKitWebView*);
+
+ WebKitDownload*
+ webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response);
void
webkit_download_set_suggested_filename(WebKitDownload* download, const gchar* suggestedFilename);
@@ -187,6 +263,9 @@ extern "C" {
WebKitNetworkRequest*
webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest);
+ WebKitNetworkResponse*
+ webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse);
+
// FIXME: move this to webkitnetworkrequest.h once the API is agreed upon.
WEBKIT_API SoupMessage*
webkit_network_request_get_message(WebKitNetworkRequest* request);
@@ -206,6 +285,9 @@ extern "C" {
WEBKIT_API gchar*
webkit_web_frame_dump_render_tree (WebKitWebFrame* frame);
+ WEBKIT_API guint
+ webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame);
+
WEBKIT_API bool
webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
@@ -250,6 +332,32 @@ extern "C" {
WEBKIT_API void
webkit_application_cache_set_maximum_size(unsigned long long size);
+
+ WEBKIT_API unsigned int
+ webkit_worker_thread_count();
+
+ WEBKIT_API void
+ webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains);
+
+ WEBKIT_API void
+ webkit_reset_origin_access_white_lists();
+
+ // WebKitWebDataSource private
+ WebKitWebDataSource*
+ webkit_web_data_source_new_with_loader(PassRefPtr<WebKit::DocumentLoader>);
+
+ WEBKIT_API WebKitWebDatabase *
+ webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const char* databaseName);
+
+ WEBKIT_API void
+ webkit_web_frame_layout(WebKitWebFrame* frame);
+}
+
+namespace WTF {
+ template <> void freeOwnedGPtr<SoupMessage>(SoupMessage*);
+ template <> void freeOwnedGPtr<WebKitNetworkRequest>(WebKitNetworkRequest*);
+ template <> void freeOwnedGPtr<WebKitNetworkResponse>(WebKitNetworkResponse*);
+ template <> void freeOwnedGPtr<WebKitWebResource>(WebKitWebResource*);
}
#endif
diff --git a/WebKit/gtk/webkit/webkitsecurityorigin.cpp b/WebKit/gtk/webkit/webkitsecurityorigin.cpp
new file mode 100644
index 0000000..cd80236
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitsecurityorigin.cpp
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2009 Martin Robinson, Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitwebdatabase.h"
+
+#include "webkitprivate.h"
+
+#include "CString.h"
+#include "PlatformString.h"
+#include "DatabaseTracker.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitsecurityorigin
+ * @short_description: A security boundary for web sites
+ *
+ * #WebKitSecurityOrigin is a representation of a security domain defined
+ * by web sites. An origin consists of a host name, a protocol, and a port
+ * number. Web sites with the same security origin can access each other's
+ * resources for client-side scripting or database access.
+ *
+ * Use #webkit_web_frame_get_security_origin to get the security origin of a
+ * #WebKitWebFrame.
+ *
+ * Database quotas and usages are also defined per security origin. The
+ * cumulative disk usage of an origin's databases may be retrieved with
+ * #webkit_security_origin_get_web_database_usage. An origin's quota can be
+ * adjusted with #webkit_security_origin_set_web_database_quota.
+ */
+
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_PROTOCOL,
+ PROP_HOST,
+ PROP_PORT,
+ PROP_DATABASE_USAGE,
+ PROP_DATABASE_QUOTA
+};
+
+G_DEFINE_TYPE(WebKitSecurityOrigin, webkit_security_origin, G_TYPE_OBJECT)
+
+static void webkit_security_origin_finalize(GObject* object)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+
+ g_free(priv->protocol);
+ g_free(priv->host);
+
+ G_OBJECT_CLASS(webkit_security_origin_parent_class)->finalize(object);
+}
+
+static void webkit_security_origin_dispose(GObject* object)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+
+ if (!priv->disposed) {
+ priv->coreOrigin->deref();
+ g_hash_table_destroy(priv->webDatabases);
+ priv->disposed = true;
+ }
+
+ G_OBJECT_CLASS(webkit_security_origin_parent_class)->dispose(object);
+}
+
+static void webkit_security_origin_set_property(GObject* object, guint propId, const GValue* value, GParamSpec* pspec)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+
+ switch (propId) {
+ case PROP_DATABASE_QUOTA:
+ webkit_security_origin_set_web_database_quota(securityOrigin, g_value_get_uint64(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static void webkit_security_origin_get_property(GObject* object, guint propId, GValue* value, GParamSpec* pspec)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+
+ switch (propId) {
+ case PROP_PROTOCOL:
+ g_value_set_string(value, webkit_security_origin_get_protocol(securityOrigin));
+ break;
+ case PROP_HOST:
+ g_value_set_string(value, webkit_security_origin_get_host(securityOrigin));
+ break;
+ case PROP_PORT:
+ g_value_set_uint(value, webkit_security_origin_get_port(securityOrigin));
+ break;
+ case PROP_DATABASE_USAGE:
+ g_value_set_uint64(value, webkit_security_origin_get_web_database_usage(securityOrigin));
+ break;
+ case PROP_DATABASE_QUOTA:
+ g_value_set_uint64(value, webkit_security_origin_get_web_database_quota(securityOrigin));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static GHashTable* webkit_security_origins()
+{
+ static GHashTable* securityOrigins = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref);
+ return securityOrigins;
+}
+
+static void webkit_security_origin_class_init(WebKitSecurityOriginClass* klass)
+{
+ GObjectClass* gobjectClass = G_OBJECT_CLASS(klass);
+ gobjectClass->dispose = webkit_security_origin_dispose;
+ gobjectClass->finalize = webkit_security_origin_finalize;
+ gobjectClass->set_property = webkit_security_origin_set_property;
+ gobjectClass->get_property = webkit_security_origin_get_property;
+
+ /**
+ * WebKitSecurityOrigin:protocol:
+ *
+ * The protocol of the security origin.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_PROTOCOL,
+ g_param_spec_string("protocol",
+ _("Protocol"),
+ _("The protocol of the security origin"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitSecurityOrigin:host:
+ *
+ * The host of the security origin.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_HOST,
+ g_param_spec_string("host",
+ _("Host"),
+ _("The host of the security origin"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitSecurityOrigin:port:
+ *
+ * The port of the security origin.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_PORT,
+ g_param_spec_uint("port",
+ _("Port"),
+ _("The port of the security origin"),
+ 0, G_MAXUSHORT, 0,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitSecurityOrigin:web-database-usage:
+ *
+ * The cumulative size of all web databases in the security origin in bytes.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_DATABASE_USAGE,
+ g_param_spec_uint64("web-database-usage",
+ _("Web Database Usage"),
+ _("The cumulative size of all web databases in the security origin"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitSecurityOrigin:web-database-quota:
+ *
+ * The web database qouta of the security origin in bytes.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_DATABASE_QUOTA,
+ g_param_spec_uint64("web-database-quota",
+ _("Web Database Quota"),
+ _("The web database quota of the security origin in bytes"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READWRITE));
+
+ g_type_class_add_private(klass, sizeof(WebKitSecurityOriginPrivate));
+}
+
+static void webkit_security_origin_init(WebKitSecurityOrigin* securityOrigin)
+{
+ WebKitSecurityOriginPrivate* priv = WEBKIT_SECURITY_ORIGIN_GET_PRIVATE(securityOrigin);
+ priv->webDatabases = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
+ securityOrigin->priv = priv;
+}
+
+/**
+ * webkit_security_origin_get_protocol:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the protocol for the security origin.
+ *
+ * Returns: the protocol for the security origin
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_security_origin_get_protocol(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+ WebCore::String protocol = priv->coreOrigin->protocol();
+
+ if (!priv->protocol)
+ priv->protocol = g_strdup(protocol.utf8().data());
+
+ return priv->protocol;
+}
+
+/**
+ * webkit_security_origin_get_host:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the hostname for the security origin.
+ *
+ * Returns: the hostname for the security origin
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_security_origin_get_host(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+ WebCore::String host = priv->coreOrigin->host();
+
+ if (!priv->host)
+ priv->host = g_strdup(host.utf8().data());
+
+ return priv->host;
+}
+
+/**
+ * webkit_security_origin_get_port:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the port for the security origin.
+ *
+ * Returns: the port for the security origin
+ *
+ * Since: 1.1.14
+ **/
+guint webkit_security_origin_get_port(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), 0);
+
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ return coreOrigin->port();
+}
+
+/**
+ * webkit_security_origin_get_web_database_usage:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the cumulative size of all Web Database database's in the origin
+ * in bytes.
+ *
+ * Returns: the cumulative size of all databases
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_security_origin_get_web_database_usage(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), 0);
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ return WebCore::DatabaseTracker::tracker().usageForOrigin(coreOrigin);
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_security_origin_get_web_database_quota:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the quota for Web Database storage of the security origin
+ * in bytes.
+ *
+ * Returns: the Web Database quota
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_security_origin_get_web_database_quota(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), 0);
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ return WebCore::DatabaseTracker::tracker().quotaForOrigin(coreOrigin);
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_security_origin_set_web_database_quota:
+ * @security_origin: a #WebKitSecurityOrigin
+ * @quota: a new Web Database quota in bytes
+ *
+ * Adjust the quota for Web Database storage of the security origin
+ *
+ * Since: 1.1.14
+ **/
+void webkit_security_origin_set_web_database_quota(WebKitSecurityOrigin* securityOrigin, guint64 quota)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin));
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ WebCore::DatabaseTracker::tracker().setQuota(coreOrigin, quota);
+#endif
+}
+
+/**
+ * webkit_security_origin_get_all_web_databases:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns a list of all Web Databases in the security origin.
+ *
+ * Returns: a #Glist of databases in the security origin.
+ *
+ * Since: 1.1.14
+ **/
+GList* webkit_security_origin_get_all_web_databases(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+ GList* databases = NULL;
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ Vector<WebCore::String> databaseNames;
+
+ if (!WebCore::DatabaseTracker::tracker().databaseNamesForOrigin(coreOrigin, databaseNames))
+ return NULL;
+
+ for (unsigned i = 0; i < databaseNames.size(); ++i) {
+ WebKitWebDatabase* database = webkit_security_origin_get_web_database(securityOrigin, databaseNames[i].utf8().data());
+ databases = g_list_append(databases, database);
+ }
+#endif
+
+ return databases;
+}
+
+WebKitSecurityOrigin* WebKit::kit(WebCore::SecurityOrigin* coreOrigin)
+{
+ ASSERT(coreOrigin);
+
+ GHashTable* table = webkit_security_origins();
+ WebKitSecurityOrigin* origin = (WebKitSecurityOrigin*) g_hash_table_lookup(table, coreOrigin);
+
+ if (!origin) {
+ origin = WEBKIT_SECURITY_ORIGIN(g_object_new(WEBKIT_TYPE_SECURITY_ORIGIN, NULL));
+ origin->priv->coreOrigin = coreOrigin;
+ g_hash_table_insert(table, coreOrigin, origin);
+ }
+
+ return origin;
+}
+
+
+WebCore::SecurityOrigin* WebKit::core(WebKitSecurityOrigin* securityOrigin)
+{
+ ASSERT(securityOrigin);
+
+ return securityOrigin->priv->coreOrigin.get();
+}
+
+WebKitWebDatabase* webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const gchar* databaseName)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+ GHashTable* databaseHash = priv->webDatabases;
+ WebKitWebDatabase* database = (WebKitWebDatabase*) g_hash_table_lookup(databaseHash, databaseName);
+
+ if (!database) {
+ database = WEBKIT_WEB_DATABASE(g_object_new(WEBKIT_TYPE_WEB_DATABASE,
+ "security-origin", securityOrigin,
+ "name", databaseName,
+ NULL));
+ g_hash_table_insert(databaseHash, g_strdup(databaseName), database);
+ }
+
+ return database;
+}
+
diff --git a/WebKit/gtk/webkit/webkitsecurityorigin.h b/WebKit/gtk/webkit/webkitsecurityorigin.h
new file mode 100644
index 0000000..57bcd19
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitsecurityorigin.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2009 Martin Robinson, Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitsecurityorigin_h
+#define webkitsecurityorigin_h
+
+#include "webkitsecurityorigin.h"
+#include "webkitwebdatabase.h"
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_SECURITY_ORIGIN (webkit_security_origin_get_type())
+#define WEBKIT_SECURITY_ORIGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOrigin))
+#define WEBKIT_SECURITY_ORIGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginClass))
+#define WEBKIT_IS_SECURITY_ORIGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_SECURITY_ORIGIN))
+#define WEBKIT_IS_SECURITY_ORIGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_SECURITY_ORIGIN))
+#define WEBKIT_SECURITY_ORIGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginClass))
+
+typedef struct _WebKitSecurityOriginPrivate WebKitSecurityOriginPrivate;
+
+struct _WebKitSecurityOrigin {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitSecurityOriginPrivate* priv;
+};
+
+struct _WebKitSecurityOriginClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+ void (*_webkit_reserved4) (void);
+};
+
+WEBKIT_API GType
+webkit_security_origin_get_type (void);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_security_origin_get_protocol (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_security_origin_get_host (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API guint
+webkit_security_origin_get_port (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API guint64
+webkit_security_origin_get_web_database_usage (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API guint64
+webkit_security_origin_get_web_database_quota (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API void
+webkit_security_origin_set_web_database_quota (WebKitSecurityOrigin* securityOrigin, guint64 quota);
+
+WEBKIT_API GList *
+webkit_security_origin_get_all_web_databases (WebKitSecurityOrigin* securityOrigin);
+
+G_END_DECLS
+
+#endif /* __WEBKIT_SECURITY_ORIGIN_H__ */
diff --git a/WebKit/gtk/webkit/webkitsoupauthdialog.c b/WebKit/gtk/webkit/webkitsoupauthdialog.c
index 9bc188e..538dbfa 100644
--- a/WebKit/gtk/webkit/webkitsoupauthdialog.c
+++ b/WebKit/gtk/webkit/webkitsoupauthdialog.c
@@ -19,25 +19,24 @@
#include "config.h"
+#define LIBSOUP_I_HAVE_READ_BUG_594377_AND_KNOW_SOUP_PASSWORD_MANAGER_MIGHT_GO_AWAY
+
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <libsoup/soup.h>
-#if USE(GNOMEKEYRING)
-#include <gnome-keyring.h>
-#endif
#include "webkitmarshal.h"
#include "webkitsoupauthdialog.h"
/**
* SECTION:webkitsoupauthdialog
- * @short_description: A #SoupFeature to provide a simple
+ * @short_description: A #SoupSessionFeature to provide a simple
* authentication dialog for HTTP basic auth support.
*
- * #WebKitSoupAuthDialog is a #SoupFeature that you can attach to your
- * #SoupSession to provide a simple authentication dialog, with
- * optional GNOME Keyring support, while handling HTTP basic auth. It
- * is built as a simple C-only module to ease reuse.
+ * #WebKitSoupAuthDialog is a #SoupSessionFeature that you can attach to your
+ * #SoupSession to provide a simple authentication dialog while
+ * handling HTTP basic auth. It is built as a simple C-only module
+ * to ease reuse.
*/
static void webkit_soup_auth_dialog_session_feature_init(SoupSessionFeatureInterface* feature_interface, gpointer interface_data);
@@ -88,9 +87,7 @@ typedef struct _WebKitAuthData {
SoupSessionFeature* manager;
GtkWidget* loginEntry;
GtkWidget* passwordEntry;
-#if USE(GNOMEKEYRING)
GtkWidget* checkButton;
-#endif
char *username;
char *password;
} WebKitAuthData;
@@ -103,63 +100,53 @@ static void free_authData(WebKitAuthData* authData)
g_slice_free(WebKitAuthData, authData);
}
-#if USE(GNOMEKEYRING)
-static void set_password_callback(GnomeKeyringResult result, guint32 val, gpointer user_data)
-{
- /* Dummy callback, gnome_keyring_set_network_password does not accept a NULL one */
-}
-
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
static void save_password_callback(SoupMessage* msg, WebKitAuthData* authData)
{
- /* Check only for Success status codes (2xx) */
- if (msg->status_code >= 200 && msg->status_code < 300) {
- SoupURI* uri = soup_message_get_uri(authData->msg);
- gnome_keyring_set_network_password(NULL,
- authData->username,
- soup_auth_get_realm(authData->auth),
- uri->host,
- NULL,
- uri->scheme,
- soup_auth_get_scheme_name(authData->auth),
- uri->port,
- authData->password,
- (GnomeKeyringOperationGetIntCallback)set_password_callback,
- NULL,
- NULL);
- }
+ /* Anything but 401 and 5xx means the password was accepted */
+ if (msg->status_code != 401 && msg->status_code < 500)
+ soup_auth_save_password(authData->auth, authData->username, authData->password);
+
+ /* Disconnect the callback. If the authentication succeeded we are
+ * done, and if it failed we'll create a new authData and we'll
+ * connect to 'got-headers' again in response_callback */
+ g_signal_handlers_disconnect_by_func(msg, save_password_callback, authData);
+
free_authData(authData);
}
#endif
static void response_callback(GtkDialog* dialog, gint response_id, WebKitAuthData* authData)
{
- switch(response_id) {
- case GTK_RESPONSE_OK:
+ gboolean freeAuthData = TRUE;
+
+ if (response_id == GTK_RESPONSE_OK) {
authData->username = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->loginEntry)));
authData->password = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->passwordEntry)));
+
soup_auth_authenticate(authData->auth, authData->username, authData->password);
-#if USE(GNOMEKEYRING)
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(authData->checkButton)))
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ if (authData->checkButton &&
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(authData->checkButton))) {
g_signal_connect(authData->msg, "got-headers", G_CALLBACK(save_password_callback), authData);
+ freeAuthData = FALSE;
+ }
#endif
- default:
- break;
}
soup_session_unpause_message(authData->session, authData->msg);
-#if !USE(GNOMEKEYRING)
- free_authData(authData);
-#endif
+ if (freeAuthData)
+ free_authData(authData);
gtk_widget_destroy(GTK_WIDGET(dialog));
}
static GtkWidget *
-table_add_entry (GtkWidget* table,
- int row,
- const char* label_text,
- const char* value,
- gpointer user_data)
+table_add_entry(GtkWidget* table,
+ int row,
+ const char* label_text,
+ const char* value,
+ gpointer user_data)
{
GtkWidget* entry;
GtkWidget* label;
@@ -182,6 +169,15 @@ table_add_entry (GtkWidget* table,
return entry;
}
+static gboolean session_can_save_passwords(SoupSession* session)
+{
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ return soup_session_get_feature(session, SOUP_TYPE_PASSWORD_MANAGER) != NULL;
+#else
+ return FALSE;
+#endif
+}
+
static void show_auth_dialog(WebKitAuthData* authData, const char* login, const char* password)
{
GtkWidget* toplevel;
@@ -197,10 +193,8 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
GtkWidget* messageLabel;
char* message;
SoupURI* uri;
-#if USE(GNOMEKEYRING)
GtkWidget* rememberBox;
GtkWidget* checkButton;
-#endif
/* From GTK+ gtkmountoperation.c, modified and simplified. LGPL 2 license */
@@ -215,9 +209,9 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
/* Set the dialog up with HIG properties */
gtk_dialog_set_has_separator(dialog, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER (dialog), 5);
+ gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
gtk_box_set_spacing(GTK_BOX(dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width(GTK_CONTAINER (dialog->action_area), 5);
+ gtk_container_set_border_width(GTK_CONTAINER(dialog->action_area), 5);
gtk_box_set_spacing(GTK_BOX(dialog->action_area), 6);
gtk_window_set_resizable(window, FALSE);
@@ -256,7 +250,7 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
FALSE, FALSE, 0);
vbox = gtk_vbox_new(FALSE, 6);
- gtk_box_pack_start(GTK_BOX (mainVBox), vbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(mainVBox), vbox, FALSE, FALSE, 0);
/* The table that holds the entries */
entryContainer = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
@@ -268,8 +262,8 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
FALSE, FALSE, 0);
table = gtk_table_new(2, 2, FALSE);
- gtk_table_set_col_spacings(GTK_TABLE (table), 12);
- gtk_table_set_row_spacings(GTK_TABLE (table), 6);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 12);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 6);
gtk_container_add(GTK_CONTAINER(entryContainer), table);
authData->loginEntry = table_add_entry(table, 0, _("Username:"),
@@ -279,77 +273,55 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
gtk_entry_set_visibility(GTK_ENTRY(authData->passwordEntry), FALSE);
-#if USE(GNOMEKEYRING)
- rememberBox = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), rememberBox,
- FALSE, FALSE, 0);
-
- checkButton = gtk_check_button_new_with_mnemonic(_("_Remember password"));
- if (login && password)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkButton), TRUE);
- gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkButton))), TRUE);
- gtk_box_pack_start (GTK_BOX (rememberBox), checkButton, FALSE, FALSE, 0);
- authData->checkButton = checkButton;
-#endif
+ if (session_can_save_passwords(authData->session)) {
+ rememberBox = gtk_vbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(vbox), rememberBox,
+ FALSE, FALSE, 0);
+ checkButton = gtk_check_button_new_with_mnemonic(_("_Remember password"));
+ if (login && password)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkButton), TRUE);
+ gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkButton))), TRUE);
+ gtk_box_pack_start(GTK_BOX(rememberBox), checkButton, FALSE, FALSE, 0);
+ authData->checkButton = checkButton;
+ }
g_signal_connect(dialog, "response", G_CALLBACK(response_callback), authData);
gtk_widget_show_all(widget);
}
-#if USE(GNOMEKEYRING)
-static void find_password_callback(GnomeKeyringResult result, GList* list, WebKitAuthData* authData)
-{
- GList* p;
- const char* login = NULL;
- const char* password = NULL;
-
- for (p = list; p; p = p->next) {
- /* FIXME: support multiple logins/passwords ? */
- GnomeKeyringNetworkPasswordData* data = (GnomeKeyringNetworkPasswordData*)p->data;
- login = data->user;
- password = data->password;
- break;
- }
-
- show_auth_dialog(authData, login, password);
-}
-#endif
-
static void session_authenticate(SoupSession* session, SoupMessage* msg, SoupAuth* auth, gboolean retrying, gpointer user_data)
{
SoupURI* uri;
WebKitAuthData* authData;
SoupSessionFeature* manager = (SoupSessionFeature*)user_data;
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ GSList* users;
+#endif
+ const char *login, *password;
soup_session_pause_message(session, msg);
/* We need to make sure the message sticks around when pausing it */
g_object_ref(msg);
uri = soup_message_get_uri(msg);
- authData = g_slice_new(WebKitAuthData);
+ authData = g_slice_new0(WebKitAuthData);
authData->msg = msg;
authData->auth = auth;
authData->session = session;
authData->manager = manager;
- /*
- * If we have gnome-keyring let's try to find the password first in the ring.
- * Otherwise just show the dialog straight away
- */
-#if USE(GNOMEKEYRING)
- gnome_keyring_find_network_password(NULL,
- soup_auth_get_realm(auth),
- uri->host,
- NULL,
- uri->scheme,
- soup_auth_get_scheme_name(auth),
- uri->port,
- (GnomeKeyringOperationGetListCallback)find_password_callback,
- authData,
- NULL);
-#else
- show_auth_dialog(authData, NULL, NULL);
+ login = password = NULL;
+
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ users = soup_auth_get_saved_users(auth);
+ if (users) {
+ login = users->data;
+ password = soup_auth_get_saved_password(auth, login);
+ g_slist_free(users);
+ }
#endif
+
+ show_auth_dialog(authData, login, password);
}
static void attach(SoupSessionFeature* manager, SoupSession* session)
diff --git a/WebKit/gtk/webkit/webkitsoupauthdialog.h b/WebKit/gtk/webkit/webkitsoupauthdialog.h
index 9721c72..01ccfc8 100644
--- a/WebKit/gtk/webkit/webkitsoupauthdialog.h
+++ b/WebKit/gtk/webkit/webkitsoupauthdialog.h
@@ -22,8 +22,8 @@
#include <webkit/webkitdefines.h>
-#ifndef WEBKIT_SOUP_AUTH_DIALOG_H
-#define WEBKIT_SOUP_AUTH_DIALOG_H 1
+#ifndef webkitsoupauthdialog_h
+#define webkitsoupauthdialog_h
G_BEGIN_DECLS
@@ -49,4 +49,4 @@ webkit_soup_auth_dialog_get_type (void);
G_END_DECLS
-#endif /* WEBKIT_SOUP_AUTH_DIALOG_H */
+#endif /* webkitsoupauthdialog_h */
diff --git a/WebKit/gtk/webkit/webkitversion.h.in b/WebKit/gtk/webkit/webkitversion.h.in
index 9f1b818..5eb9426 100644
--- a/WebKit/gtk/webkit/webkitversion.h.in
+++ b/WebKit/gtk/webkit/webkitversion.h.in
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_VERSION_H
-#define WEBKIT_VERSION_H
+#ifndef webkitversion_h
+#define webkitversion_h
#include <glib.h>
#include <webkit/webkitdefines.h>
diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.h b/WebKit/gtk/webkit/webkitwebbackforwardlist.h
index a44cbcd..d08566e 100644
--- a/WebKit/gtk/webkit/webkitwebbackforwardlist.h
+++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_BACK_FORWARD_LIST_H
-#define WEBKIT_WEB_BACK_FORWARD_LIST_H
+#ifndef webkitwebbackforwardlist_h
+#define webkitwebbackforwardlist_h
#include <glib.h>
#include <glib-object.h>
@@ -114,4 +114,4 @@ webkit_web_back_forward_list_add_item (WebKitWebBackForwardLi
G_END_DECLS
-#endif /* WEBKIT_WEB_BACK_FORWARD_LIST_H */
+#endif /* webkitwebbackforwardlist_h */
diff --git a/WebKit/gtk/webkit/webkitwebdatabase.cpp b/WebKit/gtk/webkit/webkitwebdatabase.cpp
new file mode 100644
index 0000000..100176e
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatabase.cpp
@@ -0,0 +1,533 @@
+/*
+ * Copyright (C) 2009 Martin Robinson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitwebdatabase.h"
+
+#include "webkitprivate.h"
+
+#include "CString.h"
+#include "DatabaseDetails.h"
+#include "DatabaseTracker.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitwebdatabase
+ * @short_description: A WebKit web application database
+ *
+ * #WebKitWebDatabase is a representation of a Web Database database. The
+ * proposed Web Database standard introduces support for SQL databases that web
+ * sites can create and access on a local computer through JavaScript.
+ *
+ * To get access to all databases defined by a security origin, use
+ * #webkit_security_origin_get_databases. Each database has a canonical
+ * name, as well as a user-friendly display name.
+ *
+ * WebKit uses SQLite to create and access the local SQL databases. The location
+ * of a #WebKitWebDatabase can be accessed wth #webkit_web_database_get_filename.
+ * You can configure the location of all databases with
+ * #webkit_set_database_directory_path.
+ *
+ * For each database the web site can define an estimated size which can be
+ * accessed with #webkit_web_database_get_expected_size. The current size of the
+ * database in bytes is returned by #webkit_web_database_get_size.
+ *
+ * For more information refer to the Web Database specification proposal at
+ * http://dev.w3.org/html5/webdatabase
+ */
+
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_SECURITY_ORIGIN,
+ PROP_NAME,
+ PROP_DISPLAY_NAME,
+ PROP_EXPECTED_SIZE,
+ PROP_SIZE,
+ PROP_PATH
+};
+
+G_DEFINE_TYPE(WebKitWebDatabase, webkit_web_database, G_TYPE_OBJECT)
+
+struct _WebKitWebDatabasePrivate {
+ WebKitSecurityOrigin* origin;
+ gchar* name;
+ gchar* displayName;
+ gchar* filename;
+};
+
+static gchar* webkit_database_directory_path = NULL;
+static guint64 webkit_default_database_quota = 5 * 1024 * 1024;
+
+#define WEBKIT_WEB_DATABASE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabasePrivate))
+
+static void webkit_web_database_set_security_origin(WebKitWebDatabase* webDatabase, WebKitSecurityOrigin* security_origin);
+
+static void webkit_web_database_set_name(WebKitWebDatabase* webDatabase, const gchar* name);
+
+static void webkit_web_database_finalize(GObject* object)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ g_free(priv->name);
+ g_free(priv->displayName);
+ g_free(priv->filename);
+
+ G_OBJECT_CLASS(webkit_web_database_parent_class)->finalize(object);
+}
+
+static void webkit_web_database_dispose(GObject* object)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ if (priv->origin) {
+ g_object_unref(priv->origin);
+ priv->origin = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_web_database_parent_class)->dispose(object);
+}
+
+static void webkit_web_database_set_property(GObject* object, guint propId, const GValue* value, GParamSpec* pspec)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+
+ switch (propId) {
+ case PROP_SECURITY_ORIGIN:
+ webkit_web_database_set_security_origin(webDatabase, WEBKIT_SECURITY_ORIGIN(g_value_get_object(value)));
+ break;
+ case PROP_NAME:
+ webkit_web_database_set_name(webDatabase, g_value_get_string(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static void webkit_web_database_get_property(GObject* object, guint propId, GValue* value, GParamSpec* pspec)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ switch (propId) {
+ case PROP_SECURITY_ORIGIN:
+ g_value_set_object(value, priv->origin);
+ break;
+ case PROP_NAME:
+ g_value_set_string(value, webkit_web_database_get_name(webDatabase));
+ break;
+ case PROP_DISPLAY_NAME:
+ g_value_set_string(value, webkit_web_database_get_display_name(webDatabase));
+ break;
+ case PROP_EXPECTED_SIZE:
+ g_value_set_uint64(value, webkit_web_database_get_expected_size(webDatabase));
+ break;
+ case PROP_SIZE:
+ g_value_set_uint64(value, webkit_web_database_get_size(webDatabase));
+ break;
+ case PROP_PATH:
+ g_value_set_string(value, webkit_web_database_get_filename(webDatabase));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static void webkit_web_database_class_init(WebKitWebDatabaseClass* klass)
+{
+ GObjectClass* gobjectClass = G_OBJECT_CLASS(klass);
+ gobjectClass->dispose = webkit_web_database_dispose;
+ gobjectClass->finalize = webkit_web_database_finalize;
+ gobjectClass->set_property = webkit_web_database_set_property;
+ gobjectClass->get_property = webkit_web_database_get_property;
+
+ /**
+ * WebKitWebDatabase:security-origin:
+ *
+ * The security origin of the database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_SECURITY_ORIGIN,
+ g_param_spec_object("security-origin",
+ _("Security Origin"),
+ _("The security origin of the database"),
+ WEBKIT_TYPE_SECURITY_ORIGIN,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitWebDatabase:name:
+ *
+ * The name of the Web Database database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_NAME,
+ g_param_spec_string("name",
+ _("Name"),
+ _("The name of the Web Database database"),
+ NULL,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitWebDatabase:display-name:
+ *
+ * The display name of the Web Database database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_DISPLAY_NAME,
+ g_param_spec_string("display-name",
+ _("Display Name"),
+ _("The display name of the Web Storage database"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebDatabase:expected-size:
+ *
+ * The expected size of the database in bytes as defined by the web author.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_EXPECTED_SIZE,
+ g_param_spec_uint64("expected-size",
+ _("Expected Size"),
+ _("The expected size of the Web Database database"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebDatabase:size:
+ *
+ * The current size of the database in bytes.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_SIZE,
+ g_param_spec_uint64("size",
+ _("Size"),
+ _("The current size of the Web Database database"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebDatabase:filename:
+ *
+ * The absolute filename of the Web Database database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_PATH,
+ g_param_spec_string("filename",
+ _("Filename"),
+ _("The absolute filename of the Web Storage database"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ g_type_class_add_private(klass, sizeof(WebKitWebDatabasePrivate));
+}
+
+static void webkit_web_database_init(WebKitWebDatabase* webDatabase)
+{
+ webDatabase->priv = WEBKIT_WEB_DATABASE_GET_PRIVATE(webDatabase);
+}
+
+// Internal use only
+static void webkit_web_database_set_security_origin(WebKitWebDatabase *webDatabase, WebKitSecurityOrigin *securityOrigin)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase));
+ g_return_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin));
+
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ if (priv->origin)
+ g_object_unref(priv->origin);
+
+ g_object_ref(securityOrigin);
+ priv->origin = securityOrigin;
+}
+
+static void webkit_web_database_set_name(WebKitWebDatabase* webDatabase, const gchar* name)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase));
+
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ g_free(priv->name);
+ priv->name = g_strdup(name);
+}
+
+/**
+ * webkit_web_database_get_security_origin:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the security origin of the #WebKitWebDatabase.
+ *
+ * Returns: the security origin of the database
+ *
+ * Since: 1.1.14
+ **/
+WebKitSecurityOrigin* webkit_web_database_get_security_origin(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ return priv->origin;
+}
+
+/**
+ * webkit_web_database_get_name:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the canonical name of the #WebKitWebDatabase.
+ *
+ * Returns: the name of the database
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_web_database_get_name(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ return priv->name;
+}
+
+/**
+ * webkit_web_database_get_display_name:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the name of the #WebKitWebDatabase as seen by the user.
+ *
+ * Returns: the name of the database as seen by the user.
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_web_database_get_display_name(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(priv->name, core(priv->origin));
+ WebCore::String displayName = details.displayName();
+
+ if (displayName.isEmpty())
+ return "";
+
+ g_free(priv->displayName);
+ priv->displayName = g_strdup(displayName.utf8().data());
+ return priv->displayName;
+#else
+ return "";
+#endif
+}
+
+/**
+ * webkit_web_database_get_expected_size:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the expected size of the #WebKitWebDatabase in bytes as defined by the
+ * web author. The Web Database standard allows web authors to specify an expected
+ * size of the database to optimize the user experience.
+ *
+ * Returns: the expected size of the database in bytes
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_web_database_get_expected_size(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), 0);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(priv->name, core(priv->origin));
+ return details.expectedUsage();
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_web_database_get_size:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the actual size of the #WebKitWebDatabase space on disk in bytes.
+ *
+ * Returns: the actual size of the database in bytes
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_web_database_get_size(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), 0);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(priv->name, core(priv->origin));
+ return details.currentUsage();
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_web_database_get_filename:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the absolute filename to the #WebKitWebDatabase file on disk.
+ *
+ * Returns: the absolute filename of the database
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_web_database_get_filename(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::String coreName = WebCore::String::fromUTF8(priv->name);
+ WebCore::String corePath = WebCore::DatabaseTracker::tracker().fullPathForDatabase(core(priv->origin), coreName);
+
+ if (corePath.isEmpty())
+ return"";
+
+ g_free(priv->filename);
+ priv->filename = g_strdup(corePath.utf8().data());
+ return priv->filename;
+
+#else
+ return "";
+#endif
+}
+
+/**
+ * webkit_web_database_remove:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Removes the #WebKitWebDatabase from its security origin and destroys all data
+ * stored in the database.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_web_database_remove(WebKitWebDatabase* webDatabase)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase));
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseTracker::tracker().deleteDatabase(core(priv->origin), priv->name);
+#endif
+}
+
+/**
+ * webkit_remove_all_web_databases:
+ *
+ * Removes all web databases from the current database directory path.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_remove_all_web_databases()
+{
+#if ENABLE(DATABASE)
+ WebCore::DatabaseTracker::tracker().deleteAllDatabases();
+#endif
+}
+
+/**
+ * webkit_get_web_database_directory_path:
+ *
+ * Returns the current path to the directory WebKit will write Web
+ * Database databases. By default this path will be in the user data
+ * directory.
+ *
+ * Returns: the current database directory path
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_get_web_database_directory_path()
+{
+#if ENABLE(DATABASE)
+ WebCore::String path = WebCore::DatabaseTracker::tracker().databaseDirectoryPath();
+
+ if (path.isEmpty())
+ return "";
+
+ g_free(webkit_database_directory_path);
+ webkit_database_directory_path = g_strdup(path.utf8().data());
+ return webkit_database_directory_path;
+#else
+ return "";
+#endif
+}
+
+/**
+ * webkit_set_web_database_directory_path:
+ * @path: the new database directory path
+ *
+ * Sets the current path to the directory WebKit will write Web
+ * Database databases.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_set_web_database_directory_path(const gchar* path)
+{
+#if ENABLE(DATABASE)
+ WebCore::String corePath = WebCore::String::fromUTF8(path);
+ WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(corePath);
+
+ g_free(webkit_database_directory_path);
+ webkit_database_directory_path = g_strdup(corePath.utf8().data());
+#endif
+}
+
+/**
+ * webkit_get_default_web_database_quota:
+ *
+ * Returns the default quota for Web Database databases. By default
+ * this value is 5MB.
+
+ * Returns: the current default database quota in bytes
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_get_default_web_database_quota()
+{
+ return webkit_default_database_quota;
+}
+
+/**
+ * webkit_set_default_web_database_quota:
+ * @default_quota: the new default database quota
+ *
+ * Sets the current path to the directory WebKit will write Web
+ * Database databases.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_set_default_web_database_quota(guint64 defaultQuota)
+{
+ webkit_default_database_quota = defaultQuota;
+}
diff --git a/WebKit/gtk/webkit/webkitwebdatabase.h b/WebKit/gtk/webkit/webkitwebdatabase.h
new file mode 100644
index 0000000..8a9a151
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatabase.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009 Martin Robinson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitwebdatabase_h
+#define webkitwebdatabase_h
+
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_DATABASE (webkit_web_database_get_type())
+#define WEBKIT_WEB_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabase))
+#define WEBKIT_WEB_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabaseClass))
+#define WEBKIT_IS_WEB_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_DATABASE))
+#define WEBKIT_IS_WEB_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_DATABASE))
+#define WEBKIT_WEB_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabaseClass))
+
+typedef struct _WebKitWebDatabasePrivate WebKitWebDatabasePrivate;
+
+struct _WebKitWebDatabase {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitWebDatabasePrivate* priv;
+};
+
+struct _WebKitWebDatabaseClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+ void (*_webkit_reserved4) (void);
+};
+
+WEBKIT_API GType
+webkit_web_database_get_type (void);
+
+WEBKIT_API WebKitSecurityOrigin *
+webkit_web_database_get_security_origin (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_web_database_get_name (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_web_database_get_display_name (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API guint64
+webkit_web_database_get_expected_size (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API guint64
+webkit_web_database_get_size (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_web_database_get_filename (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API void
+webkit_web_database_remove (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API void
+webkit_remove_all_web_databases (void);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_get_web_database_directory_path (void);
+
+WEBKIT_API void
+webkit_set_web_database_directory_path (const gchar* path);
+
+WEBKIT_API guint64
+webkit_get_default_web_database_quota (void);
+
+WEBKIT_API void
+webkit_set_default_web_database_quota (guint64 defaultQuota);
+
+G_END_DECLS
+
+#endif /* webkitwebdatabase_h */
diff --git a/WebKit/gtk/webkit/webkitwebdatasource.cpp b/WebKit/gtk/webkit/webkitwebdatasource.cpp
new file mode 100644
index 0000000..059688e
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatasource.cpp
@@ -0,0 +1,436 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitwebdatasource.h"
+
+#include "ArchiveResource.h"
+#include "DocumentLoaderGtk.h"
+#include "FrameLoaderClientGtk.h"
+#include "FrameLoader.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "ResourceRequest.h"
+#include "runtime/InitializeThreading.h"
+#include "SharedBuffer.h"
+#include "SubstituteData.h"
+#include "webkitwebresource.h"
+#include "webkitprivate.h"
+#include "wtf/Assertions.h"
+
+#include <glib.h>
+
+/**
+ * SECTION:webkitwebdatasource
+ * @short_description: Encapsulates the content to be displayed in a #WebKitWebFrame.
+ * @see_also: #WebKitWebFrame
+ *
+ * Data source encapsulates the content of a #WebKitWebFrame. A
+ * #WebKitWebFrame has a main resource and subresources and the data source
+ * provides access to these resources. When a request gets loaded initially,
+ * it is set to a provisional state. The application can request for the
+ * request that initiated the load by asking for the provisional data source
+ * and invoking the webkit_web_data_source_get_initial_request method of
+ * #WebKitWebDataSource. This data source may not have enough data and some
+ * methods may return empty values. To get a "full" data source with the data
+ * and resources loaded, you need to get the non-provisional data source
+ * through #WebKitWebFrame's webkit_web_frame_get_data_source method. This
+ * data source will have the data after everything was loaded. Make sure that
+ * the data source was finished loading before using any of its methods. You
+ * can do this via webkit_web_data_source_is_loading.
+ */
+
+using namespace WebCore;
+using namespace WebKit;
+
+struct _WebKitWebDataSourcePrivate {
+ WebKit::DocumentLoader* loader;
+
+ WebKitNetworkRequest* initialRequest;
+ WebKitNetworkRequest* networkRequest;
+ WebKitWebResource* mainresource;
+
+ GString* data;
+
+ gchar* textEncoding;
+ gchar* unreachableURL;
+};
+
+#define WEBKIT_WEB_DATA_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourcePrivate))
+
+G_DEFINE_TYPE(WebKitWebDataSource, webkit_web_data_source, G_TYPE_OBJECT);
+
+static void webkit_web_data_source_dispose(GObject* object)
+{
+ WebKitWebDataSource* webDataSource = WEBKIT_WEB_DATA_SOURCE(object);
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ ASSERT(priv->loader);
+ ASSERT(!priv->loader->isLoading());
+ priv->loader->detachDataSource();
+ priv->loader->deref();
+
+ if (priv->initialRequest) {
+ g_object_unref(priv->initialRequest);
+ priv->initialRequest = NULL;
+ }
+
+ if (priv->networkRequest) {
+ g_object_unref(priv->networkRequest);
+ priv->networkRequest = NULL;
+ }
+
+ if (priv->mainresource) {
+ g_object_unref(priv->mainresource);
+ priv->mainresource = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_web_data_source_parent_class)->dispose(object);
+}
+
+static void webkit_web_data_source_finalize(GObject* object)
+{
+ WebKitWebDataSource* dataSource = WEBKIT_WEB_DATA_SOURCE(object);
+ WebKitWebDataSourcePrivate* priv = dataSource->priv;
+
+ g_free(priv->unreachableURL);
+ g_free(priv->textEncoding);
+
+ if (priv->data) {
+ g_string_free(priv->data, TRUE);
+ priv->data = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_web_data_source_parent_class)->finalize(object);
+}
+
+static void webkit_web_data_source_class_init(WebKitWebDataSourceClass* klass)
+{
+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+ gobject_class->dispose = webkit_web_data_source_dispose;
+ gobject_class->finalize = webkit_web_data_source_finalize;
+
+ webkit_init();
+
+ g_type_class_add_private(gobject_class, sizeof(WebKitWebDataSourcePrivate));
+}
+
+static void webkit_web_data_source_init(WebKitWebDataSource* webDataSource)
+{
+ webDataSource->priv = WEBKIT_WEB_DATA_SOURCE_GET_PRIVATE(webDataSource);
+}
+
+WebKitWebDataSource* webkit_web_data_source_new_with_loader(PassRefPtr<WebKit::DocumentLoader> loader)
+{
+ WebKitWebDataSource* webDataSource = WEBKIT_WEB_DATA_SOURCE(g_object_new(WEBKIT_TYPE_WEB_DATA_SOURCE, NULL));
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ priv->loader = loader.releaseRef();
+
+ return webDataSource;
+}
+
+/**
+ * webkit_web_data_source_new:
+ *
+ * Creates a new #WebKitWebDataSource instance. The URL of the
+ * #WebKitWebDataSource will be set to "about:blank".
+ *
+ * Return: a new #WebKitWebDataSource.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_data_source_new()
+{
+ WebKitNetworkRequest* request = webkit_network_request_new("about:blank");
+ WebKitWebDataSource* datasource = webkit_web_data_source_new_with_request(request);
+ g_object_unref(request);
+
+ return datasource;
+}
+
+/**
+ * webkit_web_data_source_new_with_request:
+ * @request: the #WebKitNetworkRequest to use to create this data source
+ *
+ * Creates a new #WebKitWebDataSource from a #WebKitNetworkRequest. Normally,
+ * #WebKitWebFrame objects create their data sources so you will almost never
+ * want to invoke this method directly.
+ *
+ * Returns: a new #WebKitWebDataSource
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_data_source_new_with_request(WebKitNetworkRequest* request)
+{
+ ASSERT(request);
+
+ const gchar* uri = webkit_network_request_get_uri(request);
+
+ WebKitWebDataSource* datasource;
+ datasource = webkit_web_data_source_new_with_loader(
+ WebKit::DocumentLoader::create(ResourceRequest(KURL(KURL(), String::fromUTF8(uri))),
+ SubstituteData()));
+
+ WebKitWebDataSourcePrivate* priv = datasource->priv;
+ priv->initialRequest = request;
+
+ return datasource;
+}
+
+/**
+ * webkit_web_data_source_get_web_frame
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the #WebKitWebFrame that represents this data source
+ *
+ * Return value: the #WebKitWebFrame that represents the @data_source. The
+ * #WebKitWebFrame is owned by WebKit and should not be freed or destroyed.
+ * This will return %NULL of the @data_source is not attached to a frame.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebFrame* webkit_web_data_source_get_web_frame(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ FrameLoader* frameLoader = priv->loader->frameLoader();
+
+ if (!frameLoader)
+ return NULL;
+
+ return static_cast<WebKit::FrameLoaderClient*>(frameLoader->client())->webFrame();
+}
+
+/**
+ * webkit_web_data_source_get_initial_request:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns a reference to the original request that was used to load the web
+ * content. The #WebKitNetworkRequest returned by this method is the request
+ * prior to the "committed" load state. See webkit_web_data_source_get_request
+ * for getting the "committed" request.
+ *
+ * Return value: the original #WebKitNetworkRequest
+ *
+ * Since: 1.1.14
+ */
+WebKitNetworkRequest* webkit_web_data_source_get_initial_request(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ ResourceRequest request = priv->loader->originalRequest();
+
+ if (priv->initialRequest)
+ g_object_unref(priv->initialRequest);
+
+ priv->initialRequest = webkit_network_request_new_with_core_request(request);
+ return priv->initialRequest;
+}
+
+/**
+ * webkit_web_data_source_get_request:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns a #WebKitNetworkRequest that was used to create this
+ * #WebKitWebDataSource. The #WebKitNetworkRequest returned by this method is
+ * the request that was "committed", and hence, different from the request you
+ * get from the webkit_web_data_source_get_initial_request method.
+ *
+ * Return value: the #WebKitNetworkRequest that created the @data_source or
+ * %NULL if the @data_source is not attached to the frame or the frame hasn't
+ * been loaded.
+ *
+ * Since: 1.1.14
+ */
+WebKitNetworkRequest* webkit_web_data_source_get_request(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ FrameLoader* frameLoader = priv->loader->frameLoader();
+ if (!frameLoader || !frameLoader->frameHasLoaded())
+ return NULL;
+
+ ResourceRequest request = priv->loader->request();
+
+ if (priv->networkRequest)
+ g_object_unref(priv->networkRequest);
+
+ priv->networkRequest = webkit_network_request_new_with_core_request(request);
+ return priv->networkRequest;
+}
+
+/**
+ * webkit_web_data_source_get_encoding:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the text encoding name as set in the #WebKitWebView, or if not, the
+ * text encoding of the response.
+ *
+ * Return value: the encoding name of the #WebKitWebView or of the response.
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_data_source_get_encoding(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ String textEncodingName = priv->loader->overrideEncoding();
+
+ if (!textEncodingName)
+ textEncodingName = priv->loader->response().textEncodingName();
+
+ CString encoding = textEncodingName.utf8();
+ g_free(priv->textEncoding);
+ priv->textEncoding = g_strdup(encoding.data());
+ return priv->textEncoding;
+}
+
+/**
+ * webkit_web_data_source_is_loading:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Determines whether the data source is in the process of loading its content.
+ *
+ * Return value: %TRUE if the @data_source is still loading, %FALSE otherwise
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_data_source_is_loading(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ return priv->loader->isLoadingInAPISense();
+}
+
+/**
+ * webkit_web_data_source_get_data:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the raw data that represents the the frame's content.The data will
+ * be incomplete until the data has finished loading. Returns %NULL if the web
+ * frame hasn't loaded any data. Use webkit_web_data_source_is_loading to test
+ * if data source is in the process of loading.
+ *
+ * Return value: a #GString which contains the raw data that represents the @data_source or %NULL if the
+ * @data_source hasn't loaded any data.
+ *
+ * Since: 1.1.14
+ */
+GString* webkit_web_data_source_get_data(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ RefPtr<SharedBuffer> mainResourceData = priv->loader->mainResourceData();
+
+ if (!mainResourceData)
+ return NULL;
+
+ if (priv->data) {
+ g_string_free(priv->data, TRUE);
+ priv->data = NULL;
+ }
+
+ priv->data = g_string_new_len(mainResourceData->data(), mainResourceData->size());
+ return priv->data;
+}
+
+/**
+ * webkit_web_data_source_get_main_resource:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the main resource of the @data_source
+ *
+ * Return value: a new #WebKitWebResource representing the main resource of
+ * the @data_source.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebResource* webkit_web_data_source_get_main_resource(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ if (priv->mainresource)
+ return priv->mainresource;
+
+ WebKitWebFrame* webFrame = webkit_web_data_source_get_web_frame(webDataSource);
+ WebKitWebView* webView = getViewFromFrame(webFrame);
+
+ priv->mainresource = WEBKIT_WEB_RESOURCE(g_object_ref(webkit_web_view_get_main_resource(webView)));
+
+ return priv->mainresource;
+}
+
+/**
+ * webkit_web_data_source_get_unreachable_uri:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Return the unreachable URI of @data_source. The @data_source will have an
+ * unreachable URL if it was created using #WebKitWebFrame's
+ * webkit_web_frame_load_alternate_html_string method.
+ *
+ * Return value: the unreachable URL of @data_source or %NULL if there is no unreachable URL.
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_data_source_get_unreachable_uri(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ const KURL& unreachableURL = priv->loader->unreachableURL();
+
+ if (unreachableURL.isEmpty())
+ return NULL;
+
+ g_free(priv->unreachableURL);
+ priv->unreachableURL = g_strdup(unreachableURL.string().utf8().data());
+ return priv->unreachableURL;
+}
+
+/**
+ * webkit_web_data_source_get_subresources
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Gives you a #GList of #WebKitWebResource objects that compose the
+ * #WebView to which this #WebKitWebDataSource is attached.
+ *
+ * Return value: a #GList of #WebKitResource objects; the objects are
+ * owned by WebKit, but the GList must be freed.
+ *
+ * Since: 1.1.15
+ */
+GList* webkit_web_data_source_get_subresources(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebFrame* webFrame = webkit_web_data_source_get_web_frame(webDataSource);
+ WebKitWebView* webView = getViewFromFrame(webFrame);
+
+ return webkit_web_view_get_subresources(webView);
+}
diff --git a/WebKit/gtk/webkit/webkitwebdatasource.h b/WebKit/gtk/webkit/webkitwebdatasource.h
new file mode 100644
index 0000000..df83118
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatasource.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitwebdatasource_h
+#define webkitwebdatasource_h
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+#include <webkit/webkitwebframe.h>
+#include <webkit/webkitnetworkrequest.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_DATA_SOURCE (webkit_web_data_source_get_type())
+#define WEBKIT_WEB_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSource))
+#define WEBKIT_WEB_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourceClass))
+#define WEBKIT_IS_WEB_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_DATA_SOURCE))
+#define WEBKIT_IS_WEB_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_DATA_SOURCE))
+#define WEBKIT_WEB_DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourceClass))
+
+typedef struct _WebKitWebDataSourcePrivate WebKitWebDataSourcePrivate;
+
+struct _WebKitWebDataSource {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitWebDataSourcePrivate *priv;
+};
+
+struct _WebKitWebDataSourceClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_web_data_source_get_type (void);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_data_source_new (void);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_data_source_new_with_request (WebKitNetworkRequest *request);
+
+WEBKIT_API WebKitWebFrame *
+webkit_web_data_source_get_web_frame (WebKitWebDataSource *data_source);
+
+WEBKIT_API WebKitNetworkRequest *
+webkit_web_data_source_get_initial_request (WebKitWebDataSource *data_source);
+
+WEBKIT_API WebKitNetworkRequest *
+webkit_web_data_source_get_request (WebKitWebDataSource *data_source);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_data_source_get_encoding (WebKitWebDataSource *data_source);
+
+WEBKIT_API gboolean
+webkit_web_data_source_is_loading (WebKitWebDataSource *data_source);
+
+WEBKIT_API GString *
+webkit_web_data_source_get_data (WebKitWebDataSource *data_source);
+
+WEBKIT_API WebKitWebResource *
+webkit_web_data_source_get_main_resource (WebKitWebDataSource *data_source);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_data_source_get_unreachable_uri (WebKitWebDataSource *data_source);
+
+WEBKIT_API GList*
+webkit_web_data_source_get_subresources (WebKitWebDataSource *data_source);
+
+G_END_DECLS
+
+#endif /* webkitwebdatasource_h */
diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp
index fba084e..67fa632 100644
--- a/WebKit/gtk/webkit/webkitwebframe.cpp
+++ b/WebKit/gtk/webkit/webkitwebframe.cpp
@@ -37,6 +37,7 @@
#include "AXObjectCache.h"
#include "CString.h"
#include "DocumentLoader.h"
+#include "DocumentLoaderGtk.h"
#include "FrameLoader.h"
#include "FrameLoaderClientGtk.h"
#include "FrameTree.h"
@@ -85,6 +86,7 @@ enum {
LOAD_DONE,
TITLE_CHANGED,
HOVERING_OVER_LINK,
+ SCROLLBARS_POLICY_CHANGED,
LAST_SIGNAL
};
@@ -94,7 +96,9 @@ enum {
PROP_NAME,
PROP_TITLE,
PROP_URI,
- PROP_LOAD_STATUS
+ PROP_LOAD_STATUS,
+ PROP_HORIZONTAL_SCROLLBAR_POLICY,
+ PROP_VERTICAL_SCROLLBAR_POLICY
};
static guint webkit_web_frame_signals[LAST_SIGNAL] = { 0, };
@@ -118,6 +122,12 @@ static void webkit_web_frame_get_property(GObject* object, guint prop_id, GValue
case PROP_LOAD_STATUS:
g_value_set_enum(value, webkit_web_frame_get_load_status(frame));
break;
+ case PROP_HORIZONTAL_SCROLLBAR_POLICY:
+ g_value_set_enum(value, webkit_web_frame_get_horizontal_scrollbar_policy(frame));
+ break;
+ case PROP_VERTICAL_SCROLLBAR_POLICY:
+ g_value_set_enum(value, webkit_web_frame_get_vertical_scrollbar_policy(frame));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -133,6 +143,11 @@ void webkit_web_frame_core_frame_gone(WebKitWebFrame* frame)
frame->priv->coreFrame = 0;
}
+static WebKitWebDataSource* webkit_web_frame_get_data_source_from_core_loader(WebCore::DocumentLoader* loader)
+{
+ return loader ? static_cast<WebKit::DocumentLoader*>(loader)->dataSource() : NULL;
+}
+
static void webkit_web_frame_finalize(GObject* object)
{
WebKitWebFrame* frame = WEBKIT_WEB_FRAME(object);
@@ -214,6 +229,37 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
G_TYPE_NONE, 2,
G_TYPE_STRING, G_TYPE_STRING);
+ /**
+ * WebKitWebFrame::scrollbars-policy-changed:
+ * @web_view: the object which received the signal
+ *
+ * Signal emitted when policy for one or both of the scrollbars of
+ * the view has changed. The default handler will apply the new
+ * policy to the container that holds the #WebKitWebFrame if it is
+ * a #GtkScrolledWindow and the frame is the main frame. If you do
+ * not want this to be handled automatically, you need to handle
+ * this signal.
+ *
+ * The exception to this rule is that policies to disable the
+ * scrollbars are applied as %GTK_POLICY_AUTOMATIC instead, since
+ * the size request of the widget would force browser windows to
+ * not be resizable.
+ *
+ * You can obtain the new policies from the
+ * WebKitWebFrame:horizontal-scrollbar-policy and
+ * WebKitWebFrame:vertical-scrollbar-policy properties.
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_frame_signals[SCROLLBARS_POLICY_CHANGED] = g_signal_new("scrollbars-policy-changed",
+ G_TYPE_FROM_CLASS(frameClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN, 0);
+
/*
* implementations of virtual methods
*/
@@ -260,6 +306,42 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
WEBKIT_LOAD_FINISHED,
WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebFrame:horizontal-scrollbar-policy:
+ *
+ * Determines the current policy for the horizontal scrollbar of
+ * the frame. For the main frame, make sure to set the same policy
+ * on the scrollable widget containing the #WebKitWebView, unless
+ * you know what you are doing.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_HORIZONTAL_SCROLLBAR_POLICY,
+ g_param_spec_enum("horizontal-scrollbar-policy",
+ _("Horizontal Scrollbar Policy"),
+ _("Determines the current policy for the horizontal scrollbar of the frame."),
+ GTK_TYPE_POLICY_TYPE,
+ GTK_POLICY_AUTOMATIC,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebFrame:vertical-scrollbar-policy:
+ *
+ * Determines the current policy for the vertical scrollbar of
+ * the frame. For the main frame, make sure to set the same policy
+ * on the scrollable widget containing the #WebKitWebView, unless
+ * you know what you are doing.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_VERTICAL_SCROLLBAR_POLICY,
+ g_param_spec_enum("vertical-scrollbar-policy",
+ _("Vertical Scrollbar Policy"),
+ _("Determines the current policy for the vertical scrollbar of the frame."),
+ GTK_TYPE_POLICY_TYPE,
+ GTK_POLICY_AUTOMATIC,
+ WEBKIT_PARAM_READABLE));
+
g_type_class_add_private(frameClass, sizeof(WebKitWebFramePrivate));
}
@@ -295,6 +377,8 @@ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView)
priv->coreFrame = Frame::create(viewPriv->corePage, 0, client).get();
priv->coreFrame->init();
+ priv->origin = NULL;
+
return frame;
}
@@ -443,7 +527,7 @@ static void webkit_web_frame_load_data(WebKitWebFrame* frame, const gchar* conte
SubstituteData substituteData(sharedBuffer.release(),
mimeType ? String::fromUTF8(mimeType) : String::fromUTF8("text/html"),
encoding ? String::fromUTF8(encoding) : String::fromUTF8("UTF-8"),
- baseKURL,
+ KURL(KURL(), String::fromUTF8(unreachableURL)),
KURL(KURL(), String::fromUTF8(unreachableURL)));
coreFrame->loader()->load(request, substituteData, false);
@@ -603,6 +687,46 @@ JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame)
}
/**
+ * webkit_web_frame_get_data_source:
+ * @frame: a #WebKitWebFrame
+ *
+ * Returns the committed data source.
+ *
+ * Return value: the committed #WebKitWebDataSource.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_frame_get_data_source(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
+
+ Frame* coreFrame = core(frame);
+ return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->documentLoader());
+}
+
+/**
+ * webkit_web_frame_get_provisional_data_source:
+ * @frame: a #WebKitWebFrame
+ *
+ * You use the webkit_web_frame_load_request method to initiate a request that
+ * creates a provisional data source. The provisional data source will
+ * transition to a committed data source once any data has been received. Use
+ * webkit_web_frame_get_data_source to get the committed data source.
+ *
+ * Return value: the provisional #WebKitWebDataSource or %NULL if a load
+ * request is not in progress.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_frame_get_provisional_data_source(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
+
+ Frame* coreFrame = core(frame);
+ return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->provisionalDocumentLoader());
+}
+
+/**
* webkit_web_frame_get_children:
* @frame: a #WebKitWebFrame
*
@@ -674,6 +798,19 @@ gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame)
return g_strdup(string.utf8().data());
}
+/**
+ * webkit_web_frame_get_pending_unload_event_count:
+ * @frame: a #WebKitWebFrame
+ *
+ * Return value: number of pending unload events
+ */
+guint webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0);
+
+ return core(frame)->domWindow()->pendingUnloadEventListeners();
+}
+
static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
{
PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
@@ -696,6 +833,9 @@ static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context,
{
PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
+ if (page_nr >= printContext->pageCount())
+ return;
+
cairo_t* cr = gtk_print_context_get_cairo_context(context);
GraphicsContext ctx(cr);
float width = gtk_print_context_get_width(context);
@@ -813,7 +953,7 @@ unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame)
gchar* webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame)
{
Frame* coreFrame = core(frame);
- DocumentLoader* docLoader = coreFrame->loader()->documentLoader();
+ WebCore::DocumentLoader* docLoader = coreFrame->loader()->documentLoader();
String mimeType = docLoader->responseMIMEType();
return g_strdup(mimeType.utf8().data());
}
@@ -883,3 +1023,82 @@ AtkObject* webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame
return NULL;
#endif
}
+
+GtkPolicyType webkit_web_frame_get_horizontal_scrollbar_policy(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_POLICY_AUTOMATIC);
+
+ Frame* coreFrame = core(frame);
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return GTK_POLICY_AUTOMATIC;
+
+ ScrollbarMode hMode = view->horizontalScrollbarMode();
+
+ if (hMode == ScrollbarAlwaysOn)
+ return GTK_POLICY_ALWAYS;
+
+ if (hMode == ScrollbarAlwaysOff)
+ return GTK_POLICY_NEVER;
+
+ return GTK_POLICY_AUTOMATIC;
+}
+
+GtkPolicyType webkit_web_frame_get_vertical_scrollbar_policy(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_POLICY_AUTOMATIC);
+
+ Frame* coreFrame = core(frame);
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return GTK_POLICY_AUTOMATIC;
+
+ ScrollbarMode vMode = view->verticalScrollbarMode();
+
+ if (vMode == ScrollbarAlwaysOn)
+ return GTK_POLICY_ALWAYS;
+
+ if (vMode == ScrollbarAlwaysOff)
+ return GTK_POLICY_NEVER;
+
+ return GTK_POLICY_AUTOMATIC;
+}
+
+/**
+ * webkit_web_frame_get_security_origin:
+ * @frame: a #WebKitWebFrame
+ *
+ * Returns the @frame's security origin.
+ *
+ * Return value: the security origin of @frame
+ *
+ * Since: 1.1.14
+ */
+WebKitSecurityOrigin* webkit_web_frame_get_security_origin(WebKitWebFrame* frame)
+{
+ WebKitWebFramePrivate* priv = frame->priv;
+ if (!priv->coreFrame || !priv->coreFrame->document() || !priv->coreFrame->document()->securityOrigin())
+ return NULL;
+
+ if (priv->origin && priv->origin->priv->coreOrigin.get() == priv->coreFrame->document()->securityOrigin())
+ return priv->origin;
+
+ if (priv->origin)
+ g_object_unref(priv->origin);
+
+ priv->origin = kit(priv->coreFrame->document()->securityOrigin());
+ return priv->origin;
+}
+
+void webkit_web_frame_layout(WebKitWebFrame* frame)
+{
+ Frame* coreFrame = core(frame);
+ if (!coreFrame)
+ return;
+
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return;
+
+ view->layout();
+}
diff --git a/WebKit/gtk/webkit/webkitwebframe.h b/WebKit/gtk/webkit/webkitwebframe.h
index b2e61b9..7a95545 100644
--- a/WebKit/gtk/webkit/webkitwebframe.h
+++ b/WebKit/gtk/webkit/webkitwebframe.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_FRAME_H
-#define WEBKIT_WEB_FRAME_H
+#ifndef webkitwebframe_h
+#define webkitwebframe_h
#include <glib-object.h>
#include <gtk/gtk.h>
@@ -28,6 +28,7 @@
#include <webkit/webkitdefines.h>
#include <webkit/webkitnetworkrequest.h>
+#include <webkit/webkitwebdatasource.h>
G_BEGIN_DECLS
@@ -72,15 +73,19 @@ struct _WebKitWebFrameClass {
* actual visible content happened; one or more layouts may have
* happened before that caused nothing to be visible on the screen,
* because the data available at the time was not significant enough.
- * @WEBKIT_LOAD_FINISHED: This state means either that everything that
- * was required to display the page has been loaded, or that an error
- * has happened.
+ * @WEBKIT_LOAD_FINISHED: This state means that everything that was
+ * required to display the page has been loaded.
+ * @WEBKIT_LOAD_FAILED: This state means that some error occurred
+ * during the page load that prevented it from being completed. You
+ * can connect to the #WebKitWebView::load-error signal if you want to
+ * know precisely what kind of error occurred.
*/
typedef enum {
WEBKIT_LOAD_PROVISIONAL,
WEBKIT_LOAD_COMMITTED,
WEBKIT_LOAD_FINISHED,
- WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
+ WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT,
+ WEBKIT_LOAD_FAILED
} WebKitLoadStatus;
WEBKIT_API GType
@@ -152,6 +157,21 @@ webkit_web_frame_print (WebKitWebFrame *frame);
WEBKIT_API WebKitLoadStatus
webkit_web_frame_get_load_status (WebKitWebFrame *frame);
+WEBKIT_API GtkPolicyType
+webkit_web_frame_get_horizontal_scrollbar_policy (WebKitWebFrame *frame);
+
+WEBKIT_API GtkPolicyType
+webkit_web_frame_get_vertical_scrollbar_policy (WebKitWebFrame *frame);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_frame_get_data_source (WebKitWebFrame *frame);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_frame_get_provisional_data_source (WebKitWebFrame *frame);
+
+WEBKIT_API WebKitSecurityOrigin*
+webkit_web_frame_get_security_origin (WebKitWebFrame *frame);
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
index a75bc0d..aab8b51 100644
--- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
+++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
@@ -297,12 +297,11 @@ WebKitWebHistoryItem* webkit_web_history_item_new()
*/
WebKitWebHistoryItem* webkit_web_history_item_new_with_data(const gchar* uri, const gchar* title)
{
- WebCore::KURL historyUri(uri);
- WebCore::String historyTitle = WebCore::String::fromUTF8(title);
-
WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
+ WebCore::KURL historyUri(WebCore::KURL(), uri);
+ WebCore::String historyTitle = WebCore::String::fromUTF8(title);
RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(historyUri, historyTitle, 0);
priv->historyItem = item.release().releaseRef();
webkit_history_item_add(webHistoryItem, priv->historyItem);
diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.h b/WebKit/gtk/webkit/webkitwebhistoryitem.h
index c8a754a..cafeb36 100644
--- a/WebKit/gtk/webkit/webkitwebhistoryitem.h
+++ b/WebKit/gtk/webkit/webkitwebhistoryitem.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_HISTORY_ITEM_H
-#define WEBKIT_WEB_HISTORY_ITEM_H
+#ifndef webkitwebhistoryitem_h
+#define webkitwebhistoryitem_h
#include <glib.h>
#include <glib-object.h>
@@ -84,4 +84,4 @@ webkit_web_history_item_get_last_visited_time (WebKitWebHistoryItem *web_history
G_END_DECLS
-#endif /* WEBKIT_WEB_HISTORY_ITEM_H */
+#endif /* webkitwebhistoryitem_h */
diff --git a/WebKit/gtk/webkit/webkitwebinspector.h b/WebKit/gtk/webkit/webkitwebinspector.h
index 41ccf92..9010e26 100644
--- a/WebKit/gtk/webkit/webkitwebinspector.h
+++ b/WebKit/gtk/webkit/webkitwebinspector.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __WEBKIT_WEB_INSPECTOR_H__
-#define __WEBKIT_WEB_INSPECTOR_H__
+#ifndef webkitwebinspector_h
+#define webkitwebinspector_h
#include <glib-object.h>
@@ -62,4 +62,4 @@ webkit_web_inspector_get_inspected_uri(WebKitWebInspector* web_inspector);
G_END_DECLS
-#endif /* __WEBKIT_WEB_INSPECTOR_H__ */
+#endif /* webkitwebinspector_h */
diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.h b/WebKit/gtk/webkit/webkitwebnavigationaction.h
index c437c50..dbb47a8 100644
--- a/WebKit/gtk/webkit/webkitwebnavigationaction.h
+++ b/WebKit/gtk/webkit/webkitwebnavigationaction.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_NAVIGATION_ACTION_H
-#define WEBKIT_WEB_NAVIGATION_ACTION_H
+#ifndef webkitwebnavigationaction_h
+#define webkitwebnavigationaction_h
#include <glib-object.h>
diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
index b2bab6b..5ef6310 100644
--- a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
+++ b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
@@ -86,7 +86,7 @@ void webkit_web_policy_decision_use(WebKitWebPolicyDecision* decision)
WebKitWebPolicyDecisionPrivate* priv = decision->priv;
if (!priv->isCancelled)
- (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyUse);
+ (core(priv->frame)->loader()->policyChecker()->*(priv->framePolicyFunction))(WebCore::PolicyUse);
}
/**
@@ -104,7 +104,7 @@ void webkit_web_policy_decision_ignore(WebKitWebPolicyDecision* decision)
WebKitWebPolicyDecisionPrivate* priv = decision->priv;
if (!priv->isCancelled)
- (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyIgnore);
+ (core(priv->frame)->loader()->policyChecker()->*(priv->framePolicyFunction))(WebCore::PolicyIgnore);
}
/**
@@ -122,7 +122,7 @@ void webkit_web_policy_decision_download(WebKitWebPolicyDecision* decision)
WebKitWebPolicyDecisionPrivate* priv = decision->priv;
if (!priv->isCancelled)
- (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyDownload);
+ (core(priv->frame)->loader()->policyChecker()->*(priv->framePolicyFunction))(WebCore::PolicyDownload);
}
void webkit_web_policy_decision_cancel(WebKitWebPolicyDecision* decision)
diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.h b/WebKit/gtk/webkit/webkitwebpolicydecision.h
index f1ec963..2b61837 100644
--- a/WebKit/gtk/webkit/webkitwebpolicydecision.h
+++ b/WebKit/gtk/webkit/webkitwebpolicydecision.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_POLICY_DECISION_H
-#define WEBKIT_WEB_POLICY_DECISION_H
+#ifndef webkitwebpolicydecision_h
+#define webkitwebpolicydecision_h
#include <glib-object.h>
#include <stdint.h>
diff --git a/WebKit/gtk/webkit/webkitwebresource.cpp b/WebKit/gtk/webkit/webkitwebresource.cpp
new file mode 100644
index 0000000..e995e08
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebresource.cpp
@@ -0,0 +1,401 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "webkitwebresource.h"
+#include "webkitprivate.h"
+
+#include "ArchiveResource.h"
+#include "CString.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "SharedBuffer.h"
+#include "webkitenumtypes.h"
+#include "webkitmarshal.h"
+#include "wtf/Assertions.h"
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitwebresource
+ * @short_description: Represents a downloaded URI.
+ * @see_also: #WebKitWebDataSource
+ *
+ * A web resource encapsulates the data of the download as well as the URI,
+ * MIME type and frame name of the resource.
+ */
+
+using namespace WebCore;
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_URI,
+ PROP_MIME_TYPE,
+ PROP_ENCODING,
+ PROP_FRAME_NAME
+};
+
+G_DEFINE_TYPE(WebKitWebResource, webkit_web_resource, G_TYPE_OBJECT);
+
+static void webkit_web_resource_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
+static void webkit_web_resource_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
+
+static void webkit_web_resource_cleanup(WebKitWebResource* webResource)
+{
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ g_free(priv->uri);
+ priv->uri = NULL;
+
+ g_free(priv->mimeType);
+ priv->mimeType = NULL;
+
+ g_free(priv->textEncoding);
+ priv->textEncoding = NULL;
+
+ g_free(priv->frameName);
+ priv->frameName = NULL;
+
+ if (priv->data)
+ g_string_free(priv->data, TRUE);
+ priv->data = NULL;
+}
+
+static void webkit_web_resource_dispose(GObject* object)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ if (priv->resource) {
+ priv->resource->deref();
+ priv->resource = 0;
+ }
+
+ G_OBJECT_CLASS(webkit_web_resource_parent_class)->dispose(object);
+}
+
+static void webkit_web_resource_finalize(GObject* object)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+
+ webkit_web_resource_cleanup(webResource);
+
+ G_OBJECT_CLASS(webkit_web_resource_parent_class)->finalize(object);
+}
+
+static void webkit_web_resource_class_init(WebKitWebResourceClass* klass)
+{
+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = webkit_web_resource_dispose;
+ gobject_class->finalize = webkit_web_resource_finalize;
+ gobject_class->get_property = webkit_web_resource_get_property;
+ gobject_class->set_property = webkit_web_resource_set_property;
+
+ /**
+ * WebKitWebResource:uri:
+ *
+ * The URI of the web resource
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_URI,
+ g_param_spec_string(
+ "uri",
+ _("URI"),
+ _("The uri of the resource"),
+ NULL,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+ /**
+ * WebKitWebResource:mime-type:
+ *
+ * The MIME type of the web resource.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_MIME_TYPE,
+ g_param_spec_string(
+ "mime-type",
+ _("MIME Type"),
+ _("The MIME type of the resource"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebResource:encoding:
+ *
+ * The encoding name to which the web resource was encoded in.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENCODING,
+ g_param_spec_string(
+ "encoding",
+ _("Encoding"),
+ _("The text encoding name of the resource"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebResource:frame-name:
+ *
+ * The frame name for the web resource.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_FRAME_NAME,
+ g_param_spec_string(
+ "frame-name",
+ _("Frame Name"),
+ _("The frame name of the resource"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ g_type_class_add_private(gobject_class, sizeof(WebKitWebResourcePrivate));
+}
+
+static void webkit_web_resource_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+
+ switch (prop_id) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_web_resource_get_uri(webResource));
+ break;
+ case PROP_MIME_TYPE:
+ g_value_set_string(value, webkit_web_resource_get_mime_type(webResource));
+ break;
+ case PROP_ENCODING:
+ g_value_set_string(value, webkit_web_resource_get_encoding(webResource));
+ break;
+ case PROP_FRAME_NAME:
+ g_value_set_string(value, webkit_web_resource_get_frame_name(webResource));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void webkit_web_resource_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+
+ switch (prop_id) {
+ case PROP_URI:
+ g_free(webResource->priv->uri);
+ webResource->priv->uri = g_value_dup_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void webkit_web_resource_init(WebKitWebResource* webResource)
+{
+ webResource->priv = WEBKIT_WEB_RESOURCE_GET_PRIVATE(webResource);
+}
+
+// internal use only
+WebKitWebResource* webkit_web_resource_new_with_core_resource(PassRefPtr<ArchiveResource> resource)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL));
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ priv->resource = resource.releaseRef();
+
+ return webResource;
+}
+
+void webkit_web_resource_init_with_core_resource(WebKitWebResource* webResource, PassRefPtr<ArchiveResource> resource)
+{
+ ASSERT(resource);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ if (priv->resource)
+ priv->resource->deref();
+
+ priv->resource = resource.releaseRef();
+}
+
+/**
+ * webkit_web_resource_new:
+ * @data: the data to initialize the #WebKitWebResource
+ * @length: the length of @data
+ * @uri: the uri of the #WebKitWebResource
+ * @mime_type: the MIME type of the #WebKitWebResource
+ * @text_encoding_name: the text encoding name of the #WebKitWebResource
+ * @frame_name: the frame name of the #WebKitWebResource
+ *
+ * Returns a new #WebKitWebResource. The @text_encoding_name can be %NULL. The
+ * @frame_name argument can be used if the resource represents contents of an
+ * entire HTML frame, otherwise pass %NULL.
+ *
+ * Return value: a new #WebKitWebResource
+ *
+ * Since: 1.1.14
+ */
+WebKitWebResource* webkit_web_resource_new(const gchar* data,
+ gssize size,
+ const gchar* uri,
+ const gchar* mimeType,
+ const gchar* encoding,
+ const gchar* frameName)
+{
+ g_return_val_if_fail(data, NULL);
+ g_return_val_if_fail(uri, NULL);
+ g_return_val_if_fail(mimeType, NULL);
+
+ if (size < 0)
+ size = strlen(data);
+
+ RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size);
+ WebKitWebResource* webResource = webkit_web_resource_new_with_core_resource(ArchiveResource::create(buffer, KURL(KURL(), String::fromUTF8(uri)), String::fromUTF8(mimeType), String::fromUTF8(encoding), String::fromUTF8(frameName)));
+
+ return webResource;
+}
+
+/**
+ * webkit_web_resource_get_data:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Returns the data of the @webResource.
+ *
+ * Return value: a #GString containing the character data of the @webResource.
+ * The string is owned by WebKit and should not be freed or destroyed.
+ *
+ * Since: 1.1.14
+ */
+GString* webkit_web_resource_get_data(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->data)
+ priv->data = g_string_new_len(priv->resource->data()->data(), priv->resource->data()->size());
+
+ return priv->data;
+}
+
+/**
+ * webkit_web_resource_get_uri:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the URI of the resource
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_uri(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+
+ // We may have an URI without having a resource assigned to us (e.g., if the
+ // FrameLoaderClient only had a ResourceRequest when we got created
+ if (priv->uri)
+ return priv->uri;
+
+ if (!priv->resource)
+ return NULL;
+
+ priv->uri = g_strdup(priv->resource->url().string().utf8().data());
+
+ return priv->uri;
+}
+
+/**
+ * webkit_web_resource_get_mime_type:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the MIME type of the resource
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_mime_type(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->mimeType)
+ priv->mimeType = g_strdup(priv->resource->mimeType().utf8().data());
+
+ return priv->mimeType;
+}
+
+/**
+ * webkit_web_resource_get_encoding:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the encoding name of the resource
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_encoding(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->textEncoding)
+ priv->textEncoding = g_strdup(priv->resource->textEncoding().utf8().data());
+
+ return priv->textEncoding;
+}
+
+/**
+ * webkit_web_resource_get_frame_name:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the frame name of the resource.
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_frame_name(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->frameName)
+ priv->frameName = g_strdup(priv->resource->frameName().utf8().data());
+
+ return priv->frameName;
+}
+
diff --git a/WebKit/gtk/webkit/webkitwebresource.h b/WebKit/gtk/webkit/webkitwebresource.h
new file mode 100644
index 0000000..05f6066
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebresource.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitwebresource_h
+#define webkitwebresource_h
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_RESOURCE (webkit_web_resource_get_type())
+#define WEBKIT_WEB_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResource))
+#define WEBKIT_WEB_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourceClass))
+#define WEBKIT_IS_WEB_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_RESOURCE))
+#define WEBKIT_IS_WEB_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_RESOURCE))
+#define WEBKIT_WEB_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourceClass))
+
+typedef struct _WebKitWebResourcePrivate WebKitWebResourcePrivate;
+
+struct _WebKitWebResource {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitWebResourcePrivate *priv;
+};
+
+struct _WebKitWebResourceClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_web_resource_get_type (void);
+
+WEBKIT_API WebKitWebResource *
+webkit_web_resource_new (const gchar *data,
+ gssize size,
+ const gchar *uri,
+ const gchar *mime_type,
+ const gchar *encoding,
+ const gchar *frame_name);
+
+WEBKIT_API GString *
+webkit_web_resource_get_data (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_uri (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_mime_type (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_encoding (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_frame_name (WebKitWebResource *web_resource);
+
+G_END_DECLS
+
+#endif /* webkitwebresource_h */
diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp
index 061d3e2..588d5bd 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.cpp
+++ b/WebKit/gtk/webkit/webkitwebsettings.cpp
@@ -24,6 +24,7 @@
#include "config.h"
#include "webkitwebsettings.h"
+#include "webkitenumtypes.h"
#include "webkitprivate.h"
#include "webkitversion.h"
@@ -93,6 +94,8 @@ struct _WebKitWebSettingsPrivate {
gchar* user_agent;
gboolean javascript_can_open_windows_automatically;
gboolean enable_offline_web_application_cache;
+ WebKitEditingBehavior editing_behavior;
+ gboolean enable_universal_access_from_file_uris;
};
#define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
@@ -130,7 +133,9 @@ enum {
PROP_ENABLE_XSS_AUDITOR,
PROP_USER_AGENT,
PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
- PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE
+ PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
+ PROP_EDITING_BEHAVIOR,
+ PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS
};
// Create a default user agent string
@@ -433,7 +438,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
*
* This is currently experimental for WebKitGtk.
*
- * Since 1.1.2
+ * Since: 1.1.2
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_PRIVATE_BROWSING,
@@ -449,7 +454,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
*
* Whether to enable spell checking while typing.
*
- * Since 1.1.6
+ * Since: 1.1.6
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_SPELL_CHECKING,
@@ -473,7 +478,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* If no value is specified then the value returned by
* gtk_get_default_language will be used.
*
- * Since 1.1.6
+ * Since: 1.1.6
*/
g_object_class_install_property(gobject_class,
PROP_SPELL_CHECKING_LANGUAGES,
@@ -489,7 +494,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
*
* Whether to enable caret browsing mode.
*
- * Since 1.1.6
+ * Since: 1.1.6
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_CARET_BROWSING,
@@ -505,7 +510,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* SQL database allows web pages to store structured data and be able to
* use SQL to manipulate that data asynchronously.
*
- * Since 1.1.8
+ * Since: 1.1.8
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_HTML5_DATABASE,
@@ -521,7 +526,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Whether to enable HTML5 localStorage support. localStorage provides
* simple synchronous storage access.
*
- * Since 1.1.8
+ * Since: 1.1.8
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_HTML5_LOCAL_STORAGE,
@@ -536,7 +541,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Whether to enable the XSS Auditor. This feature filters some kinds of
* reflective XSS attacks on vulnerable web sites.
*
- * Since 1.1.11
+ * Since: 1.1.11
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_XSS_AUDITOR,
@@ -571,7 +576,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Whether JavaScript can open popup windows automatically without user
* intervention.
*
- * Since 1.1.11
+ * Since: 1.1.11
*/
g_object_class_install_property(gobject_class,
PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
@@ -587,7 +592,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Web Application Cache ensures web applications are available even when
* the user is not connected to the network.
*
- * Since 1.1.13
+ * Since: 1.1.13
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
@@ -597,7 +602,50 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
TRUE,
flags));
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_EDITING_BEHAVIOR_MAC) == static_cast<int>(WebCore::EditingMacBehavior), editing_behavior_type_mac_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_EDITING_BEHAVIOR_WINDOWS) == static_cast<int>(WebCore::EditingWindowsBehavior), editing_behavior_type_windows_match);
+ /**
+ * WebKitWebSettings:editing-behavior
+ *
+ * This setting controls various editing behaviors that differ
+ * between platforms and that have been combined in two groups,
+ * 'Mac' and 'Windows'. Some examples:
+ *
+ * 1) Clicking below the last line of an editable area puts the
+ * caret at the end of the last line on Mac, but in the middle of
+ * the last line on Windows.
+ *
+ * 2) Pushing down the arrow key on the last line puts the caret
+ * at the end of the last line on Mac, but does nothing on
+ * Windows. A similar case exists on the top line.
+ *
+ * Since: 1.1.13
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_EDITING_BEHAVIOR,
+ g_param_spec_enum("editing-behavior",
+ _("Editing behavior"),
+ _("The behavior mode to use in editing mode"),
+ WEBKIT_TYPE_EDITING_BEHAVIOR,
+ WEBKIT_EDITING_BEHAVIOR_MAC,
+ flags));
+
+ /**
+ * WebKitWebSettings:enable-universal-access-from-file-uris
+ *
+ * Whether to allow files loaded through file:// URIs universal access to
+ * all pages.
+ *
+ * Since: 1.1.13
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
+ g_param_spec_boolean("enable-universal-access-from-file-uris",
+ _("Enable universal access from file URIs"),
+ _("Whether to allow universal access from file URIs"),
+ FALSE,
+ flags));
g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
}
@@ -779,6 +827,12 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
priv->enable_offline_web_application_cache = g_value_get_boolean(value);
break;
+ case PROP_EDITING_BEHAVIOR:
+ priv->editing_behavior = static_cast<WebKitEditingBehavior>(g_value_get_enum(value));
+ break;
+ case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
+ priv->enable_universal_access_from_file_uris = g_value_get_boolean(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -884,7 +938,13 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
g_value_set_boolean(value, priv->enable_offline_web_application_cache);
break;
- default:
+ case PROP_EDITING_BEHAVIOR:
+ g_value_set_enum(value, priv->editing_behavior);
+ break;
+ case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
+ g_value_set_boolean(value, priv->enable_universal_access_from_file_uris);
+ break;
+ default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
@@ -946,6 +1006,8 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
"user-agent", webkit_web_settings_get_user_agent(web_settings),
"javascript-can-open-windows-automatically", priv->javascript_can_open_windows_automatically,
"enable-offline-web-application-cache", priv->enable_offline_web_application_cache,
+ "editing-behavior", priv->editing_behavior,
+ "enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris,
NULL));
return copy;
diff --git a/WebKit/gtk/webkit/webkitwebsettings.h b/WebKit/gtk/webkit/webkitwebsettings.h
index 9eac321..d8dafd9 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.h
+++ b/WebKit/gtk/webkit/webkitwebsettings.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __WEBKIT_WEB_SETTINGS_H__
-#define __WEBKIT_WEB_SETTINGS_H__
+#ifndef webkitwebsettings_h
+#define webkitwebsettings_h
#include <glib-object.h>
@@ -34,6 +34,11 @@ G_BEGIN_DECLS
#define WEBKIT_IS_WEB_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_SETTINGS))
#define WEBKIT_WEB_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsClass))
+typedef enum {
+ WEBKIT_EDITING_BEHAVIOR_MAC,
+ WEBKIT_EDITING_BEHAVIOR_WINDOWS
+} WebKitEditingBehavior;
+
typedef struct _WebKitWebSettingsPrivate WebKitWebSettingsPrivate;
struct _WebKitWebSettings {
@@ -67,4 +72,4 @@ webkit_web_settings_get_user_agent (WebKitWebSettings *web_settings);
G_END_DECLS
-#endif /* __WEBKIT_WEB_SETTINGS_H__ */
+#endif /* webkitwebsettings_h */
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index ec59e60..47d7d98 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -6,7 +6,7 @@
* Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
* Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
* Copyright (C) 2008 Nuanti Ltd.
- * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2008, 2009 Collabora Ltd.
* Copyright (C) 2009 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
@@ -25,11 +25,13 @@
*/
#include "config.h"
+#include "webkitwebview.h"
#include "webkitdownload.h"
-#include "webkitwebview.h"
#include "webkitenumtypes.h"
#include "webkitmarshal.h"
+#include "webkitnetworkrequest.h"
+#include "webkitnetworkresponse.h"
#include "webkitprivate.h"
#include "webkitwebinspector.h"
#include "webkitwebbackforwardlist.h"
@@ -60,11 +62,13 @@
#include "InspectorClientGtk.h"
#include "FrameLoader.h"
#include "FrameView.h"
+#include "MouseEventWithHitTestResults.h"
#include "PasteboardHelper.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformWheelEvent.h"
#include "ProgressTracker.h"
#include "ResourceHandle.h"
+#include "RenderView.h"
#include "ScriptValue.h"
#include "Scrollbar.h"
#include <wtf/GOwnPtr.h>
@@ -96,7 +100,7 @@
* gtk_container_add (GTK_CONTAINER (main_window), scrolled_window);
*
* /<!-- -->* Open a webpage *<!-- -->/
- * webkit_web_view_open (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");
+ * webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");
*
* /<!-- -->* Show the result *<!-- -->/
* gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
@@ -142,6 +146,10 @@ enum {
PRINT_REQUESTED,
PLUGIN_WIDGET,
CLOSE_WEB_VIEW,
+ UNDO,
+ REDO,
+ DATABASE_QUOTA_EXCEEDED,
+ RESOURCE_REQUEST_STARTING,
LAST_SIGNAL
};
@@ -172,6 +180,15 @@ G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
+static void destroy_menu_cb(GtkObject* object, gpointer data)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(data);
+ WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
+
+ g_object_unref(priv->currentMenu);
+ priv->currentMenu = NULL;
+}
+
static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event)
{
Page* page = core(webView);
@@ -203,8 +220,14 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
return FALSE;
WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
+ priv->currentMenu = GTK_MENU(g_object_ref(menu));
priv->lastPopupXPosition = event.globalX();
priv->lastPopupYPosition = event.globalY();
+
+ g_signal_connect(menu, "destroy",
+ G_CALLBACK(destroy_menu_cb),
+ NULL);
+
gtk_menu_popup(menu, NULL, NULL,
NULL,
priv, event.button() + 1, gtk_get_current_event_time());
@@ -268,7 +291,7 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
}
int x, y;
- gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformWindow())->window, &x, &y);
+ gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformPageClient())->window, &x, &y);
// FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element.
// Ideally we'd have the position of a context menu event be separate from its target node.
@@ -649,7 +672,7 @@ static void webkit_web_view_realize(GtkWidget* widget)
gdk_window_set_user_data(widget->window, widget);
widget->style = gtk_style_attach(widget->style, widget->window);
- gdk_window_set_background(widget->window, &widget->style->base[GTK_WIDGET_STATE(widget)]);
+ gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
WebKitWebViewPrivate* priv = webView->priv;
@@ -690,8 +713,6 @@ static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* wi
WebKitWebViewPrivate* priv = webView->priv;
priv->children.add(widget);
- if (GTK_WIDGET_REALIZED(container))
- gtk_widget_set_parent_window(widget, GTK_WIDGET(webView)->window);
gtk_widget_set_parent(widget, GTK_WIDGET(container));
}
@@ -866,6 +887,18 @@ static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
frame->editor()->command("Copy").execute();
}
+static void webkit_web_view_real_undo(WebKitWebView* webView)
+{
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ frame->editor()->command("Undo").execute();
+}
+
+static void webkit_web_view_real_redo(WebKitWebView* webView)
+{
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ frame->editor()->command("Redo").execute();
+}
+
static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count)
{
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE);
@@ -976,6 +1009,16 @@ static void webkit_web_view_dispose(GObject* object)
priv->paste_target_list = NULL;
}
+ if (priv->mainResource) {
+ g_object_unref(priv->mainResource);
+ priv->mainResource = NULL;
+ }
+
+ if (priv->subResources) {
+ g_hash_table_unref(priv->subResources);
+ priv->subResources = NULL;
+ }
+
G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
}
@@ -984,6 +1027,7 @@ static void webkit_web_view_finalize(GObject* object)
WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
WebKitWebViewPrivate* priv = webView->priv;
+ g_free(priv->mainResourceIdentifier);
g_free(priv->encoding);
g_free(priv->customEncoding);
@@ -1081,6 +1125,130 @@ static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previou
settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
}
+static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
+{
+ g_object_unref(context);
+}
+
+struct DNDContentsRequest
+{
+ gint info;
+ GtkSelectionData* dnd_selection_data;
+
+ gboolean is_url_label_request;
+ gchar* url;
+};
+
+void clipboard_contents_received(GtkClipboard* clipboard, GtkSelectionData* selection_data, gpointer data)
+{
+ DNDContentsRequest* contents_request = reinterpret_cast<DNDContentsRequest*>(data);
+
+ if (contents_request->is_url_label_request) {
+ // We have received contents of the label clipboard. Use them to form
+ // required structures. When formed, enhance the dnd's selection data
+ // with them and return.
+
+ // If the label is empty, use the url itself.
+ gchar* url_label = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data));
+ if (!url_label)
+ url_label = g_strdup(contents_request->url);
+
+ gchar* data = 0;
+ switch (contents_request->info) {
+ case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST:
+ data = g_strdup_printf("%s\r\n%s\r\n", contents_request->url, url_label);
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL:
+ data = g_strdup_printf("%s\n%s", contents_request->url, url_label);
+ break;
+ }
+
+ if (data) {
+ gtk_selection_data_set(contents_request->dnd_selection_data,
+ contents_request->dnd_selection_data->target, 8,
+ reinterpret_cast<const guchar*>(data), strlen(data));
+ g_free(data);
+ }
+
+ g_free(url_label);
+ g_free(contents_request->url);
+ g_free(contents_request);
+
+ return;
+ }
+
+ switch (contents_request->info) {
+ case WEBKIT_WEB_VIEW_TARGET_INFO_HTML:
+ case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT:
+ {
+ gchar* data = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data));
+ if (data) {
+ gtk_selection_data_set(contents_request->dnd_selection_data,
+ contents_request->dnd_selection_data->target, 8,
+ reinterpret_cast<const guchar*>(data),
+ strlen(data));
+ g_free(data);
+ }
+ break;
+ }
+ case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE:
+ {
+ GdkPixbuf* pixbuf = gtk_selection_data_get_pixbuf(selection_data);
+ if (pixbuf) {
+ gtk_selection_data_set_pixbuf(contents_request->dnd_selection_data, pixbuf);
+ g_object_unref(pixbuf);
+ }
+ break;
+ }
+ case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST:
+ case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL:
+ // URL's label is stored in another clipboard, so we store URL into
+ // contents request, mark the latter as an url label request
+ // and request for contents of the label clipboard.
+ contents_request->is_url_label_request = TRUE;
+ contents_request->url = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data));
+
+ gtk_clipboard_request_contents(gtk_clipboard_get(gdk_atom_intern_static_string("WebKitClipboardUrlLabel")),
+ selection_data->target, clipboard_contents_received, contents_request);
+ break;
+ }
+}
+
+static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data, guint info, guint time_)
+{
+ GdkAtom selection_atom = GDK_NONE;
+ GdkAtom target_atom = selection_data->target;
+
+ switch (info) {
+ case WEBKIT_WEB_VIEW_TARGET_INFO_HTML:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardHtml");
+ // HTML markup data is set as text, therefor, we need a text-like target atom
+ target_atom = gdk_atom_intern_static_string("UTF8_STRING");
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardText");
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardImage");
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST:
+ case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardUrl");
+ // We require URL and label, which are both stored in text format
+ // and are needed to be retrieved as such.
+ target_atom = gdk_atom_intern_static_string("UTF8_STRING");
+ break;
+ }
+
+ DNDContentsRequest* contents_request = g_new(DNDContentsRequest, 1);
+ contents_request->info = info;
+ contents_request->is_url_label_request = FALSE;
+ contents_request->dnd_selection_data = selection_data;
+
+ gtk_clipboard_request_contents(gtk_clipboard_get(selection_atom), target_atom,
+ clipboard_contents_received, contents_request);
+}
+
static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
{
GtkBindingSet* binding_set;
@@ -1104,11 +1272,11 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* The new #WebKitWebView should not be displayed to the user
* until the #WebKitWebView::web-view-ready signal is emitted.
*
- * The signal handlers should not try to deal with the reference
- * count for the new #WebKitWebView. The widget to which the
- * widget is added will handle that.
+ * The signal handlers should not try to deal with the reference count for
+ * the new #WebKitWebView. The widget to which the widget is added will
+ * handle that.
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1137,7 +1305,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* time of the window, so you may want to connect to the ::notify
* signal of the #WebKitWebWindowFeatures object to handle those.
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1154,10 +1322,12 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @return: %TRUE to stop handlers from being invoked for the event or
* %FALSE to propagate the event furter
*
- * Emitted when closing a WebView is requested. This occurs when a call
- * is made from JavaScript's window.close function.
+ * Emitted when closing a #WebKitWebView is requested. This occurs when a
+ * call is made from JavaScript's window.close function. The default
+ * signal handler does not do anything. It is the owner's responsibility
+ * to hide or delete the web view, if necessary.
*
- * Since 1.1.11
+ * Since: 1.1.11
*/
webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1727,6 +1897,44 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_NONE, 0);
/**
+ * WebKitWebView::undo
+ * @web_view: the object which received the signal
+ *
+ * The #WebKitWebView::undo signal is a keybinding signal which gets emitted to
+ * undo the last editing command.
+ *
+ * The default binding for this signal is Ctrl-z
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[UNDO] = g_signal_new("undo",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ G_STRUCT_OFFSET(WebKitWebViewClass, undo),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * WebKitWebView::redo
+ * @web_view: the object which received the signal
+ *
+ * The #WebKitWebView::redo signal is a keybinding signal which gets emitted to
+ * redo the last editing command.
+ *
+ * The default binding for this signal is Ctrl-Shift-z
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[REDO] = g_signal_new("redo",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ G_STRUCT_OFFSET(WebKitWebViewClass, redo),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
* WebKitWebView::move-cursor:
* @web_view: the object which received the signal
* @step: the type of movement, one of #GtkMovementStep
@@ -1774,6 +1982,69 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
GTK_TYPE_WIDGET, 3,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE);
+ /**
+ * WebKitWebView::database-quota-exceeded
+ * @web_view: the object which received the signal
+ * @frame: the relevant frame
+ * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin
+ *
+ * The #WebKitWebView::database-exceeded-quota signal will be emitted when
+ * a Web Database exceeds the quota of its security origin. This signal
+ * may be used to increase the size of the quota before the originating
+ * operation fails.
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[DATABASE_QUOTA_EXCEEDED] = g_signal_new("database-quota-exceeded",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ NULL, NULL,
+ webkit_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ G_TYPE_OBJECT, G_TYPE_OBJECT);
+
+ /**
+ * WebKitWebView::resource-request-starting:
+ * @web_view: the object which received the signal
+ * @web_frame: the #WebKitWebFrame whose load dispatched this request
+ * @web_resource: an empty #WebKitWebResource object
+ * @request: the #WebKitNetworkRequest that will be dispatched
+ * @response: the #WebKitNetworkResponse representing the redirect
+ * response, if any
+ *
+ * Emitted when a request is about to be sent. You can modify the
+ * request while handling this signal. You can set the URI in the
+ * #WebKitNetworkRequest object itself, and add/remove/replace
+ * headers using the #SoupMessage object it carries, if it is
+ * present. See webkit_network_request_get_message(). Setting the
+ * request URI to "about:blank" will effectively cause the request
+ * to load nothing, and can be used to disable the loading of
+ * specific resources.
+ *
+ * Notice that information about an eventual redirect is available
+ * in @response's #SoupMessage, not in the #SoupMessage carried by
+ * the @request. If @response is %NULL, then this is not a
+ * redirected request.
+ *
+ * The #WebKitWebResource object will be the same throughout all
+ * the lifetime of the resource, but the contents may change from
+ * inbetween signal emissions.
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ NULL, NULL,
+ webkit_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT,
+ G_TYPE_NONE, 4,
+ WEBKIT_TYPE_WEB_FRAME,
+ WEBKIT_TYPE_WEB_RESOURCE,
+ WEBKIT_TYPE_NETWORK_REQUEST,
+ WEBKIT_TYPE_NETWORK_RESPONSE);
+
/*
* implementations of virtual methods
*/
@@ -1791,6 +2062,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard;
webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
+ webViewClass->undo = webkit_web_view_real_undo;
+ webViewClass->redo = webkit_web_view_real_redo;
webViewClass->move_cursor = webkit_web_view_real_move_cursor;
GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
@@ -1816,6 +2089,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
widgetClass->focus_out_event = webkit_web_view_focus_out_event;
widgetClass->get_accessible = webkit_web_view_get_accessible;
widgetClass->screen_changed = webkit_web_view_screen_changed;
+ widgetClass->drag_end = webkit_web_view_drag_end;
+ widgetClass->drag_data_get = webkit_web_view_drag_data_get;
GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
containerClass->add = webkit_web_view_container_add;
@@ -1852,6 +2127,10 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
"copy_clipboard", 0);
gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK,
"paste_clipboard", 0);
+ gtk_binding_entry_add_signal(binding_set, GDK_z, GDK_CONTROL_MASK,
+ "undo", 0);
+ gtk_binding_entry_add_signal(binding_set, GDK_z, static_cast<GdkModifierType>(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
+ "redo", 0);
gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK,
"cut_clipboard", 0);
@@ -2112,7 +2391,10 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
gboolean autoLoadImages, autoShrinkImages, printBackgrounds,
enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas,
enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage,
- enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache;
+ enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache,
+ enableUniversalAccessFromFileURI;
+
+ WebKitEditingBehavior editingBehavior;
g_object_get(webSettings,
"default-encoding", &defaultEncoding,
@@ -2137,6 +2419,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
"enable-xss-auditor", &enableXSSAuditor,
"javascript-can-open-windows-automatically", &javascriptCanOpenWindows,
"enable-offline-web-application-cache", &enableOfflineWebAppCache,
+ "editing-behavior", &editingBehavior,
+ "enable-universal-access-from-file-uris", &enableUniversalAccessFromFileURI,
NULL);
settings->setDefaultTextEncodingName(defaultEncoding);
@@ -2161,6 +2445,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
settings->setXSSAuditorEnabled(enableXSSAuditor);
settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows);
settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache);
+ settings->setEditingBehavior(core(editingBehavior));
+ settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI);
g_free(defaultEncoding);
g_free(cursiveFontFamily);
@@ -2243,6 +2529,10 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value));
else if (name == g_intern_string("enable-offline-web-application-cache"))
settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value));
+ else if (name == g_intern_string("editing-behavior"))
+ settings->setEditingBehavior(core(static_cast<WebKitEditingBehavior>(g_value_get_enum(&value))));
+ else if (name == g_intern_string("enable-universal-access-from-file-uris"))
+ settings->setAllowUniversalAccessFromFileURLs(g_value_get_boolean(&value));
else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name))
g_warning("Unexpected setting '%s'", name);
g_value_unset(&value);
@@ -2256,7 +2546,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->imContext = gtk_im_multicontext_new();
WebKit::InspectorClient* inspectorClient = new WebKit::InspectorClient(webView);
- priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient, inspectorClient);
+ priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient(webView), inspectorClient, 0);
// We also add a simple wrapper class to provide the public
// interface for the Web Inspector.
@@ -2294,6 +2584,8 @@ static void webkit_web_view_init(WebKitWebView* webView)
g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
priv->webWindowFeatures = webkit_web_window_features_new();
+
+ priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
}
GtkWidget* webkit_web_view_new(void)
@@ -2312,14 +2604,16 @@ void webkit_web_view_notify_ready(WebKitWebView* webView)
g_signal_emit(webView, webkit_web_view_signals[WEB_VIEW_READY], 0, &isHandled);
}
-void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response)
+void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response, ResourceHandle* handle)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
- WebKitDownload* download = webkit_download_new(request);
+ WebKitDownload* download;
- if (!response.isNull() && !response.suggestedFilename().isEmpty())
- webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data());
+ if (handle)
+ download = webkit_download_new_with_handle(request, handle, response);
+ else
+ download = webkit_download_new(request);
gboolean handled;
g_signal_emit(webView, webkit_web_view_signals[DOWNLOAD_REQUESTED], 0, download, &handled);
@@ -2535,8 +2829,7 @@ void webkit_web_view_go_back_or_forward(WebKitWebView* webView, gint steps)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
- Frame* frame = core(webView)->mainFrame();
- frame->loader()->goBackOrForward(steps);
+ core(webView)->goBackOrForward(steps);
}
/**
@@ -2585,8 +2878,7 @@ gboolean webkit_web_view_can_go_back_or_forward(WebKitWebView* webView, gint ste
{
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
- Frame* frame = core(webView)->mainFrame();
- return frame->loader()->canGoBackOrForward(steps);
+ return core(webView)->canGoBackOrForward(steps);
}
/**
@@ -2740,6 +3032,12 @@ void webkit_web_view_load_request(WebKitWebView* webView, WebKitNetworkRequest*
webkit_web_frame_load_request(frame, request);
}
+/**
+ * webkit_web_view_stop_loading:
+ * @webView: a #WebKitWebView
+ *
+ * Stops any ongoing load in the @webView.
+ **/
void webkit_web_view_stop_loading(WebKitWebView* webView)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
@@ -2747,7 +3045,7 @@ void webkit_web_view_stop_loading(WebKitWebView* webView)
Frame* frame = core(webView)->mainFrame();
if (FrameLoader* loader = frame->loader())
- loader->stopAllLoaders();
+ loader->stopForUserCancel();
}
/**
@@ -2805,7 +3103,11 @@ void webkit_web_view_set_highlight_text_matches(WebKitWebView* webView, gboolean
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
- core(webView)->mainFrame()->setMarkedTextMatchesAreHighlighted(shouldHighlight);
+ Frame *frame = core(webView)->mainFrame();
+ do {
+ frame->setMarkedTextMatchesAreHighlighted(shouldHighlight);
+ frame = frame->tree()->traverseNextWithWrap(false);
+ } while (frame);
}
/**
@@ -3462,3 +3764,205 @@ void webkit_web_view_set_group_name(WebKitWebView* webView, const gchar* groupNa
priv->corePage->setGroupName(String::fromUTF8(groupName));
}
+
+/**
+ * webkit_web_view_can_undo:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines whether or not it is currently possible to undo the last
+ * editing command in the view.
+ *
+ * Return value: %TRUE if a undo can be done, %FALSE if not
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_view_can_undo(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ return frame->editor()->canUndo();
+}
+
+/**
+ * webkit_web_view_undo:
+ * @web_view: a #WebKitWebView
+ *
+ * Undoes the last editing command in the view, if possible.
+ *
+ * Since: 1.1.14
+ */
+void webkit_web_view_undo(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ if (webkit_web_view_can_undo(webView))
+ g_signal_emit(webView, webkit_web_view_signals[UNDO], 0);
+}
+
+/**
+ * webkit_web_view_can_redo:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines whether or not it is currently possible to redo the last
+ * editing command in the view.
+ *
+ * Return value: %TRUE if a redo can be done, %FALSE if not
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_view_can_redo(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ return frame->editor()->canRedo();
+}
+
+/**
+ * webkit_web_view_redo:
+ * @web_view: a #WebKitWebView
+ *
+ * Redoes the last editing command in the view, if possible.
+ *
+ * Since: 1.1.14
+ */
+void webkit_web_view_redo(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ if (webkit_web_view_can_redo(webView))
+ g_signal_emit(webView, webkit_web_view_signals[REDO], 0);
+}
+
+
+/**
+ * webkit_web_view_set_view_source_mode:
+ * @web_view: a #WebKitWebView
+ * @view_source_mode: the mode to turn on or off view source mode
+ *
+ * Set whether the view should be in view source mode. Setting this mode to
+ * %TRUE before loading a URI will display the source of the web page in a
+ * nice and readable format.
+ *
+ * Since: 1.1.14
+ */
+void webkit_web_view_set_view_source_mode (WebKitWebView* webView, gboolean mode)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ if (Frame* mainFrame = core(webView)->mainFrame())
+ mainFrame->setInViewSourceMode(mode);
+}
+
+/**
+ * webkit_web_view_get_view_source_mode:
+ * @web_view: a #WebKitWebView
+ *
+ * Return value: %TRUE if @web_view is in view source mode, %FALSE otherwise.
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_view_get_view_source_mode (WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ if (Frame* mainFrame = core(webView)->mainFrame())
+ return mainFrame->inViewSourceMode();
+
+ return FALSE;
+}
+
+// Internal subresource management
+void webkit_web_view_add_resource(WebKitWebView* webView, char* identifier, WebKitWebResource* webResource)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ if (!priv->mainResource) {
+ priv->mainResource = webResource;
+ priv->mainResourceIdentifier = g_strdup(identifier);
+ return;
+ }
+
+ g_hash_table_insert(priv->subResources, identifier, webResource);
+}
+
+WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* identifier)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ gpointer webResource = NULL;
+
+ gboolean resourceFound = g_hash_table_lookup_extended(priv->subResources, identifier, NULL, &webResource);
+
+ // The only resource we do not store in this hash table is the main!
+ g_return_val_if_fail(resourceFound || g_str_equal(identifier, priv->mainResourceIdentifier), NULL);
+
+ if (!webResource)
+ return webkit_web_view_get_main_resource(webView);
+
+ return WEBKIT_WEB_RESOURCE(webResource);
+}
+
+WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView* webView)
+{
+ return webView->priv->mainResource;
+}
+
+void webkit_web_view_clear_resources(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ g_free(priv->mainResourceIdentifier);
+ priv->mainResourceIdentifier = NULL;
+
+ if (priv->mainResource) {
+ g_object_unref(priv->mainResource);
+ priv->mainResource = NULL;
+ }
+
+ if (priv->subResources)
+ g_hash_table_remove_all(priv->subResources);
+}
+
+GList* webkit_web_view_get_subresources(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ GList* subResources = g_hash_table_get_values(priv->subResources);
+ return g_list_remove(subResources, priv->mainResource);
+}
+
+/* From EventHandler.cpp */
+static IntPoint documentPointForWindowPoint(Frame* frame, const IntPoint& windowPoint)
+{
+ FrameView* view = frame->view();
+ // FIXME: Is it really OK to use the wrong coordinates here when view is 0?
+ // Historically the code would just crash; this is clearly no worse than that.
+ return view ? view->windowToContents(windowPoint) : windowPoint;
+}
+
+/**
+ * webkit_web_view_get_hit_test_result:
+ * @webView: a #WebKitWebView
+ * @event: a #GdkEventButton
+ *
+ * Does a 'hit test' in the coordinates specified by @event to figure
+ * out context information about that position in the @webView.
+ *
+ * Returns: a newly created #WebKitHitTestResult with the context of the
+ * specified position.
+ *
+ * Since: 1.1.15
+ **/
+WebKitHitTestResult* webkit_web_view_get_hit_test_result(WebKitWebView* webView, GdkEventButton* event)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
+ g_return_val_if_fail(event, NULL);
+
+ PlatformMouseEvent mouseEvent = PlatformMouseEvent(event);
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ HitTestRequest request(HitTestRequest::Active);
+ IntPoint documentPoint = documentPointForWindowPoint(frame, mouseEvent.pos());
+ MouseEventWithHitTestResults mev = frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
+
+ return kit(mev.hitTestResult());
+}
diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h
index fbdefa8..1297695 100644
--- a/WebKit/gtk/webkit/webkitwebview.h
+++ b/WebKit/gtk/webkit/webkitwebview.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_VIEW_H
-#define WEBKIT_WEB_VIEW_H
+#ifndef webkitwebview_h
+#define webkitwebview_h
#include <gtk/gtk.h>
#include <libsoup/soup.h>
@@ -52,7 +52,10 @@ typedef enum {
typedef enum
{
WEBKIT_WEB_VIEW_TARGET_INFO_HTML,
- WEBKIT_WEB_VIEW_TARGET_INFO_TEXT
+ WEBKIT_WEB_VIEW_TARGET_INFO_TEXT,
+ WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE,
+ WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST,
+ WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL
} WebKitWebViewTargetInfo;
struct _WebKitWebView {
@@ -116,13 +119,15 @@ struct _WebKitWebViewClass {
void (* set_scroll_adjustments) (WebKitWebView *web_view,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
+
+ void (* undo) (WebKitWebView *web_view);
+ void (* redo) (WebKitWebView *web_view);
+
/* Padding for future expansion */
void (*_webkit_reserved0) (void);
void (*_webkit_reserved1) (void);
void (*_webkit_reserved2) (void);
void (*_webkit_reserved3) (void);
- void (*_webkit_reserved4) (void);
- void (*_webkit_reserved5) (void);
};
WEBKIT_API GType
@@ -339,6 +344,28 @@ webkit_web_view_get_load_status (WebKitWebView *web_view)
WEBKIT_API gdouble
webkit_web_view_get_progress (WebKitWebView *web_view);
+WEBKIT_API void
+webkit_web_view_undo (WebKitWebView *webView);
+
+WEBKIT_API gboolean
+webkit_web_view_can_undo (WebKitWebView *webView);
+
+WEBKIT_API void
+webkit_web_view_redo (WebKitWebView *webView);
+
+WEBKIT_API gboolean
+webkit_web_view_can_redo (WebKitWebView *webView);
+
+WEBKIT_API void
+webkit_web_view_set_view_source_mode (WebKitWebView *web_view,
+ gboolean view_source_mode);
+
+WEBKIT_API gboolean
+webkit_web_view_get_view_source_mode (WebKitWebView *web_view);
+
+WEBKIT_API WebKitHitTestResult*
+webkit_web_view_get_hit_test_result (WebKitWebView *webView,
+ GdkEventButton *event);
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
index 47610d3..cdb6858 100644
--- a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
+++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
@@ -371,7 +371,7 @@ static void webkit_web_window_features_get_property(GObject* object, guint prop_
*
* Returns: a new #WebKitWebWindowFeatures instance
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
WebKitWebWindowFeatures* webkit_web_window_features_new()
{
@@ -418,7 +418,7 @@ WebKitWebWindowFeatures* webkit_web_window_features_new_from_core_features(const
* Returns: %TRUE if the instances have the same values, %FALSE
* otherwise
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
gboolean webkit_web_window_features_equal(WebKitWebWindowFeatures* features1, WebKitWebWindowFeatures* features2)
{
diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.h b/WebKit/gtk/webkit/webkitwebwindowfeatures.h
index cd28988..a79119d 100644
--- a/WebKit/gtk/webkit/webkitwebwindowfeatures.h
+++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_WINDOW_FEATURES_H
-#define WEBKIT_WEB_WINDOW_FEATURES_H
+#ifndef webkitwebwindowfeatures_h
+#define webkitwebwindowfeatures_h
#include <glib-object.h>
@@ -65,4 +65,4 @@ webkit_web_window_features_equal (WebKitWebWindowFeatures* feature
G_END_DECLS
-#endif /* WEBKIT_WEB_WINDOW_FEATURES_H */
+#endif /* webkitwebwindowfeatures_h */
diff --git a/WebKit/gtk/webkit/webkitworkers.cpp b/WebKit/gtk/webkit/webkitworkers.cpp
new file mode 100644
index 0000000..255863c
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitworkers.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "webkitprivate.h"
+
+#include "WorkerThread.h"
+
+unsigned int webkit_worker_thread_count(void)
+{
+#if ENABLE(WORKERS)
+ return WebCore::WorkerThread::workerThreadCount();
+#else
+ return 0;
+#endif
+}
+
+