+2012-07-01 Christophe Dumez <christophe.dumez@intel.com>
+
+ [EFL][WK2] Add API to inspect a Web Intent
+ https://bugs.webkit.org/show_bug.cgi?id=89749
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Add EFL API to inspect a Web Intent and emit a signal
+ on the view when a new intent request is made.
+
+ * PlatformEfl.cmake:
+ * UIProcess/API/efl/EWebKit2.h:
+ * UIProcess/API/efl/ewk_intent.cpp: Added.
+ (_Ewk_Intent):
+ (ewk_intent_ref):
+ (ewk_intent_unref):
+ (ewk_intent_action_get):
+ (ewk_intent_type_get):
+ (ewk_intent_service_get):
+ (ewk_intent_suggestions_get):
+ (ewk_intent_extra_get):
+ (ewk_intent_extra_names_get):
+ (ewk_intent_new):
+ * UIProcess/API/efl/ewk_intent.h: Added.
+ * UIProcess/API/efl/ewk_intent_private.h: Copied from Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp.
+ * UIProcess/API/efl/ewk_view.cpp:
+ (ewk_view_intent_request_new):
+ * UIProcess/API/efl/ewk_view.h:
+ * UIProcess/API/efl/ewk_view_loader_client.cpp:
+ (didReceiveIntentForFrame):
+ (ewk_view_loader_client_attach):
+ * UIProcess/API/efl/ewk_view_private.h:
+
2012-06-29 Luiz Agostini <luiz.agostini@nokia.com>
[Qt][WK2] Private non-QtQuick API
UIProcess/API/efl/PageClientImpl.cpp
UIProcess/API/efl/ewk_context.cpp
+ UIProcess/API/efl/ewk_intent.cpp
UIProcess/API/efl/ewk_view.cpp
UIProcess/API/efl/ewk_view_loader_client.cpp
#define EWebKit2_h
#include "ewk_context.h"
+#include "ewk_intent.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.h"
+
+#include "WKAPICast.h"
+#include "WKArray.h"
+#include "WKDictionary.h"
+#include "WKIntentData.h"
+#include "WKRetainPtr.h"
+#include "WKString.h"
+#include "WKURL.h"
+#include "ewk_intent_private.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+/**
+ * \struct _Ewk_Intent
+ * @brief Contains the intent data.
+ */
+struct _Ewk_Intent {
+ unsigned int __ref; /**< the reference count of the object */
+#if ENABLE(WEB_INTENTS)
+ WKRetainPtr<WKIntentDataRef> wkIntent;
+#endif
+ const char* action;
+ const char* type;
+ const char* service;
+};
+
+#define EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent_, ...) \
+ if (!(intent)) { \
+ EINA_LOG_CRIT("intent is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ if (!(intent)->wkIntent) { \
+ EINA_LOG_CRIT("intent->wkIntent is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ WKIntentDataRef wkIntent_ = (intent)->wkIntent.get()
+
+void ewk_intent_ref(Ewk_Intent* intent)
+{
+#if ENABLE(WEB_INTENTS)
+ EINA_SAFETY_ON_NULL_RETURN(intent);
+ ++intent->__ref;
+#endif
+}
+
+void ewk_intent_unref(Ewk_Intent* intent)
+{
+#if ENABLE(WEB_INTENTS)
+ EINA_SAFETY_ON_NULL_RETURN(intent);
+
+ if (--intent->__ref)
+ return;
+
+ eina_stringshare_del(intent->action);
+ eina_stringshare_del(intent->type);
+ eina_stringshare_del(intent->service);
+ delete intent;
+#endif
+}
+
+const char* ewk_intent_action_get(const Ewk_Intent* intent)
+{
+#if ENABLE(WEB_INTENTS)
+ EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
+
+ WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKIntentDataCopyAction(wkIntent));
+ Ewk_Intent* ewkIntent = const_cast<Ewk_Intent*>(intent);
+ eina_stringshare_replace(&ewkIntent->action, toImpl(wkAction.get())->string().utf8().data());
+ return intent->action;
+#else
+ return 0;
+#endif
+}
+
+const char* ewk_intent_type_get(const Ewk_Intent* intent)
+{
+#if ENABLE(WEB_INTENTS)
+ EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
+
+ WKRetainPtr<WKStringRef> wkType(AdoptWK, WKIntentDataCopyType(wkIntent));
+ Ewk_Intent* ewkIntent = const_cast<Ewk_Intent*>(intent);
+ eina_stringshare_replace(&ewkIntent->type, toImpl(wkType.get())->string().utf8().data());
+ return intent->type;
+#else
+ return 0;
+#endif
+}
+
+const char* ewk_intent_service_get(const Ewk_Intent* intent)
+{
+#if ENABLE(WEB_INTENTS)
+ EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
+
+ WKRetainPtr<WKURLRef> wkService(AdoptWK, WKIntentDataCopyService(wkIntent));
+ Ewk_Intent* ewkIntent = const_cast<Ewk_Intent*>(intent);
+ eina_stringshare_replace(&ewkIntent->service, toImpl(wkService.get())->string().utf8().data());
+ return intent->service;
+#else
+ return 0;
+#endif
+}
+
+Eina_List* ewk_intent_suggestions_get(const Ewk_Intent* intent)
+{
+#if ENABLE(WEB_INTENTS)
+ EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
+
+ Eina_List* listOfSuggestions = 0;
+ WKRetainPtr<WKArrayRef> wkSuggestions(AdoptWK, WKIntentDataCopySuggestions(wkIntent));
+ const size_t numSuggestions = WKArrayGetSize(wkSuggestions.get());
+ for (size_t i = 0; i < numSuggestions; ++i) {
+ WKURLRef wkSuggestion = static_cast<WKURLRef>(WKArrayGetItemAtIndex(wkSuggestions.get(), i));
+ listOfSuggestions = eina_list_append(listOfSuggestions, strdup(toImpl(wkSuggestion)->string().utf8().data()));
+ }
+ return listOfSuggestions;
+#else
+ return 0;
+#endif
+}
+
+char* ewk_intent_extra_get(const Ewk_Intent* intent, const char* key)
+{
+#if ENABLE(WEB_INTENTS)
+ EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
+
+ WKRetainPtr<WKStringRef> keyRef = adoptWK(WKStringCreateWithUTF8CString(key));
+ WKRetainPtr<WKStringRef> wkValue(AdoptWK, WKIntentDataCopyExtra(wkIntent, keyRef.get()));
+ String value = toImpl(wkValue.get())->string();
+ if (value.isEmpty())
+ return 0;
+ return strdup(value.utf8().data());
+#else
+ return 0;
+#endif
+}
+
+Eina_List* ewk_intent_extra_names_get(const Ewk_Intent* intent)
+{
+#if ENABLE(WEB_INTENTS)
+ EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
+
+ Eina_List* listOfKeys = 0;
+ WKRetainPtr<WKDictionaryRef> wkExtras(AdoptWK, WKIntentDataCopyExtras(wkIntent));
+ WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(wkExtras.get()));
+ const size_t numKeys = WKArrayGetSize(wkKeys.get());
+ for (size_t i = 0; i < numKeys; ++i) {
+ WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
+ listOfKeys = eina_list_append(listOfKeys, strdup(toImpl(wkKey)->string().utf8().data()));
+ }
+ return listOfKeys;
+#else
+ return 0;
+#endif
+}
+
+#if ENABLE(WEB_INTENTS)
+Ewk_Intent* ewk_intent_new(WKIntentDataRef intentData)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(intentData, 0);
+
+ Ewk_Intent* ewkIntent = static_cast<Ewk_Intent*>(calloc(1, sizeof(Ewk_Intent)));
+ ewkIntent->__ref = 1;
+ ewkIntent->wkIntent = intentData;
+ return ewkIntent;
+}
+#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.h
+ * @brief Describes the Ewk Intent API.
+ */
+
+#ifndef ewk_intent_h
+#define ewk_intent_h
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for _Ewk_Intent */
+typedef struct _Ewk_Intent Ewk_Intent;
+
+/**
+ * Increases the reference count of the given object.
+ *
+ * @param intent the intent object to increase the reference count
+ */
+EAPI void ewk_intent_ref(Ewk_Intent *intent);
+
+/**
+ * Decreases the reference count of the given object, possibly freeing it.
+ *
+ * When the reference count it's reached 0, the intent is freed.
+ *
+ * @param intent the intent object to decrease the reference count
+ */
+EAPI void ewk_intent_unref(Ewk_Intent *intent);
+
+/**
+ * Query action for this intent.
+ *
+ * @param intent intent 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_action_get(const Ewk_Intent *intent);
+
+/**
+ * Query type for this intent.
+ *
+ * @param intent intent 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_type_get(const Ewk_Intent *intent);
+
+/**
+ * Query service for this intent.
+ *
+ * @param intent intent item to query.
+ *
+ * @return the service 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_get(const Ewk_Intent *intent);
+
+/**
+ * Query suggestions for this intent.
+ *
+ * This function provides a list of (absolute) suggested Service URLs of which the Client
+ * is aware and which can handle the intent.
+ *
+ * @param intent intent item to query.
+ *
+ * @return @c Eina_List with suggested service URLs on success, or @c 0 on failure,
+ * the Eina_List and its items should be freed after use. Use free() to free the
+ * items.
+ */
+EAPI Eina_List *ewk_intent_suggestions_get(const Ewk_Intent *intent);
+
+/**
+ * Retrieves the value (if any) from the extra data dictionary this intent was constructed with.
+ *
+ * @param intent intent item to query.
+ * @param key key to query in the dictionary.
+ *
+ * @return a newly allocated string or @c NULL in case of error or if the key does not exist.
+ */
+EAPI char *ewk_intent_extra_get(const Ewk_Intent *intent, const char *key);
+
+/**
+ * Retrieve a list of the names of extra metadata associated with the intent.
+ *
+ * @param intent intent item to query.
+ *
+ * @return @c Eina_List with names of extra metadata on success, or @c 0 on failure,
+ * the Eina_List and its items should be freed after use. Use free() to free the
+ * items.
+ */
+EAPI Eina_List *ewk_intent_extra_names_get(const Ewk_Intent *intent);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ewk_intent_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_private_h
+#define ewk_intent_private_h
+
+#if ENABLE(WEB_INTENTS)
+
+#include <WebKit2/WKBase.h>
+
+typedef struct _Ewk_Intent Ewk_Intent;
+
+Ewk_Intent* ewk_intent_new(WKIntentDataRef intentData);
+
+#endif // ENABLE(WEB_INTENTS)
+
+#endif // ewk_intent_private_h
evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
}
+/**
+ * @internal
+ * The view received a new intent request.
+ *
+ * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
+ */
+void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent)
+{
+#if ENABLE(WEB_INTENTS)
+ evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent));
+#endif
+}
+
void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
{
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
*
* The following signals (see evas_object_smart_callback_add()) are emitted:
*
+ * - "intent,request,new", Ewk_Intent_Request*: reports new Web intent request.
* - "title,changed", const char*: title of the main frame was changed.
*/
#include "config.h"
#include "WKFrame.h"
+#include "ewk_intent.h"
+#include "ewk_intent_private.h"
#include "ewk_view_loader_client_private.h"
#include "ewk_view_private.h"
#include <wtf/text/CString.h>
ewk_view_title_changed(ewkView, toImpl(title)->string().utf8().data());
}
+#if ENABLE(WEB_INTENTS)
+static void didReceiveIntentForFrame(WKPageRef page, WKFrameRef frame, WKIntentDataRef intent, const void* clientInfo)
+{
+ Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+ Ewk_Intent* ewkIntent = ewk_intent_new(intent);
+ ewk_view_intent_request_new(ewkView, ewkIntent);
+ ewk_intent_unref(ewkIntent);
+}
+#endif
+
void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
{
WKPageLoaderClient loadClient;
loadClient.version = kWKPageLoaderClientCurrentVersion;
loadClient.clientInfo = ewkView;
loadClient.didReceiveTitleForFrame = didReceiveTitleForFrame;
+#if ENABLE(WEB_INTENTS)
+ loadClient.didReceiveIntentForFrame = didReceiveIntentForFrame;
+#endif
WKPageSetPageLoaderClient(pageRef, &loadClient);
}
class IntSize;
}
+#if ENABLE(WEB_INTENTS)
+typedef struct _Ewk_Intent Ewk_Intent;
+#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);
void ewk_view_title_changed(Evas_Object* ewkView, const char* title);
Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef);
+#if ENABLE(WEB_INTENTS)
+void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent);
+#endif
+
WebKit::WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView);
#endif // ewk_view_private_h