Source/WebKit2/ChangeLog

 12012-11-01 Jihye Kang <jye.kang@samsung.com>
 2
 3 [EFL][WK2] Add ewk_security_origin and ewk_storage_manager APIs
 4 https://bugs.webkit.org/show_bug.cgi?id=92827
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add ewk_security_origin APIs to get security origin.
 9 These APIs will be used to get host, protocol and port of security
 10 origin.
 11 Add ewk_storage_manager to manage web storage and
 12 ewk_storage_manager_origins_get to get origins list of web storage.
 13 Add Unit tests for ewk_storage_manager and ewk_security_origin APIs.
 14
 15 * PlatformEfl.cmake:
 16 * UIProcess/API/efl/EWebKit2.h:
 17 * UIProcess/API/efl/ewk_context.cpp:
 18 (Ewk_Context::storageManager):
 19 (ewk_context_storage_manager_get):
 20 * UIProcess/API/efl/ewk_context.h:
 21 * UIProcess/API/efl/ewk_context_private.h:
 22 (Ewk_Context):
 23 * UIProcess/API/efl/ewk_security_origin.cpp: Added.
 24 (Ewk_Security_Origin::Ewk_Security_Origin):
 25 (Ewk_Security_Origin::host):
 26 (Ewk_Security_Origin::protocol):
 27 (Ewk_Security_Origin::port):
 28 (ewk_security_origin_ref):
 29 (ewk_security_origin_unref):
 30 (ewk_security_origin_host_get):
 31 (ewk_security_origin_protocol_get):
 32 (ewk_security_origin_port_get):
 33 * UIProcess/API/efl/ewk_security_origin.h: Added.
 34 * UIProcess/API/efl/ewk_security_origin_private.h: Added.
 35 (Ewk_Security_Origin):
 36 (Ewk_Security_Origin::create):
 37 * UIProcess/API/efl/ewk_storage_manager.cpp: Added.
 38 (Ewk_Storage_Manager::Ewk_Storage_Manager):
 39 (Ewk_Storage_Manager::getStorageOrigins):
 40 (Ewk_Storage_Manager::createOriginList):
 41 (_Ewk_Storage_Origins_Async_Get_Context):
 42 (_Ewk_Storage_Origins_Async_Get_Context::_Ewk_Storage_Origins_Async_Get_Context):
 43 (getStorageOriginsCallback):
 44 (ewk_storage_manager_origins_get):
 45 * UIProcess/API/efl/ewk_storage_manager.h: Added.
 46 * UIProcess/API/efl/ewk_storage_manager_private.h: Added.
 47 (Ewk_Storage_Manager):
 48 (Ewk_Storage_Manager::create):
 49 * UIProcess/API/efl/tests/test_ewk2_context.cpp:
 50 (TEST_F):
 51 * UIProcess/API/efl/tests/test_ewk2_storage_manager.cpp: Added.
 52 (getStorageOriginsCallback):
 53 (TEST_F):
 54
1552012-10-31 Alexandru Chiculita <achicu@adobe.com>
256
357 CustomFilterOperation parameters list is not decoded correctly in CoordinatedGraphicsArgumentCoders

Source/WebKit2/PlatformEfl.cmake

@@LIST(APPEND WebKit2_SOURCES
6262 UIProcess/API/efl/ewk_popup_menu.cpp
6363 UIProcess/API/efl/ewk_popup_menu_item.cpp
6464 UIProcess/API/efl/ewk_resource.cpp
 65 UIProcess/API/efl/ewk_security_origin.cpp
6566 UIProcess/API/efl/ewk_settings.cpp
 67 UIProcess/API/efl/ewk_storage_manager.cpp
6668 UIProcess/API/efl/ewk_text_checker.cpp
6769 UIProcess/API/efl/ewk_url_request.cpp
6870 UIProcess/API/efl/ewk_url_response.cpp

@@SET (EWebKit2_HEADERS
260262 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_popup_menu.h"
261263 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_popup_menu_item.h"
262264 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_resource.h"
 265 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_security_origin.h"
263266 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_settings.h"
 267 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_storage_manager.h"
264268 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_text_checker.h"
265269 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_touch.h"
266270 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_url_request.h"

@@SET(EWK2UnitTests_BINARIES
358362 test_ewk2_intents
359363 test_ewk2_popup_menu
360364 test_ewk2_settings
 365 test_ewk2_storage_manager
361366 test_ewk2_text_checker
362367 test_ewk2_view
363368)

Source/WebKit2/UIProcess/API/efl/EWebKit2.h

4646#include "ewk_popup_menu.h"
4747#include "ewk_popup_menu_item.h"
4848#include "ewk_resource.h"
 49#include "ewk_security_origin.h"
4950#include "ewk_settings.h"
 51#include "ewk_storage_manager.h"
5052#include "ewk_text_checker.h"
5153#include "ewk_touch.h"
5254#include "ewk_url_request.h"

Source/WebKit2/UIProcess/API/efl/ewk_context.cpp

3838#include "ewk_cookie_manager_private.h"
3939#include "ewk_favicon_database_private.h"
4040#include "ewk_private.h"
 41#include "ewk_storage_manager_private.h"
4142#include "ewk_url_scheme_request_private.h"
4243#include <WebCore/FileSystem.h>
4344#include <WebCore/IconDatabase.h>

@@static inline ContextMap& contextMap()
6263
6364Ewk_Context::Ewk_Context(WKContextRef context)
6465 : m_context(context)
 66 , m_storageManager(Ewk_Storage_Manager::create(WKContextGetKeyValueStorageManager(m_context.get())))
6567#if ENABLE(BATTERY_STATUS)
6668 , m_batteryProvider(BatteryProvider::create(context))
6769#endif

@@Ewk_Favicon_Database* Ewk_Context::faviconDatabase()
158160 return m_faviconDatabase.get();
159161}
160162
 163Ewk_Storage_Manager* Ewk_Context::storageManager() const
 164{
 165 return m_storageManager.get();
 166}
 167
161168RequestManagerClientEfl* Ewk_Context::requestManager()
162169{
163170 return m_requestManagerClient.get();

@@Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkCon
215222 return const_cast<Ewk_Context*>(ewkContext)->faviconDatabase();
216223}
217224
 225Ewk_Storage_Manager* ewk_context_storage_manager_get(const Ewk_Context* ewkContext)
 226{
 227 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
 228
 229 return ewkContext->storageManager();
 230}
 231
218232WKContextRef Ewk_Context::wkContext()
219233{
220234 return m_context.get();

Source/WebKit2/UIProcess/API/efl/ewk_context.h

4040#include "ewk_cookie_manager.h"
4141#include "ewk_favicon_database.h"
4242#include "ewk_navigation_data.h"
 43#include "ewk_storage_manager.h"
4344#include "ewk_url_scheme_request.h"
4445#include <Evas.h>
4546

@@EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *conte
192193EAPI Ewk_Favicon_Database *ewk_context_favicon_database_get(const Ewk_Context *context);
193194
194195/**
 196 * Gets the storage manager instance for this @a context.
 197 *
 198 * @param context context object to query.
 199 *
 200 * @return Ewk_Storage_Manager object instance or @c NULL in case of failure.
 201 */
 202EAPI Ewk_Storage_Manager *ewk_context_storage_manager_get(const Ewk_Context *context);
 203
 204/**
195205 * Register @a scheme in @a context.
196206 *
197207 * When an URL request with @a scheme is made in the #Ewk_Context, the callback

Source/WebKit2/UIProcess/API/efl/ewk_context_private.h

@@public:
5757
5858 Ewk_Favicon_Database* faviconDatabase();
5959
 60 Ewk_Storage_Manager* storageManager() const;
 61
6062 WebKit::RequestManagerClientEfl* requestManager();
6163
6264#if ENABLE(VIBRATION)

@@private:
8486
8587 OwnPtr<Ewk_Cookie_Manager> m_cookieManager;
8688 OwnPtr<Ewk_Favicon_Database> m_faviconDatabase;
 89 OwnPtr<Ewk_Storage_Manager> m_storageManager;
8790#if ENABLE(BATTERY_STATUS)
8891 RefPtr<WebKit::BatteryProvider> m_batteryProvider;
8992#endif

Source/WebKit2/UIProcess/API/efl/ewk_security_origin.cpp

 1/*
 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "ewk_security_origin.h"
 28
 29#include "WKAPICast.h"
 30#include "WKSecurityOrigin.h"
 31#include "ewk_security_origin_private.h"
 32
 33using namespace WebKit;
 34
 35Ewk_Security_Origin::Ewk_Security_Origin(WKSecurityOriginRef originRef)
 36 : m_wkOrigin(originRef)
 37 , m_host(AdoptWK, WKSecurityOriginCopyHost(originRef))
 38 , m_protocol(AdoptWK, WKSecurityOriginCopyProtocol(originRef))
 39{ }
 40
 41const char* Ewk_Security_Origin::host() const
 42{
 43 return m_host;
 44}
 45
 46const char* Ewk_Security_Origin::protocol() const
 47{
 48 return m_protocol;
 49}
 50
 51uint32_t Ewk_Security_Origin::port() const
 52{
 53 return WKSecurityOriginGetPort(m_wkOrigin.get());
 54}
 55
 56Ewk_Security_Origin* ewk_security_origin_ref(Ewk_Security_Origin* origin)
 57{
 58 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0);
 59
 60 origin->ref();
 61 return origin;
 62}
 63
 64void ewk_security_origin_unref(Ewk_Security_Origin* origin)
 65{
 66 EINA_SAFETY_ON_NULL_RETURN(origin);
 67
 68 origin->deref();
 69}
 70
 71const char* ewk_security_origin_host_get(const Ewk_Security_Origin* origin)
 72{
 73 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0);
 74
 75 return origin->host();
 76}
 77
 78const char* ewk_security_origin_protocol_get(const Ewk_Security_Origin* origin)
 79{
 80 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0);
 81
 82 return origin->protocol();
 83}
 84
 85uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin* origin)
 86{
 87 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0);
 88
 89 return origin->port();
 90}

Source/WebKit2/UIProcess/API/efl/ewk_security_origin.h

 1/*
 2 * Copyright (C) 2012 Intel Corporation. All rights reserved.
 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 23 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 25 */
 26
 27/**
 28 * @file ewk_security_origin.h
 29 * @brief Security Origin API.
 30 *
 31 * Security Origin is the mechanism that defines the access limits of a website.
 32 * Based on information such as domain, protocol and port, you can or cannot grant
 33 * authorization for accessing data and performing certain tasks.
 34 */
 35
 36#ifndef ewk_security_origin_h
 37#define ewk_security_origin_h
 38
 39#include <Eina.h>
 40
 41#ifdef __cplusplus
 42extern "C" {
 43#endif
 44
 45/** Creates a type name for Ewk_Security_Origin. */
 46typedef struct Ewk_Security_Origin Ewk_Security_Origin;
 47
 48/**
 49 * Increases the reference count of the given object.
 50 *
 51 * @param origin the origin object to increase the reference count
 52 *
 53 * @return a pointer to the object on success, @c NULL otherwise
 54 */
 55EAPI Ewk_Security_Origin *ewk_security_origin_ref(Ewk_Security_Origin *o);
 56
 57/**
 58 * Decreases the reference count of the given object, possibly freeing it.
 59 *
 60 * When the reference count reaches 0, the origin is freed.
 61 *
 62 * @param origin the origin object to decrease the reference count
 63 */
 64EAPI void ewk_security_origin_unref(Ewk_Security_Origin *o);
 65
 66/**
 67 * Returns the host of the security origin.
 68 *
 69 * @param o security origin object
 70 *
 71 * @return the host domain pointer or @c NULL if there is not a host scheme.
 72 * This pointer is guaranteed to be eina_stringshare, so whenever possible
 73 * save yourself from cpu cycles and use eina_stringshare_ref()
 74 * instead of eina_stringshare_add() or strdup().
 75 */
 76EAPI const char *ewk_security_origin_host_get(const Ewk_Security_Origin *o);
 77
 78/**
 79 * Returns the port of the security origin.
 80 *
 81 * @param o security origin object
 82 *
 83 * @return the port number or @c 0 if there is not a proper security origin scheme
 84 */
 85EAPI uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin *o);
 86
 87/**
 88 * Returns the protocol of the security origin.
 89 *
 90 * @param o security origin object
 91 *
 92 * @return the protocol scheme pointer or @c NULL if there is not a protocol scheme.
 93 * This pointer is guaranteed to be eina_stringshare, so whenever possible
 94 * save yourself from cpu cycles and use eina_stringshare_ref()
 95 * instead of eina_stringshare_add() or strdup().
 96 */
 97EAPI const char *ewk_security_origin_protocol_get(const Ewk_Security_Origin *o);
 98
 99#ifdef __cplusplus
 100}
 101#endif
 102#endif // ewk_security_origin_h

Source/WebKit2/UIProcess/API/efl/ewk_security_origin_private.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef ewk_security_origin_private_h
 27#define ewk_security_origin_private_h
 28
 29#include "WKEinaSharedString.h"
 30#include "WKSecurityOrigin.h"
 31#include <WebKit2/WKBase.h>
 32#include <wtf/PassRefPtr.h>
 33#include <wtf/RefCounted.h>
 34
 35class Ewk_Security_Origin : public RefCounted<Ewk_Security_Origin> {
 36public:
 37 static PassRefPtr<Ewk_Security_Origin> create(WKSecurityOriginRef originRef)
 38 {
 39 return adoptRef(new Ewk_Security_Origin(originRef));
 40 }
 41
 42 const char* host() const;
 43 const char* protocol() const;
 44 uint32_t port() const;
 45
 46private:
 47 explicit Ewk_Security_Origin(WKSecurityOriginRef originRef);
 48
 49 WKRetainPtr<WKSecurityOriginRef> m_wkOrigin;
 50 WKEinaSharedString m_host;
 51 WKEinaSharedString m_protocol;
 52};
 53
 54#endif // ewk_security_origin_private_h

Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.cpp

 1/*
 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "ewk_storage_manager.h"
 28
 29#include "WKAPICast.h"
 30#include "WKArray.h"
 31#include "WKKeyValueStorageManager.h"
 32#include "ewk_error_private.h"
 33#include "ewk_security_origin.h"
 34#include "ewk_security_origin_private.h"
 35#include "ewk_storage_manager_private.h"
 36#include <wtf/RefCounted.h>
 37
 38using namespace WebKit;
 39
 40Ewk_Storage_Manager::Ewk_Storage_Manager(WKKeyValueStorageManagerRef wkStorageManagerRef)
 41 : m_wkStorageManager(wkStorageManagerRef)
 42{ }
 43
 44void Ewk_Storage_Manager::getStorageOrigins(void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback) const
 45{
 46 WKKeyValueStorageManagerGetKeyValueStorageOrigins(m_wkStorageManager.get(), context, callback);
 47}
 48
 49Eina_List* Ewk_Storage_Manager::createOriginList(WKArrayRef origins) const
 50{
 51 Eina_List* originList = 0;
 52 const size_t length = WKArrayGetSize(origins);
 53
 54 for (size_t i = 0; i < length; ++i) {
 55 WKSecurityOriginRef wkOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
 56 RefPtr<Ewk_Security_Origin> origin = m_wrapperCache.get(wkOriginRef);
 57 if (!origin) {
 58 origin = Ewk_Security_Origin::create(wkOriginRef);
 59 m_wrapperCache.set(wkOriginRef, origin);
 60 }
 61 originList = eina_list_append(originList, origin.release().leakRef());
 62 }
 63
 64 return originList;
 65}
 66
 67struct Ewk_Storage_Origins_Async_Get_Context {
 68 const Ewk_Storage_Manager* manager;
 69 Ewk_Storage_Origins_Get_Cb callback;
 70 void* userData;
 71
 72 Ewk_Storage_Origins_Async_Get_Context(const Ewk_Storage_Manager* manager, Ewk_Storage_Origins_Get_Cb callback, void* userData)
 73 : manager(manager)
 74 , callback(callback)
 75 , userData(userData)
 76 { }
 77};
 78
 79static void getStorageOriginsCallback(WKArrayRef origins, WKErrorRef wkError, void* context)
 80{
 81 Eina_List* originList = 0;
 82 OwnPtr<Ewk_Storage_Origins_Async_Get_Context*> webStorageContext = adoptPtr(static_cast<Ewk_Storage_Origins_Async_Get_Context*>(context));
 83
 84 originList = webStorageContext->manager->createOriginList(origins);
 85
 86 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError);
 87 webStorageContext->callback(originList, ewkError.get(), webStorageContext->userData);
 88}
 89
 90Eina_Bool ewk_storage_manager_origins_get(const Ewk_Storage_Manager* ewkStorageManager, Ewk_Storage_Origins_Get_Cb callback, void* userData)
 91{
 92 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkStorageManager, false);
 93 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
 94
 95 Ewk_Storage_Origins_Async_Get_Context* context = new Ewk_Storage_Origins_Async_Get_Context(ewkStorageManager, callback, userData);
 96 ewkStorageManager->getStorageOrigins(context, getStorageOriginsCallback);
 97
 98 return true;
 99}

Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26/**
 27 * @file ewk_storage_manager.h
 28 * @brief Describes the Ewk Storage Manager API.
 29 *
 30 * Ewk Storage Manager manages web storage.
 31 */
 32
 33#ifndef ewk_storage_manager_h
 34#define ewk_storage_manager_h
 35
 36#include "ewk_error.h"
 37#include <Eina.h>
 38
 39#ifdef __cplusplus
 40extern "C" {
 41#endif
 42
 43/** Creates a type name for Ewk_Storage_Manager. */
 44typedef struct Ewk_Storage_Manager Ewk_Storage_Manager;
 45
 46/**
 47 * @typedef Ewk_Storage_Origins_Get_Cb Ewk_Storage_Origins_Get_Cb
 48 * @brief Callback type for use with ewk_storage_manager_origins_get().
 49 *
 50 * @param origins @c Eina_List containing @c Ewk_Security_Origin elements or @c NULL in case of error,
 51 * the Eina_List and its items should be freed after use. Use ewk_security_origin_unref()
 52 * to free the items
 53 */
 54typedef void (*Ewk_Storage_Origins_Get_Cb)(Eina_List *origins, Ewk_Error *error, void *user_data);
 55
 56/**
 57 * Gets list of origins that are stored in storage db asynchronously.
 58 *
 59 * This function allocates memory for context structure made from callback and user_data.
 60 *
 61 * @param manager Ewk_Storage_Manager object
 62 * @param callback callback to get storage origins
 63 * @param user_data user_data will be passed when result_callback is called,
 64 * -i.e., user data will be kept until callback is called
 65 *
 66 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure
 67 */
 68EAPI Eina_Bool ewk_storage_manager_origins_get(const Ewk_Storage_Manager *manager, Ewk_Storage_Origins_Get_Cb callback, void *user_data);
 69
 70#ifdef __cplusplus
 71}
 72#endif
 73#endif // ewk_storage_manager_h

Source/WebKit2/UIProcess/API/efl/ewk_storage_manager_private.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef ewk_storage_manager_private_h
 27#define ewk_storage_manager_private_h
 28
 29#include "WKKeyValueStorageManager.h"
 30#include "WKRetainPtr.h"
 31#include "ewk_security_origin_private.h"
 32#include <WebKit2/WKBase.h>
 33#include <wtf/PassOwnPtr.h>
 34
 35class Ewk_Storage_Manager {
 36public:
 37 static PassOwnPtr<Ewk_Storage_Manager> create(WKKeyValueStorageManagerRef wkStorageManagerRef)
 38 {
 39 return adoptPtr(new Ewk_Storage_Manager(wkStorageManagerRef));
 40 }
 41
 42 Eina_List* createOriginList(WKArrayRef wkList) const;
 43 void getStorageOrigins(void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback) const;
 44
 45private:
 46 explicit Ewk_Storage_Manager(WKKeyValueStorageManagerRef wkStorageManagerRef);
 47
 48 WKRetainPtr<WKKeyValueStorageManagerRef> m_wkStorageManager;
 49 mutable HashMap<WKSecurityOriginRef, RefPtr<Ewk_Security_Origin> > m_wrapperCache;
 50};
 51
 52#endif // ewk_storage_manager_private_h

Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp

@@TEST_F(EWK2UnitTestBase, ewk_context_favicon_database_get)
6161 ASSERT_EQ(faviconDatabase, ewk_context_favicon_database_get(context));
6262}
6363
 64TEST_F(EWK2UnitTestBase, ewk_context_storage_manager_get)
 65{
 66 Ewk_Context* context = ewk_view_context_get(webView());
 67 Ewk_Storage_Manager* storageManager = ewk_context_storage_manager_get(context);
 68 ASSERT_TRUE(storageManager);
 69 ASSERT_EQ(storageManager, ewk_context_storage_manager_get(context));
 70}
 71
6472static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userData)
6573{
6674 const char* scheme = ewk_url_scheme_request_scheme_get(request);

Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_storage_manager.cpp

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27
 28#include "UnitTestUtils/EWK2UnitTestBase.h"
 29#include <EWebKit2.h>
 30#include <Ecore.h>
 31#include <gtest/gtest.h>
 32
 33using namespace EWK2UnitTest;
 34
 35static void getStorageOriginsCallback(Eina_List *origins, Ewk_Error *error, void *user_data)
 36{
 37 ASSERT_FALSE(error);
 38
 39 Eina_List** ret = static_cast<Eina_List**>(user_data);
 40 Eina_List* l;
 41 void* data;
 42 EINA_LIST_FOREACH(origins, l, data)
 43 *ret = eina_list_append(*ret, data);
 44
 45 ecore_main_loop_quit();
 46}
 47
 48TEST_F(EWK2UnitTestBase, ewk_storage_manager_origins_get)
 49{
 50 const char* storageHTML =
 51 "<html><head><title>original title</title></head>"
 52 "<body>"
 53 "<script type='text/javascript'>"
 54 " localStorage.setItem('item', 'storage');"
 55 " document.title = 'Set';"
 56 " </script>"
 57 "</body></html>";
 58
 59 // Wait until storage tracker is made and synchronized so that we can get the origins of web storage form storage tracker.
 60 ewk_view_html_string_load(webView(), storageHTML, "http://www.storagetest.com", 0);
 61 ASSERT_FALSE(waitUntilTitleChangedTo("Wait until db sync is finished", 2));
 62
 63 Eina_List* origins = 0;
 64 ASSERT_TRUE(ewk_storage_manager_origins_get(ewk_context_storage_manager_get(ewk_view_context_get(webView())), getStorageOriginsCallback, &origins));
 65 ecore_main_loop_begin();
 66
 67 ASSERT_LE(1, eina_list_count(origins));
 68
 69 Ewk_Security_Origin* origin = static_cast<Ewk_Security_Origin*>(eina_list_nth(origins, 0));
 70 EXPECT_STREQ("http", ewk_security_origin_protocol_get(origin));
 71 EXPECT_STREQ("www.storagetest.com", ewk_security_origin_host_get(origin));
 72 EXPECT_EQ(0, ewk_security_origin_port_get(origin));
 73
 74 EXPECT_EQ(origin, ewk_security_origin_ref(origin));
 75 ewk_security_origin_unref(origin);
 76}