From 40ce29c760e705ff638433183e924ad3e24b2eb7 Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Fri, 18 May 2012 07:03:28 +0000 Subject: [PATCH] [EFL] Add simple implementation of Web Intents https://bugs.webkit.org/show_bug.cgi?id=86354 Patch by Christophe Dumez on 2012-05-18 Reviewed by Eric Seidel. .: Enable WEB_INTENTS flag by default on EFL port. * Source/cmake/OptionsEfl.cmake: Source/WebKit: Add new ewk_intent.* and ewk_intent_request.* files to CMake. * CMakeLists.txt: * PlatformEfl.cmake: Source/WebKit/efl: Add new EFL wrappers for WebCore's Intent and IntentRequest. Implement dispatchIntent() in EFL's FrameLoaderClient and emit a new "intent,new" signal on the frame to notify clients of new intent requests. * WebCoreSupport/FrameLoaderClientEfl.cpp: (WebCore): (WebCore::FrameLoaderClientEfl::dispatchIntent): * WebCoreSupport/FrameLoaderClientEfl.h: (FrameLoaderClientEfl): * ewk/ewk_frame.cpp: (ewk_frame_intent_new): * ewk/ewk_frame.h: * ewk/ewk_frame_private.h: * ewk/ewk_intent.cpp: Added. (_Ewk_Intent): (ewk_intent_action_get): (ewk_intent_type_get): (ewk_intent_data_get): (ewk_intent_service_get): (ewk_intent_extra_get): (ewk_intent_new): (ewk_intent_free): * ewk/ewk_intent.h: Added. * ewk/ewk_intent_private.h: Added. (WebCore): * ewk/ewk_intent_request.cpp: Added. (_Ewk_Intent_Request): (ewk_intent_request_ref): (ewk_intent_request_unref): (ewk_intent_request_intent_get): (ewk_intent_request_result_post): (ewk_intent_request_failure_post): (ewk_intent_request_new): * ewk/ewk_intent_request.h: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117551 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- ChangeLog | 11 ++ Source/WebKit/CMakeLists.txt | 1 + Source/WebKit/ChangeLog | 12 ++ Source/WebKit/PlatformEfl.cmake | 4 + Source/WebKit/efl/ChangeLog | 43 ++++++ .../efl/WebCoreSupport/FrameLoaderClientEfl.cpp | 11 ++ .../efl/WebCoreSupport/FrameLoaderClientEfl.h | 3 + Source/WebKit/efl/ewk/ewk_frame.cpp | 12 ++ Source/WebKit/efl/ewk/ewk_frame.h | 1 + Source/WebKit/efl/ewk/ewk_frame_private.h | 2 + Source/WebKit/efl/ewk/ewk_intent.cpp | 156 +++++++++++++++++++++ Source/WebKit/efl/ewk/ewk_intent.h | 97 +++++++++++++ Source/WebKit/efl/ewk/ewk_intent_private.h | 35 +++++ Source/WebKit/efl/ewk/ewk_intent_request.cpp | 122 ++++++++++++++++ Source/WebKit/efl/ewk/ewk_intent_request.h | 82 +++++++++++ Source/cmake/OptionsEfl.cmake | 1 + 16 files changed, 593 insertions(+) create mode 100644 Source/WebKit/efl/ewk/ewk_intent.cpp create mode 100644 Source/WebKit/efl/ewk/ewk_intent.h create mode 100644 Source/WebKit/efl/ewk/ewk_intent_private.h create mode 100644 Source/WebKit/efl/ewk/ewk_intent_request.cpp create mode 100644 Source/WebKit/efl/ewk/ewk_intent_request.h diff --git a/ChangeLog b/ChangeLog index e28abdd..ff732be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2012-05-18 Christophe Dumez + + [EFL] Add simple implementation of Web Intents + https://bugs.webkit.org/show_bug.cgi?id=86354 + + Reviewed by Eric Seidel. + + Enable WEB_INTENTS flag by default on EFL port. + + * Source/cmake/OptionsEfl.cmake: + 2012-05-17 Dan Bernstein REGRESSION (r117428): WebKit API/SPI was removed diff --git a/Source/WebKit/CMakeLists.txt b/Source/WebKit/CMakeLists.txt index 394a555..18c7d5d 100644 --- a/Source/WebKit/CMakeLists.txt +++ b/Source/WebKit/CMakeLists.txt @@ -2,6 +2,7 @@ SET(WebKit_INCLUDE_DIRECTORIES "${WEBKIT_DIR}" "${WEBCORE_DIR}" "${WEBCORE_DIR}/Modules/webdatabase" + "${WEBCORE_DIR}/Modules/intents" "${WEBCORE_DIR}/accessibility" "${WEBCORE_DIR}/bindings/js" "${WEBCORE_DIR}/bindings" diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index 322a207..bbbbefe 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,15 @@ +2012-05-18 Christophe Dumez + + [EFL] Add simple implementation of Web Intents + https://bugs.webkit.org/show_bug.cgi?id=86354 + + Reviewed by Eric Seidel. + + Add new ewk_intent.* and ewk_intent_request.* files to CMake. + + * CMakeLists.txt: + * PlatformEfl.cmake: + 2012-05-17 Thiago Marcos P. Santos [EFL] Add API for Web Database handling diff --git a/Source/WebKit/PlatformEfl.cmake b/Source/WebKit/PlatformEfl.cmake index 1843c2d..295f872 100644 --- a/Source/WebKit/PlatformEfl.cmake +++ b/Source/WebKit/PlatformEfl.cmake @@ -119,6 +119,8 @@ LIST(APPEND WebKit_SOURCES efl/ewk/ewk_view.cpp efl/ewk/ewk_view_single.cpp efl/ewk/ewk_view_tiled.cpp + efl/ewk/ewk_intent.cpp + efl/ewk/ewk_intent_request.cpp efl/ewk/ewk_window_features.cpp efl/ewk/ewk_web_database.cpp ) @@ -267,6 +269,8 @@ SET(EWebKit_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_security_policy.h ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_settings.h ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_view.h + ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_intent.h + ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_intent_request.h ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_window_features.h ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_web_database.h ) diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog index 1824620..d151b71 100644 --- a/Source/WebKit/efl/ChangeLog +++ b/Source/WebKit/efl/ChangeLog @@ -1,3 +1,46 @@ +2012-05-18 Christophe Dumez + + [EFL] Add simple implementation of Web Intents + https://bugs.webkit.org/show_bug.cgi?id=86354 + + Reviewed by Eric Seidel. + + Add new EFL wrappers for WebCore's Intent and IntentRequest. + Implement dispatchIntent() in EFL's FrameLoaderClient and emit a new + "intent,new" signal on the frame to notify clients of new intent + requests. + + * WebCoreSupport/FrameLoaderClientEfl.cpp: + (WebCore): + (WebCore::FrameLoaderClientEfl::dispatchIntent): + * WebCoreSupport/FrameLoaderClientEfl.h: + (FrameLoaderClientEfl): + * ewk/ewk_frame.cpp: + (ewk_frame_intent_new): + * ewk/ewk_frame.h: + * ewk/ewk_frame_private.h: + * ewk/ewk_intent.cpp: Added. + (_Ewk_Intent): + (ewk_intent_action_get): + (ewk_intent_type_get): + (ewk_intent_data_get): + (ewk_intent_service_get): + (ewk_intent_extra_get): + (ewk_intent_new): + (ewk_intent_free): + * ewk/ewk_intent.h: Added. + * ewk/ewk_intent_private.h: Added. + (WebCore): + * ewk/ewk_intent_request.cpp: Added. + (_Ewk_Intent_Request): + (ewk_intent_request_ref): + (ewk_intent_request_unref): + (ewk_intent_request_intent_get): + (ewk_intent_request_result_post): + (ewk_intent_request_failure_post): + (ewk_intent_request_new): + * ewk/ewk_intent_request.h: Added. + 2012-05-17 Raphael Kubo da Costa [EFL][DRT] Call resetInternalsObject() after each test. diff --git a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp index d78f021..f5be725 100644 --- a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp +++ b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp @@ -43,6 +43,7 @@ #include "FrameTree.h" #include "FrameView.h" #include "HTMLFormElement.h" +#include "IntentRequest.h" #include "MIMETypeRegistry.h" #include "NotImplemented.h" #include "Page.h" @@ -54,6 +55,7 @@ #include "Settings.h" #include "WebKitVersion.h" #include "ewk_frame_private.h" +#include "ewk_intent_request.h" #include "ewk_private.h" #include "ewk_settings_private.h" #include "ewk_view_private.h" @@ -970,6 +972,15 @@ void FrameLoaderClientEfl::dispatchDidBecomeFrameset(bool) { } +#if ENABLE(WEB_INTENTS) +void FrameLoaderClientEfl::dispatchIntent(PassRefPtr intentRequest) +{ + Ewk_Intent_Request* ewkRequest = ewk_intent_request_new(intentRequest); + ewk_frame_intent_new(m_frame, ewkRequest); + ewk_intent_request_unref(ewkRequest); +} +#endif + PassRefPtr FrameLoaderClientEfl::createNetworkingContext() { return FrameNetworkingContextEfl::create(EWKPrivate::coreFrame(m_frame), m_frame); diff --git a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h index 6706114..c2529c5 100644 --- a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h +++ b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h @@ -185,6 +185,9 @@ class FrameLoaderClientEfl : public FrameLoaderClient { virtual void provisionalLoadStarted(); virtual void didFinishLoad(); virtual void prepareForDataSourceReplacement(); +#if ENABLE(WEB_INTENTS) + virtual void dispatchIntent(PassRefPtr); +#endif virtual WTF::PassRefPtr createDocumentLoader(const ResourceRequest&, const SubstituteData&); virtual void setTitle(const StringWithDirection& title, const KURL&); diff --git a/Source/WebKit/efl/ewk/ewk_frame.cpp b/Source/WebKit/efl/ewk/ewk_frame.cpp index 611de17..a002a4c 100644 --- a/Source/WebKit/efl/ewk/ewk_frame.cpp +++ b/Source/WebKit/efl/ewk/ewk_frame.cpp @@ -1518,6 +1518,18 @@ void ewk_frame_load_progress_changed(Evas_Object* ewkFrame) ewk_view_load_progress_changed(smartData->view); } +/** + * @internal + * Reports new intent. + * + * Emits signal: "intent,new" with pointer to a Ewk_Intent_Request. + */ +void ewk_frame_intent_new(Evas_Object* ewkFrame, Ewk_Intent_Request* request) +{ +#if ENABLE(WEB_INTENTS) + evas_object_smart_callback_call(ewkFrame, "intent,new", request); +#endif +} /** * @internal diff --git a/Source/WebKit/efl/ewk/ewk_frame.h b/Source/WebKit/efl/ewk/ewk_frame.h index f5bba1b..69eff3a 100644 --- a/Source/WebKit/efl/ewk/ewk_frame.h +++ b/Source/WebKit/efl/ewk/ewk_frame.h @@ -40,6 +40,7 @@ * - "editorclient,contents,changed", void: reports that editor client's * contents were changed * - "icon,changed", void: frame favicon changed. + * - "intent,new", EwkIntentRequest*: reports new intent. * - "load,committed", void: reports load committed. * - "load,document,finished", void: frame finished loading the document. * - "load,error", const Ewk_Frame_Load_Error*: reports load failed diff --git a/Source/WebKit/efl/ewk/ewk_frame_private.h b/Source/WebKit/efl/ewk/ewk_frame_private.h index bd087de..dd37860 100644 --- a/Source/WebKit/efl/ewk/ewk_frame_private.h +++ b/Source/WebKit/efl/ewk/ewk_frame_private.h @@ -22,6 +22,7 @@ #define ewk_frame_private_h #include "ewk_frame.h" +#include "ewk_intent_request.h" #include #include #include @@ -67,6 +68,7 @@ void ewk_frame_view_create_for_view(Evas_Object* ewkFrame, Evas_Object* view); bool ewk_frame_uri_changed(Evas_Object* ewkFrame); void ewk_frame_force_layout(Evas_Object* ewkFrame); void ewk_frame_icon_changed(Evas_Object* ewkFrame); +void ewk_frame_intent_new(Evas_Object* ewkFrame, Ewk_Intent_Request* request); WTF::PassRefPtr ewk_frame_plugin_create(Evas_Object* ewkFrame, const WebCore::IntSize& pluginSize, WebCore::HTMLPlugInElement* element, const WebCore::KURL& url, const WTF::Vector& paramNames, const WTF::Vector& paramValues, const WTF::String& mimeType, bool loadManually); diff --git a/Source/WebKit/efl/ewk/ewk_intent.cpp b/Source/WebKit/efl/ewk/ewk_intent.cpp new file mode 100644 index 0000000..9d8c410 --- /dev/null +++ b/Source/WebKit/efl/ewk/ewk_intent.cpp @@ -0,0 +1,156 @@ +/* + 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 "ewk_intent.h" + +#include "Intent.h" +#include "NotImplemented.h" +#include "SerializedScriptValue.h" +#include "ewk_intent_private.h" +#include "ewk_private.h" +#include +#include +#include + +/** + * \struct _Ewk_Intent + * @brief Contains the intent data. + */ +struct _Ewk_Intent { +#if ENABLE(WEB_INTENTS) + WebCore::Intent* core; /**< WebCore object which is responsible for the intent */ +#endif + const char* action; + const char* type; + const char* data; + const char* service; +}; + +#define EWK_INTENT_CORE_GET_OR_RETURN(intent, core_, ...) \ + if (!(intent)) { \ + CRITICAL("intent is NULL."); \ + return __VA_ARGS__; \ + } \ + if (!(intent)->core) { \ + CRITICAL("intent->core is NULL."); \ + return __VA_ARGS__; \ + } \ + WebCore::Intent* core_ = (intent)->core + +const char* ewk_intent_action_get(const Ewk_Intent* intent) +{ +#if ENABLE(WEB_INTENTS) + EWK_INTENT_CORE_GET_OR_RETURN(intent, core, 0); + + // hide the following optimzation from outside + Ewk_Intent* ewkIntent = const_cast(intent); + eina_stringshare_replace(&ewkIntent->action, + core->action().utf8().data()); + return ewkIntent->action; +#else + return 0; +#endif +} + +const char* ewk_intent_type_get(const Ewk_Intent* intent) +{ +#if ENABLE(WEB_INTENTS) + EWK_INTENT_CORE_GET_OR_RETURN(intent, core, 0); + + // hide the following optimzation from outside + Ewk_Intent* ewkIntent = const_cast(intent); + eina_stringshare_replace(&ewkIntent->type, + core->type().utf8().data()); + return ewkIntent->type; +#else + return 0; +#endif +} + +const char* ewk_intent_data_get(const Ewk_Intent* intent) +{ +#if ENABLE(WEB_INTENTS) + notImplemented(); + return 0; +#else + return 0; +#endif +} + +const char* ewk_intent_service_get(const Ewk_Intent* intent) +{ +#if ENABLE(WEB_INTENTS) + EWK_INTENT_CORE_GET_OR_RETURN(intent, core, 0); + + // hide the following optimzation from outside + Ewk_Intent* ewkIntent = const_cast(intent); + eina_stringshare_replace(&ewkIntent->service, + core->service().string().utf8().data()); + return ewkIntent->service; +#else + return 0; +#endif +} + +char* ewk_intent_extra_get(const Ewk_Intent* intent, const char* key) +{ +#if ENABLE(WEB_INTENTS) + EWK_INTENT_CORE_GET_OR_RETURN(intent, core, 0); + WTF::HashMap::const_iterator val = core->extras().find(String::fromUTF8(key)); + if (val == core->extras().end()) + return 0; + return strdup(val->second.utf8().data()); +#else + return 0; +#endif +} + +#if ENABLE(WEB_INTENTS) +/** + * @internal + * + * Creates a new Ewk_Intent object. + * + * @param core WebCore::Intent instance to use internally. + * @return a new allocated the Ewk_Intent object on sucess or @c 0 on failure + */ +Ewk_Intent* ewk_intent_new(WebCore::Intent* core) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(core, 0); + Ewk_Intent* intent = new Ewk_Intent; + intent->core = core; + + return intent; +} + +/** + * @internal + * + * Free given Ewk_Intent instance. + * + * @param intent the object to free. + */ +void ewk_intent_free(Ewk_Intent* intent) +{ + EINA_SAFETY_ON_NULL_RETURN(intent); + + delete intent; +} +#endif diff --git a/Source/WebKit/efl/ewk/ewk_intent.h b/Source/WebKit/efl/ewk/ewk_intent.h new file mode 100644 index 0000000..35d1bb8 --- /dev/null +++ b/Source/WebKit/efl/ewk/ewk_intent.h @@ -0,0 +1,97 @@ +/* + 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 ewk_intent_h +#define ewk_intent_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Intent */ +typedef struct _Ewk_Intent Ewk_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 data for this intent. + * + * @param intent intent item to query. + * + * @return the data 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_data_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); + +/** + * 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); + +#ifdef __cplusplus +} +#endif +#endif // ewk_intent_h diff --git a/Source/WebKit/efl/ewk/ewk_intent_private.h b/Source/WebKit/efl/ewk/ewk_intent_private.h new file mode 100644 index 0000000..9ac7673 --- /dev/null +++ b/Source/WebKit/efl/ewk/ewk_intent_private.h @@ -0,0 +1,35 @@ +/* + 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 ewk_intent_private_h +#define ewk_intent_private_h + +#if ENABLE(WEB_INTENTS) +// forward declarations +namespace WebCore { +class Intent; +class IntentRequest; +} + +Ewk_Intent* ewk_intent_new(WebCore::Intent* core); +void ewk_intent_free(Ewk_Intent* intent); +Ewk_Intent_Request* ewk_intent_request_new(PassRefPtr core); +#endif + +#endif // ewk_intent_private_h diff --git a/Source/WebKit/efl/ewk/ewk_intent_request.cpp b/Source/WebKit/efl/ewk/ewk_intent_request.cpp new file mode 100644 index 0000000..6cbd189 --- /dev/null +++ b/Source/WebKit/efl/ewk/ewk_intent_request.cpp @@ -0,0 +1,122 @@ +/* + 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 "ewk_intent_request.h" + +#include "IntentRequest.h" +#include "SerializedScriptValue.h" +#include "ewk_intent_private.h" +#include "ewk_private.h" + +/** + * \struct _Ewk_Intent_Request + * @brief Contains the intent request data. + */ +struct _Ewk_Intent_Request { + unsigned int __ref; /**< the reference count of the object */ +#if ENABLE(WEB_INTENTS) + RefPtr core; +#endif + Ewk_Intent* intent; +}; + +#define EWK_INTENT_REQUEST_CORE_GET_OR_RETURN(request, core_, ...) \ + if (!(request)) { \ + CRITICAL("request is NULL."); \ + return __VA_ARGS__; \ + } \ + if (!(request)->core) { \ + CRITICAL("request->core is NULL."); \ + return __VA_ARGS__; \ + } \ + RefPtr core_ = (request)->core + +void ewk_intent_request_ref(Ewk_Intent_Request* request) +{ +#if ENABLE(WEB_INTENTS) + EINA_SAFETY_ON_NULL_RETURN(request); + ++request->__ref; +#endif +} + +void ewk_intent_request_unref(Ewk_Intent_Request* request) +{ +#if ENABLE(WEB_INTENTS) + EINA_SAFETY_ON_NULL_RETURN(request); + + if (--request->__ref) + return; + + ewk_intent_free(request->intent); + delete request; +#endif +} + +Ewk_Intent* ewk_intent_request_intent_get(const Ewk_Intent_Request* request) +{ +#if ENABLE(WEB_INTENTS) + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + return request->intent; +#else + return 0; +#endif +} + +void ewk_intent_request_result_post(Ewk_Intent_Request* request, const char* result) +{ +#if ENABLE(WEB_INTENTS) + EWK_INTENT_REQUEST_CORE_GET_OR_RETURN(request, core); + + RefPtr value = WebCore::SerializedScriptValue::create(String::fromUTF8(result)); + core->postResult(value.release().leakRef()); +#endif +} + +void ewk_intent_request_failure_post(Ewk_Intent_Request* request, const char* failure) +{ +#if ENABLE(WEB_INTENTS) + EWK_INTENT_REQUEST_CORE_GET_OR_RETURN(request, core); + + RefPtr value = WebCore::SerializedScriptValue::create(String::fromUTF8(failure)); + core->postResult(value.release().leakRef()); +#endif +} + +#if ENABLE(WEB_INTENTS) +/** + * @internal + * + * Creates a new Ewk_Intent_Request object. + * + * @param core WebCore::IntentRequest instance to use internally. + * @return a new allocated the Ewk_Intent_Request object on sucess or @c 0 on failure + */ +Ewk_Intent_Request* ewk_intent_request_new(PassRefPtr core) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(core, 0); + Ewk_Intent_Request* request = new Ewk_Intent_Request; + request->__ref = 1; + request->core = core; + request->intent = ewk_intent_new(core->intent()); + + return request; +} +#endif diff --git a/Source/WebKit/efl/ewk/ewk_intent_request.h b/Source/WebKit/efl/ewk/ewk_intent_request.h new file mode 100644 index 0000000..7554644 --- /dev/null +++ b/Source/WebKit/efl/ewk/ewk_intent_request.h @@ -0,0 +1,82 @@ +/* + 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 ewk_intent_request_h +#define ewk_intent_request_h + +#include "ewk_intent.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Intent */ +typedef struct _Ewk_Intent_Request Ewk_Intent_Request; + +/** + * Increases the reference count of the given object. + * + * @param request the intent request object to increase the reference count + */ +EAPI void ewk_intent_request_ref(Ewk_Intent_Request *request); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count it's reached 0, the intent request is freed. + * + * @param request the intent request object to decrease the reference count + */ +EAPI void ewk_intent_request_unref(Ewk_Intent_Request *request); + +/** + * Query intent for this request. + * + * @param request request item to query. + * + * @return A pointer to the intent instance. + */ +EAPI Ewk_Intent *ewk_intent_request_intent_get(const Ewk_Intent_Request *request); + +/** + * Report request success. + * + * The payload data will be passed to the success callback registered by the client. + * + * @param request request item. + * @param result payload data. + */ +EAPI void ewk_intent_request_result_post(Ewk_Intent_Request *request, const char *result); + +/** + * Report request failure. + * + * The payload data will be passed to the error callback registered by the client. + * + * @param request request item. + * @param failure payload data. + */ +EAPI void ewk_intent_request_failure_post(Ewk_Intent_Request *request, const char *failure); + +#ifdef __cplusplus +} +#endif +#endif // ewk_intent_request_h diff --git a/Source/cmake/OptionsEfl.cmake b/Source/cmake/OptionsEfl.cmake index d848c98..08d05cdf 100644 --- a/Source/cmake/OptionsEfl.cmake +++ b/Source/cmake/OptionsEfl.cmake @@ -81,6 +81,7 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO ON) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_INTENTS, ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WORKERS ON) WEBKIT_OPTION_END() -- 2.7.4