summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.cpp18
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.h2
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp53
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h43
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp14
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.h4
-rw-r--r--Source/WebKit2/UIProcess/API/efl/EWebKit2.h1
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_context.cpp20
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_context.h10
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp197
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h157
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h36
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view.cpp28
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view.h20
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp17
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_web_error.h8
-rw-r--r--Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp22
-rw-r--r--Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h3
-rw-r--r--Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp5
-rw-r--r--Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp46
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h27
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp118
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h65
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h28
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp38
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h77
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt20
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp20
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp82
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2.h1
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp9
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h3
-rw-r--r--Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h3
38 files changed, 1145 insertions, 63 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
index 7bfc04aed..d168363e8 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -189,6 +189,15 @@ WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef)
return toAPI(toImpl(contextRef)->geolocationManagerProxy());
}
+WKNetworkInfoManagerRef WKContextGetNetworkInfoManager(WKContextRef contextRef)
+{
+#if ENABLE(NETWORK_INFO)
+ return toAPI(toImpl(contextRef)->networkInfoManagerProxy());
+#else
+ return 0;
+#endif
+}
+
WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef contextRef)
{
return toAPI(toImpl(contextRef)->iconDatabase());
@@ -219,6 +228,15 @@ WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef contextR
return toAPI(toImpl(contextRef)->resourceCacheManagerProxy());
}
+WKVibrationRef WKContextGetVibration(WKContextRef contextRef)
+{
+#if ENABLE(VIBRATION)
+ return toAPI(toImpl(contextRef)->vibrationProxy());
+#else
+ return 0;
+#endif
+}
+
void WKContextStartMemorySampler(WKContextRef contextRef, WKDoubleRef interval)
{
toImpl(contextRef)->startMemorySampler(toImpl(interval)->value());
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h
index 85e4c157c..412227de7 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContext.h
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.h
@@ -155,9 +155,11 @@ WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef co
WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context);
WK_EXPORT WKMediaCacheManagerRef WKContextGetMediaCacheManager(WKContextRef context);
+WK_EXPORT WKNetworkInfoManagerRef WKContextGetNetworkInfoManager(WKContextRef context);
WK_EXPORT WKNotificationManagerRef WKContextGetNotificationManager(WKContextRef context);
WK_EXPORT WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef context);
WK_EXPORT WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context);
+WK_EXPORT WKVibrationRef WKContextGetVibration(WKContextRef context);
typedef void (*WKContextGetStatisticsFunction)(WKDictionaryRef statistics, WKErrorRef error, void* functionContext);
WK_EXPORT void WKContextGetStatistics(WKContextRef context, void* functionContext, WKContextGetStatisticsFunction function);
diff --git a/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp b/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp
new file mode 100644
index 000000000..a9bfd3cb1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "WKNetworkInfo.h"
+
+#if ENABLE(NETWORK_INFO)
+#include "WKAPICast.h"
+#include "WebNetworkInfo.h"
+
+using namespace WebKit;
+#endif
+
+WKTypeID WKNetworkInfoGetTypeID()
+{
+#if ENABLE(NETWORK_INFO)
+ return toAPI(WebNetworkInfo::APIType);
+#else
+ return 0;
+#endif
+}
+
+WKNetworkInfoRef WKNetworkInfoCreate(double bandwidth, bool isMetered)
+{
+#if ENABLE(NETWORK_INFO)
+ RefPtr<WebNetworkInfo> networkInfo = WebNetworkInfo::create(bandwidth, isMetered);
+ return toAPI(networkInfo.release().leakRef());
+#else
+ return 0;
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h b/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h
new file mode 100644
index 000000000..cff864a75
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#ifndef WKNetworkInfo_h
+#define WKNetworkInfo_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKNetworkInfoGetTypeID();
+
+WK_EXPORT WKNetworkInfoRef WKNetworkInfoCreate(double bandwidth, bool isMetered);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKNetworkInfo_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp b/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp
index 1e0733ac2..85620ad61 100644
--- a/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp
@@ -39,3 +39,17 @@ WKTypeID WKNetworkInfoManagerGetTypeID()
return 0;
#endif
}
+
+void WKNetworkInfoManagerSetProvider(WKNetworkInfoManagerRef networkInfoManager, const WKNetworkInfoProvider* provider)
+{
+#if ENABLE(NETWORK_INFO)
+ toImpl(networkInfoManager)->initializeProvider(provider);
+#endif
+}
+
+void WKNetworkInfoManagerProviderDidChangeNetworkInformation(WKNetworkInfoManagerRef networkInfoManager, WKStringRef eventType, WKNetworkInfoRef networkInfo)
+{
+#if ENABLE(NETWORK_INFO)
+ toImpl(networkInfoManager)->providerDidChangeNetworkInformation(AtomicString(toImpl(eventType)->string()), toImpl(networkInfo));
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.h b/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.h
index efecf4ef8..dd92eb868 100644
--- a/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.h
+++ b/Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.h
@@ -52,6 +52,10 @@ enum { kWKNetworkInfoProviderCurrentVersion = 0 };
WK_EXPORT WKTypeID WKNetworkInfoManagerGetTypeID();
+WK_EXPORT void WKNetworkInfoManagerSetProvider(WKNetworkInfoManagerRef networkInfoManager, const WKNetworkInfoProvider* provider);
+
+WK_EXPORT void WKNetworkInfoManagerProviderDidChangeNetworkInformation(WKNetworkInfoManagerRef networkInfoManager, WKStringRef eventType, WKNetworkInfoRef networkInfo);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h
index 8fa90aeb9..d7d796368 100644
--- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h
+++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h
@@ -28,6 +28,7 @@
#define EWebKit2_h
#include "ewk_context.h"
+#include "ewk_cookie_manager.h"
#include "ewk_intent.h"
#include "ewk_intent_service.h"
#include "ewk_navigation_policy_decision.h"
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
index e1ccff23b..21c157c22 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
@@ -25,20 +25,40 @@
#include "WKAPICast.h"
#include "WKRetainPtr.h"
#include "ewk_context_private.h"
+#include "ewk_cookie_manager_private.h"
using namespace WebKit;
struct _Ewk_Context {
WKRetainPtr<WKContextRef> context;
+
+ Ewk_Cookie_Manager* cookieManager;
#if ENABLE(BATTERY_STATUS)
RefPtr<BatteryProvider> batteryProvider;
#endif
_Ewk_Context(WKContextRef contextRef)
: context(contextRef)
+ , cookieManager(0)
{ }
+
+ ~_Ewk_Context()
+ {
+ if (cookieManager)
+ ewk_cookie_manager_free(cookieManager);
+ }
};
+Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
+
+ if (!ewkContext->cookieManager)
+ const_cast<Ewk_Context*>(ewkContext)->cookieManager = ewk_cookie_manager_new(WKContextGetCookieManager(ewkContext->context.get()));
+
+ return ewkContext->cookieManager;
+}
+
WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext)
{
return ewkContext->context.get();
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.h b/Source/WebKit2/UIProcess/API/efl/ewk_context.h
index 794d05204..e89037766 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_context.h
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.h
@@ -29,6 +29,7 @@
#ifndef ewk_context_h
#define ewk_context_h
+#include "ewk_cookie_manager.h"
#include <Evas.h>
#ifdef __cplusplus
@@ -45,6 +46,15 @@ typedef struct _Ewk_Context Ewk_Context;
*/
EAPI Ewk_Context *ewk_context_default_get();
+/**
+ * Gets the cookie manager instance for this @a context.
+ *
+ * @param context context object to query.
+ *
+ * @return Ewk_Cookie_Manager object instance or @c NULL in case of failure.
+ */
+EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *context);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp
new file mode 100644
index 000000000..02f1fbd76
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "ewk_cookie_manager.h"
+
+#include "SoupCookiePersistentStorageType.h"
+#include "WKAPICast.h"
+#include "WKArray.h"
+#include "WKCookieManager.h"
+#include "WKRetainPtr.h"
+#include "WKString.h"
+#include "WebCookieManagerProxy.h"
+#include "ewk_private.h"
+#include "ewk_web_error_private.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebKit;
+
+/**
+ * \struct _Ewk_Cookie_Manager
+ * @brief Contains the cookie manager data.
+ */
+struct _Ewk_Cookie_Manager {
+ WKRetainPtr<WKCookieManagerRef> wkCookieManager;
+
+ _Ewk_Cookie_Manager(WKCookieManagerRef cookieManagerRef)
+ : wkCookieManager(cookieManagerRef)
+ { }
+};
+
+#define EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager_, ...) \
+ if (!(manager)) { \
+ EINA_LOG_CRIT("manager is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ if (!(manager)->wkCookieManager) { \
+ EINA_LOG_CRIT("manager->wkCookieManager is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ WKCookieManagerRef wkManager_ = (manager)->wkCookieManager.get()
+
+// Ewk_Cookie_Accept_Policy enum validation
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_ALWAYS, kWKHTTPCookieAcceptPolicyAlways);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_NEVER, kWKHTTPCookieAcceptPolicyNever);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY, kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
+
+// Ewk_Cookie_Persistent_Storage enum validation
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_TEXT, SoupCookiePersistentStorageText);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_SQLITE, SoupCookiePersistentStorageSQLite);
+
+void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager* manager, const char* filename, Ewk_Cookie_Persistent_Storage storage)
+{
+ EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+ EINA_SAFETY_ON_NULL_RETURN(filename);
+
+ toImpl(wkManager)->setCookiePersistentStorage(String::fromUTF8(filename), storage);
+}
+
+void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager* manager, Ewk_Cookie_Accept_Policy policy)
+{
+ EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+
+ WKCookieManagerSetHTTPCookieAcceptPolicy(wkManager, static_cast<WKHTTPCookieAcceptPolicy>(policy));
+}
+
+struct Get_Policy_Async_Data {
+ Ewk_Cookie_Manager_Async_Policy_Get_Cb callback;
+ void* userData;
+};
+
+static void getAcceptPolicyCallback(WKHTTPCookieAcceptPolicy policy, WKErrorRef wkError, void* data)
+{
+ Get_Policy_Async_Data* callbackData = static_cast<Get_Policy_Async_Data*>(data);
+ Ewk_Web_Error* ewkError = wkError ? ewk_web_error_new(wkError) : 0;
+
+ callbackData->callback(static_cast<Ewk_Cookie_Accept_Policy>(policy), ewkError, callbackData->userData);
+
+ if (ewkError)
+ ewk_web_error_free(ewkError);
+ delete callbackData;
+}
+
+void ewk_cookie_manager_async_accept_policy_get(const Ewk_Cookie_Manager* manager, Ewk_Cookie_Manager_Async_Policy_Get_Cb callback, void* data)
+{
+ EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+ EINA_SAFETY_ON_NULL_RETURN(callback);
+
+ Get_Policy_Async_Data* callbackData = new Get_Policy_Async_Data;
+ callbackData->callback = callback;
+ callbackData->userData = data;
+
+ WKCookieManagerGetHTTPCookieAcceptPolicy(wkManager, callbackData, getAcceptPolicyCallback);
+}
+
+struct Get_Hostnames_Async_Data {
+ Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback;
+ void* userData;
+};
+
+static void getHostnamesWithCookiesCallback(WKArrayRef wkHostnames, WKErrorRef wkError, void* context)
+{
+ Eina_List* hostnames = 0;
+ Get_Hostnames_Async_Data* callbackData = static_cast<Get_Hostnames_Async_Data*>(context);
+ Ewk_Web_Error* ewkError = wkError ? ewk_web_error_new(wkError) : 0;
+
+ const size_t hostnameCount = WKArrayGetSize(wkHostnames);
+ for (size_t i = 0; i < hostnameCount; ++i) {
+ WKStringRef wkHostname = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkHostnames, i));
+ String hostname = toImpl(wkHostname)->string();
+ if (hostname.isEmpty())
+ continue;
+ hostnames = eina_list_append(hostnames, eina_stringshare_add(hostname.utf8().data()));
+ }
+
+ callbackData->callback(hostnames, ewkError, callbackData->userData);
+
+ void* item;
+ EINA_LIST_FREE(hostnames, item)
+ eina_stringshare_del(static_cast<Eina_Stringshare*>(item));
+ if (ewkError)
+ ewk_web_error_free(ewkError);
+ delete callbackData;
+}
+
+void ewk_cookie_manager_async_hostnames_with_cookies_get(const Ewk_Cookie_Manager* manager, Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback, void* data)
+{
+ EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+ EINA_SAFETY_ON_NULL_RETURN(callback);
+
+ Get_Hostnames_Async_Data* callbackData = new Get_Hostnames_Async_Data;
+ callbackData->callback = callback;
+ callbackData->userData = data;
+
+ WKCookieManagerGetHostnamesWithCookies(wkManager, callbackData, getHostnamesWithCookiesCallback);
+}
+
+void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager* manager, const char* hostName)
+{
+ EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+ EINA_SAFETY_ON_NULL_RETURN(hostName);
+
+ WKRetainPtr<WKStringRef> wkHostName(AdoptWK, WKStringCreateWithUTF8CString(hostName));
+ WKCookieManagerDeleteCookiesForHostname(wkManager, wkHostName.get());
+}
+
+void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager* manager)
+{
+ EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+
+ WKCookieManagerDeleteAllCookies(wkManager);
+}
+
+/**
+ * @internal
+ * Frees a Ewk_Cookie_Manager object.
+ */
+void ewk_cookie_manager_free(Ewk_Cookie_Manager* manager)
+{
+ EINA_SAFETY_ON_NULL_RETURN(manager);
+
+ delete manager;
+}
+
+/**
+ * @internal
+ * Constructs a Ewk_Cookie_Manager from a WKCookieManagerRef.
+ */
+Ewk_Cookie_Manager* ewk_cookie_manager_new(WKCookieManagerRef wkCookieManager)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wkCookieManager, 0);
+
+ return new Ewk_Cookie_Manager(wkCookieManager);
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h
new file mode 100644
index 000000000..442c4f7ca
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+/**
+ * @file ewk_cookie_manager.h
+ * @brief Describes the Ewk Cookie Manager API.
+ */
+
+#ifndef ewk_cookie_manager_h
+#define ewk_cookie_manager_h
+
+#include "ewk_web_error.h"
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for _Ewk_Cookie_Manager */
+typedef struct _Ewk_Cookie_Manager Ewk_Cookie_Manager;
+
+/**
+ * \enum _Ewk_Cookie_Accept_Policy
+ *
+ * @brief Contains accept policies for the cookies.
+ */
+enum _Ewk_Cookie_Accept_Policy {
+ /// Accepts every cookie sent from any page.
+ EWK_COOKIE_ACCEPT_POLICY_ALWAYS,
+ /// Rejects all cookies.
+ EWK_COOKIE_ACCEPT_POLICY_NEVER,
+ /// Accepts cookies only from the main page.
+ EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY
+};
+
+/// Creates a type name for the _Ewk_Cookie_Accept_Policy.
+typedef enum _Ewk_Cookie_Accept_Policy Ewk_Cookie_Accept_Policy;
+
+/**
+ * \enum _Ewk_Cookie_Persistent_Storage
+ *
+ * @brief Enum values to denote cookies persistent storage type.
+ */
+enum _Ewk_Cookie_Persistent_Storage {
+ /// Cookies are stored in a text file in the Mozilla "cookies.txt" format.
+ EWK_COOKIE_PERSISTENT_STORAGE_TEXT,
+ /// Cookies are stored in a SQLite file in the current Mozilla format.
+ EWK_COOKIE_PERSISTENT_STORAGE_SQLITE
+};
+
+/// Creates a type name for the _Ewk_Cookie_Persistent_Storage.
+typedef enum _Ewk_Cookie_Persistent_Storage Ewk_Cookie_Persistent_Storage;
+
+/**
+ * @typedef Ewk_Cookie_Manager_Async_Policy_Get_Cb Ewk_Cookie_Manager_Async_Policy_Get_Cb
+ * @brief Callback type for use with ewk_cookie_manager_async_accept_policy_get
+ */
+typedef void (*Ewk_Cookie_Manager_Async_Policy_Get_Cb)(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *error, void *event_info);
+
+/**
+ * @typedef Ewk_Cookie_Manager_Async_Hostnames_Get_Cb Ewk_Cookie_Manager_Async_Hostnames_Get_Cb
+ * @brief Callback type for use with ewk_cookie_manager_async_hostnames_with_cookies_get
+ *
+ * @note The @a hostnames list items are guaranteed to be eina_stringshare. Whenever possible
+ * save yourself some cpu cycles and use eina_stringshare_ref() instead of eina_stringshare_add()
+ * or strdup().
+ */
+typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List* hostnames, Ewk_Web_Error *error, void *event_info);
+
+/**
+ * Set the @a filename where non-session cookies are stored persistently using @a storage as the format to read/write the cookies.
+ *
+ * Cookies are initially read from @filename to create an initial set of cookies.
+ * Then, non-session cookies will be written to @filename.
+ *
+ * By default, @a manager doesn't store the cookies persistenly, so you need to call this
+ * method to keep cookies saved across sessions.
+ *
+ * @param cookie_manager The cookie manager to update.
+ * @param filename the filename to read to/write from.
+ * @param storage the type of storage.
+ */
+EAPI void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager *manager, const char *filename, Ewk_Cookie_Persistent_Storage storage);
+
+/**
+ * Set @a policy as the cookie acceptance policy for @a manager.
+ *
+ * By default, cookies are always accepted.
+ *
+ * @param manager The cookie manager to update.
+ * @param policy a #Ewk_Cookie_Accept_Policy
+ */
+
+EAPI void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager *manager, Ewk_Cookie_Accept_Policy policy);
+
+/**
+ * Asynchronously get the cookie acceptance policy of @a manager.
+ *
+ * By default, cookies are always accepted.
+ *
+ * @param manager The cookie manager to query.
+ * @param callback The function to call when the policy is received or an error occured.
+ * @param data User data (may be @c NULL).
+ */
+EAPI void ewk_cookie_manager_async_accept_policy_get(const Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Async_Policy_Get_Cb callback, void *data);
+
+/**
+ * Asynchronously get the list of host names for which @a manager contains cookies.
+ *
+ * @param manager The cookie manager to query.
+ * @param callback The function to call when the host names have been received.
+ * @param data User data (may be @c NULL).
+ */
+EAPI void ewk_cookie_manager_async_hostnames_with_cookies_get(const Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback, void *data);
+
+/**
+ * Remove all cookies of @a manager for the given @a hostname.
+ *
+ * @param manager The cookie manager to update.
+ * @param hostname A host name.
+ */
+EAPI void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager *manager, const char *hostname);
+
+/**
+ * Delete all cookies of @a manager.
+ *
+ * @param manager The cookie manager to update.
+ */
+EAPI void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager *manager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_cookie_manager_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h
new file mode 100644
index 000000000..64285c981
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#ifndef ewk_cookie_manager_private_h
+#define ewk_cookie_manager_private_h
+
+#include <WebKit2/WKBase.h>
+
+typedef struct _Ewk_Cookie_Manager Ewk_Cookie_Manager;
+
+Ewk_Cookie_Manager* ewk_cookie_manager_new(WKCookieManagerRef wkCookieManager);
+void ewk_cookie_manager_free(Ewk_Cookie_Manager* manager);
+
+#endif // ewk_cookie_manager_private_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
index 8b7132b48..3f80aa11d 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
@@ -27,6 +27,7 @@
#include "PageClientImpl.h"
#include "WKAPICast.h"
#include "WKRetainPtr.h"
+#include "WKString.h"
#include "WKURL.h"
#include "ewk_context.h"
#include "ewk_context_private.h"
@@ -50,12 +51,14 @@ struct _Ewk_View_Private_Data {
const char* uri;
const char* title;
const char* theme;
+ const char* customEncoding;
LoadingResourcesMap loadingResourcesMap;
_Ewk_View_Private_Data()
: uri(0)
, title(0)
, theme(0)
+ , customEncoding(0)
{ }
~_Ewk_View_Private_Data()
@@ -63,6 +66,7 @@ struct _Ewk_View_Private_Data {
eina_stringshare_del(uri);
eina_stringshare_del(title);
eina_stringshare_del(theme);
+ eina_stringshare_del(customEncoding);
}
};
@@ -960,3 +964,27 @@ WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
return priv->pageClient->page();
}
+
+const char* ewk_view_setting_encoding_custom_get(const Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
+
+ WKRetainPtr<WKStringRef> wkEncodingName(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(priv->pageClient->page())));
+ if (WKStringIsEmpty(wkEncodingName.get()))
+ return 0;
+
+ eina_stringshare_replace(&priv->customEncoding, toImpl(wkEncodingName.get())->string().utf8().data());
+ return priv->customEncoding;
+}
+
+Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+ WKRetainPtr<WKStringRef> wkEncodingName = encoding ? adoptWK(WKStringCreateWithUTF8CString(encoding)) : 0;
+ if (eina_stringshare_replace(&priv->customEncoding, encoding))
+ WKPageSetCustomTextEncodingName(toAPI(priv->pageClient->page()), wkEncodingName.get());
+ return true;
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h
index fe3f10675..6a8e74f82 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h
@@ -420,6 +420,26 @@ EAPI void ewk_view_theme_set(Evas_Object *o, const char *path);
*/
EAPI const char *ewk_view_theme_get(const Evas_Object *o);
+/**
+ * Gets the current custom character encoding name.
+ *
+ * @param o view object to get the current encoding
+ *
+ * @return @c eina_strinshare containing the current encoding, or
+ * @c NULL if it's not set
+ */
+EAPI const char *ewk_view_setting_encoding_custom_get(const Evas_Object *o);
+
+/**
+ * Sets the custom character encoding and reloads the page.
+ *
+ * @param o view to set the encoding
+ * @param encoding the new encoding to set or @c NULL to restore the default one
+ *
+ * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object *o, const char *encoding);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp
index f16fb2cc3..e6e3eb891 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "ewk_web_error.h"
+#include "ErrorsEfl.h"
#include "WKString.h"
#include "WKURL.h"
#include "ewk_web_error_private.h"
@@ -34,11 +35,9 @@
#include <WKRetainPtr.h>
#include <wtf/text/CString.h>
+using namespace WebCore;
using namespace WebKit;
-// Copied from ErrorsGtk.h which is used by DownloadSoup.cpp.
-static const char errorDomainDownload[] = "WebKitDownloadError";
-
struct _Ewk_Web_Error {
WKRetainPtr<WKErrorRef> wkError;
@@ -83,12 +82,16 @@ Ewk_Web_Error_Type ewk_web_error_type_get(const Ewk_Web_Error* error)
WKRetainPtr<WKStringRef> wkDomain(AdoptWK, WKErrorCopyDomain(wkError));
WTF::String errorDomain = toWTFString(wkDomain.get());
- if (errorDomain == String(g_quark_to_string(SOUP_HTTP_ERROR)))
- return EWK_WEB_ERROR_TYPE_HTTP;
- if (errorDomain == String(g_quark_to_string(G_IO_ERROR)))
- return EWK_WEB_ERROR_TYPE_IO;
+ if (errorDomain == errorDomainNetwork)
+ return EWK_WEB_ERROR_TYPE_NETWORK;
+ if (errorDomain == errorDomainPolicy)
+ return EWK_WEB_ERROR_TYPE_POLICY;
+ if (errorDomain == errorDomainPlugin)
+ return EWK_WEB_ERROR_TYPE_PLUGIN;
if (errorDomain == errorDomainDownload)
return EWK_WEB_ERROR_TYPE_DOWNLOAD;
+ if (errorDomain == errorDomainPrint)
+ return EWK_WEB_ERROR_TYPE_PRINT;
return EWK_WEB_ERROR_TYPE_INTERNAL;
}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h b/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h
index 2d9666581..4ba0c7acd 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h
@@ -44,9 +44,11 @@ typedef struct _Ewk_Web_Error Ewk_Web_Error;
typedef enum {
EWK_WEB_ERROR_TYPE_NONE,
EWK_WEB_ERROR_TYPE_INTERNAL,
- EWK_WEB_ERROR_TYPE_HTTP,
- EWK_WEB_ERROR_TYPE_IO,
- EWK_WEB_ERROR_TYPE_DOWNLOAD
+ EWK_WEB_ERROR_TYPE_NETWORK,
+ EWK_WEB_ERROR_TYPE_POLICY,
+ EWK_WEB_ERROR_TYPE_PLUGIN,
+ EWK_WEB_ERROR_TYPE_DOWNLOAD,
+ EWK_WEB_ERROR_TYPE_PRINT
} Ewk_Web_Error_Type;
/**
diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp
index b96643049..05168e26d 100644
--- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp
@@ -29,19 +29,17 @@ extern EWK2UnitTest::EWK2UnitTestEnvironment* environment;
namespace EWK2UnitTest {
-static void onLoadProgress(void* userData, Evas_Object* webView, void* eventInfo)
+static void onLoadFinished(void* userData, Evas_Object* webView, void* eventInfo)
{
UNUSED_PARAM(webView);
+ UNUSED_PARAM(eventInfo);
- EWK2UnitTestBase* test = static_cast<EWK2UnitTestBase*>(userData);
- double progress = *static_cast<double*>(eventInfo);
-
- test->setLoadProgress(progress);
+ bool* loadFinished = static_cast<bool*>(userData);
+ *loadFinished = true;
}
EWK2UnitTestBase::EWK2UnitTestBase()
- : m_loadProgress(0)
- , m_ecoreEvas(0)
+ : m_ecoreEvas(0)
, m_webView(0)
{
}
@@ -62,6 +60,8 @@ void EWK2UnitTestBase::SetUp()
Evas* evas = ecore_evas_get(m_ecoreEvas);
m_webView = ewk_view_add(evas);
+ ewk_view_theme_set(m_webView, environment->defaultTheme());
+
evas_object_resize(m_webView, width, height);
evas_object_show(m_webView);
evas_object_focus_set(m_webView, true);
@@ -76,15 +76,15 @@ void EWK2UnitTestBase::TearDown()
void EWK2UnitTestBase::loadUrlSync(const char* url)
{
- m_loadProgress = 0;
+ bool loadFinished = false;
- evas_object_smart_callback_add(m_webView, "load,progress", onLoadProgress, this);
+ evas_object_smart_callback_add(m_webView, "load,finished", onLoadFinished, &loadFinished);
ewk_view_uri_set(m_webView, url);
- while (m_loadProgress != 1)
+ while (!loadFinished)
ecore_main_loop_iterate();
- evas_object_smart_callback_del(m_webView, "load,progress", onLoadProgress);
+ evas_object_smart_callback_del(m_webView, "load,finished", onLoadFinished);
}
} // namespace EWK2UnitTest
diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h
index 794688140..8fa1b5021 100644
--- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h
+++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h
@@ -28,7 +28,6 @@ namespace EWK2UnitTest {
class EWK2UnitTestBase : public ::testing::Test {
public:
- void setLoadProgress(float progress) { m_loadProgress = progress; }
Evas_Object* webView() { return m_webView; }
protected:
@@ -42,8 +41,6 @@ protected:
private:
Evas_Object* m_webView;
Ecore_Evas* m_ecoreEvas;
-
- float m_loadProgress;
};
} // namespace EWK2UnitTest
diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp
index 61cb53e0f..e7bc0d621 100644
--- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp
@@ -34,4 +34,9 @@ const char* EWK2UnitTestEnvironment::defaultTestPageUrl() const
return "file://"TEST_RESOURCES_DIR"/default_test_page.html";
}
+const char* EWK2UnitTestEnvironment::defaultTheme() const
+{
+ return TEST_THEME_DIR"/default.edj";
+}
+
} // namespace EWK2UnitTest
diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h
index 9e076bea0..fac0f5988 100644
--- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h
+++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h
@@ -29,6 +29,7 @@ public:
bool useX11Window() const { return m_useX11Window; }
const char* defaultTestPageUrl() const;
+ const char* defaultTheme() const;
virtual unsigned int defaultWidth() const { return m_defaultWidth; }
virtual unsigned int defaultHeight() const { return m_defaultHeight; }
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp
new file mode 100644
index 000000000..fd5be3daf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 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 "WebKitFormClient.h"
+
+#include "WebKitFormSubmissionRequestPrivate.h"
+#include "WebKitPrivate.h"
+#include "WebKitWebViewBasePrivate.h"
+#include "WebKitWebViewPrivate.h"
+#include <wtf/gobject/GRefPtr.h>
+
+using namespace WebKit;
+
+static void willSubmitForm(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo)
+{
+ GRefPtr<WebKitFormSubmissionRequest> request = adoptGRef(webkitFormSubmissionRequestCreate(values, listener));
+ webkitWebViewSubmitFormRequest(WEBKIT_WEB_VIEW(clientInfo), request.get());
+}
+
+void attachFormClientToView(WebKitWebView* webView)
+{
+ WKPageFormClient wkFormClient = {
+ kWKPageFormClientCurrentVersion,
+ webView, // clientInfo
+ willSubmitForm
+ };
+ WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
+ WKPageSetPageFormClient(wkPage, &wkFormClient);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h
new file mode 100644
index 000000000..a37022731
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 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 WebKitFormClient_h
+#define WebKitFormClient_h
+
+#include "WebKitWebView.h"
+
+void attachFormClientToView(WebKitWebView*);
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp
new file mode 100644
index 000000000..40e2d17f1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2012 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 "WebKitFormSubmissionRequest.h"
+
+#include "WebKitFormSubmissionRequestPrivate.h"
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+G_DEFINE_TYPE(WebKitFormSubmissionRequest, webkit_form_submission_request, G_TYPE_OBJECT)
+
+struct _WebKitFormSubmissionRequestPrivate {
+ WKRetainPtr<WKDictionaryRef> wkValues;
+ WKRetainPtr<WKFormSubmissionListenerRef> wkListener;
+ GRefPtr<GHashTable> values;
+ bool handledRequest;
+};
+
+static void webkit_form_submission_request_init(WebKitFormSubmissionRequest* request)
+{
+ WebKitFormSubmissionRequestPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestPrivate);
+ request->priv = priv;
+ new (priv) WebKitFormSubmissionRequestPrivate();
+}
+
+static void webkitFormSubmissionRequestFinalize(GObject* object)
+{
+ WebKitFormSubmissionRequest* request = WEBKIT_FORM_SUBMISSION_REQUEST(object);
+
+ // Make sure the request is always handled before finalizing.
+ if (!request->priv->handledRequest)
+ webkit_form_submission_request_submit(request);
+
+ request->priv->~WebKitFormSubmissionRequestPrivate();
+ G_OBJECT_CLASS(webkit_form_submission_request_parent_class)->finalize(object);
+}
+
+static void webkit_form_submission_request_class_init(WebKitFormSubmissionRequestClass* requestClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+ objectClass->finalize = webkitFormSubmissionRequestFinalize;
+ g_type_class_add_private(requestClass, sizeof(WebKitFormSubmissionRequestPrivate));
+}
+
+WebKitFormSubmissionRequest* webkitFormSubmissionRequestCreate(WKDictionaryRef wkValues, WKFormSubmissionListenerRef wkListener)
+{
+ WebKitFormSubmissionRequest* request = WEBKIT_FORM_SUBMISSION_REQUEST(g_object_new(WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, NULL));
+ request->priv->wkValues = wkValues;
+ request->priv->wkListener = wkListener;
+ return request;
+}
+
+/**
+ * webkit_form_submission_request_get_text_fields:
+ * @request: a #WebKitFormSubmissionRequest
+ *
+ * Get a #GHashTable with the values of the text fields contained in the form
+ * associated to @request.
+ *
+ * Returns: (transfer none): a #GHashTable with the form text fields, or %NULL if the
+ * form doesn't contain text fields.
+ */
+GHashTable* webkit_form_submission_request_get_text_fields(WebKitFormSubmissionRequest* request)
+{
+ g_return_val_if_fail(WEBKIT_IS_FORM_SUBMISSION_REQUEST(request), 0);
+
+ if (request->priv->values)
+ return request->priv->values.get();
+
+ if (!WKDictionaryGetSize(request->priv->wkValues.get()))
+ return 0;
+
+ request->priv->values = adoptGRef(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free));
+
+ WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(request->priv->wkValues.get()));
+ for (size_t i = 0; i < WKArrayGetSize(wkKeys.get()); ++i) {
+ WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
+ WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(request->priv->wkValues.get(), wkKey));
+ g_hash_table_insert(request->priv->values.get(), g_strdup(toImpl(wkKey)->string().utf8().data()), g_strdup(toImpl(wkValue)->string().utf8().data()));
+ }
+
+ request->priv->wkValues = 0;
+
+ return request->priv->values.get();
+}
+
+/**
+ * webkit_form_submission_request_submit:
+ * @request: a #WebKitFormSubmissionRequest
+ *
+ * Continue the form submission.
+ */
+void webkit_form_submission_request_submit(WebKitFormSubmissionRequest* request)
+{
+ g_return_if_fail(WEBKIT_IS_FORM_SUBMISSION_REQUEST(request));
+
+ WKFormSubmissionListenerContinue(request->priv->wkListener.get());
+ request->priv->handledRequest = true;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h
new file mode 100644
index 000000000..910a81c6d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitFormSubmissionRequest_h
+#define WebKitFormSubmissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_FORM_SUBMISSION_REQUEST (webkit_form_submission_request_get_type())
+#define WEBKIT_FORM_SUBMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequest))
+#define WEBKIT_IS_FORM_SUBMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST))
+#define WEBKIT_FORM_SUBMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestClass))
+#define WEBKIT_IS_FORM_SUBMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST))
+#define WEBKIT_FORM_SUBMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestClass))
+
+typedef struct _WebKitFormSubmissionRequest WebKitFormSubmissionRequest;
+typedef struct _WebKitFormSubmissionRequestClass WebKitFormSubmissionRequestClass;
+typedef struct _WebKitFormSubmissionRequestPrivate WebKitFormSubmissionRequestPrivate;
+
+struct _WebKitFormSubmissionRequest {
+ GObject parent;
+
+ /*< private >*/
+ WebKitFormSubmissionRequestPrivate *priv;
+};
+
+struct _WebKitFormSubmissionRequestClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_form_submission_request_get_type (void);
+
+WEBKIT_API GHashTable *
+webkit_form_submission_request_get_text_fields (WebKitFormSubmissionRequest *request);
+
+WEBKIT_API void
+webkit_form_submission_request_submit (WebKitFormSubmissionRequest *request);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h
new file mode 100644
index 000000000..ad4a6190b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2012 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 WebKitFormSubmissionRequestPrivate_h
+#define WebKitFormSubmissionRequestPrivate_h
+
+#include "WebKitFormSubmissionRequest.h"
+#include "WebKitPrivate.h"
+
+WebKitFormSubmissionRequest* webkitFormSubmissionRequestCreate(WKDictionaryRef, WKFormSubmissionListenerRef);
+
+#endif // WebKitFormSubmissionRequestPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index 8bfabeec6..8bf4d8fe0 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -29,6 +29,7 @@
#include "WebKitContextMenuPrivate.h"
#include "WebKitEnumTypes.h"
#include "WebKitError.h"
+#include "WebKitFormClient.h"
#include "WebKitFullscreenClient.h"
#include "WebKitHitTestResultPrivate.h"
#include "WebKitJavascriptResultPrivate.h"
@@ -90,6 +91,8 @@ enum {
CONTEXT_MENU,
CONTEXT_MENU_DISMISSED,
+ SUBMIT_FORM,
+
LAST_SIGNAL
};
@@ -325,6 +328,7 @@ static void webkitWebViewConstructed(GObject* object)
attachResourceLoadClientToView(webView);
attachFullScreenClientToView(webView);
attachContextMenuClientToView(webView);
+ attachFormClientToView(webView);
WebPageProxy* page = webkitWebViewBaseGetPage(webViewBase);
priv->backForwardList = adoptGRef(webkitBackForwardListCreate(WKPageGetBackForwardList(toAPI(page))));
@@ -1060,6 +1064,33 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
0, 0,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * WebKitWebView::submit-form:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @request: a #WebKitFormSubmissionRequest
+ *
+ * This signal is emitted when a form is about to be submitted. The @request
+ * argument passed contains information about the text fields of the form. This
+ * is typically used to store login information that can be used later to
+ * pre-fill the form.
+ * The form will not be submitted until webkit_form_submission_request_submit() is called.
+ *
+ * It is possible to handle the form submission request asynchronously, by
+ * simply calling g_object_ref() on the @request argument and calling
+ * webkit_form_submission_request_submit() when done to continue with the form submission.
+ * If the last reference is removed on a #WebKitFormSubmissionRequest and the
+ * form has not been submitted, webkit_form_submission_request_submit() will be called.
+ */
+ signals[SUBMIT_FORM] =
+ g_signal_new("submit-form",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, submit_form),
+ 0, 0,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ WEBKIT_TYPE_FORM_SUBMISSION_REQUEST);
}
static bool updateReplaceContentStatus(WebKitWebView* webView, WebKitLoadEvent loadEvent)
@@ -1250,7 +1281,7 @@ void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WKFrameRef wkFrame
WebKitWebViewPrivate* priv = webView->priv;
WebKitWebResource* resource = webkitWebResourceCreate(wkFrame, request, isMainResource);
- if (WKFrameIsMainFrame(wkFrame) && isMainResource)
+ if (WKFrameIsMainFrame(wkFrame) && (isMainResource || !priv->mainResource))
priv->mainResource = resource;
priv->loadingResourcesMap.set(resourceIdentifier, adoptGRef(resource));
g_signal_emit(webView, signals[RESOURCE_LOAD_STARTED], 0, resource, request);
@@ -1388,6 +1419,11 @@ void webkitWebViewPopulateContextMenu(WebKitWebView* webView, WKArrayRef wkPropo
webkit_context_menu_remove_all(contextMenu.get());
}
+void webkitWebViewSubmitFormRequest(WebKitWebView* webView, WebKitFormSubmissionRequest* request)
+{
+ g_signal_emit(webView, signals[SUBMIT_FORM], 0, request);
+}
+
/**
* webkit_web_view_new:
*
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
index bac32a78e..2553b1840 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
@@ -33,6 +33,7 @@
#include <webkit2/WebKitDefines.h>
#include <webkit2/WebKitFileChooserRequest.h>
#include <webkit2/WebKitFindController.h>
+#include <webkit2/WebKitFormSubmissionRequest.h>
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>
#include <webkit2/WebKitPermissionRequest.h>
@@ -127,43 +128,45 @@ struct _WebKitWebView {
struct _WebKitWebViewClass {
WebKitWebViewBaseClass parent;
- void (* load_changed) (WebKitWebView *web_view,
- WebKitLoadEvent load_event);
- gboolean (* load_failed) (WebKitWebView *web_view,
- WebKitLoadEvent load_event,
- const gchar *failing_uri,
- GError *error);
-
- GtkWidget *(* create) (WebKitWebView *web_view);
- void (* ready_to_show) (WebKitWebView *web_view);
- void (* run_as_modal) (WebKitWebView *web_view);
- void (* close) (WebKitWebView *web_view);
-
- gboolean (* script_dialog) (WebKitWebView *web_view,
- WebKitScriptDialog *dialog);
-
- gboolean (* decide_policy) (WebKitWebView *web_view,
- WebKitPolicyDecision *decision,
- WebKitPolicyDecisionType type);
- gboolean (* permission_request) (WebKitWebView *web_view,
- WebKitPermissionRequest *permission_request);
- void (* mouse_target_changed) (WebKitWebView *web_view,
- WebKitHitTestResult *hit_test_result,
- guint modifiers);
- gboolean (* print_requested) (WebKitWebView *web_view,
- WebKitPrintOperation *print_operation);
- void (* resource_load_started) (WebKitWebView *web_view,
- WebKitWebResource *resource,
- WebKitURIRequest *request);
- gboolean (* enter_fullscreen) (WebKitWebView *web_view);
- gboolean (* leave_fullscreen) (WebKitWebView *web_view);
- gboolean (* run_file_chooser) (WebKitWebView *web_view,
- WebKitFileChooserRequest *request);
- gboolean (* context_menu) (WebKitWebView *web_view,
- WebKitContextMenu *context_menu,
- GdkEvent *event,
- WebKitHitTestResult *hit_test_result);
- void (* context_menu_dismissed) (WebKitWebView *web_view);
+ void (* load_changed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event);
+ gboolean (* load_failed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event,
+ const gchar *failing_uri,
+ GError *error);
+
+ GtkWidget *(* create) (WebKitWebView *web_view);
+ void (* ready_to_show) (WebKitWebView *web_view);
+ void (* run_as_modal) (WebKitWebView *web_view);
+ void (* close) (WebKitWebView *web_view);
+
+ gboolean (* script_dialog) (WebKitWebView *web_view,
+ WebKitScriptDialog *dialog);
+
+ gboolean (* decide_policy) (WebKitWebView *web_view,
+ WebKitPolicyDecision *decision,
+ WebKitPolicyDecisionType type);
+ gboolean (* permission_request) (WebKitWebView *web_view,
+ WebKitPermissionRequest *permission_request);
+ void (* mouse_target_changed) (WebKitWebView *web_view,
+ WebKitHitTestResult *hit_test_result,
+ guint modifiers);
+ gboolean (* print_requested) (WebKitWebView *web_view,
+ WebKitPrintOperation *print_operation);
+ void (* resource_load_started) (WebKitWebView *web_view,
+ WebKitWebResource *resource,
+ WebKitURIRequest *request);
+ gboolean (* enter_fullscreen) (WebKitWebView *web_view);
+ gboolean (* leave_fullscreen) (WebKitWebView *web_view);
+ gboolean (* run_file_chooser) (WebKitWebView *web_view,
+ WebKitFileChooserRequest *request);
+ gboolean (* context_menu) (WebKitWebView *web_view,
+ WebKitContextMenu *context_menu,
+ GdkEvent *event,
+ WebKitHitTestResult *hit_test_result);
+ void (* context_menu_dismissed) (WebKitWebView *web_view);
+ void (* submit_form) (WebKitWebView *web_view,
+ WebKitFormSubmissionRequest *request);
/* Padding for future expansion */
void (*_webkit_reserved0) (void);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
index b602f4fe0..1833fb111 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
@@ -55,5 +55,6 @@ WebKitWebResource* webkitWebViewResourceLoadFinished(WebKitWebView*, uint64_t re
bool webkitWebViewEnterFullScreen(WebKitWebView*);
bool webkitWebViewLeaveFullScreen(WebKitWebView*);
void webkitWebViewPopulateContextMenu(WebKitWebView*, WKArrayRef proposedMenu, WKHitTestResultRef);
+void webkitWebViewSubmitFormRequest(WebKitWebView*, WebKitFormSubmissionRequest*);
#endif // WebKitWebViewPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
index 6b62d6f69..6aac7c843 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
@@ -39,6 +39,7 @@
<xi:include href="xml/WebKitVersion.xml"/>
<xi:include href="xml/WebKitContextMenu.xml"/>
<xi:include href="xml/WebKitContextMenuItem.xml"/>
+ <xi:include href="xml/WebKitFormSubmissionRequest.xml"/>
</chapter>
<index id="index-all">
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
index f5c84753c..3164177cc 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -814,3 +814,23 @@ WEBKIT_CONTEXT_MENU_ITEM_GET_CLASS
WebKitContextMenuItemPrivate
webkit_context_menu_item_get_type
</SECTION>
+
+<SECTION>
+<FILE>WebKitFormSubmissionRequest</FILE>
+WebKitFormSubmissionRequest
+webkit_form_submission_request_get_text_fields
+webkit_form_submission_request_submit
+
+<SUBSECTION Standard>
+WebKitFormSubmissionRequestClass
+WEBKIT_TYPE_FORM_SUBMISSION_REQUEST
+WEBKIT_FORM_SUBMISSION_REQUEST
+WEBKIT_IS_FORM_SUBMISSION_REQUEST
+WEBKIT_FORM_SUBMISSION_REQUEST_CLASS
+WEBKIT_IS_FORM_SUBMISSION_REQUEST_CLASS
+WEBKIT_FORM_SUBMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitFormSubmissionRequestPrivate
+webkit_form_submission_request_get_type
+</SECTION>
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp
index 43f59e1e7..dc7a518dd 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp
@@ -520,6 +520,25 @@ static void testWebViewResourcesReplacedContent(ResourcesTest* test, gconstpoint
g_assert(!webkit_web_view_get_subresources(test->m_webView));
}
+static void testWebViewResourcesHistoryCache(SingleResourceLoadTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(webkit_web_view_get_main_resource(test->m_webView));
+
+ test->loadURI(kServer->getURIForPath("/javascript.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(webkit_web_view_get_main_resource(test->m_webView));
+
+ test->goBack();
+ test->waitUntilResourceLoadFinished();
+ g_assert(webkit_web_view_get_main_resource(test->m_webView));
+
+ test->goForward();
+ test->waitUntilResourceLoadFinished();
+ g_assert(webkit_web_view_get_main_resource(test->m_webView));
+}
+
static void addCacheHTTPHeadersToResponse(SoupMessage* message)
{
// The actual date doesn't really matter.
@@ -604,6 +623,7 @@ void beforeAll()
ResourceURITrackingTest::add("WebKitWebResource", "active-uri", testWebResourceActiveURI);
ResourcesTest::add("WebKitWebResource", "get-data", testWebResourceGetData);
ResourcesTest::add("WebKitWebView", "replaced-content", testWebViewResourcesReplacedContent);
+ SingleResourceLoadTest::add("WebKitWebView", "history-cache", testWebViewResourcesHistoryCache);
}
void afterAll()
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
index 3e194a179..eec6fc786 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
@@ -865,6 +865,87 @@ static void testWebViewCanShowMIMEType(WebViewTest* test, gconstpointer)
g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/octet-stream"));
}
+class FormClientTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(FormClientTest);
+
+ static void submitFormCallback(WebKitWebView*, WebKitFormSubmissionRequest* request, FormClientTest* test)
+ {
+ test->submitForm(request);
+ }
+
+ FormClientTest()
+ : m_submitPositionX(0)
+ , m_submitPositionY(0)
+ {
+ g_signal_connect(m_webView, "submit-form", G_CALLBACK(submitFormCallback), this);
+ }
+
+ ~FormClientTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void submitForm(WebKitFormSubmissionRequest* request)
+ {
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+ m_request = request;
+ webkit_form_submission_request_submit(request);
+ quitMainLoop();
+ }
+
+ GHashTable* waitUntilFormSubmittedAndGetTextFields()
+ {
+ g_main_loop_run(m_mainLoop);
+ return webkit_form_submission_request_get_text_fields(m_request.get());
+ }
+
+ static gboolean doClickIdleCallback(FormClientTest* test)
+ {
+ test->clickMouseButton(test->m_submitPositionX, test->m_submitPositionY, 1);
+ return FALSE;
+ }
+
+ void submitFormAtPosition(int x, int y)
+ {
+ m_submitPositionX = x;
+ m_submitPositionY = y;
+ g_idle_add(reinterpret_cast<GSourceFunc>(doClickIdleCallback), this);
+ }
+
+ int m_submitPositionX;
+ int m_submitPositionY;
+ GRefPtr<WebKitFormSubmissionRequest> m_request;
+};
+
+static void testWebViewSubmitForm(FormClientTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ const char* formHTML =
+ "<html><body>"
+ " <form action='#'>"
+ " <input type='text' name='text1' value='value1'>"
+ " <input type='text' name='text2' value='value2'>"
+ " <input type='password' name='password' value='secret'>"
+ " <textarea cols='5' rows='5' name='textarea'>Text</textarea>"
+ " <input type='hidden' name='hidden1' value='hidden1'>"
+ " <input type='submit' value='Submit' style='position:absolute; left:1; top:1' size='10'>"
+ " </form>"
+ "</body></html>";
+
+ test->loadHtml(formHTML, "file:///");
+ test->waitUntilLoadFinished();
+
+ test->submitFormAtPosition(5, 5);
+ GHashTable* values = test->waitUntilFormSubmittedAndGetTextFields();
+ g_assert(values);
+ g_assert_cmpuint(g_hash_table_size(values), ==, 3);
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text1")), ==, "value1");
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text2")), ==, "value2");
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "password")), ==, "secret");
+}
+
void beforeAll()
{
WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
@@ -883,6 +964,7 @@ void beforeAll()
FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen);
WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType);
+ FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm);
}
void afterAll()
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
index 58ac2b7e9..116dafc2d 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -36,6 +36,7 @@
#include <webkit2/WebKitError.h>
#include <webkit2/WebKitFileChooserRequest.h>
#include <webkit2/WebKitFindController.h>
+#include <webkit2/WebKitFormSubmissionRequest.h>
#include <webkit2/WebKitGeolocationPermissionRequest.h>
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index 25bf2e7df..1ba028f23 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -1660,6 +1660,12 @@ bool QQuickWebView::childMouseEventFilter(QQuickItem* item, QEvent* event)
if (!isVisible() || !isEnabled() || !s_flickableViewportEnabled)
return QQuickFlickable::childMouseEventFilter(item, event);
+ Q_D(QQuickWebView);
+ if (d->m_dialogActive) {
+ event->ignore();
+ return false;
+ }
+
// This function is used by MultiPointTouchArea and PinchArea to filter
// touch events, thus to hinder the canvas from sending synthesized
// mouse events to the Flickable implementation we need to reimplement
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
index 9a30e1fd6..e66f368c5 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
@@ -66,6 +66,10 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute
#if ENABLE(WEBGL)
case WebGLEnabled:
return WKPreferencesGetWebGLEnabled(preferencesRef());
+#if ENABLE(CSS_SHADERS)
+ case CSSCustomFilterEnabled:
+ return WKPreferencesGetCSSCustomFilterEnabled(preferencesRef());
+#endif
#endif
default:
ASSERT_NOT_REACHED();
@@ -114,6 +118,11 @@ void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute a
case WebGLEnabled:
WKPreferencesSetWebGLEnabled(preferencesRef(), enable);
break;
+#if ENABLE(CSS_SHADERS)
+ case CSSCustomFilterEnabled:
+ WKPreferencesSetCSSCustomFilterEnabled(preferencesRef(), enable);
+ break;
+#endif
#endif
default:
ASSERT_NOT_REACHED();
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
index 7c1c9bd4f..004500c90 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
@@ -39,7 +39,8 @@ public:
PrivateBrowsingEnabled,
DnsPrefetchEnabled,
DeveloperExtrasEnabled,
- WebGLEnabled
+ WebGLEnabled,
+ CSSCustomFilterEnabled
};
enum FontFamily {
diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
index 16bb567ba..121f90d88 100644
--- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
@@ -25,7 +25,9 @@
#include "LayerTreeCoordinatorProxy.h"
#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
+#if ENABLE(TOUCH_EVENTS)
#include "NativeWebTouchEvent.h"
+#endif
#include "NativeWebWheelEvent.h"
#include "NotImplemented.h"
#include "WebContext.h"
@@ -378,7 +380,9 @@ void QRawWebView::sendWheelEvent(QWheelEvent* event)
d->m_webPageProxy->handleWheelEvent(WebKit::NativeWebWheelEvent(event, QTransform()));
}
+#if ENABLE(TOUCH_EVENTS)
void QRawWebView::sendTouchEvent(QTouchEvent* event)
{
d->m_webPageProxy->handleTouchEvent(WebKit::NativeWebTouchEvent(event, QTransform()));
}
+#endif
diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h
index b8cba692d..a4bef5dd2 100644
--- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h
@@ -30,6 +30,7 @@
#include <WebKit2/WKContext.h>
#include <WebKit2/WKPage.h>
#include <WebKit2/WKPageGroup.h>
+#include <wtf/Platform.h>
class QRect;
class QRectF;
@@ -92,7 +93,9 @@ public:
void sendKeyEvent(QKeyEvent*);
void sendMouseEvent(QMouseEvent*, int clickCount = 0);
void sendWheelEvent(QWheelEvent*);
+#if ENABLE(TOUCH_EVENTS)
void sendTouchEvent(QTouchEvent*);
+#endif
private:
QRawWebViewPrivate* d;