2012-07-02 Christophe Dumez <christophe.dumez@intel.com>
+ [EFL][WK2] Add API to inspect a Web Intent service
+ https://bugs.webkit.org/show_bug.cgi?id=90066
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Add EFL API to inspect a Web Intent Service and emit
+ a signal on the view when a new intent service
+ registers.
+
+ * PlatformEfl.cmake:
+ * UIProcess/API/efl/EWebKit2.h:
+ * UIProcess/API/efl/ewk_intent_service.cpp: Added.
+ (_Ewk_Intent_Service):
+ (ewk_intent_service_ref):
+ (ewk_intent_service_unref):
+ (ewk_intent_service_action_get):
+ (ewk_intent_service_type_get):
+ (ewk_intent_service_href_get):
+ (ewk_intent_service_title_get):
+ (ewk_intent_service_disposition_get):
+ (ewk_intent_service_new):
+ * UIProcess/API/efl/ewk_intent_service.h: Added.
+ * UIProcess/API/efl/ewk_intent_service_private.h: Copied from Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp.
+ * UIProcess/API/efl/ewk_view.cpp:
+ (ewk_view_intent_service_register):
+ * UIProcess/API/efl/ewk_view.h:
+ * UIProcess/API/efl/ewk_view_loader_client.cpp:
+ (registerIntentServiceForFrame):
+ (ewk_view_loader_client_attach):
+ * UIProcess/API/efl/ewk_view_private.h:
+
+2012-07-02 Christophe Dumez <christophe.dumez@intel.com>
+
[WK2][EFL] Free Ewk_Intent calloc'd memory with free() instead of delete
https://bugs.webkit.org/show_bug.cgi?id=90433
UIProcess/API/efl/PageClientImpl.cpp
UIProcess/API/efl/ewk_context.cpp
UIProcess/API/efl/ewk_intent.cpp
+ UIProcess/API/efl/ewk_intent_service.cpp
UIProcess/API/efl/ewk_view.cpp
UIProcess/API/efl/ewk_view_loader_client.cpp
#include "ewk_context.h"
#include "ewk_intent.h"
+#include "ewk_intent_service.h"
#include "ewk_view.h"
#endif // EWebKit2_h
--- /dev/null
+/*
+ * 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_intent_service.h"
+
+#include "IntentServiceInfo.h"
+#include "WKAPICast.h"
+#include "WKIntentServiceInfo.h"
+#include "WKRetainPtr.h"
+#include "WKURL.h"
+#include "ewk_intent_service_private.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+/**
+ * \struct _Ewk_Intent_Service
+ * @brief Contains the intent service data.
+ */
+struct _Ewk_Intent_Service {
+ unsigned int __ref; /**< the reference count of the object */
+#if ENABLE(WEB_INTENTS_TAG)
+ WKRetainPtr<WKIntentServiceInfoRef> wkService;
+#endif
+ const char* action;
+ const char* type;
+ const char* href;
+ const char* title;
+ const char* disposition;
+};
+
+#define EWK_INTENT_SERVICE_WK_GET_OR_RETURN(service, wkService_, ...) \
+ if (!(service)) { \
+ EINA_LOG_CRIT("service is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ if (!(service)->wkService) { \
+ EINA_LOG_CRIT("service->wkService is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ WKIntentServiceInfoRef wkService_ = (service)->wkService.get()
+
+void ewk_intent_service_ref(Ewk_Intent_Service* service)
+{
+#if ENABLE(WEB_INTENTS_TAG)
+ EINA_SAFETY_ON_NULL_RETURN(service);
+ ++service->__ref;
+#endif
+}
+
+void ewk_intent_service_unref(Ewk_Intent_Service* service)
+{
+#if ENABLE(WEB_INTENTS_TAG)
+ EINA_SAFETY_ON_NULL_RETURN(service);
+
+ if (--service->__ref)
+ return;
+
+ eina_stringshare_del(service->action);
+ eina_stringshare_del(service->type);
+ eina_stringshare_del(service->href);
+ eina_stringshare_del(service->title);
+ eina_stringshare_del(service->disposition);
+ free(service);
+#endif
+}
+
+const char* ewk_intent_service_action_get(const Ewk_Intent_Service* service)
+{
+#if ENABLE(WEB_INTENTS_TAG)
+ EWK_INTENT_SERVICE_WK_GET_OR_RETURN(service, wkService, 0);
+
+ WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKIntentServiceInfoCopyAction(wkService));
+ Ewk_Intent_Service* ewkIntentService = const_cast<Ewk_Intent_Service*>(service);
+ eina_stringshare_replace(&ewkIntentService->action, toImpl(wkAction.get())->string().utf8().data());
+
+ return service->action;
+#else
+ return 0;
+#endif
+}
+
+const char* ewk_intent_service_type_get(const Ewk_Intent_Service* service)
+{
+#if ENABLE(WEB_INTENTS_TAG)
+ EWK_INTENT_SERVICE_WK_GET_OR_RETURN(service, wkService, 0);
+
+ WKRetainPtr<WKStringRef> wkType(AdoptWK, WKIntentServiceInfoCopyType(wkService));
+ Ewk_Intent_Service* ewkIntentService = const_cast<Ewk_Intent_Service*>(service);
+ eina_stringshare_replace(&ewkIntentService->type, toImpl(wkType.get())->string().utf8().data());
+
+ return service->type;
+#else
+ return 0;
+#endif
+}
+
+const char* ewk_intent_service_href_get(const Ewk_Intent_Service* service)
+{
+#if ENABLE(WEB_INTENTS_TAG)
+ EWK_INTENT_SERVICE_WK_GET_OR_RETURN(service, wkService, 0);
+
+ WKRetainPtr<WKURLRef> wkHref(AdoptWK, WKIntentServiceInfoCopyHref(wkService));
+ Ewk_Intent_Service* ewkIntentService = const_cast<Ewk_Intent_Service*>(service);
+ eina_stringshare_replace(&ewkIntentService->href, toImpl(wkHref.get())->string().utf8().data());
+
+ return service->href;
+#else
+ return 0;
+#endif
+}
+
+const char* ewk_intent_service_title_get(const Ewk_Intent_Service* service)
+{
+#if ENABLE(WEB_INTENTS_TAG)
+ EWK_INTENT_SERVICE_WK_GET_OR_RETURN(service, wkService, 0);
+
+ WKRetainPtr<WKStringRef> wkTitle(AdoptWK, WKIntentServiceInfoCopyTitle(wkService));
+ Ewk_Intent_Service* ewkIntentService = const_cast<Ewk_Intent_Service*>(service);
+ eina_stringshare_replace(&ewkIntentService->title, toImpl(wkTitle.get())->string().utf8().data());
+
+ return service->title;
+#else
+ return 0;
+#endif
+}
+
+const char* ewk_intent_service_disposition_get(const Ewk_Intent_Service* service)
+{
+#if ENABLE(WEB_INTENTS_TAG)
+ EWK_INTENT_SERVICE_WK_GET_OR_RETURN(service, wkService, 0);
+
+ WKRetainPtr<WKStringRef> wkDisposition(AdoptWK, WKIntentServiceInfoCopyDisposition(wkService));
+ Ewk_Intent_Service* ewkIntentService = const_cast<Ewk_Intent_Service*>(service);
+ eina_stringshare_replace(&ewkIntentService->disposition, toImpl(wkDisposition.get())->string().utf8().data());
+
+ return service->disposition;
+#else
+ return 0;
+#endif
+}
+
+#if ENABLE(WEB_INTENTS_TAG)
+Ewk_Intent_Service* ewk_intent_service_new(WKIntentServiceInfoRef wkService)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wkService, 0);
+
+ Ewk_Intent_Service* ewkIntentService = static_cast<Ewk_Intent_Service*>(calloc(1, sizeof(Ewk_Intent_Service)));
+ ewkIntentService->__ref = 1;
+ ewkIntentService->wkService = wkService;
+
+ return ewkIntentService;
+}
+#endif
--- /dev/null
+/*
+ * 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_intent_service.h
+ * @brief Describes the Ewk Intent Service API.
+ */
+
+#ifndef ewk_intent_service_h
+#define ewk_intent_service_h
+
+#include <Evas.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for _Ewk_Intent_Service */
+typedef struct _Ewk_Intent_Service Ewk_Intent_Service;
+
+/**
+ * Increases the reference count of the given object.
+ *
+ * @param service the intent service object to increase the reference count
+ */
+EAPI void ewk_intent_service_ref(Ewk_Intent_Service *service);
+
+/**
+ * Decreases the reference count of the given object, possibly freeing it.
+ *
+ * When the reference count it's reached 0, the intent service is freed.
+ *
+ * @param service the intent service object to decrease the reference count
+ */
+EAPI void ewk_intent_service_unref(Ewk_Intent_Service *service);
+
+/**
+ * Query action for this intent service.
+ *
+ * @param service service item to query.
+ *
+ * @return the action 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_intent_service_action_get(const Ewk_Intent_Service *service);
+
+/**
+ * Query type for this intent service.
+ *
+ * @param service service item to query.
+ *
+ * @return the type 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_intent_service_type_get(const Ewk_Intent_Service *service);
+
+/**
+ * Query URL for this intent service.
+ *
+ * @param service service item 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_intent_service_href_get(const Ewk_Intent_Service *service);
+
+/**
+ * Query title for this intent service.
+ *
+ * @param service service item to query.
+ *
+ * @return the title 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_intent_service_title_get(const Ewk_Intent_Service *service);
+
+/**
+ * Query disposition for this intent service.
+ *
+ * @param service service item to query.
+ *
+ * @return the disposition 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_intent_service_disposition_get(const Ewk_Intent_Service *service);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_intent_service_h
--- /dev/null
+/*
+ * 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_intent_service_private_h
+#define ewk_intent_service_private_h
+
+#if ENABLE(WEB_INTENTS_TAG)
+
+#include <WebKit2/WKBase.h>
+
+typedef struct _Ewk_Intent_Service Ewk_Intent_Service;
+
+Ewk_Intent_Service* ewk_intent_service_new(WKIntentServiceInfoRef wkService);
+
+#endif // ENABLE(WEB_INTENTS_TAG)
+
+#endif // ewk_intent_service_private_h
evas_object_image_data_copy_set(smartData->image, imageData);
}
+#if ENABLE(WEB_INTENTS_TAG)
+/**
+ * @internal
+ * The view received a new intent service registration.
+ *
+ * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
+ */
+void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService)
+{
+ evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService));
+}
+#endif // ENABLE(WEB_INTENTS_TAG)
+
WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
{
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
* The following signals (see evas_object_smart_callback_add()) are emitted:
*
* - "intent,request,new", Ewk_Intent_Request*: reports new Web intent request.
+ * - "intent,service,register", Ewk_Intent_Service*: reports new Web intent service registration.
* - "title,changed", const char*: title of the main frame was changed.
*/
#include "WKFrame.h"
#include "ewk_intent.h"
#include "ewk_intent_private.h"
+#include "ewk_intent_service.h"
+#include "ewk_intent_service_private.h"
#include "ewk_view_loader_client_private.h"
#include "ewk_view_private.h"
#include <wtf/text/CString.h>
}
#endif
+#if ENABLE(WEB_INTENTS_TAG)
+static void registerIntentServiceForFrame(WKPageRef page, WKFrameRef frame, WKIntentServiceInfoRef serviceInfo, const void *clientInfo)
+{
+ Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+ Ewk_Intent_Service* ewkIntentService = ewk_intent_service_new(serviceInfo);
+ ewk_view_intent_service_register(ewkView, ewkIntentService);
+ ewk_intent_service_unref(ewkIntentService);
+}
+#endif
+
void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
{
WKPageLoaderClient loadClient;
#if ENABLE(WEB_INTENTS)
loadClient.didReceiveIntentForFrame = didReceiveIntentForFrame;
#endif
+#if ENABLE(WEB_INTENTS_TAG)
+ loadClient.registerIntentServiceForFrame = registerIntentServiceForFrame;
+#endif
WKPageSetPageLoaderClient(pageRef, &loadClient);
}
#if ENABLE(WEB_INTENTS)
typedef struct _Ewk_Intent Ewk_Intent;
#endif
+#if ENABLE(WEB_INTENTS_TAG)
+typedef struct _Ewk_Intent_Service Ewk_Intent_Service;
+#endif
void ewk_view_display(Evas_Object* ewkView, const WebCore::IntRect& rect);
void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size);
#if ENABLE(WEB_INTENTS)
void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent);
#endif
+#if ENABLE(WEB_INTENTS_TAG)
+void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService);
+#endif
WebKit::WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView);