1 // Copyright 2013 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ewk_cookie_manager.h"
7 #include "cookie_manager.h"
8 #include "public/ewk_log.h"
9 #include "private/ewk_cookie_manager_private.h"
11 #define EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager, ...) \
13 CRITICAL("ewk cookie manager is NULL."); \
16 if (!(manager)->cookieManager().get()) { \
17 CRITICAL("ewk cookie manager->cookieManager() is NULL."); \
20 scoped_refptr<CookieManager> cookie_manager = (manager)->cookieManager()
23 void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager* manager,
24 const char* file_name,
25 Ewk_Cookie_Persistent_Storage storage)
27 EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager);
28 EINA_SAFETY_ON_NULL_RETURN(file_name);
29 std::string fileName(file_name);
30 cookie_manager->SetStoragePath(file_name, true /*persist session*/, storage);
33 void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager* manager,
34 Ewk_Cookie_Accept_Policy policy)
36 EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager);
37 cookie_manager->SetCookiePolicy(policy);
40 void ewk_cookie_manager_accept_policy_async_get(const Ewk_Cookie_Manager* manager,
41 Ewk_Cookie_Manager_Policy_Async_Get_Cb callback,
44 EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager);
45 EINA_SAFETY_ON_NULL_RETURN(callback);
47 cookie_manager->GetAcceptPolicyAsync(callback, data);
50 void ewk_cookie_manager_async_hostnames_with_cookies_get(const Ewk_Cookie_Manager* manager,
51 Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback,
54 EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager);
55 EINA_SAFETY_ON_NULL_RETURN(callback);
56 cookie_manager->GetHostNamesWithCookiesAsync(callback, data);
59 void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager* manager,
60 const char* host_name)
62 EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager);
63 EINA_SAFETY_ON_NULL_RETURN(host_name);
64 std::string url(host_name);
65 cookie_manager->DeleteCookiesAsync(url);
68 void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager* manager)
70 EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager);
71 cookie_manager->DeleteCookiesAsync();