Diff
Modified: trunk/Source/WebKit2/ChangeLog (154539 => 154540)
--- trunk/Source/WebKit2/ChangeLog 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/ChangeLog 2013-08-24 08:44:44 UTC (rev 154540)
@@ -1,3 +1,70 @@
+2013-08-24 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Expose WebKitFrame in WebKit2GTK+ web extensions API
+ https://bugs.webkit.org/show_bug.cgi?id=119743
+
+ Reviewed by Anders Carlsson.
+
+ * GNUmakefile.list.am: Add new files to compilation.
+ * Shared/APIClientTraits.cpp: Update for new interface version.
+ * Shared/APIClientTraits.h: Ditto.
+ * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add WebKitFrame
+ section.
+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new public
+ symbols.
+ * UIProcess/API/gtk/docs/webkit2gtk.types: Add
+ webkit_frame_get_type.
+ * UIProcess/API/gtk/tests/FrameTest.cpp: Added.
+ (WebKitFrameTest::create):
+ (WebKitFrameTest::webPageFromArgs):
+ (WebKitFrameTest::testMainFrame):
+ (WebKitFrameTest::testURI):
+ (WebKitFrameTest::testJavaScriptContext):
+ (WebKitFrameTest::runTest):
+ (registerTests):
+ * UIProcess/API/gtk/tests/GNUmakefile.am: Add new test files.
+ * UIProcess/API/gtk/tests/TestFrame.cpp: Added.
+ (webkitFrameTestRun):
+ (testWebKitFrameMainFrame):
+ (testWebKitFrameURI):
+ (testWebKitFrameJavaScriptContext):
+ (beforeAll):
+ (afterAll):
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Add
+ willDestroyFrame callback to the injected bundle loader client, to
+ notify the client when a frame is about to be destroyed.
+ * WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp: Added.
+ (webkit_frame_class_init):
+ (webkitFrameCreate):
+ (webkit_frame_is_main_frame):
+ (webkit_frame_get_uri):
+ (webkit_frame_get_javascript_global_context):
+ * WebProcess/InjectedBundle/API/gtk/WebKitFrame.h: Added.
+ * WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h: Added.
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
+ (webkitFrameGetOrCreate): Helper function to create a WebKitFrame
+ wrapping the given WebFrame or returning the wrapper if it already
+ exists.
+ (willDestroyFrame): Remove the WebKitFrame wrapping the given
+ WebFrame if it exists.
+ (webkitWebPageCreate): Add willDestroyFrame implementation to
+ injected bundle loader client.
+ (webkit_web_page_get_main_frame): Return the main frame of the
+ page.
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h:
+ * WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h:
+ Include WebKitFrame.h.
+ * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
+ (WebKit::InjectedBundlePageLoaderClient::willDestroyFrame): New
+ callback to be called when a frame is about to be destroyed.
+ * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::frameLoaderDestroyed): Call
+ willDestroyFrame callback of injected bundle loader client.
+ * WebProcess/qt/QtBuiltinBundlePage.cpp:
+ (WebKit::QtBuiltinBundlePage::QtBuiltinBundlePage): Add
+ willDestroyFrame callback.
+
2013-08-24 Antti Koivisto <[email protected]>
Revert accidental change.
Modified: trunk/Source/WebKit2/GNUmakefile.list.am (154539 => 154540)
--- trunk/Source/WebKit2/GNUmakefile.list.am 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/GNUmakefile.list.am 2013-08-24 08:44:44 UTC (rev 154540)
@@ -138,6 +138,7 @@
webkit2_web_extension_h_api += \
$(WebKit2)/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h \
+ $(WebKit2)/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h \
$(WebKit2)/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h \
$(WebKit2)/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h
@@ -1059,6 +1060,9 @@
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h \
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp \
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h \
+ Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp \
+ Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h \
+ Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h \
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp \
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h \
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionPrivate.h \
Modified: trunk/Source/WebKit2/Shared/APIClientTraits.cpp (154539 => 154540)
--- trunk/Source/WebKit2/Shared/APIClientTraits.cpp 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -43,6 +43,7 @@
offsetof(WKBundlePageLoaderClient, registerIntentServiceForFrame_unavailable),
offsetof(WKBundlePageLoaderClient, didLayout),
offsetof(WKBundlePageLoaderClient, featuresUsedInPage),
+ offsetof(WKBundlePageLoaderClient, willLoadDataRequest),
sizeof(WKBundlePageLoaderClient)
};
Modified: trunk/Source/WebKit2/Shared/APIClientTraits.h (154539 => 154540)
--- trunk/Source/WebKit2/Shared/APIClientTraits.h 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.h 2013-08-24 08:44:44 UTC (rev 154540)
@@ -44,7 +44,7 @@
};
template<> struct APIClientTraits<WKBundlePageLoaderClient> {
- static const size_t interfaceSizesByVersion[7];
+ static const size_t interfaceSizesByVersion[8];
};
template<> struct APIClientTraits<WKBundlePageResourceLoadClient> {
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (154539 => 154540)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2013-08-24 08:44:44 UTC (rev 154540)
@@ -49,6 +49,7 @@
<title>Web Extensions</title>
<xi:include href=""
<xi:include href=""
+ <xi:include href=""
</chapter>
<index id="index-all">
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (154539 => 154540)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2013-08-24 08:44:44 UTC (rev 154540)
@@ -1040,6 +1040,7 @@
webkit_web_page_get_dom_document
webkit_web_page_get_id
webkit_web_page_get_uri
+webkit_web_page_get_main_frame
<SUBSECTION Standard>
WebKitWebPageClass
@@ -1054,3 +1055,24 @@
WebKitWebPagePrivate
webkit_web_page_get_type
</SECTION>
+
+<SECTION>
+<FILE>WebKitFrame</FILE>
+WebKitFrame
+webkit_frame_is_main_frame
+webkit_frame_get_uri
+webkit_frame_get_javascript_global_context
+
+<SUBSECTION Standard>
+WebKitFrameClass
+WEBKIT_TYPE_FRAME
+WEBKIT_FRAME
+WEBKIT_IS_FRAME
+WEBKIT_FRAME_CLASS
+WEBKIT_IS_FRAME_CLASS
+WEBKIT_FRAME_GET_CLASS
+
+<SUBSECTION Private>
+WebKitFramePrivate
+webkit_frame_get_type
+</SECTION>
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types (154539 => 154540)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types 2013-08-24 08:44:44 UTC (rev 154540)
@@ -25,4 +25,5 @@
webkit_web_extension_get_type
webkit_web_page_get_type
webkit_authentication_request_get_type
-webkit_credential_get_type
\ No newline at end of file
+webkit_credential_get_type
+webkit_frame_get_type
Added: trunk/Source/WebKit2/UIProcess/API/gtk/tests/FrameTest.cpp (0 => 154540)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/FrameTest.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/FrameTest.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2013 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 "WebProcessTest.h"
+#include <gio/gio.h>
+#include <webkit2/webkit-web-extension.h>
+
+class WebKitFrameTest : public WebProcessTest {
+public:
+ static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitFrameTest()); }
+
+private:
+ guint64 webPageFromArgs(GVariant* args)
+ {
+ GVariantIter iter;
+ g_variant_iter_init(&iter, args);
+
+ const char* key;
+ GVariant* value;
+ while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
+ if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
+ return g_variant_get_uint64(value);
+ }
+
+ g_assert_not_reached();
+ return 0;
+ }
+
+ bool testMainFrame(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+
+ WebKitFrame* frame = webkit_web_page_get_main_frame(page);
+ g_assert(WEBKIT_IS_FRAME(frame));
+ g_assert(webkit_frame_is_main_frame(frame));
+
+ return true;
+ }
+
+ bool testURI(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+
+ WebKitFrame* frame = webkit_web_page_get_main_frame(page);
+ g_assert(WEBKIT_IS_FRAME(frame));
+ g_assert_cmpstr(webkit_web_page_get_uri(page), ==, webkit_frame_get_uri(frame));
+
+ return true;
+ }
+
+ bool testJavaScriptContext(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+
+ WebKitFrame* frame = webkit_web_page_get_main_frame(page);
+ g_assert(WEBKIT_IS_FRAME(frame));
+ g_assert(webkit_frame_get_javascript_global_context(frame));
+
+ return true;
+ }
+
+ virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+ {
+ if (!strcmp(testName, "main-frame"))
+ return testMainFrame(extension, args);
+ if (!strcmp(testName, "uri"))
+ return testURI(extension, args);
+ if (!strcmp(testName, "_javascript_-context"))
+ return testJavaScriptContext(extension, args);
+
+ g_assert_not_reached();
+ return false;
+ }
+};
+
+static void __attribute__((constructor)) registerTests()
+{
+ REGISTER_TEST(WebKitFrameTest, "WebKitFrame/main-frame");
+ REGISTER_TEST(WebKitFrameTest, "WebKitFrame/uri");
+ REGISTER_TEST(WebKitFrameTest, "WebKitFrame/_javascript_-context");
+}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am (154539 => 154540)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am 2013-08-24 08:44:44 UTC (rev 154540)
@@ -7,6 +7,7 @@
Programs/WebKit2APITests/TestCookieManager \
Programs/WebKit2APITests/TestDOMNode \
Programs/WebKit2APITests/TestDownloads \
+ Programs/WebKit2APITests/TestFrame \
Programs/WebKit2APITests/TestInspector \
Programs/WebKit2APITests/TestInspectorServer \
Programs/WebKit2APITests/TestLoaderClient \
@@ -126,6 +127,7 @@
noinst_LTLIBRARIES += Libraries/WebExtensions/libWebProcessTest.la
Libraries_WebExtensions_libWebProcessTest_la_SOURCES = \
Source/WebKit2/UIProcess/API/gtk/tests/DOMNodeTest.cpp \
+ Source/WebKit2/UIProcess/API/gtk/tests/FrameTest.cpp \
Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.cpp \
Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.h
@@ -303,4 +305,10 @@
Programs_WebKit2APITests_TestDOMNode_LDADD = $(webkit2_tests_ldadd)
Programs_WebKit2APITests_TestDOMNode_LDFLAGS = $(webkit2_tests_ldflags)
+Programs_WebKit2APITests_TestFrame_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestFrame.cpp
+Programs_WebKit2APITests_TestFrame_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestFrame_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestFrame_LDFLAGS = $(webkit2_tests_ldflags)
+
endif # ENABLE_WEBKIT2
Added: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestFrame.cpp (0 => 154540)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestFrame.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestFrame.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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 "WebProcessTestRunner.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static WebProcessTestRunner* testRunner;
+
+static void webkitFrameTestRun(WebViewTest* test, const char* testName)
+{
+ static const char* testHTML = "<html><body></body></html>";
+ test->loadHtml(testHTML, 0);
+ test->waitUntilLoadFinished();
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
+ g_assert(testRunner->runTest("WebKitFrame", testName, g_variant_builder_end(&builder)));
+}
+
+static void testWebKitFrameMainFrame(WebViewTest* test, gconstpointer)
+{
+ webkitFrameTestRun(test, "main-frame");
+}
+
+static void testWebKitFrameURI(WebViewTest* test, gconstpointer)
+{
+ webkitFrameTestRun(test, "uri");
+}
+
+static void testWebKitFrameJavaScriptContext(WebViewTest* test, gconstpointer)
+{
+ webkitFrameTestRun(test, "_javascript_-context");
+}
+
+void beforeAll()
+{
+ testRunner = new WebProcessTestRunner();
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+
+ WebViewTest::add("WebKitFrame", "main-frame", testWebKitFrameMainFrame);
+ WebViewTest::add("WebKitFrame", "uri", testWebKitFrameURI);
+ WebViewTest::add("WebKitFrame", "_javascript_-context", testWebKitFrameJavaScriptContext);
+}
+
+void afterAll()
+{
+ delete testRunner;
+}
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2013-08-24 08:44:44 UTC (rev 154540)
@@ -112,6 +112,7 @@
typedef void (*WKBundlePageFeaturesUsedInPageCallback)(WKBundlePageRef page, WKArrayRef featureStrings, const void *clientInfo);
typedef void (*WKBundlePageWillLoadURLRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKTypeRef userData, const void *clientInfo);
typedef void (*WKBundlePageWillLoadDataRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKBundlePageWillDestroyFrame)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
struct WKBundlePageLoaderClient {
int version;
@@ -164,10 +165,13 @@
// Version 6
WKBundlePageWillLoadURLRequestCallback willLoadURLRequest;
WKBundlePageWillLoadDataRequestCallback willLoadDataRequest;
+
+ // Version 7
+ WKBundlePageWillDestroyFrame willDestroyFrame;
};
typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
-enum { kWKBundlePageLoaderClientCurrentVersion = 6 };
+enum { kWKBundlePageLoaderClientCurrentVersion = 7 };
enum {
WKBundlePagePolicyActionPassThrough,
Added: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp (0 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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 "WebKitFrame.h"
+
+#include "WebKitFramePrivate.h"
+#include "WebKitPrivate.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+struct _WebKitFramePrivate {
+ RefPtr<WebFrame> webFrame;
+
+ CString uri;
+};
+
+WEBKIT_DEFINE_TYPE(WebKitFrame, webkit_frame, G_TYPE_OBJECT)
+
+static void webkit_frame_class_init(WebKitFrameClass* klass)
+{
+}
+
+WebKitFrame* webkitFrameCreate(WebFrame* webFrame)
+{
+ WebKitFrame* frame = WEBKIT_FRAME(g_object_new(WEBKIT_TYPE_FRAME, NULL));
+ frame->priv->webFrame = webFrame;
+ return frame;
+}
+
+/**
+ * webkit_frame_is_main_frame:
+ * @frame: a #WebKitFrame
+ *
+ * Gets whether @frame is the a main frame of a #WebKitWebPage
+ *
+ * Returns: %TRUE if @frame is a main frame or %FALSE otherwise
+ *
+ * Since: 2.2
+ */
+gboolean webkit_frame_is_main_frame(WebKitFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_FRAME(frame), FALSE);
+
+ return frame->priv->webFrame->isMainFrame();
+}
+
+/**
+ * webkit_frame_get_uri:
+ * @frame: a #WebKitFrame
+ *
+ * Gets the current active URI of @frame.
+ *
+ * Returns: the current active URI of @frame or %NULL if nothing has been
+ * loaded yet.
+ *
+ * Since: 2.2
+ */
+const gchar* webkit_frame_get_uri(WebKitFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_FRAME(frame), 0);
+
+ if (frame->priv->uri.isNull())
+ frame->priv->uri = frame->priv->webFrame->url().utf8();
+
+ return frame->priv->uri.data();
+}
+
+/**
+ * webkit_frame_get_javascript_global_context:
+ * @frame: a #WebKitFrame
+ *
+ * Gets the global _javascript_ execution context. Use this function to bridge
+ * between the WebKit and _javascript_Core APIs.
+ *
+ * Returns: (transfer none): the global _javascript_ context of @frame
+ *
+ * Since: 2.2
+ */
+JSGlobalContextRef webkit_frame_get_javascript_global_context(WebKitFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_FRAME(frame), 0);
+
+ return frame->priv->webFrame->jsContext();
+}
Added: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h (0 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h 2013-08-24 08:44:44 UTC (rev 154540)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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.
+ */
+
+#if !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit-web-extension.h> can be included directly."
+#endif
+
+#ifndef WebKitFrame_h
+#define WebKitFrame_h
+
+#include <_javascript_Core/JSBase.h>
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_FRAME (webkit_frame_get_type())
+#define WEBKIT_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FRAME, WebKitFrame))
+#define WEBKIT_IS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FRAME))
+#define WEBKIT_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FRAME, WebKitFrameClass))
+#define WEBKIT_IS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FRAME))
+#define WEBKIT_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FRAME, WebKitFrameClass))
+
+typedef struct _WebKitFrame WebKitFrame;
+typedef struct _WebKitFrameClass WebKitFrameClass;
+typedef struct _WebKitFramePrivate WebKitFramePrivate;
+
+struct _WebKitFrame {
+ GObject parent;
+
+ WebKitFramePrivate *priv;
+};
+
+struct _WebKitFrameClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_frame_get_type (void);
+
+WEBKIT_API gboolean
+webkit_frame_is_main_frame (WebKitFrame *frame);
+
+WEBKIT_API const gchar *
+webkit_frame_get_uri (WebKitFrame *frame);
+
+WEBKIT_API JSGlobalContextRef
+webkit_frame_get_javascript_global_context (WebKitFrame *frame);
+
+G_END_DECLS
+
+#endif
Copied: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h (from rev 154539, trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h) (0 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitFramePrivate.h 2013-08-24 08:44:44 UTC (rev 154540)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2013 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 WebKitFramePrivate_h
+#define WebKitFramePrivate_h
+
+#include "WebFrame.h"
+#include "WebKitFrame.h"
+
+WebKitFrame* webkitFrameCreate(WebKit::WebFrame*);
+
+#endif // WebKitFramePrivate_h
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -25,9 +25,9 @@
#include "InjectedBundle.h"
#include "WKBundleAPICast.h"
#include "WKBundleFrame.h"
-#include "WebFrame.h"
#include "WebImage.h"
#include "WebKitDOMDocumentPrivate.h"
+#include "WebKitFramePrivate.h"
#include "WebKitMarshal.h"
#include "WebKitPrivate.h"
#include "WebKitURIRequestPrivate.h"
@@ -39,6 +39,7 @@
#include <WebCore/Frame.h>
#include <WebCore/FrameView.h>
#include <glib/gi18n-lib.h>
+#include <wtf/NeverDestroyed.h>
#include <wtf/text/CString.h>
using namespace WebKit;
@@ -67,6 +68,26 @@
WEBKIT_DEFINE_TYPE(WebKitWebPage, webkit_web_page, G_TYPE_OBJECT)
+typedef HashMap<WebFrame*, GRefPtr<WebKitFrame>> WebFrameMap;
+
+static WebFrameMap& webFrameMap()
+{
+ static NeverDestroyed<WebFrameMap> map;
+ return map;
+}
+
+static WebKitFrame* webkitFrameGetOrCreate(WebFrame* webFrame)
+{
+ GRefPtr<WebKitFrame> frame = webFrameMap().get(webFrame);
+ if (frame)
+ return frame.get();
+
+ frame = adoptGRef(webkitFrameCreate(webFrame));
+ webFrameMap().set(webFrame, frame);
+
+ return frame.get();
+}
+
static CString getProvisionalURLForFrame(WebFrame* webFrame)
{
DocumentLoader* documentLoader = webFrame->coreFrame()->loader().provisionalDocumentLoader();
@@ -117,6 +138,11 @@
g_signal_emit(WEBKIT_WEB_PAGE(clientInfo), signals[DOCUMENT_LOADED], 0);
}
+static void willDestroyFrame(WKBundlePageRef, WKBundleFrameRef frame, const void *clientInfo)
+{
+ webFrameMap().remove(toImpl(frame));
+}
+
static void didInitiateLoadForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, bool pageLoadIsProvisional, const void*)
{
ImmutableDictionary::MapType message;
@@ -311,8 +337,9 @@
0, // registerIntentServiceForFrame_unavailable
0, // didLayout
0, // featuresUsedInPage
- 0, // willLoadURLRequest;
- 0, // willLoadDataRequest;
+ 0, // willLoadURLRequest
+ 0, // willLoadDataRequest
+ willDestroyFrame
};
WKBundlePageSetPageLoaderClient(toAPI(webPage), &loaderClient);
@@ -420,3 +447,10 @@
return webPage->priv->uri.data();
}
+
+WebKitFrame* webkit_web_page_get_main_frame(WebKitWebPage* webPage)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_PAGE(webPage), 0);
+
+ return webkitFrameGetOrCreate(webPage->priv->webPage->mainWebFrame());
+}
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h 2013-08-24 08:44:44 UTC (rev 154540)
@@ -26,6 +26,7 @@
#include <glib-object.h>
#include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitFrame.h>
#include <webkitdom/webkitdom.h>
G_BEGIN_DECLS
@@ -61,8 +62,11 @@
webkit_web_page_get_id (WebKitWebPage *web_page);
WEBKIT_API const gchar *
-webkit_web_page_get_uri (WebKitWebPage *web_page);
+webkit_web_page_get_uri (WebKitWebPage *web_page);
+WEBKIT_API WebKitFrame *
+webkit_web_page_get_main_frame (WebKitWebPage *web_page);
+
G_END_DECLS
#endif
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h 2013-08-24 08:44:44 UTC (rev 154540)
@@ -22,6 +22,7 @@
#define __WEBKIT_WEB_EXTENSION_H_INSIDE__
+#include <webkit2/WebKitFrame.h>
#include <webkit2/WebKitURIRequest.h>
#include <webkit2/WebKitURIResponse.h>
#include <webkit2/WebKitWebExtension.h>
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -352,4 +352,12 @@
return m_client.featuresUsedInPage(toAPI(page), toAPI(featureStringObjectsArray.get()), m_client.clientInfo);
}
+void InjectedBundlePageLoaderClient::willDestroyFrame(WebPage* page, WebFrame* frame)
+{
+ if (!m_client.willDestroyFrame)
+ return;
+
+ m_client.willDestroyFrame(toAPI(page), toAPI(frame), m_client.clientInfo);
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h 2013-08-24 08:44:44 UTC (rev 154540)
@@ -90,6 +90,8 @@
bool shouldForceUniversalAccessFromLocalURL(WebPage*, const String& url);
void featuresUsedInPage(WebPage*, const Vector<String>&);
+
+ void willDestroyFrame(WebPage*, WebFrame*);
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -95,6 +95,9 @@
void WebFrameLoaderClient::frameLoaderDestroyed()
{
+ if (WebPage* webPage = m_frame->page())
+ webPage->injectedBundleLoaderClient().willDestroyFrame(webPage, m_frame);
+
m_frame->invalidate();
// Balances explicit ref() in WebFrame::createMainFrame and WebFrame::createSubframe.
Modified: trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp (154539 => 154540)
--- trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -82,6 +82,7 @@
0, // featuresUsedInPage
0, // willLoadURLRequest
0, // willLoadDataRequest
+ 0, // willDestroyFrame
};
WKBundlePageSetPageLoaderClient(m_page, &loaderClient);
}
Modified: trunk/Tools/ChangeLog (154539 => 154540)
--- trunk/Tools/ChangeLog 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Tools/ChangeLog 2013-08-24 08:44:44 UTC (rev 154540)
@@ -1,3 +1,14 @@
+2013-08-24 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Expose WebKitFrame in WebKit2GTK+ web extensions API
+ https://bugs.webkit.org/show_bug.cgi?id=119743
+
+ Reviewed by Anders Carlsson.
+
+ * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+ (WTR::InjectedBundlePage::InjectedBundlePage): Add
+ willDestroyFrame.
+
2013-08-23 Thiago de Barros Lacerda <[email protected]>
Move TestWebKitAPI_LIBRARIES before platform specific cmake include
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (154539 => 154540)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp 2013-08-24 07:41:52 UTC (rev 154539)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp 2013-08-24 08:44:44 UTC (rev 154540)
@@ -309,6 +309,7 @@
0, // featuresUsedInPage
0, // willLoadURLRequest
0, // willLoadDataRequest
+ 0, // willDestroyFrame
};
WKBundlePageSetPageLoaderClient(m_page, &loaderClient);