summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/efl
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-07-23 09:28:44 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-07-23 09:28:44 +0200
commit815f1ed417bd26fbe2abbdf20ac5d3423b30796c (patch)
tree923c9a9e2834ccab60f5caecfb8f0ac410c1dd9e /Source/WebKit2/UIProcess/API/efl
parentb4ad5d9d2b96baacd0180ead50de5195ca78af2d (diff)
downloadqtwebkit-815f1ed417bd26fbe2abbdf20ac5d3423b30796c.tar.gz
Imported WebKit commit e65cbc5b6ac32627c797e7fc7f46eb7794410c92 (http://svn.webkit.org/repository/webkit/trunk@123308)
New snapshot with better configure tests
Diffstat (limited to 'Source/WebKit2/UIProcess/API/efl')
-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
14 files changed, 501 insertions, 24 deletions
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; }