Title: [140542] trunk/Source/WebKit2
Revision
140542
Author
[email protected]
Date
2013-01-23 10:20:46 -0800 (Wed, 23 Jan 2013)

Log Message

[EFL][WK2] Use C API inside ewk_cookie_manager
https://bugs.webkit.org/show_bug.cgi?id=107661

Reviewed by Alexey Proskuryakov.

Use C API inside ewk_cookie_manager instead of
accessing C++ classes directly and violating
layering.

* PlatformEfl.cmake:
* UIProcess/API/C/soup/WKCookieManagerSoup.cpp: Added.
(toSoupCookiePersistentStorageType):
(WKCookieManagerSetCookiePersistentStorage): Add C API for setting
the persistent storage path and type when using libsoup.
* UIProcess/API/C/soup/WKCookieManagerSoup.h: Added.
* UIProcess/API/efl/ewk_context.cpp:
(EwkContext::cookieManager):
* UIProcess/API/efl/ewk_cookie_manager.cpp:
(EwkCookieManager::EwkCookieManager):
(EwkCookieManager::~EwkCookieManager):
(EwkCookieManager::setPersistentStorage):
(EwkCookieManager::setHTTPAcceptPolicy):
(EwkCookieManager::clearHostnameCookies):
(EwkCookieManager::clearAllCookies):
(EwkCookieManager::watchChanges):
(EwkCookieManager::getHostNamesWithCookies):
(EwkCookieManager::getHTTPAcceptPolicy):
(ewk_cookie_manager_persistent_storage_set):
(ewk_cookie_manager_hostname_cookies_clear):
* UIProcess/API/efl/ewk_cookie_manager_private.h:
(EwkCookieManager::create):
(EwkCookieManager):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (140541 => 140542)


--- trunk/Source/WebKit2/ChangeLog	2013-01-23 18:04:07 UTC (rev 140541)
+++ trunk/Source/WebKit2/ChangeLog	2013-01-23 18:20:46 UTC (rev 140542)
@@ -1,3 +1,38 @@
+2013-01-23  Christophe Dumez  <[email protected]>
+
+        [EFL][WK2] Use C API inside ewk_cookie_manager
+        https://bugs.webkit.org/show_bug.cgi?id=107661
+
+        Reviewed by Alexey Proskuryakov.
+
+        Use C API inside ewk_cookie_manager instead of
+        accessing C++ classes directly and violating
+        layering.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/C/soup/WKCookieManagerSoup.cpp: Added.
+        (toSoupCookiePersistentStorageType):
+        (WKCookieManagerSetCookiePersistentStorage): Add C API for setting
+        the persistent storage path and type when using libsoup.
+        * UIProcess/API/C/soup/WKCookieManagerSoup.h: Added.
+        * UIProcess/API/efl/ewk_context.cpp:
+        (EwkContext::cookieManager):
+        * UIProcess/API/efl/ewk_cookie_manager.cpp:
+        (EwkCookieManager::EwkCookieManager):
+        (EwkCookieManager::~EwkCookieManager):
+        (EwkCookieManager::setPersistentStorage):
+        (EwkCookieManager::setHTTPAcceptPolicy):
+        (EwkCookieManager::clearHostnameCookies):
+        (EwkCookieManager::clearAllCookies):
+        (EwkCookieManager::watchChanges):
+        (EwkCookieManager::getHostNamesWithCookies):
+        (EwkCookieManager::getHTTPAcceptPolicy):
+        (ewk_cookie_manager_persistent_storage_set):
+        (ewk_cookie_manager_hostname_cookies_clear):
+        * UIProcess/API/efl/ewk_cookie_manager_private.h:
+        (EwkCookieManager::create):
+        (EwkCookieManager):
+
 2013-01-22  Anders Carlsson  <[email protected]>
 
         Use a platforom strategy for local storage

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (140541 => 140542)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2013-01-23 18:04:07 UTC (rev 140541)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2013-01-23 18:20:46 UTC (rev 140542)
@@ -37,6 +37,7 @@
     UIProcess/API/cpp/efl/WKEinaSharedString.cpp
 
     UIProcess/API/C/soup/WKContextSoup.cpp
+    UIProcess/API/C/soup/WKCookieManagerSoup.cpp
     UIProcess/API/C/soup/WKSoupRequestManager.cpp
 
     UIProcess/API/efl/EwkViewImpl.cpp

Added: trunk/Source/WebKit2/UIProcess/API/C/soup/WKCookieManagerSoup.cpp (0 => 140542)


--- trunk/Source/WebKit2/UIProcess/API/C/soup/WKCookieManagerSoup.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/soup/WKCookieManagerSoup.cpp	2013-01-23 18:20:46 UTC (rev 140542)
@@ -0,0 +1,51 @@
+/*
+ * 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 "WKCookieManagerSoup.h"
+
+#include "SoupCookiePersistentStorageType.h"
+#include "WKAPICast.h"
+#include "WebCookieManagerProxy.h"
+
+using namespace WebKit;
+
+inline SoupCookiePersistentStorageType toSoupCookiePersistentStorageType(WKCookieStorageType wkCookieStorageType)
+{
+    switch (wkCookieStorageType) {
+    case kWKCookieStorageTypeText:
+        return SoupCookiePersistentStorageText;
+    case kWKCookieStorageTypeSQLite:
+        return SoupCookiePersistentStorageSQLite;
+    }
+
+    ASSERT_NOT_REACHED();
+    return SoupCookiePersistentStorageText;
+}
+
+void WKCookieManagerSetCookiePersistentStorage(WKCookieManagerRef cookieManager, WKStringRef storagePath, WKCookieStorageType storageType)
+{
+    toImpl(cookieManager)->setCookiePersistentStorage(toWTFString(storagePath), storageType);
+}

Added: trunk/Source/WebKit2/UIProcess/API/C/soup/WKCookieManagerSoup.h (0 => 140542)


--- trunk/Source/WebKit2/UIProcess/API/C/soup/WKCookieManagerSoup.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/soup/WKCookieManagerSoup.h	2013-01-23 18:20:46 UTC (rev 140542)
@@ -0,0 +1,47 @@
+/*
+ * 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 WKCookieManagerSoup_h
+#define WKCookieManagerSoup_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+    kWKCookieStorageTypeText = 0,
+    kWKCookieStorageTypeSQLite = 1
+};
+typedef uint32_t WKCookieStorageType;
+
+WK_EXPORT void WKCookieManagerSetCookiePersistentStorage(WKCookieManagerRef cookieManager, WKStringRef storagePath, WKCookieStorageType storageType);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKCookieManagerSoup_h

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp (140541 => 140542)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2013-01-23 18:04:07 UTC (rev 140541)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2013-01-23 18:20:46 UTC (rev 140542)
@@ -136,7 +136,7 @@
 EwkCookieManager* EwkContext::cookieManager()
 {
     if (!m_cookieManager)
-        m_cookieManager = EwkCookieManager::create(m_context->supplement<WebCookieManagerProxy>());
+        m_cookieManager = EwkCookieManager::create(WKContextGetCookieManager(toAPI(m_context.get())));
 
     return m_cookieManager.get();
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp (140541 => 140542)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp	2013-01-23 18:04:07 UTC (rev 140541)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp	2013-01-23 18:20:46 UTC (rev 140542)
@@ -28,8 +28,8 @@
 
 #include "WKAPICast.h"
 #include "WKArray.h"
+#include "WKCookieManagerSoup.h"
 #include "WKString.h"
-#include "WebCookieManagerProxy.h"
 #include "ewk_cookie_manager_private.h"
 #include "ewk_error_private.h"
 #include "ewk_private.h"
@@ -39,7 +39,7 @@
 
 using namespace WebKit;
 
-EwkCookieManager::EwkCookieManager(PassRefPtr<WebCookieManagerProxy> cookieManager)
+EwkCookieManager::EwkCookieManager(WKCookieManagerRef cookieManager)
     : m_cookieManager(cookieManager)
 {
     ASSERT(m_cookieManager);
@@ -49,40 +49,42 @@
         this, // clientInfo
         cookiesDidChange
     };
-    WKCookieManagerSetClient(toAPI(m_cookieManager.get()), &wkCookieManagerClient);
+    WKCookieManagerSetClient(m_cookieManager.get(), &wkCookieManagerClient);
 }
 
 EwkCookieManager::~EwkCookieManager()
 {
     if (isWatchingForChanges())
-        m_cookieManager->stopObservingCookieChanges();
+        WKCookieManagerStopObservingCookieChanges(m_cookieManager.get());
 }
 
-void EwkCookieManager::setPersistentStorage(const String& filename, SoupCookiePersistentStorageType storage)
+void EwkCookieManager::setPersistentStorage(const char* filename, WKCookieStorageType storageType)
 {
     bool isWatchingChanges = isWatchingForChanges();
     if (isWatchingChanges)
-        m_cookieManager->stopObservingCookieChanges();
+        WKCookieManagerStopObservingCookieChanges(m_cookieManager.get());
 
-    m_cookieManager->setCookiePersistentStorage(filename, storage);
+    WKRetainPtr<WKStringRef> wkFilename(AdoptWK, WKStringCreateWithUTF8CString(filename));
+    WKCookieManagerSetCookiePersistentStorage(m_cookieManager.get(), wkFilename.get(), storageType);
 
     if (isWatchingChanges)
-        m_cookieManager->startObservingCookieChanges();
+        WKCookieManagerStartObservingCookieChanges(m_cookieManager.get());
 }
 
 void EwkCookieManager::setHTTPAcceptPolicy(WKHTTPCookieAcceptPolicy policy)
 {
-    m_cookieManager->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+    WKCookieManagerSetHTTPCookieAcceptPolicy(m_cookieManager.get(), policy);
 }
 
-void EwkCookieManager::clearHostnameCookies(const String& hostname)
+void EwkCookieManager::clearHostnameCookies(const char* hostname)
 {
-    m_cookieManager->deleteCookiesForHostname(hostname);
+    WKRetainPtr<WKStringRef> wkHostname(AdoptWK, WKStringCreateWithUTF8CString(hostname));
+    WKCookieManagerDeleteCookiesForHostname(m_cookieManager.get(), wkHostname.get());
 }
 
 void EwkCookieManager::clearAllCookies()
 {
-    m_cookieManager->deleteAllCookies();
+    WKCookieManagerDeleteAllCookies(m_cookieManager.get());
 }
 
 void EwkCookieManager::watchChanges(const Cookie_Change_Handler& changeHandler)
@@ -90,9 +92,9 @@
     m_changeHandler = changeHandler;
 
     if (changeHandler.callback)
-        m_cookieManager->startObservingCookieChanges();
+        WKCookieManagerStartObservingCookieChanges(m_cookieManager.get());
     else
-        m_cookieManager->stopObservingCookieChanges();
+        WKCookieManagerStopObservingCookieChanges(m_cookieManager.get());
 }
 
 bool EwkCookieManager::isWatchingForChanges() const
@@ -102,12 +104,12 @@
 
 void EwkCookieManager::getHostNamesWithCookies(WKCookieManagerGetCookieHostnamesFunction callback, void* userData) const
 {
-    m_cookieManager->getHostnamesWithCookies(ArrayCallback::create(userData, callback));
+    WKCookieManagerGetHostnamesWithCookies(m_cookieManager.get(), userData, callback);
 }
 
 void EwkCookieManager::getHTTPAcceptPolicy(WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback, void* userData) const
 {
-    m_cookieManager->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyCallback::create(userData, callback));
+    WKCookieManagerGetHTTPCookieAcceptPolicy(m_cookieManager.get(), userData, callback);
 }
 
 void EwkCookieManager::cookiesDidChange(WKCookieManagerRef, const void* clientInfo)
@@ -121,15 +123,15 @@
 }
 
 // Ewk_Cookie_Persistent_Storage enum validation.
-COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_TEXT, SoupCookiePersistentStorageText);
-COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_SQLITE, SoupCookiePersistentStorageSQLite);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_TEXT, kWKCookieStorageTypeText);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_SQLITE, kWKCookieStorageTypeSQLite);
 
 void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager* manager, const char* filename, Ewk_Cookie_Persistent_Storage storage)
 {
     EINA_SAFETY_ON_NULL_RETURN(manager);
     EINA_SAFETY_ON_NULL_RETURN(filename);
 
-    manager->setPersistentStorage(String::fromUTF8(filename), static_cast<SoupCookiePersistentStorageType>(storage));
+    manager->setPersistentStorage(filename, static_cast<WKCookieStorageType>(storage));
 }
 
 // Ewk_Cookie_Accept_Policy enum validation.
@@ -221,7 +223,7 @@
     EINA_SAFETY_ON_NULL_RETURN(manager);
     EINA_SAFETY_ON_NULL_RETURN(hostname);
 
-    manager->clearHostnameCookies(String::fromUTF8(hostname));
+    manager->clearHostnameCookies(hostname);
 }
 
 void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager* manager)

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h (140541 => 140542)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h	2013-01-23 18:04:07 UTC (rev 140541)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h	2013-01-23 18:20:46 UTC (rev 140542)
@@ -26,9 +26,9 @@
 #ifndef ewk_cookie_manager_private_h
 #define ewk_cookie_manager_private_h
 
-#include "SoupCookiePersistentStorageType.h"
 #include "WKCookieManager.h"
-#include "WebCookieManagerProxy.h"
+#include "WKCookieManagerSoup.h"
+#include "WKRetainPtr.h"
 #include "ewk_cookie_manager.h"
 #include <WebKit2/WKBase.h>
 #include <wtf/PassOwnPtr.h>
@@ -50,32 +50,32 @@
 
 class EwkCookieManager {
 public:
-    static PassOwnPtr<EwkCookieManager> create(PassRefPtr<WebKit::WebCookieManagerProxy> cookieManager)
+    static PassOwnPtr<EwkCookieManager> create(WKCookieManagerRef cookieManager)
     {
         return adoptPtr(new EwkCookieManager(cookieManager));
     }
 
     ~EwkCookieManager();
 
-    void setPersistentStorage(const String& filename, WebKit::SoupCookiePersistentStorageType storage);
+    void setPersistentStorage(const char* filename, WKCookieStorageType);
 
     void getHTTPAcceptPolicy(WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback, void* userData) const;
     void setHTTPAcceptPolicy(WKHTTPCookieAcceptPolicy policy);
 
-    void clearHostnameCookies(const String& hostname);
+    void clearHostnameCookies(const char* hostname);
     void clearAllCookies();
 
     void getHostNamesWithCookies(WKCookieManagerGetCookieHostnamesFunction callback, void* userData) const;
     void watchChanges(const Cookie_Change_Handler& changeHandler);
 
 private:
-    explicit EwkCookieManager(PassRefPtr<WebKit::WebCookieManagerProxy> cookieManager);
+    explicit EwkCookieManager(WKCookieManagerRef cookieManager);
 
     bool isWatchingForChanges() const;
 
     static void cookiesDidChange(WKCookieManagerRef, const void* clientInfo);
 
-    RefPtr<WebKit::WebCookieManagerProxy> m_cookieManager;
+    WKRetainPtr<WKCookieManagerRef> m_cookieManager;
     Cookie_Change_Handler m_changeHandler;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to