diff options
Diffstat (limited to 'Source/WebKit2/UIProcess')
52 files changed, 942 insertions, 233 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp index d168363e8..7fadf3087 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp @@ -181,7 +181,11 @@ WKBatteryManagerRef WKContextGetBatteryManager(WKContextRef contextRef) WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef contextRef) { +#if ENABLE(SQL_DATABASE) return toAPI(toImpl(contextRef)->databaseManagerProxy()); +#else + return 0; +#endif } WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef) diff --git a/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp index 8075a1c0d..4f9496878 100644 --- a/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp @@ -37,118 +37,176 @@ using namespace WebKit; WKTypeID WKDatabaseManagerGetTypeID() { +#if ENABLE(SQL_DATABASE) return toAPI(WebDatabaseManagerProxy::APIType); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetOriginKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::originKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetOriginQuotaKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::originQuotaKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetOriginUsageKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::originUsageKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetDatabaseDetailsKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsNameKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsDisplayNameKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsExpectedUsageKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey() { +#if ENABLE(SQL_DATABASE) static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsCurrentUsageKey()).leakRef(); return toAPI(key); +#else + return 0; +#endif } void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManagerRef, const WKDatabaseManagerClient* wkClient) { +#if ENABLE(SQL_DATABASE) if (wkClient && wkClient->version) return; toImpl(databaseManagerRef)->initializeClient(wkClient); +#endif } void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabasesByOriginFunction callback) { +#if ENABLE(SQL_DATABASE) toImpl(databaseManagerRef)->getDatabasesByOrigin(ArrayCallback::create(context, callback)); +#endif } #ifdef __BLOCKS__ static void callGetDatabasesByOriginBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context) { +#if ENABLE(SQL_DATABASE) WKDatabaseManagerGetDatabasesByOriginBlock block = (WKDatabaseManagerGetDatabasesByOriginBlock)context; block(resultValue, errorRef); Block_release(block); +#endif } void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabasesByOriginBlock block) { +#if ENABLE(SQL_DATABASE) WKDatabaseManagerGetDatabasesByOrigin(databaseManagerRef, Block_copy(block), callGetDatabasesByOriginBlockAndDispose); -} #endif +} +#endif // __BLOCKS__ void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction callback) { +#if ENABLE(SQL_DATABASE) toImpl(databaseManagerRef)->getDatabaseOrigins(ArrayCallback::create(context, callback)); +#endif } #ifdef __BLOCKS__ static void callGetDatabaseOriginsBlockBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context) { +#if ENABLE(SQL_DATABASE) WKDatabaseManagerGetDatabaseOriginsBlock block = (WKDatabaseManagerGetDatabaseOriginsBlock)context; block(resultValue, errorRef); Block_release(block); +#endif } void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabaseOriginsBlock block) { +#if ENABLE(SQL_DATABASE) WKDatabaseManagerGetDatabaseOrigins(databaseManagerRef, Block_copy(block), callGetDatabaseOriginsBlockBlockAndDispose); -} #endif +} +#endif // __BLOCKS__ void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManagerRef, WKStringRef databaseNameRef, WKSecurityOriginRef originRef) { +#if ENABLE(SQL_DATABASE) toImpl(databaseManagerRef)->deleteDatabaseWithNameForOrigin(toWTFString(databaseNameRef), toImpl(originRef)); +#endif } void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManagerRef, WKSecurityOriginRef originRef) { +#if ENABLE(SQL_DATABASE) toImpl(databaseManagerRef)->deleteDatabasesForOrigin(toImpl(originRef)); +#endif } void WKDatabaseManagerDeleteAllDatabases(WKDatabaseManagerRef databaseManagerRef) { +#if ENABLE(SQL_DATABASE) toImpl(databaseManagerRef)->deleteAllDatabases(); +#endif } void WKDatabaseManagerSetQuotaForOrigin(WKDatabaseManagerRef databaseManagerRef, WKSecurityOriginRef originRef, uint64_t quota) { +#if ENABLE(SQL_DATABASE) toImpl(databaseManagerRef)->setQuotaForOrigin(toImpl(originRef), quota); +#endif } diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h index 12a7b63e9..fdacf8b4d 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.h +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -73,8 +73,8 @@ typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBa typedef void (*WKPageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo); typedef void (*WKPageWillGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, WKTypeRef userData, const void *clientInfo); typedef void (*WKPagePluginDidFailCallback)(WKPageRef page, WKErrorCode errorCode, WKStringRef mimeType, WKStringRef pluginIdentifier, WKStringRef pluginVersion, const void* clientInfo); -typedef void (*WKPageDidReceiveIntentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKIntentDataRef intent, const void *clientInfo); -typedef void (*WKPageRegisterIntentServiceForFrameCallback)(WKPageRef page, WKFrameRef frame, WKIntentServiceInfoRef serviceInfo, const void *clientInfo); +typedef void (*WKPageDidReceiveIntentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKIntentDataRef intent, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageRegisterIntentServiceForFrameCallback)(WKPageRef page, WKFrameRef frame, WKIntentServiceInfoRef serviceInfo, WKTypeRef userData, const void *clientInfo); // Deprecated typedef void (*WKPageDidFailToInitializePluginCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef mimeType, const void* clientInfo); diff --git a/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h b/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h index 78df4ac42..974db375f 100644 --- a/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h +++ b/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h @@ -29,7 +29,9 @@ // a Qt specific WKNativeEvent.h file is needed because that the use of __APPLE__ // in original WKNativeEvent.h file breaks Qt build in MacOS +QT_BEGIN_NAMESPACE class QEvent; +QT_END_NAMESPACE typedef const QEvent* WKNativeEventPtr; #endif /* WKNativeEvent_h */ diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h index d7d796368..597cf24cb 100644 --- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h +++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h @@ -34,6 +34,7 @@ #include "ewk_navigation_policy_decision.h" #include "ewk_url_request.h" #include "ewk_url_response.h" +#include "ewk_url_scheme_request.h" #include "ewk_view.h" #include "ewk_web_error.h" #include "ewk_web_resource.h" diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index 21c157c22..b8607e584 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -23,12 +23,34 @@ #include "BatteryProvider.h" #include "WKAPICast.h" +#include "WKContextSoup.h" #include "WKRetainPtr.h" +#include "WKString.h" #include "ewk_context_private.h" +#include "ewk_context_request_manager_client_private.h" #include "ewk_cookie_manager_private.h" +#include <wtf/HashMap.h> +#include <wtf/text/WTFString.h> using namespace WebKit; +struct _Ewk_Url_Scheme_Handler { + Ewk_Url_Scheme_Request_Cb callback; + void* userData; + + _Ewk_Url_Scheme_Handler() + : callback(0) + , userData(0) + { } + + _Ewk_Url_Scheme_Handler(Ewk_Url_Scheme_Request_Cb callback, void* userData) + : callback(callback) + , userData(userData) + { } +}; + +typedef HashMap<String, _Ewk_Url_Scheme_Handler> URLSchemeHandlerMap; + struct _Ewk_Context { WKRetainPtr<WKContextRef> context; @@ -37,10 +59,21 @@ struct _Ewk_Context { RefPtr<BatteryProvider> batteryProvider; #endif + WKRetainPtr<WKSoupRequestManagerRef> requestManager; + URLSchemeHandlerMap urlSchemeHandlers; + _Ewk_Context(WKContextRef contextRef) : context(contextRef) , cookieManager(0) - { } + , requestManager(WKContextGetSoupRequestManager(contextRef)) + { +#if ENABLE(BATTERY_STATUS) + WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(contextRef); + batteryProvider = BatteryProvider::create(wkBatteryManager); +#endif + + ewk_context_request_manager_client_attach(this); + } ~_Ewk_Context() { @@ -64,17 +97,39 @@ WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext) return ewkContext->context.get(); } -static inline Ewk_Context* createDefaultEwkContext() +/** + * @internal + * Retrieve the request manager for @a ewkContext. + * + * @param ewkContext a #Ewk_Context object. + */ +WKSoupRequestManagerRef ewk_context_request_manager_get(const Ewk_Context* ewkContext) { - WKContextRef wkContext = WKContextGetSharedProcessContext(); - Ewk_Context* ewkContext = new Ewk_Context(wkContext); + return ewkContext->requestManager.get(); +} -#if ENABLE(BATTERY_STATUS) - WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(wkContext); - ewkContext->batteryProvider = BatteryProvider::create(wkBatteryManager); -#endif +/** + * @internal + * A new URL request was received. + * + * @param ewkContext a #Ewk_Context object. + * @param schemeRequest a #Ewk_Url_Scheme_Request object. + */ +void ewk_context_url_scheme_request_received(Ewk_Context* ewkContext, Ewk_Url_Scheme_Request* schemeRequest) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EINA_SAFETY_ON_NULL_RETURN(schemeRequest); + + _Ewk_Url_Scheme_Handler handler = ewkContext->urlSchemeHandlers.get(ewk_url_scheme_request_scheme_get(schemeRequest)); + if (!handler.callback) + return; + + handler.callback(schemeRequest, handler.userData); +} - return ewkContext; +static inline Ewk_Context* createDefaultEwkContext() +{ + return new Ewk_Context(WKContextGetSharedProcessContext()); } Ewk_Context* ewk_context_default_get() @@ -83,3 +138,16 @@ Ewk_Context* ewk_context_default_get() return defaultContext; } + +Eina_Bool ewk_context_uri_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(scheme, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false); + + ewkContext->urlSchemeHandlers.set(String::fromUTF8(scheme), _Ewk_Url_Scheme_Handler(callback, userData)); + WKRetainPtr<WKStringRef> wkScheme(AdoptWK, WKStringCreateWithUTF8CString(scheme)); + WKSoupRequestManagerRegisterURIScheme(ewkContext->requestManager.get(), wkScheme.get()); + + return true; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.h b/Source/WebKit2/UIProcess/API/efl/ewk_context.h index e89037766..3df362f6f 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.h @@ -30,6 +30,7 @@ #define ewk_context_h #include "ewk_cookie_manager.h" +#include "ewk_url_scheme_request.h" #include <Evas.h> #ifdef __cplusplus @@ -40,6 +41,12 @@ extern "C" { typedef struct _Ewk_Context Ewk_Context; /** + * @typedef Ewk_Url_Scheme_Request_Cb Ewk_Url_Scheme_Request_Cb + * @brief Callback type for use with ewk_context_uri_scheme_register(). + */ +typedef void (*Ewk_Url_Scheme_Request_Cb) (Ewk_Url_Scheme_Request *request, void *user_data); + +/** * Gets default Ewk_Context instance. * * @return Ewk_Context object. @@ -55,6 +62,49 @@ EAPI Ewk_Context *ewk_context_default_get(); */ EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *context); +/** + * Register @a scheme in @a context. + * + * When an URL request with @a scheme is made in the #Ewk_Context, the callback + * function provided will be called with a #Ewk_Url_Scheme_Request. + * + * It is possible to handle URL scheme requests asynchronously, by calling ewk_url_scheme_ref() on the + * #Ewk_Url_Scheme_Request and calling ewk_url_scheme_request_finish() later when the data of + * the request is available. + * + * @param context a #Ewk_Context object. + * @param scheme the network scheme to register + * @param callback the function to be called when an URL request with @a scheme is made. + * @param user_data data to pass to callback function + * + * @code + * static void about_uri_scheme_request_cb(Ewk_Url_Scheme_Request *request, void *user_data) + * { + * const char *path; + * char *contents_data = NULL; + * unsigned int contents_length = 0; + * + * path = ewk_url_scheme_request_path_get(request); + * if (!strcmp(path, "plugins")) { + * // Initialize contents_data with the contents of plugins about page, and set its length to contents_length + * } else if (!strcmp(path, "memory")) { + * // Initialize contents_data with the contents of memory about page, and set its length to contents_length + * } else if (!strcmp(path, "applications")) { + * // Initialize contents_data with the contents of application about page, and set its length to contents_length + * } else { + * Eina_Strbuf *buf = eina_strbuf_new(); + * eina_strbuf_append_printf(buf, "<html><body><p>Invalid about:%s page</p></body></html>", path); + * contents_data = eina_strbuf_string_steal(buf); + * contents_length = strlen(contents); + * eina_strbuf_free(buf); + * } + * ewk_url_scheme_request_finish(request, contents_data, contents_length, "text/html"); + * free(contents_data); + * } + * @endcode + */ +EAPI Eina_Bool ewk_context_uri_scheme_register(Ewk_Context *context, const char *scheme, Ewk_Url_Scheme_Request_Cb callback, void *user_data); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h index 813a94257..d78e1e961 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h @@ -23,7 +23,10 @@ #include <WebKit2/WKBase.h> typedef struct _Ewk_Context Ewk_Context; +typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; WKContextRef ewk_context_WKContext_get(const Ewk_Context*); +WKSoupRequestManagerRef ewk_context_request_manager_get(const Ewk_Context*); +void ewk_context_url_scheme_request_received(Ewk_Context*, Ewk_Url_Scheme_Request*); #endif // ewk_context_private_h diff --git a/Source/WebKit2/UIProcess/WebIntentData.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp index 96128dbe2..b22bd36ff 100644 --- a/Source/WebKit2/UIProcess/WebIntentData.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp @@ -24,52 +24,34 @@ */ #include "config.h" -#include "WebIntentData.h" -#if ENABLE(WEB_INTENTS) +#include "WKBase.h" +#include "WKSoupRequestManager.h" +#include "ewk_context_private.h" +#include "ewk_context_request_manager_client_private.h" +#include "ewk_url_scheme_request.h" +#include "ewk_url_scheme_request_private.h" -#include "ImmutableArray.h" -#include "ImmutableDictionary.h" -#include "WebString.h" -#include "WebURL.h" - -namespace WebKit { - -WebIntentData::WebIntentData(const IntentData& store) - : m_store(store) +static inline Ewk_Context* toEwkContext(const void* clientInfo) { + return static_cast<Ewk_Context*>(const_cast<void*>(clientInfo)); } -PassRefPtr<WebSerializedScriptValue> WebIntentData::data() const +static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, uint64_t requestID, const void* clientInfo) { - Vector<uint8_t> dataCopy = m_store.data; - return WebSerializedScriptValue::adopt(dataCopy); + Ewk_Url_Scheme_Request* schemeRequest = ewk_url_scheme_request_new(soupRequestManagerRef, urlRef, requestID); + ewk_context_url_scheme_request_received(toEwkContext(clientInfo), schemeRequest); + ewk_url_scheme_request_unref(schemeRequest); } -PassRefPtr<ImmutableArray> WebIntentData::suggestions() const +void ewk_context_request_manager_client_attach(Ewk_Context* context) { - const size_t numSuggestions = m_store.suggestions.size(); - Vector<RefPtr<APIObject> > wkSuggestions(numSuggestions); - for (unsigned i = 0; i < numSuggestions; ++i) - wkSuggestions[i] = WebURL::create(m_store.suggestions[i]); - return ImmutableArray::adopt(wkSuggestions); -} + WKSoupRequestManagerClient wkRequestManagerClient; + memset(&wkRequestManagerClient, 0, sizeof(WKSoupRequestManagerClient)); -String WebIntentData::extra(const String& key) const -{ - return m_store.extras.get(key); -} + wkRequestManagerClient.version = kWKSoupRequestManagerClientCurrentVersion; + wkRequestManagerClient.clientInfo = context; + wkRequestManagerClient.didReceiveURIRequest = didReceiveURIRequest; -PassRefPtr<ImmutableDictionary> WebIntentData::extras() const -{ - ImmutableDictionary::MapType wkExtras; - HashMap<String, String>::const_iterator end = m_store.extras.end(); - for (HashMap<String, String>::const_iterator it = m_store.extras.begin(); it != end; ++it) - wkExtras.set(it->first, WebString::create(it->second)); - return ImmutableDictionary::adopt(wkExtras); + WKSoupRequestManagerSetClient(ewk_context_request_manager_get(context), &wkRequestManagerClient); } - -} // namespace WebKit - -#endif // ENABLE(WEB_INTENTS) - diff --git a/Source/WebKit2/UIProcess/WebIntentServiceInfo.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client_private.h index 84329c5e7..689bbf622 100644 --- a/Source/WebKit2/UIProcess/WebIntentServiceInfo.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client_private.h @@ -23,18 +23,11 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "WebIntentServiceInfo.h" +#ifndef ewk_context_request_manager_client_private_h +#define ewk_context_request_manager_client_private_h -#if ENABLE(WEB_INTENTS_TAG) +typedef struct _Ewk_Context Ewk_Context; -namespace WebKit { +void ewk_context_request_manager_client_attach(Ewk_Context* context); -WebIntentServiceInfo::WebIntentServiceInfo(const IntentServiceInfo& store) - : m_store(store) -{ -} - -} // namespace WebKit - -#endif // ENABLE(WEB_INTENTS_TAG) +#endif // ewk_context_request_manager_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h index 442c4f7ca..e93ed8ed8 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h @@ -51,7 +51,7 @@ enum _Ewk_Cookie_Accept_Policy { EWK_COOKIE_ACCEPT_POLICY_ALWAYS, /// Rejects all cookies. EWK_COOKIE_ACCEPT_POLICY_NEVER, - /// Accepts cookies only from the main page. + /// Accepts only cookies set by the main document loaded. EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY }; @@ -107,7 +107,7 @@ EAPI void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager *manager, /** * Set @a policy as the cookie acceptance policy for @a manager. * - * By default, cookies are always accepted. + * By default, only cookies set by the main document loaded are accepted. * * @param manager The cookie manager to update. * @param policy a #Ewk_Cookie_Accept_Policy @@ -118,7 +118,7 @@ EAPI void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager *manager, Ewk_ /** * Asynchronously get the cookie acceptance policy of @a manager. * - * By default, cookies are always accepted. + * By default, only cookies set by the main document loaded are accepted. * * @param manager The cookie manager to query. * @param callback The function to call when the policy is received or an error occured. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp index a424ddda3..f209952fe 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp @@ -31,7 +31,6 @@ #include "WKURL.h" #include "WKURLRequest.h" #include "WebURLRequest.h" -#include "WebURLRequestEfl.h" #include "ewk_url_request_private.h" #include <wtf/text/CString.h> diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp new file mode 100644 index 000000000..693ff3df6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp @@ -0,0 +1,141 @@ +/* + * 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_url_scheme_request.h" + +#include "WKData.h" +#include "WKRetainPtr.h" +#include "WKSoupRequestManager.h" +#include "WKString.h" +#include <wtf/text/CString.h> + +using namespace WebKit; + +/** + * \struct _Ewk_Url_Scheme_Request + * @brief Contains the URL scheme request data. + */ +struct _Ewk_Url_Scheme_Request { + unsigned int __ref; /**< the reference count of the object */ + WKRetainPtr<WKSoupRequestManagerRef> wkRequestManager; + const char* url; + uint64_t requestID; + const char* scheme; + const char* path; + + _Ewk_Url_Scheme_Request(WKSoupRequestManagerRef manager, const char* _url, uint64_t _requestID) + : __ref(1) + , wkRequestManager(manager) + , url(eina_stringshare_add(_url)) + , requestID(_requestID) + { + SoupURI* soupURI = soup_uri_new(_url); + scheme = eina_stringshare_add(soupURI->scheme); + path = eina_stringshare_add(soupURI->path); + soup_uri_free(soupURI); + } + + ~_Ewk_Url_Scheme_Request() + { + ASSERT(!__ref); + eina_stringshare_del(url); + eina_stringshare_del(scheme); + eina_stringshare_del(path); + } +}; + +void ewk_url_scheme_request_ref(Ewk_Url_Scheme_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN(request); + ++request->__ref; +} + +void ewk_url_scheme_request_unref(Ewk_Url_Scheme_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN(request); + + if (--request->__ref) + return; + + delete request; +} + +const char* ewk_url_scheme_request_scheme_get(const Ewk_Url_Scheme_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + return request->scheme; +} + +const char* ewk_url_scheme_request_url_get(const Ewk_Url_Scheme_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + return request->url; +} + +const char* ewk_url_scheme_request_path_get(const Ewk_Url_Scheme_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + return request->path; +} + +/** + * @internal + * Returns the #Ewk_Url_Scheme_Request identifier. + */ +uint64_t ewk_url_scheme_request_id_get(const Ewk_Url_Scheme_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + return request->requestID; +} + +Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request* request, void* contentData, unsigned int contentLength, const char* mimeType) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); + + WKRetainPtr<WKDataRef> wkData(AdoptWK, WKDataCreate(contentLength ? reinterpret_cast<const unsigned char*>(contentData) : 0, contentLength)); + WKRetainPtr<WKStringRef> wkMimeType = mimeType ? adoptWK(WKStringCreateWithUTF8CString(mimeType)) : 0; + + // In case of empty reply an empty WKDataRef is sent to the WebProcess. + WKSoupRequestManagerDidHandleURIRequest(request->wkRequestManager.get(), wkData.get(), contentLength, wkMimeType.get(), request->requestID); + + return true; +} + +/** + * @internal + * Constructs a Ewk_Url_Scheme_Request. + */ +Ewk_Url_Scheme_Request* ewk_url_scheme_request_new(WKSoupRequestManagerRef requestManager, WKURLRef url, uint64_t requestID) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(requestManager, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0); + + return new Ewk_Url_Scheme_Request(requestManager, toImpl(url)->string().utf8().data(), requestID); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h new file mode 100644 index 000000000..034cbd474 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h @@ -0,0 +1,112 @@ +/* + * 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_url_scheme_request.h + * @brief Describes the Ewk URL scheme request API. + */ + +#ifndef ewk_url_scheme_request_h +#define ewk_url_scheme_request_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Url_Scheme_Request */ +typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; + +/** + * Increases the reference count of the given object. + * + * @param request the URL scheme request object to increase the reference count + */ +EAPI void ewk_url_scheme_request_ref(Ewk_Url_Scheme_Request *request); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count it's reached 0, the URL scheme request is freed. + * + * @param request the URL request object to decrease the reference count + */ +EAPI void ewk_url_scheme_request_unref(Ewk_Url_Scheme_Request *request); + +/** + * Query the URL scheme for this request. + * + * @param request request object to query. + * + * @return the URL scheme pointer, that may be @c NULL. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup(). + */ +EAPI const char *ewk_url_scheme_request_scheme_get(const Ewk_Url_Scheme_Request *request); + +/** + * Query the URL for this request. + * + * @param request request object to query. + * + * @return the URL pointer, that may be @c NULL. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup(). + */ +EAPI const char *ewk_url_scheme_request_url_get(const Ewk_Url_Scheme_Request *request); + +/** + * Query the path part of the URL for this request. + * + * @param request request object to query. + * + * @return the path pointer, that may be @c NULL. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup(). + */ +EAPI const char *ewk_url_scheme_request_path_get(const Ewk_Url_Scheme_Request *request); + +/** + * Finish a Ewk_Url_Scheme_Request by setting the content of the request and its mime type. + * + * @param request a Ewk_Url_Scheme_Request. + * @param content_data the data content of the request (may be %c NULL if the content is empty). + * @param content_length the length of the @a content_data. + * @param mime_type the content type of the stream or %c NULL if not known + */ +EAPI Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request *request, void *content_data, unsigned int content_length, const char *mime_type); + +#ifdef __cplusplus +} +#endif + +#endif // ewk_url_scheme_request_h diff --git a/Source/WebKit2/UIProcess/WebIntentServiceInfo.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request_private.h index 8694601f0..e5dd4174b 100644 --- a/Source/WebKit2/UIProcess/WebIntentServiceInfo.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request_private.h @@ -23,44 +23,16 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebIntentServiceInfo_h -#define WebIntentServiceInfo_h +#ifndef ewk_url_scheme_request_private_h +#define ewk_url_scheme_request_private_h -#if ENABLE(WEB_INTENTS_TAG) +#include "WKBase.h" -#include "APIObject.h" -#include "IntentServiceInfo.h" -#include <wtf/PassRefPtr.h> +typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; +typedef struct _Ewk_Context Ewk_Context; -namespace WebKit { +Ewk_Url_Scheme_Request* ewk_url_scheme_request_new(WKSoupRequestManagerRef, WKURLRef, uint64_t requestID); -class WebIntentServiceInfo : public APIObject { -public: - static const Type APIType = TypeIntentServiceInfo; +uint64_t ewk_url_scheme_request_id_get(const Ewk_Url_Scheme_Request* request); - static PassRefPtr<WebIntentServiceInfo> create(const IntentServiceInfo& store) - { - return adoptRef(new WebIntentServiceInfo(store)); - } - - virtual ~WebIntentServiceInfo() { } - - const String& action() const { return m_store.action; } - const String& payloadType() const { return m_store.type; } - const WebCore::KURL& href() const { return m_store.href; } - const String& title() const { return m_store.title; } - const String& disposition() const { return m_store.disposition; } - -private: - WebIntentServiceInfo(const IntentServiceInfo&); - - virtual Type type() const { return APIType; } - - IntentServiceInfo m_store; -}; - -} // namespace WebKit - -#endif // ENABLE(WEB_INTENTS_TAG) - -#endif // WebIntentServiceInfo_h +#endif // ewk_url_scheme_request_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index 6a8e74f82..924dbcf67 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -161,7 +161,7 @@ typedef struct _Ewk_Web_Resource_Request Ewk_Web_Resource_Request; struct _Ewk_Web_Resource_Request { Ewk_Web_Resource *resource; /**< resource being requested */ Ewk_Url_Request *request; /**< URL request for the resource */ - Ewk_Url_Response *redirect_response; /**< Possible redirect response for the resource */ + Ewk_Url_Response *redirect_response; /**< Possible redirect response for the resource or @c NULL */ }; /// Creates a type name for _Ewk_Web_Resource_Load_Response. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp index 3c28f2984..cc8b120cd 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp @@ -48,7 +48,7 @@ static void didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef fra } #if ENABLE(WEB_INTENTS) -static void didReceiveIntentForFrame(WKPageRef page, WKFrameRef frame, WKIntentDataRef intent, const void* clientInfo) +static void didReceiveIntentForFrame(WKPageRef page, WKFrameRef frame, WKIntentDataRef intent, WKTypeRef, const void* clientInfo) { Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); Ewk_Intent* ewkIntent = ewk_intent_new(intent); @@ -58,7 +58,7 @@ static void didReceiveIntentForFrame(WKPageRef page, WKFrameRef frame, WKIntentD #endif #if ENABLE(WEB_INTENTS_TAG) -static void registerIntentServiceForFrame(WKPageRef page, WKFrameRef frame, WKIntentServiceInfoRef serviceInfo, const void *clientInfo) +static void registerIntentServiceForFrame(WKPageRef page, WKFrameRef frame, WKIntentServiceInfoRef serviceInfo, WKTypeRef, const void *clientInfo) { Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); Ewk_Intent_Service* ewkIntentService = ewk_intent_service_new(serviceInfo); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp index 505bbeddb..113e178b9 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp @@ -44,6 +44,7 @@ #include "ewk_web_resource_private.h" #include <wtf/text/CString.h> +using namespace WebCore; using namespace WebKit; static inline Evas_Object* toEwkView(const void* clientInfo) @@ -66,10 +67,11 @@ static void didInitiateLoadForResource(WKPageRef, WKFrameRef wkFrame, uint64_t r static void didSendRequestForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo) { Ewk_Url_Request* request = ewk_url_request_new(wkRequest); - Ewk_Url_Response* redirectResponse = ewk_url_response_new(toImpl(wkRedirectResponse)->resourceResponse()); + Ewk_Url_Response* redirectResponse = wkRedirectResponse ? ewk_url_response_new(toImpl(wkRedirectResponse)->resourceResponse()) : 0; ewk_view_resource_request_sent(toEwkView(clientInfo), resourceIdentifier, request, redirectResponse); ewk_url_request_unref(request); - ewk_url_response_unref(redirectResponse); + if (redirectResponse) + ewk_url_response_unref(redirectResponse); } static void didReceiveResponseForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLResponseRef wkResponse, const void* clientInfo) diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp index 05168e26d..b8da86dce 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp @@ -23,6 +23,7 @@ #include "EWK2UnitTestEnvironment.h" #include <EWebKit2.h> #include <Ecore.h> +#include <glib-object.h> #include <wtf/UnusedParam.h> extern EWK2UnitTest::EWK2UnitTestEnvironment* environment; @@ -48,6 +49,11 @@ void EWK2UnitTestBase::SetUp() { ASSERT_GT(ecore_evas_init(), 0); + // glib support (for libsoup). + g_type_init(); + if (!ecore_main_loop_glib_integrate()) + fprintf(stderr, "WARNING: Glib main loop integration is not working. Some tests may fail."); + unsigned int width = environment->defaultWidth(); unsigned int height = environment->defaultHeight(); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp new file mode 100644 index 000000000..13e577984 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 Igalia S.L. + * Copyright (C) 2012 Intel Corporation + * + * 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 "EWK2UnitTestServer.h" + +EWK2UnitTestServer::EWK2UnitTestServer() +{ + SoupAddress* address = soup_address_new("127.0.0.1", SOUP_ADDRESS_ANY_PORT); + soup_address_resolve_sync(address, 0); + + m_soupServer = soup_server_new(SOUP_SERVER_INTERFACE, address, 0); + m_baseURI = soup_uri_new("http://127.0.0.1/"); + soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer)); + g_object_unref(address); +} + +EWK2UnitTestServer::~EWK2UnitTestServer() +{ + soup_uri_free(m_baseURI); + g_object_unref(m_soupServer); +} + +void EWK2UnitTestServer::run(SoupServerCallback serverCallback) +{ + soup_server_run_async(m_soupServer); + soup_server_add_handler(m_soupServer, 0, serverCallback, 0, 0); +} + +CString EWK2UnitTestServer::getURIForPath(const char* path) const +{ + SoupURI* soupURI = soup_uri_new_with_base(m_baseURI, path); + char* uri = soup_uri_to_string(soupURI, false); + CString uriString = uri; + free(uri); + soup_uri_free(soupURI); + + return uriString; +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h new file mode 100644 index 000000000..3eb146f06 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 Igalia S.L. + * Copyright (C) 2012 Intel Corporation + * + * 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 EWK2UnitTestServer_h +#define EWK2UnitTestServer_h + +#include <libsoup/soup.h> +#include <wtf/text/CString.h> + +class EWK2UnitTestServer { +public: + EWK2UnitTestServer(); + virtual ~EWK2UnitTestServer(); + + SoupURI* baseURI() const { return m_baseURI; } + + CString getURIForPath(const char* path) const; + void run(SoupServerCallback); + +private: + SoupServer* m_soupServer; + SoupURI* m_baseURI; +}; + +#endif // EWK2UnitTestServer_h + diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp new file mode 100644 index 000000000..86815b42c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp @@ -0,0 +1,239 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * Copyright (C) 2012 Intel Corporation + * + * 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 "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include "UnitTestUtils/EWK2UnitTestServer.h" +#include <EWebKit2.h> +#include <Ecore.h> +#include <Eina.h> +#include <stdlib.h> +#include <unistd.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> + +using namespace EWK2UnitTest; +using namespace WTF; + +extern EWK2UnitTestEnvironment* environment; + +static const char FIRST_PARTY_DOMAIN[] = "127.0.0.1"; +static const char THIRD_PARTY_DOMAIN[] = "localhost"; +static const char INDEX_HTML_STRING[] = + "<html><body>" + " <p>EFLWebKit2 Cookie Manager test</p>" + " <img src='http://localhost:%u/image.png' width=5 height=5></img>" + "</body></html>"; + +static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + soup_message_set_status(message, SOUP_STATUS_OK); + if (!strcmp(path, "/index.html")) { + Eina_Strbuf* buffer = eina_strbuf_new(); + eina_strbuf_append_printf(buffer, INDEX_HTML_STRING, soup_server_get_port(server)); + soup_message_headers_replace(message->response_headers, "Set-Cookie", "foo=bar; Max-Age=60"); + soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, eina_strbuf_string_steal(buffer), eina_strbuf_length_get(buffer)); + eina_strbuf_string_free(buffer); + } else if (!strcmp(path, "/image.png")) + soup_message_headers_replace(message->response_headers, "Set-Cookie", "baz=qux; Max-Age=60"); + else + FAIL(); + soup_message_body_complete(message->response_body); +} + +static void getAcceptPolicyCallback(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error* error, void* event_info) +{ + ASSERT_FALSE(error); + Ewk_Cookie_Accept_Policy* ret = static_cast<Ewk_Cookie_Accept_Policy*>(event_info); + *ret = policy; + ecore_main_loop_quit(); +} + +static Ewk_Cookie_Accept_Policy getAcceptPolicy(Ewk_Cookie_Manager* manager) +{ + Ewk_Cookie_Accept_Policy policy = EWK_COOKIE_ACCEPT_POLICY_ALWAYS; + ewk_cookie_manager_async_accept_policy_get(manager, getAcceptPolicyCallback, &policy); + ecore_main_loop_begin(); + return policy; +} + +static void getHostnamesWithCookiesCallback(Eina_List* hostnames, Ewk_Web_Error* error, void* event_info) +{ + ASSERT_FALSE(error); + + Eina_List** ret = static_cast<Eina_List**>(event_info); + Eina_List* l; + void* data; + EINA_LIST_FOREACH(hostnames, l, data) + *ret = eina_list_append(*ret, eina_stringshare_ref(static_cast<char*>(data))); + ecore_main_loop_quit(); +} + +static Eina_List* getHostnamesWithCookies(Ewk_Cookie_Manager* manager) +{ + Eina_List* ret = 0; + ewk_cookie_manager_async_hostnames_with_cookies_get(manager, getHostnamesWithCookiesCallback, &ret); + ecore_main_loop_begin(); + return ret; +} + +static void freeHostNames(Eina_List* hostnames) +{ + void* data; + EINA_LIST_FREE(hostnames, data) + eina_stringshare_del(static_cast<char*>(data)); +} + +static int countHostnamesWithCookies(Ewk_Cookie_Manager* manager) +{ + Eina_List* hostnames = getHostnamesWithCookies(manager); + int count = eina_list_count(hostnames); + freeHostNames(hostnames); + return count; +} + +TEST_F(EWK2UnitTestBase, ewk_cookie_manager_accept_policy) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + ASSERT_TRUE(cookieManager); + + // Default policy is EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY. + ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY); + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + + Eina_List* hostnames = getHostnamesWithCookies(cookieManager); + ASSERT_EQ(eina_list_count(hostnames), 1); + ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), FIRST_PARTY_DOMAIN); + freeHostNames(hostnames); + ewk_cookie_manager_cookies_clear(cookieManager); + + // Change policy to EWK_COOKIE_ACCEPT_POLICY_ALWAYS + ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + + hostnames = getHostnamesWithCookies(cookieManager); + ASSERT_EQ(eina_list_count(hostnames), 2); + ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), FIRST_PARTY_DOMAIN); + ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 1)), THIRD_PARTY_DOMAIN); + freeHostNames(hostnames); + ewk_cookie_manager_cookies_clear(cookieManager); + + // Change policy to EWK_COOKIE_ACCEPT_POLICY_NEVER + ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER); + ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_NEVER); + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); +} + +TEST_F(EWK2UnitTestBase, ewk_cookie_manager_cookies_delete) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + ASSERT_TRUE(cookieManager); + + ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + Eina_List* hostnames = getHostnamesWithCookies(cookieManager); + ASSERT_EQ(eina_list_count(hostnames), 2); + freeHostNames(hostnames); + + // Delete first party cookie + ewk_cookie_manager_hostname_cookies_clear(cookieManager, FIRST_PARTY_DOMAIN); + hostnames = getHostnamesWithCookies(cookieManager); + ASSERT_EQ(eina_list_count(hostnames), 1); + ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), THIRD_PARTY_DOMAIN); + freeHostNames(hostnames); + + // Delete third party cookie + ewk_cookie_manager_hostname_cookies_clear(cookieManager, THIRD_PARTY_DOMAIN); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + + // Get all cookies again + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + + // Clear all cookies + ewk_cookie_manager_cookies_clear(cookieManager); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); +} + +TEST_F(EWK2UnitTestBase, ewk_cookie_manager_permanent_storage) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + // Generate unique names for cookie storages. + char textStorage[] = "/tmp/txt-cookie.XXXXXX"; + ASSERT_TRUE(mktemp(textStorage)); + char sqliteStorage[] = "/tmp/sqlite-cookie.XXXXXX"; + ASSERT_TRUE(mktemp(sqliteStorage)); + + Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get()); + ASSERT_TRUE(cookieManager); + + ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + + // Text storage using a new file. + ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + + // SQLite storage using a new file. + ewk_cookie_manager_persistent_storage_set(cookieManager, sqliteStorage, EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + + loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + + // Text storage using an existing file. + ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ewk_cookie_manager_cookies_clear(cookieManager); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + + // SQLite storage with an existing file. + ewk_cookie_manager_persistent_storage_set(cookieManager, sqliteStorage, EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ewk_cookie_manager_cookies_clear(cookieManager); + ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + + // Final clean up. + unlink(textStorage); + unlink(sqliteStorage); +} + diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp index e1f6759ac..99c5ffb40 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp @@ -30,7 +30,6 @@ #include "qquickwebpage_p_p.h" #include "qquickwebview_p.h" #include "qwebkittest_p.h" -#include <QtQuick/QQuickCanvas> using namespace WebKit; diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index 1ba028f23..fa0446fec 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -491,7 +491,7 @@ void QQuickWebViewPrivate::updateIcon() { Q_Q(QQuickWebView); - QQuickView* view = qobject_cast<QQuickView*>(q->canvas()); + QQuickView* view = qobject_cast<QQuickView*>(q->window()); if (!view) return; diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index ceaab68a0..8d0f4ffb9 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -27,8 +27,10 @@ #include <QtQuick/qquickitem.h> #include <private/qquickflickable_p.h> -class QWebNavigationRequest; +QT_BEGIN_NAMESPACE class QQmlComponent; +QT_END_NAMESPACE +class QWebNavigationRequest; class QQuickWebPage; class QQuickWebViewAttached; class QWebLoadRequest; diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h index fa630754b..f1a3e572c 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h @@ -33,11 +33,13 @@ #include <QVariant> #include <QtQml/qqml.h> +QT_BEGIN_NAMESPACE class QAbstractListModel; +class QString; +class QUrl; +QT_END_NAMESPACE class QWebNavigationHistoryPrivate; class QWebNavigationListModelPrivate; -class QUrl; -class QString; class QWEBKIT_EXPORT QWebNavigationListModel : public QAbstractListModel { Q_OBJECT diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h index a4bef5dd2..4608ff9d7 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h @@ -32,6 +32,7 @@ #include <WebKit2/WKPageGroup.h> #include <wtf/Platform.h> +QT_BEGIN_NAMESPACE class QRect; class QRectF; class QPoint; @@ -43,6 +44,7 @@ class QTouchEvent; class QUrl; class QMatrix4x4; class QCursor; +QT_END_NAMESPACE class QRawWebViewPrivate; diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp index a81778270..d347e158a 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp @@ -314,9 +314,9 @@ void tst_QQuickWebView::multipleWebViews() // This should not crash. QScopedPointer<QQuickWebView> webView1(newWebView()); - webView1->setParentItem(m_window->rootItem()); + webView1->setParentItem(m_window->contentItem()); QScopedPointer<QQuickWebView> webView2(newWebView()); - webView2->setParentItem(m_window->rootItem()); + webView2->setParentItem(m_window->contentItem()); webView1->setSize(QSizeF(300, 400)); webView1->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html"))); @@ -344,7 +344,7 @@ void tst_QQuickWebView::basicRenderingSanity() // This should not crash. webView()->setVisible(true); QTest::qWait(200); - QImage grabbedWindow = m_window->grabFrameBuffer(); + QImage grabbedWindow = m_window->grabWindow(); QRgb testColor = qRgba(0, 0xff, 0, 0xff); QVERIFY(grabbedWindow.pixel(10, 10) == testColor); QVERIFY(grabbedWindow.pixel(100, 10) == testColor); @@ -376,9 +376,9 @@ void tst_QQuickWebView::transparentWebViews() // This should not crash. QScopedPointer<QQuickWebView> webView1(newWebView()); - webView1->setParentItem(m_window->rootItem()); + webView1->setParentItem(m_window->contentItem()); QScopedPointer<QQuickWebView> webView2(newWebView()); - webView2->setParentItem(m_window->rootItem()); + webView2->setParentItem(m_window->contentItem()); QVERIFY(!webView1->experimental()->transparentBackground()); webView2->experimental()->setTransparentBackground(true); QVERIFY(webView2->experimental()->transparentBackground()); diff --git a/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h index 6d855cf97..4b2cfcf11 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h +++ b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h @@ -43,7 +43,7 @@ inline TestWindow::TestWindow(QQuickItem* webView) : webView(webView) { Q_ASSERT(webView); - webView->setParentItem(rootItem()); + webView->setParentItem(contentItem()); } inline void TestWindow::resizeEvent(QResizeEvent* event) diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h index 426fea14a..805b8ac34 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.h @@ -36,7 +36,9 @@ #include <wtf/Noncopyable.h> #if PLATFORM(QT) +QT_BEGIN_NAMESPACE class QPainter; +QT_END_NAMESPACE #elif PLATFORM(GTK) typedef struct _cairo cairo_t; #endif diff --git a/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h b/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h index f3a5312a2..46a72086c 100644 --- a/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h +++ b/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h @@ -32,7 +32,9 @@ #include <wtf/Threading.h> #if PLATFORM(QT) +QT_BEGIN_NAMESPACE class QLocalSocket; +QT_END_NAMESPACE #endif namespace WebKit { diff --git a/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp b/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp index 86dddbf61..23d213545 100644 --- a/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp +++ b/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp @@ -21,11 +21,10 @@ #include "ProcessLauncher.h" #include "Connection.h" +#include "ProcessExecutablePath.h" #include <WebCore/FileSystem.h> #include <WebCore/ResourceHandle.h> #include <WebCore/RunLoop.h> -#include <libgen.h> -#include <unistd.h> #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> @@ -45,38 +44,26 @@ void ProcessLauncher::launchProcess() if (!pid) { // child process close(sockets[1]); String socket = String::format("%d", sockets[0]); - String processName; + String executablePath; switch (m_launchOptions.processType) { case WebProcess: - processName = "WebProcess"; + executablePath = executablePathOfWebProcess(); break; case PluginProcess: - processName = "PluginProcess"; + executablePath = executablePathOfPluginProcess(); break; default: ASSERT_NOT_REACHED(); return; } - String executablePath; - char readLinkBuffer[PATH_MAX]; - memset(readLinkBuffer, 0, PATH_MAX); - ssize_t result = readlink("/proc/self/exe", readLinkBuffer, PATH_MAX); - - if (result == -1) - executablePath = String("/usr/bin"); - else { - char* executablePathPtr = dirname(readLinkBuffer); - executablePath = String(executablePathPtr); - } - String fullPath = executablePath + "/" + processName; #ifndef NDEBUG if (m_launchOptions.processCmdPrefix.isEmpty()) #endif - execl(fullPath.utf8().data(), processName.utf8().data(), socket.utf8().data(), static_cast<char*>(0)); + execl(executablePath.utf8().data(), executablePath.utf8().data(), socket.utf8().data(), static_cast<char*>(0)); #ifndef NDEBUG else { - String cmd = makeString(m_launchOptions.processCmdPrefix, ' ', fullPath, ' ', socket); + String cmd = makeString(m_launchOptions.processCmdPrefix, ' ', executablePath, ' ', socket); if (system(cmd.utf8().data()) == -1) { ASSERT_NOT_REACHED(); return; @@ -92,7 +79,6 @@ void ProcessLauncher::launchProcess() ASSERT_NOT_REACHED(); return; } - } void ProcessLauncher::terminateProcess() diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp index c5c3f7145..f099d6283 100644 --- a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp +++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp @@ -101,9 +101,15 @@ void QtWebProcess::setupChildProcess() void ProcessLauncher::launchProcess() { - QString commandLine = QLatin1String("%1 %2"); - commandLine = commandLine.arg(m_launchOptions.processType == WebProcess ? - executablePathOfWebProcess() : executablePathOfPluginProcess()); + QString commandLine = QLatin1String("%1 %2 %3"); + if (m_launchOptions.processType == WebProcess) { + QByteArray webProcessPrefix = qgetenv("QT_WEBKIT2_WP_CMD_PREFIX"); + commandLine = commandLine.arg(QLatin1String(webProcessPrefix.constData())).arg(QString(executablePathOfWebProcess())); + } else if (m_launchOptions.processType == PluginProcess) { + QByteArray pluginProcessPrefix = qgetenv("QT_WEBKIT2_PP_CMD_PREFIX"); + commandLine = commandLine.arg(QLatin1String(pluginProcessPrefix.constData())).arg(QString(executablePathOfPluginProcess())); + } else + ASSERT_NOT_REACHED(); #if OS(DARWIN) // Create the listening port. diff --git a/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.h b/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.h index b4e7b7ce2..eca6900b6 100644 --- a/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.h +++ b/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.h @@ -36,7 +36,9 @@ #include <wtf/Functional.h> #include <wtf/HashSet.h> +QT_BEGIN_NAMESPACE class QSGNode; +QT_END_NAMESPACE namespace WebKit { diff --git a/Source/WebKit2/UIProcess/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp index c9c0b94df..22e4e2006 100644 --- a/Source/WebKit2/UIProcess/WebContext.cpp +++ b/Source/WebKit2/UIProcess/WebContext.cpp @@ -146,7 +146,9 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa , m_batteryManagerProxy(WebBatteryManagerProxy::create(this)) #endif , m_cookieManagerProxy(WebCookieManagerProxy::create(this)) +#if ENABLE(SQL_DATABASE) , m_databaseManagerProxy(WebDatabaseManagerProxy::create(this)) +#endif , m_geolocationManagerProxy(WebGeolocationManagerProxy::create(this)) , m_iconDatabase(WebIconDatabase::create(this)) , m_keyValueStorageManagerProxy(WebKeyValueStorageManagerProxy::create(this)) @@ -210,8 +212,10 @@ WebContext::~WebContext() m_cookieManagerProxy->invalidate(); m_cookieManagerProxy->clearContext(); +#if ENABLE(SQL_DATABASE) m_databaseManagerProxy->invalidate(); m_databaseManagerProxy->clearContext(); +#endif m_geolocationManagerProxy->invalidate(); m_geolocationManagerProxy->clearContext(); @@ -381,8 +385,10 @@ bool WebContext::shouldTerminate(WebProcessProxy* process) return false; if (!m_cookieManagerProxy->shouldTerminate(process)) return false; +#if ENABLE(SQL_DATABASE) if (!m_databaseManagerProxy->shouldTerminate(process)) return false; +#endif if (!m_keyValueStorageManagerProxy->shouldTerminate(process)) return false; if (!m_mediaCacheManagerProxy->shouldTerminate(process)) @@ -438,7 +444,9 @@ void WebContext::disconnectProcess(WebProcessProxy* process) m_batteryManagerProxy->invalidate(); #endif m_cookieManagerProxy->invalidate(); +#if ENABLE(SQL_DATABASE) m_databaseManagerProxy->invalidate(); +#endif m_geolocationManagerProxy->invalidate(); m_keyValueStorageManagerProxy->invalidate(); m_mediaCacheManagerProxy->invalidate(); @@ -788,10 +796,12 @@ void WebContext::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes return; } +#if ENABLE(SQL_DATABASE) if (messageID.is<CoreIPC::MessageClassWebDatabaseManagerProxy>()) { m_databaseManagerProxy->didReceiveWebDatabaseManagerProxyMessage(connection, messageID, arguments); return; } +#endif if (messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>()) { m_geolocationManagerProxy->didReceiveMessage(connection, messageID, arguments); diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h index c748f22f2..6b6d97e0f 100644 --- a/Source/WebKit2/UIProcess/WebContext.h +++ b/Source/WebKit2/UIProcess/WebContext.h @@ -167,7 +167,9 @@ public: WebBatteryManagerProxy* batteryManagerProxy() const { return m_batteryManagerProxy.get(); } #endif WebCookieManagerProxy* cookieManagerProxy() const { return m_cookieManagerProxy.get(); } +#if ENABLE(SQL_DATABASE) WebDatabaseManagerProxy* databaseManagerProxy() const { return m_databaseManagerProxy.get(); } +#endif WebGeolocationManagerProxy* geolocationManagerProxy() const { return m_geolocationManagerProxy.get(); } WebIconDatabase* iconDatabase() const { return m_iconDatabase.get(); } WebKeyValueStorageManagerProxy* keyValueStorageManagerProxy() const { return m_keyValueStorageManagerProxy.get(); } @@ -321,7 +323,9 @@ private: RefPtr<WebBatteryManagerProxy> m_batteryManagerProxy; #endif RefPtr<WebCookieManagerProxy> m_cookieManagerProxy; +#if ENABLE(SQL_DATABASE) RefPtr<WebDatabaseManagerProxy> m_databaseManagerProxy; +#endif RefPtr<WebGeolocationManagerProxy> m_geolocationManagerProxy; RefPtr<WebIconDatabase> m_iconDatabase; RefPtr<WebKeyValueStorageManagerProxy> m_keyValueStorageManagerProxy; diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp index e61faa162..76db33686 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "WebDatabaseManagerProxy.h" +#if ENABLE(SQL_DATABASE) + #include "ImmutableArray.h" #include "ImmutableDictionary.h" #include "WebDatabaseManagerMessages.h" @@ -231,3 +233,4 @@ void WebDatabaseManagerProxy::didModifyDatabase(const String& originIdentifier, } // namespace WebKit +#endif // ENABLE(SQL_DATABASE) diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h index d70011c38..fe920bb03 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h @@ -26,6 +26,8 @@ #ifndef WebDatabaseManagerProxy_h #define WebDatabaseManagerProxy_h +#if ENABLE(SQL_DATABASE) + #include "APIObject.h" #include "Arguments.h" #include "GenericCallback.h" @@ -99,4 +101,6 @@ private: } // namespace WebKit +#endif // ENABLE(SQL_DATABASE) + #endif // DatabaseManagerProxy_h diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in index 37a9b89ec..503275fff 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in @@ -20,9 +20,13 @@ # 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. +#if ENABLE(SQL_DATABASE) + messages -> WebDatabaseManagerProxy { DidGetDatabasesByOrigin(Vector<WebKit::OriginAndDatabases> originAndDatabases, uint64_t callbackID); DidGetDatabaseOrigins(Vector<WTF::String> originIdentifiers, uint64_t callbackID) DidModifyOrigin(WTF::String originIdentifier) DidModifyDatabase(WTF::String originIdentifier, WTF::String databaseIdentifier) } + +#endif // ENABLE(SQL_DATABASE) diff --git a/Source/WebKit2/UIProcess/WebIntentData.h b/Source/WebKit2/UIProcess/WebIntentData.h deleted file mode 100644 index decf4ae4f..000000000 --- a/Source/WebKit2/UIProcess/WebIntentData.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 WebIntentData_h -#define WebIntentData_h - -#if ENABLE(WEB_INTENTS) - -#include "APIObject.h" -#include "IntentData.h" -#include "WebSerializedScriptValue.h" -#include <wtf/PassRefPtr.h> - -namespace WebKit { - -class WebIntentData : public APIObject { -public: - static const Type APIType = TypeIntentData; - - static PassRefPtr<WebIntentData> create(const IntentData& store) - { - return adoptRef(new WebIntentData(store)); - } - - virtual ~WebIntentData() { } - - const String& action() const { return m_store.action; } - const String& payloadType() const { return m_store.type; } - const WebCore::KURL& service() const { return m_store.service; } - PassRefPtr<WebSerializedScriptValue> data() const; - String extra(const String& key) const; - PassRefPtr<ImmutableDictionary> extras() const; - PassRefPtr<ImmutableArray> suggestions() const; - - const IntentData& store() const { return m_store; } - -private: - WebIntentData(const IntentData&); - - virtual Type type() const { return APIType; } - - IntentData m_store; -}; - -} // namespace WebKit - -#endif // ENABLE(WEB_INTENTS) - -#endif // WebIntentData_h diff --git a/Source/WebKit2/UIProcess/WebLoaderClient.cpp b/Source/WebKit2/UIProcess/WebLoaderClient.cpp index 289e8797d..4d3c459ce 100644 --- a/Source/WebKit2/UIProcess/WebLoaderClient.cpp +++ b/Source/WebKit2/UIProcess/WebLoaderClient.cpp @@ -169,22 +169,22 @@ void WebLoaderClient::didDetectXSSForFrame(WebPageProxy* page, WebFrameProxy* fr } #if ENABLE(WEB_INTENTS) -void WebLoaderClient::didReceiveIntentForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentData* intentData) +void WebLoaderClient::didReceiveIntentForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentData* intentData, APIObject* userData) { if (!m_client.didReceiveIntentForFrame) return; - m_client.didReceiveIntentForFrame(toAPI(page), toAPI(frame), toAPI(intentData), m_client.clientInfo); + m_client.didReceiveIntentForFrame(toAPI(page), toAPI(frame), toAPI(intentData), toAPI(userData), m_client.clientInfo); } #endif #if ENABLE(WEB_INTENTS_TAG) -void WebLoaderClient::registerIntentServiceForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentServiceInfo* serviceInfo) +void WebLoaderClient::registerIntentServiceForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentServiceInfo* serviceInfo, APIObject* userData) { if (!m_client.registerIntentServiceForFrame) return; - m_client.registerIntentServiceForFrame(toAPI(page), toAPI(frame), toAPI(serviceInfo), m_client.clientInfo); + m_client.registerIntentServiceForFrame(toAPI(page), toAPI(frame), toAPI(serviceInfo), toAPI(userData), m_client.clientInfo); } #endif diff --git a/Source/WebKit2/UIProcess/WebLoaderClient.h b/Source/WebKit2/UIProcess/WebLoaderClient.h index f8e44c74f..f1291a288 100644 --- a/Source/WebKit2/UIProcess/WebLoaderClient.h +++ b/Source/WebKit2/UIProcess/WebLoaderClient.h @@ -73,11 +73,11 @@ public: void didRunInsecureContentForFrame(WebPageProxy*, WebFrameProxy*, APIObject*); void didDetectXSSForFrame(WebPageProxy*, WebFrameProxy*, APIObject*); #if ENABLE(WEB_INTENTS) - void didReceiveIntentForFrame(WebPageProxy*, WebFrameProxy*, WebIntentData*); + void didReceiveIntentForFrame(WebPageProxy*, WebFrameProxy*, WebIntentData*, APIObject*); #endif #if ENABLE(WEB_INTENTS_TAG) - void registerIntentServiceForFrame(WebPageProxy*, WebFrameProxy*, WebIntentServiceInfo*); + void registerIntentServiceForFrame(WebPageProxy*, WebFrameProxy*, WebIntentServiceInfo*, APIObject*); #endif // FIXME: didFirstVisuallyNonEmptyLayoutForFrame and didNewFirstVisuallyNonEmptyLayout should be merged. diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index 17cc2f425..344ed9846 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -1894,13 +1894,18 @@ void WebPageProxy::didFinishProgress() } #if ENABLE(WEB_INTENTS_TAG) -void WebPageProxy::registerIntentServiceForFrame(uint64_t frameID, const IntentServiceInfo& serviceInfo) +void WebPageProxy::registerIntentServiceForFrame(uint64_t frameID, const IntentServiceInfo& serviceInfo, CoreIPC::ArgumentDecoder* arguments) { + RefPtr<APIObject> userData; + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); + if (!arguments->decode(messageDecoder)) + return; + WebFrameProxy* frame = process()->webFrame(frameID); MESSAGE_CHECK(frame); RefPtr<WebIntentServiceInfo> webIntentServiceInfo = WebIntentServiceInfo::create(serviceInfo); - m_loaderClient.registerIntentServiceForFrame(this, frame, webIntentServiceInfo.get()); + m_loaderClient.registerIntentServiceForFrame(this, frame, webIntentServiceInfo.get(), userData.get()); } #endif @@ -2175,13 +2180,18 @@ void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, CoreIPC::ArgumentDecod } #if ENABLE(WEB_INTENTS) -void WebPageProxy::didReceiveIntentForFrame(uint64_t frameID, const IntentData& intentData) +void WebPageProxy::didReceiveIntentForFrame(uint64_t frameID, const IntentData& intentData, CoreIPC::ArgumentDecoder* arguments) { + RefPtr<APIObject> userData; + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); + if (!arguments->decode(messageDecoder)) + return; + WebFrameProxy* frame = process()->webFrame(frameID); MESSAGE_CHECK(frame); RefPtr<WebIntentData> webIntentData = WebIntentData::create(intentData); - m_loaderClient.didReceiveIntentForFrame(this, frame, webIntentData.get()); + m_loaderClient.didReceiveIntentForFrame(this, frame, webIntentData.get(), userData.get()); } #endif diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index e70036645..33c49a3ca 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -756,10 +756,10 @@ private: void didFinishProgress(); #if ENABLE(WEB_INTENTS) - void didReceiveIntentForFrame(uint64_t frameID, const IntentData&); + void didReceiveIntentForFrame(uint64_t frameID, const IntentData&, CoreIPC::ArgumentDecoder*); #endif #if ENABLE(WEB_INTENTS_TAG) - void registerIntentServiceForFrame(uint64_t frameID, const IntentServiceInfo&); + void registerIntentServiceForFrame(uint64_t frameID, const IntentServiceInfo&, CoreIPC::ArgumentDecoder*); #endif void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder*, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index 7838d643f..376904701 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -97,10 +97,10 @@ messages -> WebPageProxy { # Intent messages #if ENABLE(WEB_INTENTS) - DidReceiveIntentForFrame(uint64_t frameID, WebKit::IntentData intent) + DidReceiveIntentForFrame(uint64_t frameID, WebKit::IntentData intent, WebKit::InjectedBundleUserMessageEncoder userData) #endif #if ENABLE(WEB_INTENTS_TAG) - RegisterIntentServiceForFrame(uint64_t frameID, WebKit::IntentServiceInfo serviceInfo); + RegisterIntentServiceForFrame(uint64_t frameID, WebKit::IntentServiceInfo serviceInfo, WebKit::InjectedBundleUserMessageEncoder userData); #endif # Progress messages diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp index 82d63845d..e2b390ab3 100644 --- a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp @@ -35,7 +35,7 @@ #include "qquickwebview_p.h" #include "qquickwebview_p_p.h" #include <QGuiApplication> -#include <QQuickCanvas> +#include <QQuickWindow> #include <WebCore/Cursor.h> #include <WebCore/DragData.h> #include <WebCore/FloatRect.h> @@ -287,7 +287,7 @@ bool QtPageClient::isViewVisible() return false; // FIXME: this is a workaround while QWindow::isExposed() is not ready. - if (m_webView->canvas() && m_webView->canvas()->windowState() == Qt::WindowMinimized) + if (m_webView->window() && m_webView->window()->windowState() == Qt::WindowMinimized) return false; return m_webView->isVisible() && m_webView->page()->isVisible(); diff --git a/Source/WebKit2/UIProcess/qt/QtViewportHandler.h b/Source/WebKit2/UIProcess/qt/QtViewportHandler.h index e4a8c51fb..c93b0bd32 100644 --- a/Source/WebKit2/UIProcess/qt/QtViewportHandler.h +++ b/Source/WebKit2/UIProcess/qt/QtViewportHandler.h @@ -31,11 +31,12 @@ QT_BEGIN_NAMESPACE class QPointF; -class QQuickWebPage; -class QQuickWebView; class QWheelEvent; QT_END_NAMESPACE +class QQuickWebPage; +class QQuickWebView; + class QWebKitTest; namespace WebKit { diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp index ea595951b..d82eba2f9 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp @@ -33,7 +33,7 @@ #include <QGuiApplication> #include <QInputMethod> #include <QMimeData> -#include <QtQuick/QQuickCanvas> +#include <QQuickWindow> #include <QStyleHints> #include <QTextFormat> #include <QTouchEvent> @@ -562,7 +562,7 @@ void QtWebPageEventHandler::startDrag(const WebCore::DragData& dragData, PassRef QPoint globalPosition; Qt::DropAction actualDropAction = Qt::IgnoreAction; - if (QWindow* window = m_webPage->canvas()) { + if (QWindow* window = m_webPage->window()) { QDrag* drag = new QDrag(window); drag->setPixmap(QPixmap::fromImage(dragQImage)); drag->setMimeData(mimeData); diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h index 4c0fcfca2..22a5bcfba 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h +++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h @@ -24,7 +24,9 @@ #include <QtQuick/QSGTransformNode> #include <wtf/PassRefPtr.h> +QT_BEGIN_NAMESPACE class QSGSimpleRectNode; +QT_END_NAMESPACE namespace WebKit { diff --git a/Source/WebKit2/UIProcess/qt/WebColorChooserProxyQt.h b/Source/WebKit2/UIProcess/qt/WebColorChooserProxyQt.h index 75a74a2f6..7872dc907 100644 --- a/Source/WebKit2/UIProcess/qt/WebColorChooserProxyQt.h +++ b/Source/WebKit2/UIProcess/qt/WebColorChooserProxyQt.h @@ -25,9 +25,12 @@ #include <QtCore/QObject> #include <wtf/OwnPtr.h> +QT_BEGIN_NAMESPACE class QQmlComponent; class QQmlContext; class QQuickItem; +QT_END_NAMESPACE + class QQuickWebView; namespace WebCore { diff --git a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h index 598c74a25..e476b128d 100644 --- a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h +++ b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h @@ -26,8 +26,10 @@ #include <WebKit2/WKGeolocationPosition.h> #include <WebKit2/WKRetainPtr.h> +QT_BEGIN_NAMESPACE class QGeoPositionInfoSource; class QGeoPositionInfo; +QT_END_NAMESPACE namespace WebKit { diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h index 3eb544d61..e622f9006 100644 --- a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h +++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h @@ -31,10 +31,13 @@ #include <QtCore/QObject> #include <wtf/OwnPtr.h> +QT_BEGIN_NAMESPACE class QQmlComponent; class QQmlContext; -class QQuickWebView; class QQuickItem; +QT_END_NAMESPACE + +class QQuickWebView; namespace WebKit { |