2 * Copyright (C) 2012 Samsung Electronics
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #include "ewk_context.h"
24 #include "BatteryProvider.h"
25 #include "ContextHistoryClientEfl.h"
26 #include "NetworkInfoProvider.h"
27 #include "RequestManagerClientEfl.h"
28 #include "VibrationProvider.h"
29 #include "WKAPICast.h"
30 #include "WKContextSoup.h"
31 #include "WKRetainPtr.h"
33 #include "WebContext.h"
34 #include "WebSoupRequestManagerProxy.h"
35 #include "ewk_context_private.h"
36 #include "ewk_cookie_manager_private.h"
37 #include "ewk_favicon_database_private.h"
38 #include "ewk_url_scheme_request_private.h"
39 #include <WebCore/FileSystem.h>
40 #include <WebCore/IconDatabase.h>
41 #include <wtf/HashMap.h>
42 #include <wtf/text/WTFString.h>
45 #include "WKApplicationCacheManager.h"
47 #include "WKContext.h"
48 #include "WKContextPrivate.h"
49 #include "WKContextTizen.h"
50 #include "WKDatabaseManager.h"
51 #include "WKIconDatabase.h"
52 #include "WKIconDatabaseTizen.h"
53 #include "WKKeyValueStorageManager.h"
54 #if ENABLE(TIZEN_FILE_SYSTEM)
55 #include "WKLocalFileSystemManager.h"
58 #include "WKSecurityOrigin.h"
60 #include "ewk_context_injected_bundle_client.h"
61 #include "ewk_security_origin.h"
62 #include "ewk_private.h"
65 #if ENABLE(TIZEN_WRT_LAUNCHING_PERFORMANCE)
66 #include "ProcessLauncher.h"
70 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
71 #include "FormDatabase.h"
72 #include "WKDictionary.h"
74 #endif // #if OS(TIZEN)
75 #if ENABLE(SPELLCHECK)
76 #include "ewk_settings.h"
77 #include "ewk_text_checker_private.h"
80 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
84 using namespace WebCore;
85 using namespace WebKit;
87 typedef HashMap<WKContextRef, Ewk_Context*> ContextMap;
89 static inline ContextMap& contextMap()
91 DEFINE_STATIC_LOCAL(ContextMap, map, ());
95 Ewk_Context::Ewk_Context(WKContextRef context)
97 , m_historyClient(ContextHistoryClientEfl::create(context))
99 ContextMap::AddResult result = contextMap().add(context, this);
100 ASSERT_UNUSED(result, result.isNewEntry);
102 #if ENABLE(BATTERY_STATUS)
103 m_batteryProvider = BatteryProvider::create(context);
106 #if ENABLE(NETWORK_INFO)
107 m_networkInfoProvider = NetworkInfoProvider::create(context);
110 #if ENABLE(VIBRATION)
111 m_vibrationProvider = VibrationProvider::create(context);
114 #if ENABLE(MEMORY_SAMPLER)
115 static bool initializeMemorySampler = false;
116 static const char environmentVariable[] = "SAMPLE_MEMORY";
118 if (!initializeMemorySampler && getenv(environmentVariable)) {
119 WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(0.0));
120 WKContextStartMemorySampler(context, interval.get());
121 initializeMemorySampler = true;
125 #if ENABLE(SPELLCHECK)
126 Ewk_Text_Checker::initialize();
127 if (ewk_settings_continuous_spell_checking_enabled_get()) {
128 // Load the default language.
129 ewk_settings_spell_checking_languages_set(0);
133 // Initialize WKContext clients.
134 m_downloadManager = DownloadManagerEfl::create(this);
135 m_requestManagerClient = RequestManagerClientEfl::create(this);
138 #if ENABLE(TIZEN_SQL_DATABASE)
139 m_defaultDatabaseQuota = 5 * 1024 * 1024;
141 m_messageFromInjectedBundle.callback = 0;
142 m_messageFromInjectedBundle.userData = 0;
143 m_didStartDownload.callback = 0;
144 m_didStartDownload.userData = 0;
145 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
146 m_formDatabase = FormDatabase::create();
147 m_formDatabase->open(FormDatabase::defaultDatabaseDirectoryPath(), FormDatabase::defaultDatabaseFilename());
152 Ewk_Context::~Ewk_Context()
154 ASSERT(contextMap().get(m_context.get()) == this);
155 contextMap().remove(m_context.get());
156 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
161 PassRefPtr<Ewk_Context> Ewk_Context::create(WKContextRef context)
163 if (contextMap().contains(context))
164 return contextMap().get(context); // Will be ref-ed automatically.
166 return adoptRef(new Ewk_Context(context));
169 PassRefPtr<Ewk_Context> Ewk_Context::create()
171 return create(adoptWK(WKContextCreate()).get());
174 PassRefPtr<Ewk_Context> Ewk_Context::create(const String& injectedBundlePath)
176 if (!fileExists(injectedBundlePath))
179 WKRetainPtr<WKStringRef> injectedBundlePathWK = adoptWK(toCopiedAPI(injectedBundlePath));
180 WKRetainPtr<WKContextRef> contextWK = adoptWK(WKContextCreateWithInjectedBundlePath(injectedBundlePathWK.get()));
182 return create(contextWK.get());
185 PassRefPtr<Ewk_Context> Ewk_Context::defaultContext()
187 static RefPtr<Ewk_Context> defaultInstance = create(adoptWK(WKContextCreate()).get());
189 return defaultInstance;
192 Ewk_Cookie_Manager* Ewk_Context::cookieManager()
194 if (!m_cookieManager)
195 m_cookieManager = Ewk_Cookie_Manager::create(WKContextGetCookieManager(m_context.get()));
197 return m_cookieManager.get();
200 Ewk_Favicon_Database* Ewk_Context::faviconDatabase()
202 #if ENABLE(TIZEN_ICON_DATABASE)
205 if (!m_faviconDatabase) {
206 WKRetainPtr<WKIconDatabaseRef> iconDatabase = WKContextGetIconDatabase(m_context.get());
207 // Set the database path if it is not open yet.
208 if (!toImpl(iconDatabase.get())->isOpen()) {
209 WebContext* webContext = toImpl(m_context.get());
210 String databasePath = webContext->iconDatabasePath() + "/" + WebCore::IconDatabase::defaultDatabaseFilename();
211 webContext->setIconDatabasePath(databasePath);
213 m_faviconDatabase = Ewk_Favicon_Database::create(iconDatabase.get());
216 return m_faviconDatabase.get();
219 RequestManagerClientEfl* Ewk_Context::requestManager()
221 return m_requestManagerClient.get();
224 #if ENABLE(VIBRATION)
225 PassRefPtr<VibrationProvider> Ewk_Context::vibrationProvider()
227 return m_vibrationProvider;
231 void Ewk_Context::addVisitedLink(const String& visitedURL)
233 toImpl(m_context.get())->addVisitedLink(visitedURL);
236 void Ewk_Context::setCacheModel(Ewk_Cache_Model cacheModel)
238 WKContextSetCacheModel(m_context.get(), static_cast<Ewk_Cache_Model>(cacheModel));
241 Ewk_Cache_Model Ewk_Context::cacheModel() const
243 return static_cast<Ewk_Cache_Model>(WKContextGetCacheModel(m_context.get()));
246 Ewk_Context* ewk_context_ref(Ewk_Context* ewkContext)
248 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
255 void ewk_context_unref(Ewk_Context* ewkContext)
257 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
262 Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext)
264 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
266 return const_cast<Ewk_Context*>(ewkContext)->cookieManager();
269 Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext)
271 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
273 return const_cast<Ewk_Context*>(ewkContext)->faviconDatabase();
276 WKContextRef Ewk_Context::wkContext()
278 return m_context.get();
281 DownloadManagerEfl* Ewk_Context::downloadManager() const
283 return m_downloadManager.get();
286 ContextHistoryClientEfl* Ewk_Context::historyClient()
288 return m_historyClient.get();
292 bool Ewk_Context::setProxyAddress(const char* proxyAddress)
294 if (m_proxyAddress == proxyAddress)
297 m_proxyAddress = proxyAddress;
301 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
302 bool Ewk_Context::setCertificateFile(const char* certificateFile)
304 if (m_certificateFile == certificateFile)
307 m_certificateFile = certificateFile;
312 void Ewk_Context::setDefaultDatabaseQuota(uint64_t defaultDatabaseQuota)
314 m_defaultDatabaseQuota = defaultDatabaseQuota;
317 void Ewk_Context::setMessageFromInjectedBundleCallback(Ewk_Context_Message_From_Injected_Bundle_Callback callback, void* userData)
319 m_messageFromInjectedBundle.callback = callback;
320 m_messageFromInjectedBundle.userData = userData;
323 void Ewk_Context::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData)
325 if (!m_messageFromInjectedBundle.callback)
328 CString name = toImpl(messageName)->string().utf8();
330 if (messageBody && WKStringGetTypeID() == WKGetTypeID(messageBody))
331 body = toImpl(static_cast<WKStringRef>(messageBody))->string().utf8();
334 char* returnString = 0;
335 m_messageFromInjectedBundle.callback(name.data(), body.data(), &returnString,
336 m_messageFromInjectedBundle.userData);
338 *returnData = WKStringCreateWithUTF8CString(returnString);
341 *returnData = WKStringCreateWithUTF8CString("");
343 m_messageFromInjectedBundle.callback(name.data(), body.data(), 0, m_messageFromInjectedBundle.userData);
346 void Ewk_Context::setDidStartDownloadCallback(Ewk_Context_Did_Start_Download_Callback callback, void* userData)
348 m_didStartDownload.callback = callback;
349 m_didStartDownload.userData = userData;
352 void Ewk_Context::didStartDownload(WKStringRef downloadURL)
354 EINA_SAFETY_ON_NULL_RETURN(m_didStartDownload.callback);
356 m_didStartDownload.callback(toImpl(downloadURL)->string().utf8().data(), m_didStartDownload.userData);
359 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
360 void Ewk_Context::clearAllDecodedData()
362 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(wkContext());
363 WKResourceCacheManagerClearCacheForAllOrigins(cacheManager, WKResourceCachesToClearInDecodedDataOnly);
367 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
368 Ecore_X_Window Ewk_Context::xWindow()
373 void Ewk_Context::setXWindow(Ecore_X_Window xWindow)
375 toImpl(wkContext())->setXWindow(xWindow);
379 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
380 void Ewk_Context::addFormData(const char* url, WKDictionaryRef& formData, bool isPasswordForm)
382 EINA_SAFETY_ON_NULL_RETURN(url);
383 if (!m_formDatabase->isOpen())
386 Vector<std::pair<String, String> > formDataVector;
387 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(formData));
388 size_t numKeys = WKArrayGetSize(wkKeys.get());
389 for (size_t i = 0; i < numKeys; ++i) {
390 WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
391 WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(formData, wkKey));
393 formDataVector.append(pair<String, String>(toImpl(wkKey)->string(), toImpl(wkValue)->string()));
396 m_formDatabase->addFormDataForURL(String::fromUTF8(url), formDataVector, isPasswordForm);
399 void Ewk_Context::passwordFormData(const char* url, Vector<std::pair<String, String> >& passwordFormData)
401 EINA_SAFETY_ON_NULL_RETURN(url);
402 if (!m_formDatabase->isOpen())
404 m_formDatabase->getPasswordFormDataForURL(String::fromUTF8(url), passwordFormData);
407 void Ewk_Context::candidateFormData(const String& name, Vector<String>& candidates)
409 if (!m_formDatabase->isOpen())
411 m_formDatabase->getCandidateFormDataForName(name, candidates);
414 void Ewk_Context::clearPasswordFormData()
416 m_formDatabase->clearPasswordFormData();
419 void Ewk_Context::clearCandidateFormData()
421 m_formDatabase->clearCandidateFormData();
426 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
429 * Request WebProcess to dump cache.
431 * This sends sync message to WebProcess to dump memory cache, that is, soup cache.
433 * @param context context object
435 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
437 * @note This can effect UIProcess's performance because it calls to sync IPC message eventually.
439 void Ewk_Context::dumpCache()
441 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(wkContext());
442 toImpl(cacheManager)->dumpCache();
447 Ewk_Context* ewk_context_default_get()
449 return Ewk_Context::defaultContext().get();
453 typedef struct Ewk_Context_Callback_Context
456 #if ENABLE(TIZEN_FILE_SYSTEM)
457 Ewk_Local_File_System_Origins_Get_Callback localFileSystemOriginsCallback;
459 Ewk_Web_Application_Cache_Origins_Get_Callback webApplicationCacheOriginsCallback;
460 Ewk_Web_Application_Cache_Quota_Get_Callback webApplicationCacheQuotaCallback;
461 Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback webApplicationCacheUsageForOriginCallback;
462 Ewk_Web_Application_Cache_Path_Get_Callback webApplicationCachePathCallback;
463 Ewk_Web_Database_Origins_Get_Callback webDatabaseOriginsCallback;
464 Ewk_Web_Database_Quota_Get_Callback webDatabaseQuotaCallback;
465 Ewk_Web_Database_Usage_Get_Callback webDatabaseUsageCallback;
466 Ewk_Web_Database_Path_Get_Callback webDatabasePathCallback;
467 Ewk_Web_Storage_Origins_Get_Callback webStorageOriginsCallback;
468 Ewk_Web_Storage_Usage_Get_Callback webStorageUsageCallback;
469 Ewk_Web_Storage_Path_Get_Callback webStoragePathCallback;
472 } Ewk_Context_Callback_Context;
474 #if ENABLE(TIZEN_SQL_DATABASE)
475 struct Ewk_Context_Exceeded_Quota
477 Ewk_Security_Origin* origin;
478 const char* databaseName;
479 const char* displayName;
480 unsigned long long currentQuota;
481 unsigned long long currentOriginUsage;
482 unsigned long long currentDatabaseUsage;
483 unsigned long long expectedUsage;
484 unsigned long long newQuota;
488 #if ENABLE(TIZEN_SQL_DATABASE)
489 Ewk_Context_Exceeded_Quota* ewkContextCreateExceededQuota(WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage)
491 Ewk_Context_Exceeded_Quota* exceededQuota = new Ewk_Context_Exceeded_Quota();
493 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
494 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
495 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
497 length = WKStringGetMaximumUTF8CStringSize(displayName);
498 OwnArrayPtr<char> displayNameBuffer = adoptArrayPtr(new char[length]);
499 WKStringGetUTF8CString(displayName, displayNameBuffer.get(), length);
501 exceededQuota->origin = createSecurityOrigin(origin);
502 exceededQuota->databaseName = eina_stringshare_add(databaseNameBuffer.get());
503 exceededQuota->displayName = eina_stringshare_add(displayNameBuffer.get());
504 exceededQuota->currentQuota = currentQuota;
505 exceededQuota->currentOriginUsage = currentOriginUsage;
506 exceededQuota->currentDatabaseUsage = currentDatabaseUsage;
507 exceededQuota->expectedUsage = expectedUsage;
509 return exceededQuota;
512 void ewkContextDeleteExceededQuota(Ewk_Context_Exceeded_Quota* exceededQuota)
514 deleteSecurityOrigin(exceededQuota->origin);
515 eina_stringshare_del(exceededQuota->databaseName);
516 eina_stringshare_del(exceededQuota->displayName);
517 delete exceededQuota;
520 unsigned long long ewkContextGetNewQuotaForExceededQuota(Ewk_Context* ewkContext, Ewk_Context_Exceeded_Quota* exceededQuota)
522 if (exceededQuota->newQuota)
523 return exceededQuota->newQuota + exceededQuota->currentQuota;
525 if (exceededQuota->currentQuota)
526 return exceededQuota->currentQuota;
528 return ewkContext->defaultDatabaseQuota();
531 uint64_t ewkContextGetDatabaseQuota(Ewk_Context* ewkContext)
533 return ewkContext->defaultDatabaseQuota();
538 Ewk_Context* ewk_context_new()
541 Ewk_Context* ewk_context = Ewk_Context::create().leakRef();
542 ewkContextInjectedBundleClientAttachClient(ewk_context);
545 return Ewk_Context::create().leakRef();
548 Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path)
550 EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
552 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
553 // FIXME : OpenGL check code for WRT before launching WebProcess.
554 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
555 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
560 #if ENABLE(TIZEN_WRT_LAUNCHING_PERFORMANCE)
561 char* wrtLaunchingPerformance = getenv("WRT_LAUNCHING_PERFORMANCE");
562 if (wrtLaunchingPerformance && !strcmp(wrtLaunchingPerformance, "1")) {
563 static bool firstTime = true;
567 if (ProcessLauncher::isInitialFork())
568 ProcessLauncher::setSkipExec(true);
570 ProcessLauncher::setSkipExec(false);
572 ProcessLauncher::forkProcess();
574 if (ProcessLauncher::isParentProcess()) {
575 Ewk_Context* ewkContext = ewk_context_new_with_injected_bundle_path(path);
576 WKContextRef contextRef = ewkContext->wkContext();
577 toImpl(contextRef)->ensureWebProcess();
580 else if (ProcessLauncher::isChildProcess()) {
581 ProcessLauncher::callWebProcessMain();
585 ASSERT_NOT_REACHED();
592 Ewk_Context* ewk_context = Ewk_Context::create(String::fromUTF8(path)).leakRef();
593 ewkContextInjectedBundleClientAttachClient(ewk_context);
596 return Ewk_Context::create(String::fromUTF8(path)).leakRef();
599 void ewk_context_delete(Ewk_Context* ewkContext)
601 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
602 if (ewkContext == ewk_context_default_get() && ewkContext->hasOneRef())
608 void ewk_context_proxy_uri_set(Ewk_Context* ewkContext, const char* proxy)
610 if (ewkContext && ewkContext->setProxyAddress(proxy)) {
611 WKRetainPtr<WKURLRef> proxyAddress(AdoptWK, WKURLCreateWithUTF8CString(proxy));
613 WKContextRef contextRef = ewkContext->wkContext();
614 toImpl(contextRef)->setProxy(toWTFString(proxyAddress.get()));
618 const char* ewk_context_proxy_uri_get(Ewk_Context* ewkContext)
620 #if ENABLE(TIZEN_WEBKIT2_PATCH_FOR_TC)
621 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
623 return ewkContext->proxyAddress();
626 void ewk_context_network_session_requests_cancel(Ewk_Context* ewkContext)
628 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
630 WKContextRef contextRef = ewkContext->wkContext();
631 toImpl(contextRef)->abortSession();
634 Eina_Bool ewk_context_notify_low_memory(Ewk_Context* ewkContext)
636 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
638 WKContextRef contextRef = ewkContext->wkContext();
639 toImpl(contextRef)->notifyLowMemory();
643 #if ENABLE(TIZEN_FILE_SYSTEM)
644 static void didGetLocalFileSystemOrigins(WKArrayRef origins, WKErrorRef error, void* context)
646 Eina_List* originList = 0;
647 for (size_t i = 0; i < WKArrayGetSize(origins); ++i) {
648 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
649 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
650 originList = eina_list_append(originList, origin);
653 Ewk_Context_Callback_Context* locaFileSystemContext = static_cast<Ewk_Context_Callback_Context*>(context);
654 locaFileSystemContext->localFileSystemOriginsCallback(originList, locaFileSystemContext->userData);
655 delete locaFileSystemContext;
659 #if ENABLE(TIZEN_APPLICATION_CACHE)
660 static void didGetWebApplicationOrigins(WKArrayRef origins, WKErrorRef error, void* context)
662 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
663 Eina_List* originList = 0;
665 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
666 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
667 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
668 originList = eina_list_append(originList, origin);
671 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
672 applicationCacheContext->webApplicationCacheOriginsCallback(originList, applicationCacheContext->userData);
673 delete applicationCacheContext;
676 static void didGetWebApplicationPath(WKStringRef path, WKErrorRef error, void* context)
678 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
680 int length = WKStringGetMaximumUTF8CStringSize(path);
681 OwnArrayPtr<char> applicationCachePath = adoptArrayPtr(new char[length]);
682 WKStringGetUTF8CString(path, applicationCachePath.get(), length);
684 TIZEN_LOGI("path (%s)", applicationCachePath.get());
685 applicationCacheContext->webApplicationCachePathCallback(eina_stringshare_add(applicationCachePath.get()), applicationCacheContext->userData);
686 delete applicationCacheContext;
689 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
690 static void didGetWebApplicationQuota(WKInt64Ref quota, WKErrorRef error, void* context)
692 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
693 TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
694 applicationCacheContext->webApplicationCacheQuotaCallback(toImpl(quota)->value(), applicationCacheContext->userData);
695 delete applicationCacheContext;
698 static void didGetWebApplicationUsageForOrigin(WKInt64Ref usage, WKErrorRef error, void* context)
700 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
701 TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
702 applicationCacheContext->webApplicationCacheUsageForOriginCallback(toImpl(usage)->value(), applicationCacheContext->userData);
703 delete applicationCacheContext;
708 #if ENABLE(TIZEN_SQL_DATABASE)
709 static void didGetWebDatabaseOrigins(WKArrayRef origins, WKErrorRef error, void* context)
711 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
712 Eina_List* originList = 0;
714 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
715 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
716 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
717 originList = eina_list_append(originList, origin);
720 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
721 webDatabaseContext->webDatabaseOriginsCallback(originList, webDatabaseContext->userData);
722 delete webDatabaseContext;
725 static void didGetWebDatabaseQuota(WKUInt64Ref quota, WKErrorRef error, void* context)
727 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
728 TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
729 webDatabaseContext->webDatabaseQuotaCallback(toImpl(quota)->value(), webDatabaseContext->userData);
730 delete webDatabaseContext;
733 static void didGetWebDatabaseUsage(WKUInt64Ref usage, WKErrorRef error, void* context)
735 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
736 TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
737 webDatabaseContext->webDatabaseUsageCallback(toImpl(usage)->value(), webDatabaseContext->userData);
738 delete webDatabaseContext;
741 static void didGetWebDatabasePath(WKStringRef path, WKErrorRef error, void * context)
743 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
745 int length = WKStringGetMaximumUTF8CStringSize(path);
746 OwnArrayPtr<char> databasePath = adoptArrayPtr(new char[length]);
747 WKStringGetUTF8CString(path, databasePath.get(), length);
749 TIZEN_LOGI("path (%s)", databasePath.get());
750 webDatabaseContext->webDatabasePathCallback(eina_stringshare_add(databasePath.get()), webDatabaseContext->userData);
751 delete webDatabaseContext;
755 #if ENABLE(TIZEN_WEB_STORAGE)
756 static void didGetWebStorageOrigins(WKArrayRef origins, WKErrorRef error, void* context)
758 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
759 Eina_List* originList = 0;
761 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
762 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
763 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
764 originList = eina_list_append(originList, origin);
767 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
768 webStorageContext->webStorageOriginsCallback(originList, webStorageContext->userData);
769 delete webStorageContext;
772 static void didGetWebStoragePath(WKStringRef path, WKErrorRef error, void * context)
774 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
776 int length = WKStringGetMaximumUTF8CStringSize(path);
777 OwnArrayPtr<char> storagePath = adoptArrayPtr(new char[length]);
778 WKStringGetUTF8CString(path, storagePath.get(), length);
780 TIZEN_LOGI("path (%s)", storagePath.get());
781 webStorageContext->webStoragePathCallback(eina_stringshare_add(storagePath.get()), webStorageContext->userData);
782 delete webStorageContext;
785 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
786 static void didGetWebStorageUsage(WKInt64Ref usage, WKErrorRef error, void* context)
788 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
790 TIZEN_LOGI("usage (%s)", toImpl(usage)->value());
791 webStorageContext->webStorageUsageCallback(toImpl(usage)->value(), webStorageContext->userData);
792 delete webStorageContext;
798 Eina_Bool ewk_context_origins_free(Eina_List* originList)
800 EINA_SAFETY_ON_NULL_RETURN_VAL(originList, false);
803 EINA_LIST_FREE(originList, currentOrigin) {
804 Ewk_Security_Origin* origin = static_cast<Ewk_Security_Origin*>(currentOrigin);
805 deleteSecurityOrigin(origin);
811 Eina_Bool ewk_context_application_cache_delete_all(Ewk_Context* ewkContext)
813 #if ENABLE(TIZEN_APPLICATION_CACHE)
814 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
816 TIZEN_LOGI("ewkContext (%p)", ewkContext);
817 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
818 WKApplicationCacheManagerDeleteAllEntries(applicationCache);
826 Eina_Bool ewk_context_application_cache_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
828 #if ENABLE(TIZEN_APPLICATION_CACHE)
829 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
830 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
832 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
833 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
834 WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
835 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
836 WKApplicationCacheManagerDeleteEntriesForOrigin(applicationCacheRef, securityOriginRef.get());
844 Eina_Bool ewk_context_application_cache_origins_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Origins_Get_Callback callback, void *userData)
846 #if ENABLE(TIZEN_APPLICATION_CACHE)
847 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
848 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
850 TIZEN_LOGI("ewkContext (%p)", ewkContext);
851 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
852 context->webApplicationCacheOriginsCallback = callback;
853 context->userData = userData;
855 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
856 WKApplicationCacheManagerGetApplicationCacheOrigins(applicationCacheRef, context, didGetWebApplicationOrigins);
864 Eina_Bool ewk_context_application_cache_path_set(Ewk_Context* ewkContext, const char* path)
866 #if ENABLE(TIZEN_APPLICATION_CACHE)
867 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
868 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
871 TIZEN_LOGE("Path value is invalid");
875 TIZEN_LOGI("path (%s)", path);
876 WKRetainPtr<WKStringRef> applicationCachePathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
877 WKContextSetApplicationCacheDirectory(ewkContext->wkContext(), applicationCachePathRef.get());
885 Eina_Bool ewk_context_application_cache_path_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Path_Get_Callback callback, void* userData)
887 #if ENABLE(TIZEN_APPLICATION_CACHE)
888 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
889 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
891 TIZEN_LOGI("callback (%p)", callback);
892 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
893 context->webApplicationCachePathCallback= callback;
894 context->userData = userData;
896 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
897 WKApplicationCacheManagerGetApplicationCachePath(applicationCacheRef, context, didGetWebApplicationPath);
904 Eina_Bool ewk_context_application_cache_quota_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Quota_Get_Callback callback, void* userData)
906 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
907 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
908 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
910 TIZEN_LOGI("callback (%p)", callback);
911 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
912 context->webApplicationCacheQuotaCallback = callback;
913 context->userData = userData;
915 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
916 WKApplicationCacheManagerGetApplicationCacheQuota(applicationCacheRef, context, didGetWebApplicationQuota);
924 Eina_Bool ewk_context_application_cache_usage_for_origin_get(Ewk_Context* ewkContext, const Ewk_Security_Origin* origin, Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback callback, void* userData)
926 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
927 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
928 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
929 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
931 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
932 context->webApplicationCacheUsageForOriginCallback = callback;
933 context->userData = userData;
934 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
935 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
936 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
938 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
939 WKApplicationCacheManagerGetApplicationCacheUsageForOrigin(applicationCache, context, originRef.get(), didGetWebApplicationUsageForOrigin);
947 Eina_Bool ewk_context_application_cache_quota_set(Ewk_Context* ewkContext, int64_t quota)
949 #if ENABLE(TIZEN_APPLICATION_CACHE)
950 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
952 TIZEN_LOGE("Quota value is invalid");
956 TIZEN_LOGI("quota (%d)", quota);
957 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
958 WKApplicationCacheManagerSetApplicationCacheQuota(applicationCacheRef, quota);
966 Eina_Bool ewk_context_application_cache_quota_for_origin_set(Ewk_Context* ewkContext, const Ewk_Security_Origin* origin, int64_t quota)
968 #if ENABLE(TIZEN_APPLICATION_CACHE)
969 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
970 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
972 TIZEN_LOGE("Quota value is invalid");
976 TIZEN_LOGI("quota (%d)", quota);
977 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
978 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
979 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
981 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
982 WKApplicationCacheManagerSetApplicationCacheQuotaForOrigin(applicationCache, originRef.get(), quota);
991 Eina_Bool ewk_context_icon_database_path_set(Ewk_Context* ewkContext, const char* path)
993 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
994 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
996 WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
997 WKContextSetIconDatabasePath(ewkContext->wkContext(), databasePath.get());
1002 Evas_Object* ewk_context_icon_database_icon_object_add(Ewk_Context* ewkContext, const char* uri, Evas* canvas)
1004 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
1005 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, 0);
1006 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1008 WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1009 WKRetainPtr<WKURLRef> urlString(AdoptWK, WKURLCreateWithUTF8CString(uri));
1011 return WKIconDatabaseTryGetImageForURL(iconDatabase, canvas, urlString.get());
1014 void ewk_context_icon_database_delete_all(Ewk_Context* ewkContext)
1016 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1018 WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1019 WKIconDatabaseRemoveAllIcons(iconDatabase);
1022 Eina_Bool ewk_context_local_file_system_path_set(Ewk_Context* ewkContext, const char* path)
1024 #if ENABLE(TIZEN_FILE_SYSTEM)
1025 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1026 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1028 TIZEN_LOGI("path (%s)", path);
1029 WKRetainPtr<WKStringRef> localFileSystemPathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
1030 WKContextSetLocalFileSystemDirectory(ewkContext->wkContext(), localFileSystemPathRef.get());
1038 Eina_Bool ewk_context_local_file_system_all_delete(Ewk_Context* ewkContext)
1040 #if ENABLE(TIZEN_FILE_SYSTEM)
1041 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1043 TIZEN_LOGI("ewkContex (%p)", ewkContext);
1044 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1045 WKLocalFileSystemManagerDeleteAllLocalFileSystem(localFileSystemManager);
1049 UNUSED_PARAM(ewkContext);
1055 Eina_Bool ewk_context_local_file_system_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1057 #if ENABLE(TIZEN_FILE_SYSTEM)
1058 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1059 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1061 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1062 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1063 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1064 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1066 WKLocalFileSystemManagerDeleteLocalFileSystem(localFileSystemManager, originRef.get());
1070 UNUSED_PARAM(ewkContext);
1071 UNUSED_PARAM(origin);
1077 Eina_Bool ewk_context_local_file_system_origins_get(const Ewk_Context* ewkContext, Ewk_Local_File_System_Origins_Get_Callback callback, void* userData)
1079 #if ENABLE(TIZEN_FILE_SYSTEM)
1080 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1081 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1083 TIZEN_LOGI("callback (%p)", callback);
1084 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1085 context->localFileSystemOriginsCallback= callback;
1086 context->userData = userData;
1087 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(const_cast<Ewk_Context*>(ewkContext)->wkContext());
1089 WKLocalFileSystemManagerGetLocalFileSystemOrigins(localFileSystemManager, context, didGetLocalFileSystemOrigins);
1093 UNUSED_PARAM(ewkContext);
1094 UNUSED_PARAM(callback);
1095 UNUSED_PARAM(userData);
1101 Ewk_Security_Origin* ewk_context_web_database_exceeded_quota_security_origin_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1103 #if ENABLE(TIZEN_SQL_DATABASE)
1104 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1106 return exceededQuota->origin;
1112 const char* ewk_context_web_database_exceeded_quota_database_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1114 #if ENABLE(TIZEN_SQL_DATABASE)
1115 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1117 TIZEN_LOGI("name (%s)", exceededQuota->databaseName);
1118 return exceededQuota->databaseName;
1124 const char* ewk_context_web_database_exceeded_quota_display_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1126 #if ENABLE(TIZEN_SQL_DATABASE)
1127 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1129 TIZEN_LOGI("displayName (%s)", exceededQuota->displayName);
1130 return exceededQuota->displayName;
1136 unsigned long long ewk_context_web_database_exceeded_quota_current_quota_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1138 #if ENABLE(TIZEN_SQL_DATABASE)
1139 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1141 TIZEN_LOGI("quota (%d)", exceededQuota->currentQuota);
1142 return exceededQuota->currentQuota;
1148 unsigned long long ewk_context_web_database_exceeded_quota_current_origin_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1150 #if ENABLE(TIZEN_SQL_DATABASE)
1151 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1153 TIZEN_LOGI("currentOriginUsage (%d)", exceededQuota->currentOriginUsage);
1154 return exceededQuota->currentOriginUsage;
1160 unsigned long long ewk_context_web_database_exceeded_quota_current_database_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1162 #if ENABLE(TIZEN_SQL_DATABASE)
1163 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1165 TIZEN_LOGI("currentDatabaseUsage (%d)", exceededQuota->currentDatabaseUsage);
1166 return exceededQuota->currentDatabaseUsage;
1172 unsigned long long ewk_context_web_database_exceeded_quota_expected_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1174 #if ENABLE(TIZEN_SQL_DATABASE)
1175 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1177 TIZEN_LOGI("expectedUsage (%d)", exceededQuota->expectedUsage);
1178 return exceededQuota->expectedUsage;
1184 void ewk_context_web_database_exceeded_quota_new_quota_set(Ewk_Context_Exceeded_Quota* exceededQuota, unsigned long long quota)
1186 #if ENABLE(TIZEN_SQL_DATABASE)
1187 EINA_SAFETY_ON_NULL_RETURN(exceededQuota);
1189 TIZEN_LOGI("quota (%d)", quota);
1190 exceededQuota->newQuota = quota;
1194 Eina_Bool ewk_context_web_database_delete_all(Ewk_Context* ewkContext)
1196 #if ENABLE(TIZEN_SQL_DATABASE)
1197 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1199 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1200 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1201 WKDatabaseManagerDeleteAllDatabases(databaseManager);
1209 Eina_Bool ewk_context_web_database_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1211 #if ENABLE(TIZEN_SQL_DATABASE)
1212 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1213 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1215 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1216 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1217 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1218 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1219 WKDatabaseManagerDeleteDatabasesForOrigin(databaseManager, originRef.get());
1227 Eina_Bool ewk_context_web_database_origins_get(Ewk_Context* ewkContext, Ewk_Web_Database_Origins_Get_Callback callback, void* userData)
1229 #if ENABLE(TIZEN_SQL_DATABASE)
1230 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1231 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1233 TIZEN_LOGI("callback (%p)", callback);
1234 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1235 context->webDatabaseOriginsCallback = callback;
1236 context->userData = userData;
1238 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1239 WKDatabaseManagerGetDatabaseOrigins(databaseManager, context, didGetWebDatabaseOrigins);
1247 Eina_Bool ewk_context_web_database_path_set(Ewk_Context* ewkContext, const char* path)
1249 #if ENABLE(TIZEN_SQL_DATABASE)
1250 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1251 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1253 TIZEN_LOGI("path (%s)", path);
1254 WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1255 WKContextSetDatabaseDirectory(ewkContext->wkContext(), databasePath.get());
1263 Eina_Bool ewk_context_web_database_path_get(Ewk_Context* ewkContext, Ewk_Web_Database_Path_Get_Callback callback, void* userData)
1265 #if ENABLE(TIZEN_WEB_STORAGE)
1266 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1267 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1269 TIZEN_LOGI("callback (%p)", callback);
1270 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1271 context->webDatabasePathCallback= callback;
1272 context->userData = userData;
1274 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1275 WKDatabaseManagerGetDatabasePath(databaseManager, context, didGetWebDatabasePath);
1281 Eina_Bool ewk_context_web_database_quota_for_origin_get(Ewk_Context* ewkContext, Ewk_Web_Database_Quota_Get_Callback callback, void* userData, Ewk_Security_Origin* origin)
1283 #if ENABLE(TIZEN_SQL_DATABASE)
1284 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1285 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1286 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1288 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1289 context->webDatabaseQuotaCallback = callback;
1290 context->userData = userData;
1292 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1293 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1294 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1295 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1296 WKDatabaseManagerGetQuotaForOrigin(databaseManager, context, didGetWebDatabaseQuota, originRef.get());
1304 Eina_Bool ewk_context_web_database_default_quota_set(Ewk_Context* ewkContext, uint64_t quota)
1306 #if ENABLE(TIZEN_SQL_DATABASE)
1307 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1309 TIZEN_LOGI("quota (%d)", quota);
1310 ewkContext->setDefaultDatabaseQuota(quota);
1318 Eina_Bool ewk_context_web_database_quota_for_origin_set(Ewk_Context* ewkContext, Ewk_Security_Origin* origin, uint64_t quota)
1320 #if ENABLE(TIZEN_SQL_DATABASE)
1321 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1322 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1324 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1325 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1326 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1327 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1328 WKDatabaseManagerSetQuotaForOrigin(databaseManager, originRef.get(), quota);
1336 Eina_Bool ewk_context_web_database_usage_for_origin_get(Ewk_Context* ewkContext, Ewk_Web_Database_Quota_Get_Callback callback, void* userData, Ewk_Security_Origin* origin)
1338 #if ENABLE(TIZEN_SQL_DATABASE)
1339 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1340 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1341 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1343 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1344 context->webDatabaseQuotaCallback = callback;
1345 context->userData = userData;
1347 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1348 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1349 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1350 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1351 WKDatabaseManagerGetUsageForOrigin(databaseManager, context, didGetWebDatabaseUsage, originRef.get());
1359 Eina_Bool ewk_context_web_indexed_database_delete_all(Ewk_Context* ewkContext)
1361 #if ENABLE(TIZEN_INDEXED_DATABASE)
1362 WKContextDeleteIndexedDatabaseAll(ewkContext->wkContext());
1370 Eina_Bool ewk_context_web_storage_delete_all(Ewk_Context* ewkContext)
1372 #if ENABLE(TIZEN_WEB_STORAGE)
1373 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1375 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1376 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1377 WKKeyValueStorageManagerDeleteAllEntries(storageManager);
1385 Eina_Bool ewk_context_web_storage_origin_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1387 #if ENABLE(TIZEN_WEB_STORAGE)
1388 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1389 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1391 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1392 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1393 WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1394 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1395 WKKeyValueStorageManagerDeleteEntriesForOrigin(storageManager, securityOriginRef.get());
1403 Eina_Bool ewk_context_web_storage_origins_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Origins_Get_Callback callback, void* userData)
1405 #if ENABLE(TIZEN_WEB_STORAGE)
1406 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1407 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1409 TIZEN_LOGI("callback (%p)", callback);
1410 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1411 context->webStorageOriginsCallback = callback;
1412 context->userData = userData;
1414 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1415 WKKeyValueStorageManagerGetKeyValueStorageOrigins(storageManager, context, didGetWebStorageOrigins);
1423 Eina_Bool ewk_context_web_storage_path_set(Ewk_Context* ewkContext, const char* path)
1425 #if ENABLE(TIZEN_WEB_STORAGE)
1426 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1427 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1429 TIZEN_LOGI("path (%s)", path);
1430 WKRetainPtr<WKStringRef> webStoragePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1431 WKContextSetLocalStorageDirectory(ewkContext->wkContext(), webStoragePath.get());
1439 Eina_Bool ewk_context_web_storage_path_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Path_Get_Callback callback, void* userData)
1441 #if ENABLE(TIZEN_WEB_STORAGE)
1442 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1443 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1445 TIZEN_LOGI("callback (%p)", callback);
1446 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1447 context->webStoragePathCallback= callback;
1448 context->userData = userData;
1450 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1451 WKKeyValueStorageManagerGetKeyValueStoragePath(storageManager, context, didGetWebStoragePath);
1457 Eina_Bool ewk_context_web_storage_usage_for_origin_get(Ewk_Context* ewkContext, Ewk_Security_Origin* origin, Ewk_Web_Storage_Usage_Get_Callback callback, void* userData)
1459 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
1460 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1461 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1462 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1464 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1465 context->webStorageUsageCallback = callback;
1466 context->userData = userData;
1467 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1468 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1469 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1471 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1472 WKKeyValueStorageManagerGetKeyValueStorageUsageForOrigin(storageManager, context, didGetWebStorageUsage, originRef.get());
1480 //#if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
1481 Eina_Bool ewk_context_soup_data_directory_set(Ewk_Context* ewkContext, const char* path)
1483 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1484 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1486 WKRetainPtr<WKStringRef> soupDataDirectory(AdoptWK, WKStringCreateWithUTF8CString(path));
1487 WKContextSetSoupDataDirectory(ewkContext->wkContext(), soupDataDirectory.get());
1492 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_VIEWER, kWKCacheModelDocumentViewer);
1493 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_BROWSER, kWKCacheModelDocumentBrowser);
1494 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, kWKCacheModelPrimaryWebBrowser);
1496 Eina_Bool ewk_context_cache_model_set(Ewk_Context* ewkContext, Ewk_Cache_Model cacheModel)
1498 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1500 ewkContext->setCacheModel(cacheModel);
1505 Ewk_Cache_Model ewk_context_cache_model_get(Ewk_Context* ewkContext)
1507 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, EWK_CACHE_MODEL_DOCUMENT_VIEWER);
1509 return ewkContext->cacheModel();
1512 Eina_Bool ewk_context_cache_disabled_set(Ewk_Context* ewkContext, Eina_Bool cacheDisabled)
1514 #if ENABLE(TIZEN_CACHE_CONTROL)
1515 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1516 WKContextSetCacheDisabled(ewkContext->wkContext(), cacheDisabled);
1522 Eina_Bool ewk_context_cache_disabled_get(Ewk_Context* ewkContext)
1524 #if ENABLE(TIZEN_CACHE_CONTROL)
1525 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1526 return WKContextGetCacheDisabled(ewkContext->wkContext());
1532 Eina_Bool ewk_context_certificate_file_set(Ewk_Context* context, const char* certificateFile)
1534 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
1535 EINA_SAFETY_ON_NULL_RETURN_VAL(certificateFile, false);
1536 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1537 if (!context->setCertificateFile(certificateFile))
1540 if (fileExists(WTF::String::fromUTF8(certificateFile))) {
1541 long long fileSize = -1;
1542 getFileSize(WTF::String::fromUTF8(certificateFile), fileSize);
1543 TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile fileSize [%lld]\n", fileSize);
1545 TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile does not exist!\n");
1547 WKRetainPtr<WKStringRef> certificateFileRef(AdoptWK, WKStringCreateWithUTF8CString(certificateFile));
1548 WKContextSetCertificateFile(context->wkContext(), certificateFileRef.get());
1551 UNUSED_PARAM(context);
1552 UNUSED_PARAM(certificateFile);
1557 const char* ewk_context_certificate_file_get(const Ewk_Context* context)
1559 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1560 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1561 return context->certificateFile();
1563 UNUSED_PARAM(context);
1568 Eina_Bool ewk_context_cache_clear(Ewk_Context* ewkContext)
1570 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1571 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(ewkContext->wkContext());
1572 #if ENABLE(TIZEN_EWK_CONTEXT_CACHE_MANAGER_NULL_CHECK_WORKAROUND)
1576 WKResourceCacheManagerClearCacheForAllOrigins(cacheManager, WKResourceCachesToClearAll);
1581 void ewk_context_message_post_to_injected_bundle(Ewk_Context* ewkContext, const char* name, const char* body)
1583 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1584 EINA_SAFETY_ON_NULL_RETURN(name);
1585 EINA_SAFETY_ON_NULL_RETURN(body);
1587 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString(name));
1588 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithUTF8CString(body));
1589 WKContextPostMessageToInjectedBundle(ewkContext->wkContext(), messageName.get(), messageBody.get());
1592 void ewk_context_message_from_injected_bundle_callback_set(Ewk_Context* ewkContext, Ewk_Context_Message_From_Injected_Bundle_Callback callback, void* userData)
1594 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1596 ewkContext->setMessageFromInjectedBundleCallback(callback, userData);
1599 void ewk_context_did_start_download_callback_set(Ewk_Context* ewkContext, Ewk_Context_Did_Start_Download_Callback callback, void* userData)
1601 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1603 ewkContext->setDidStartDownloadCallback(callback, userData);
1606 #if ENABLE(MEMORY_SAMPLER)
1607 void ewk_context_memory_sampler_start(Ewk_Context* ewkContext, double timerInterval)
1609 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1610 WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(timerInterval));
1611 WKContextStartMemorySampler(ewkContext->wkContext(), interval.get());
1614 void ewk_context_memory_sampler_stop(Ewk_Context* ewkContext)
1616 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1617 WKContextStopMemorySampler(ewkContext->wkContext());
1621 Eina_Bool ewk_context_additional_plugin_path_set(Ewk_Context* ewkContext, const char* path)
1623 #if ENABLE(TIZEN_SUPPORT_PLUGINS)
1624 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1625 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1627 WKRetainPtr<WKStringRef> pluginPath(AdoptWK, WKStringCreateWithUTF8CString(path));
1628 WKContextSetAdditionalPluginsDirectory(ewkContext->wkContext(), pluginPath.get());
1636 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
1637 void ewk_context_memory_saving_mode_set(Ewk_Context* ewkContext, Eina_Bool mode)
1639 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1641 WKContextRef contextRef = ewkContext->wkContext();
1642 toImpl(contextRef)->setMemorySavingMode(mode);
1646 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1647 void ewk_context_form_password_data_clear(Ewk_Context* ewkContext)
1649 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1650 ewkContext->clearPasswordFormData();
1653 void ewk_context_form_candidate_data_clear(Ewk_Context* ewkContext)
1655 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1656 ewkContext->clearCandidateFormData();
1659 #endif // #if OS(TIZEN)
1661 Eina_Bool ewk_context_url_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData)
1663 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1664 EINA_SAFETY_ON_NULL_RETURN_VAL(scheme, false);
1665 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1667 ewkContext->requestManager()->registerURLSchemeHandler(String::fromUTF8(scheme), callback, userData);
1672 void ewk_context_vibration_client_callbacks_set(Ewk_Context* ewkContext, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void* data)
1674 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1676 TIZEN_LOGI("vibrate (%p)", vibrate);
1677 #if ENABLE(VIBRATION)
1678 ewkContext->vibrationProvider()->setVibrationClientCallbacks(vibrate, cancel, data);
1682 Eina_Bool ewk_context_tizen_extensible_api_set(Ewk_Context* ewkContext, Ewk_Extensible_API extensibleAPI, Eina_Bool enable)
1684 #if ENABLE(TIZEN_EXTENSIBLE_API)
1685 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1687 TIZEN_LOGI("extensibleAPI (%d) enable (%d)", extensibleAPI, enable);
1688 WKContextSetTizenExtensibleAPI(ewkContext->wkContext(), static_cast<WKTizenExtensibleAPI>(extensibleAPI), enable);
1692 UNUSED_PARAM(ewkContext);
1693 UNUSED_PARAM(extensibleAPI);
1694 UNUSED_PARAM(enable);
1700 void ewk_context_storage_path_reset(Ewk_Context* ewkContext)
1702 #if ENABLE(TIZEN_RESET_PATH)
1703 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1705 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1706 WKContextResetStoragePath(ewkContext->wkContext());
1708 UNUSED_PARAM(ewkContext);
1712 void ewk_context_history_callbacks_set(Ewk_Context* ewkContext, Ewk_History_Navigation_Cb navigate, Ewk_History_Client_Redirection_Cb clientRedirect, Ewk_History_Server_Redirection_Cb serverRedirect, Ewk_History_Title_Update_Cb titleUpdate, Ewk_History_Populate_Visited_Links_Cb populateVisitedLinks, void* data)
1714 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1716 ewkContext->historyClient()->setCallbacks(navigate, clientRedirect, serverRedirect, titleUpdate, populateVisitedLinks, data);
1719 void ewk_context_visited_link_add(Ewk_Context* ewkContext, const char* visitedURL)
1721 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1722 EINA_SAFETY_ON_NULL_RETURN(visitedURL);
1724 ewkContext->addVisitedLink(visitedURL);