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 int length = WKStringGetMaximumUTF8CStringSize(wkKey);
396 OwnArrayPtr<char> keyBuffer = adoptArrayPtr(new char[length]);
397 WKStringGetUTF8CString(wkKey, keyBuffer.get(), length);
399 length = WKStringGetMaximumUTF8CStringSize(wkValue);
402 OwnArrayPtr<char> valueBuffer = adoptArrayPtr(new char[length]);
403 WKStringGetUTF8CString(wkValue, valueBuffer.get(), length);
404 formDataVector.append(pair<String, String>(keyBuffer.get(), valueBuffer.get()));
407 m_formDatabase->addFormDataForURL(String::fromUTF8(url), formDataVector, isPasswordForm);
410 void Ewk_Context::passwordFormData(const char* url, Vector<std::pair<String, String> >& passwordFormData)
412 EINA_SAFETY_ON_NULL_RETURN(url);
413 if (!m_formDatabase->isOpen())
415 m_formDatabase->getPasswordFormDataForURL(String::fromUTF8(url), passwordFormData);
418 void Ewk_Context::candidateFormData(const String& name, Vector<String>& candidates)
420 if (!m_formDatabase->isOpen())
422 m_formDatabase->getCandidateFormDataForName(name, candidates);
425 void Ewk_Context::clearPasswordFormData()
427 m_formDatabase->clearPasswordFormData();
430 void Ewk_Context::clearCandidateFormData()
432 m_formDatabase->clearCandidateFormData();
437 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
440 * Request WebProcess to dump cache.
442 * This sends sync message to WebProcess to dump memory cache, that is, soup cache.
444 * @param context context object
446 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
448 * @note This can effect UIProcess's performance because it calls to sync IPC message eventually.
450 void Ewk_Context::dumpCache()
452 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(wkContext());
453 toImpl(cacheManager)->dumpCache();
458 Ewk_Context* ewk_context_default_get()
460 return Ewk_Context::defaultContext().get();
464 typedef struct Ewk_Context_Callback_Context
467 #if ENABLE(TIZEN_FILE_SYSTEM)
468 Ewk_Local_File_System_Origins_Get_Callback localFileSystemOriginsCallback;
470 Ewk_Web_Application_Cache_Origins_Get_Callback webApplicationCacheOriginsCallback;
471 Ewk_Web_Application_Cache_Quota_Get_Callback webApplicationCacheQuotaCallback;
472 Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback webApplicationCacheUsageForOriginCallback;
473 Ewk_Web_Application_Cache_Path_Get_Callback webApplicationCachePathCallback;
474 Ewk_Web_Database_Origins_Get_Callback webDatabaseOriginsCallback;
475 Ewk_Web_Database_Quota_Get_Callback webDatabaseQuotaCallback;
476 Ewk_Web_Database_Usage_Get_Callback webDatabaseUsageCallback;
477 Ewk_Web_Database_Path_Get_Callback webDatabasePathCallback;
478 Ewk_Web_Storage_Origins_Get_Callback webStorageOriginsCallback;
479 Ewk_Web_Storage_Usage_Get_Callback webStorageUsageCallback;
480 Ewk_Web_Storage_Path_Get_Callback webStoragePathCallback;
483 } Ewk_Context_Callback_Context;
485 #if ENABLE(TIZEN_SQL_DATABASE)
486 struct Ewk_Context_Exceeded_Quota
488 Ewk_Security_Origin* origin;
489 const char* databaseName;
490 const char* displayName;
491 unsigned long long currentQuota;
492 unsigned long long currentOriginUsage;
493 unsigned long long currentDatabaseUsage;
494 unsigned long long expectedUsage;
495 unsigned long long newQuota;
499 #if ENABLE(TIZEN_SQL_DATABASE)
500 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)
502 Ewk_Context_Exceeded_Quota* exceededQuota = new Ewk_Context_Exceeded_Quota();
504 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
505 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
506 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
508 length = WKStringGetMaximumUTF8CStringSize(displayName);
509 OwnArrayPtr<char> displayNameBuffer = adoptArrayPtr(new char[length]);
510 WKStringGetUTF8CString(displayName, displayNameBuffer.get(), length);
512 exceededQuota->origin = createSecurityOrigin(origin);
513 exceededQuota->databaseName = eina_stringshare_add(databaseNameBuffer.get());
514 exceededQuota->displayName = eina_stringshare_add(displayNameBuffer.get());
515 exceededQuota->currentQuota = currentQuota;
516 exceededQuota->currentOriginUsage = currentOriginUsage;
517 exceededQuota->currentDatabaseUsage = currentDatabaseUsage;
518 exceededQuota->expectedUsage = expectedUsage;
520 return exceededQuota;
523 void ewkContextDeleteExceededQuota(Ewk_Context_Exceeded_Quota* exceededQuota)
525 deleteSecurityOrigin(exceededQuota->origin);
526 eina_stringshare_del(exceededQuota->databaseName);
527 eina_stringshare_del(exceededQuota->displayName);
528 delete exceededQuota;
531 unsigned long long ewkContextGetNewQuotaForExceededQuota(Ewk_Context* ewkContext, Ewk_Context_Exceeded_Quota* exceededQuota)
533 if (exceededQuota->newQuota)
534 return exceededQuota->newQuota + exceededQuota->currentQuota;
536 if (exceededQuota->currentQuota)
537 return exceededQuota->currentQuota;
539 return ewkContext->defaultDatabaseQuota();
542 uint64_t ewkContextGetDatabaseQuota(Ewk_Context* ewkContext)
544 return ewkContext->defaultDatabaseQuota();
549 Ewk_Context* ewk_context_new()
552 Ewk_Context* ewk_context = Ewk_Context::create().leakRef();
553 ewkContextInjectedBundleClientAttachClient(ewk_context);
556 return Ewk_Context::create().leakRef();
559 Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path)
561 EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
563 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
564 // FIXME : OpenGL check code for WRT before launching WebProcess.
565 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
566 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
571 #if ENABLE(TIZEN_WRT_LAUNCHING_PERFORMANCE)
572 char* wrtLaunchingPerformance = getenv("WRT_LAUNCHING_PERFORMANCE");
573 if (wrtLaunchingPerformance && !strcmp(wrtLaunchingPerformance, "1")) {
574 static bool firstTime = true;
578 if (ProcessLauncher::isInitialFork())
579 ProcessLauncher::setSkipExec(true);
581 ProcessLauncher::setSkipExec(false);
583 ProcessLauncher::forkProcess();
585 if (ProcessLauncher::isParentProcess()) {
586 Ewk_Context* ewkContext = ewk_context_new_with_injected_bundle_path(path);
587 WKContextRef contextRef = ewkContext->wkContext();
588 toImpl(contextRef)->ensureWebProcess();
591 else if (ProcessLauncher::isChildProcess()) {
592 ProcessLauncher::callWebProcessMain();
596 ASSERT_NOT_REACHED();
603 Ewk_Context* ewk_context = Ewk_Context::create(String::fromUTF8(path)).leakRef();
604 ewkContextInjectedBundleClientAttachClient(ewk_context);
607 return Ewk_Context::create(String::fromUTF8(path)).leakRef();
610 void ewk_context_delete(Ewk_Context* ewkContext)
612 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
613 if (ewkContext == ewk_context_default_get() && ewkContext->hasOneRef())
619 void ewk_context_proxy_uri_set(Ewk_Context* ewkContext, const char* proxy)
621 if (ewkContext && ewkContext->setProxyAddress(proxy)) {
622 WKRetainPtr<WKURLRef> proxyAddress(AdoptWK, WKURLCreateWithUTF8CString(proxy));
624 WKContextRef contextRef = ewkContext->wkContext();
625 toImpl(contextRef)->setProxy(toWTFString(proxyAddress.get()));
629 const char* ewk_context_proxy_uri_get(Ewk_Context* ewkContext)
631 #if ENABLE(TIZEN_WEBKIT2_PATCH_FOR_TC)
632 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
634 return ewkContext->proxyAddress();
637 void ewk_context_network_session_requests_cancel(Ewk_Context* ewkContext)
639 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
641 WKContextRef contextRef = ewkContext->wkContext();
642 toImpl(contextRef)->abortSession();
645 Eina_Bool ewk_context_notify_low_memory(Ewk_Context* ewkContext)
647 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
649 WKContextRef contextRef = ewkContext->wkContext();
650 toImpl(contextRef)->notifyLowMemory();
654 #if ENABLE(TIZEN_FILE_SYSTEM)
655 static void didGetLocalFileSystemOrigins(WKArrayRef origins, WKErrorRef error, void* context)
657 Eina_List* originList = 0;
658 for (size_t i = 0; i < WKArrayGetSize(origins); ++i) {
659 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
660 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
661 originList = eina_list_append(originList, origin);
664 Ewk_Context_Callback_Context* locaFileSystemContext = static_cast<Ewk_Context_Callback_Context*>(context);
665 locaFileSystemContext->localFileSystemOriginsCallback(originList, locaFileSystemContext->userData);
666 delete locaFileSystemContext;
670 #if ENABLE(TIZEN_APPLICATION_CACHE)
671 static void didGetWebApplicationOrigins(WKArrayRef origins, WKErrorRef error, void* context)
673 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
674 Eina_List* originList = 0;
676 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
677 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
678 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
679 originList = eina_list_append(originList, origin);
682 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
683 applicationCacheContext->webApplicationCacheOriginsCallback(originList, applicationCacheContext->userData);
684 delete applicationCacheContext;
687 static void didGetWebApplicationPath(WKStringRef path, WKErrorRef error, void* context)
689 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
691 int length = WKStringGetMaximumUTF8CStringSize(path);
692 OwnArrayPtr<char> applicationCachePath = adoptArrayPtr(new char[length]);
693 WKStringGetUTF8CString(path, applicationCachePath.get(), length);
695 TIZEN_LOGI("path (%s)", applicationCachePath.get());
696 applicationCacheContext->webApplicationCachePathCallback(eina_stringshare_add(applicationCachePath.get()), applicationCacheContext->userData);
697 delete applicationCacheContext;
700 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
701 static void didGetWebApplicationQuota(WKInt64Ref quota, WKErrorRef error, void* context)
703 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
704 TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
705 applicationCacheContext->webApplicationCacheQuotaCallback(toImpl(quota)->value(), applicationCacheContext->userData);
706 delete applicationCacheContext;
709 static void didGetWebApplicationUsageForOrigin(WKInt64Ref usage, WKErrorRef error, void* context)
711 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
712 TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
713 applicationCacheContext->webApplicationCacheUsageForOriginCallback(toImpl(usage)->value(), applicationCacheContext->userData);
714 delete applicationCacheContext;
719 #if ENABLE(TIZEN_SQL_DATABASE)
720 static void didGetWebDatabaseOrigins(WKArrayRef origins, WKErrorRef error, void* context)
722 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
723 Eina_List* originList = 0;
725 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
726 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
727 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
728 originList = eina_list_append(originList, origin);
731 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
732 webDatabaseContext->webDatabaseOriginsCallback(originList, webDatabaseContext->userData);
733 delete webDatabaseContext;
736 static void didGetWebDatabaseQuota(WKUInt64Ref quota, WKErrorRef error, void* context)
738 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
739 TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
740 webDatabaseContext->webDatabaseQuotaCallback(toImpl(quota)->value(), webDatabaseContext->userData);
741 delete webDatabaseContext;
744 static void didGetWebDatabaseUsage(WKUInt64Ref usage, WKErrorRef error, void* context)
746 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
747 TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
748 webDatabaseContext->webDatabaseUsageCallback(toImpl(usage)->value(), webDatabaseContext->userData);
749 delete webDatabaseContext;
752 static void didGetWebDatabasePath(WKStringRef path, WKErrorRef error, void * context)
754 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
756 int length = WKStringGetMaximumUTF8CStringSize(path);
757 OwnArrayPtr<char> databasePath = adoptArrayPtr(new char[length]);
758 WKStringGetUTF8CString(path, databasePath.get(), length);
760 TIZEN_LOGI("path (%s)", databasePath.get());
761 webDatabaseContext->webDatabasePathCallback(eina_stringshare_add(databasePath.get()), webDatabaseContext->userData);
762 delete webDatabaseContext;
766 #if ENABLE(TIZEN_WEB_STORAGE)
767 static void didGetWebStorageOrigins(WKArrayRef origins, WKErrorRef error, void* context)
769 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
770 Eina_List* originList = 0;
772 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
773 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
774 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
775 originList = eina_list_append(originList, origin);
778 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
779 webStorageContext->webStorageOriginsCallback(originList, webStorageContext->userData);
780 delete webStorageContext;
783 static void didGetWebStoragePath(WKStringRef path, WKErrorRef error, void * context)
785 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
787 int length = WKStringGetMaximumUTF8CStringSize(path);
788 OwnArrayPtr<char> storagePath = adoptArrayPtr(new char[length]);
789 WKStringGetUTF8CString(path, storagePath.get(), length);
791 TIZEN_LOGI("path (%s)", storagePath.get());
792 webStorageContext->webStoragePathCallback(eina_stringshare_add(storagePath.get()), webStorageContext->userData);
793 delete webStorageContext;
796 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
797 static void didGetWebStorageUsage(WKInt64Ref usage, WKErrorRef error, void* context)
799 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
801 TIZEN_LOGI("usage (%s)", toImpl(usage)->value());
802 webStorageContext->webStorageUsageCallback(toImpl(usage)->value(), webStorageContext->userData);
803 delete webStorageContext;
809 Eina_Bool ewk_context_origins_free(Eina_List* originList)
811 EINA_SAFETY_ON_NULL_RETURN_VAL(originList, false);
814 EINA_LIST_FREE(originList, currentOrigin) {
815 Ewk_Security_Origin* origin = static_cast<Ewk_Security_Origin*>(currentOrigin);
816 deleteSecurityOrigin(origin);
822 Eina_Bool ewk_context_application_cache_delete_all(Ewk_Context* ewkContext)
824 #if ENABLE(TIZEN_APPLICATION_CACHE)
825 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
827 TIZEN_LOGI("ewkContext (%p)", ewkContext);
828 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
829 WKApplicationCacheManagerDeleteAllEntries(applicationCache);
837 Eina_Bool ewk_context_application_cache_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
839 #if ENABLE(TIZEN_APPLICATION_CACHE)
840 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
841 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
843 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
844 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
845 WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
846 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
847 WKApplicationCacheManagerDeleteEntriesForOrigin(applicationCacheRef, securityOriginRef.get());
855 Eina_Bool ewk_context_application_cache_origins_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Origins_Get_Callback callback, void *userData)
857 #if ENABLE(TIZEN_APPLICATION_CACHE)
858 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
859 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
861 TIZEN_LOGI("ewkContext (%p)", ewkContext);
862 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
863 context->webApplicationCacheOriginsCallback = callback;
864 context->userData = userData;
866 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
867 WKApplicationCacheManagerGetApplicationCacheOrigins(applicationCacheRef, context, didGetWebApplicationOrigins);
875 Eina_Bool ewk_context_application_cache_path_set(Ewk_Context* ewkContext, const char* path)
877 #if ENABLE(TIZEN_APPLICATION_CACHE)
878 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
879 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
882 TIZEN_LOGE("Path value is invalid");
886 TIZEN_LOGI("path (%s)", path);
887 WKRetainPtr<WKStringRef> applicationCachePathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
888 WKContextSetApplicationCacheDirectory(ewkContext->wkContext(), applicationCachePathRef.get());
896 Eina_Bool ewk_context_application_cache_path_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Path_Get_Callback callback, void* userData)
898 #if ENABLE(TIZEN_APPLICATION_CACHE)
899 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
900 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
902 TIZEN_LOGI("callback (%p)", callback);
903 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
904 context->webApplicationCachePathCallback= callback;
905 context->userData = userData;
907 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
908 WKApplicationCacheManagerGetApplicationCachePath(applicationCacheRef, context, didGetWebApplicationPath);
915 Eina_Bool ewk_context_application_cache_quota_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Quota_Get_Callback callback, void* userData)
917 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
918 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
919 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
921 TIZEN_LOGI("callback (%p)", callback);
922 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
923 context->webApplicationCacheQuotaCallback = callback;
924 context->userData = userData;
926 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
927 WKApplicationCacheManagerGetApplicationCacheQuota(applicationCacheRef, context, didGetWebApplicationQuota);
935 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)
937 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
938 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
939 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
940 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
942 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
943 context->webApplicationCacheUsageForOriginCallback = callback;
944 context->userData = userData;
945 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
946 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
947 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
949 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
950 WKApplicationCacheManagerGetApplicationCacheUsageForOrigin(applicationCache, context, originRef.get(), didGetWebApplicationUsageForOrigin);
958 Eina_Bool ewk_context_application_cache_quota_set(Ewk_Context* ewkContext, int64_t quota)
960 #if ENABLE(TIZEN_APPLICATION_CACHE)
961 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
963 TIZEN_LOGE("Quota value is invalid");
967 TIZEN_LOGI("quota (%d)", quota);
968 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
969 WKApplicationCacheManagerSetApplicationCacheQuota(applicationCacheRef, quota);
977 Eina_Bool ewk_context_application_cache_quota_for_origin_set(Ewk_Context* ewkContext, const Ewk_Security_Origin* origin, int64_t quota)
979 #if ENABLE(TIZEN_APPLICATION_CACHE)
980 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
981 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
983 TIZEN_LOGE("Quota value is invalid");
987 TIZEN_LOGI("quota (%d)", quota);
988 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
989 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
990 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
992 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
993 WKApplicationCacheManagerSetApplicationCacheQuotaForOrigin(applicationCache, originRef.get(), quota);
1002 Eina_Bool ewk_context_icon_database_path_set(Ewk_Context* ewkContext, const char* path)
1004 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1005 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1007 WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1008 WKContextSetIconDatabasePath(ewkContext->wkContext(), databasePath.get());
1013 Evas_Object* ewk_context_icon_database_icon_object_add(Ewk_Context* ewkContext, const char* uri, Evas* canvas)
1015 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
1016 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, 0);
1017 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1019 WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1020 WKRetainPtr<WKURLRef> urlString(AdoptWK, WKURLCreateWithUTF8CString(uri));
1022 return WKIconDatabaseTryGetImageForURL(iconDatabase, canvas, urlString.get());
1025 void ewk_context_icon_database_delete_all(Ewk_Context* ewkContext)
1027 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1029 WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1030 WKIconDatabaseRemoveAllIcons(iconDatabase);
1033 Eina_Bool ewk_context_local_file_system_path_set(Ewk_Context* ewkContext, const char* path)
1035 #if ENABLE(TIZEN_FILE_SYSTEM)
1036 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1037 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1039 TIZEN_LOGI("path (%s)", path);
1040 WKRetainPtr<WKStringRef> localFileSystemPathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
1041 WKContextSetLocalFileSystemDirectory(ewkContext->wkContext(), localFileSystemPathRef.get());
1049 Eina_Bool ewk_context_local_file_system_all_delete(Ewk_Context* ewkContext)
1051 #if ENABLE(TIZEN_FILE_SYSTEM)
1052 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1054 TIZEN_LOGI("ewkContex (%p)", ewkContext);
1055 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1056 WKLocalFileSystemManagerDeleteAllLocalFileSystem(localFileSystemManager);
1060 UNUSED_PARAM(ewkContext);
1066 Eina_Bool ewk_context_local_file_system_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1068 #if ENABLE(TIZEN_FILE_SYSTEM)
1069 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1070 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1072 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1073 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1074 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1075 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1077 WKLocalFileSystemManagerDeleteLocalFileSystem(localFileSystemManager, originRef.get());
1081 UNUSED_PARAM(ewkContext);
1082 UNUSED_PARAM(origin);
1088 Eina_Bool ewk_context_local_file_system_origins_get(const Ewk_Context* ewkContext, Ewk_Local_File_System_Origins_Get_Callback callback, void* userData)
1090 #if ENABLE(TIZEN_FILE_SYSTEM)
1091 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1092 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1094 TIZEN_LOGI("callback (%p)", callback);
1095 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1096 context->localFileSystemOriginsCallback= callback;
1097 context->userData = userData;
1098 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(const_cast<Ewk_Context*>(ewkContext)->wkContext());
1100 WKLocalFileSystemManagerGetLocalFileSystemOrigins(localFileSystemManager, context, didGetLocalFileSystemOrigins);
1104 UNUSED_PARAM(ewkContext);
1105 UNUSED_PARAM(callback);
1106 UNUSED_PARAM(userData);
1112 Ewk_Security_Origin* ewk_context_web_database_exceeded_quota_security_origin_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1114 #if ENABLE(TIZEN_SQL_DATABASE)
1115 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1117 return exceededQuota->origin;
1123 const char* ewk_context_web_database_exceeded_quota_database_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1125 #if ENABLE(TIZEN_SQL_DATABASE)
1126 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1128 TIZEN_LOGI("name (%s)", exceededQuota->databaseName);
1129 return exceededQuota->databaseName;
1135 const char* ewk_context_web_database_exceeded_quota_display_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1137 #if ENABLE(TIZEN_SQL_DATABASE)
1138 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1140 TIZEN_LOGI("displayName (%s)", exceededQuota->displayName);
1141 return exceededQuota->displayName;
1147 unsigned long long ewk_context_web_database_exceeded_quota_current_quota_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1149 #if ENABLE(TIZEN_SQL_DATABASE)
1150 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1152 TIZEN_LOGI("quota (%d)", exceededQuota->currentQuota);
1153 return exceededQuota->currentQuota;
1159 unsigned long long ewk_context_web_database_exceeded_quota_current_origin_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1161 #if ENABLE(TIZEN_SQL_DATABASE)
1162 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1164 TIZEN_LOGI("currentOriginUsage (%d)", exceededQuota->currentOriginUsage);
1165 return exceededQuota->currentOriginUsage;
1171 unsigned long long ewk_context_web_database_exceeded_quota_current_database_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1173 #if ENABLE(TIZEN_SQL_DATABASE)
1174 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1176 TIZEN_LOGI("currentDatabaseUsage (%d)", exceededQuota->currentDatabaseUsage);
1177 return exceededQuota->currentDatabaseUsage;
1183 unsigned long long ewk_context_web_database_exceeded_quota_expected_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1185 #if ENABLE(TIZEN_SQL_DATABASE)
1186 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1188 TIZEN_LOGI("expectedUsage (%d)", exceededQuota->expectedUsage);
1189 return exceededQuota->expectedUsage;
1195 void ewk_context_web_database_exceeded_quota_new_quota_set(Ewk_Context_Exceeded_Quota* exceededQuota, unsigned long long quota)
1197 #if ENABLE(TIZEN_SQL_DATABASE)
1198 EINA_SAFETY_ON_NULL_RETURN(exceededQuota);
1200 TIZEN_LOGI("quota (%d)", quota);
1201 exceededQuota->newQuota = quota;
1205 Eina_Bool ewk_context_web_database_delete_all(Ewk_Context* ewkContext)
1207 #if ENABLE(TIZEN_SQL_DATABASE)
1208 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1210 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1211 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1212 WKDatabaseManagerDeleteAllDatabases(databaseManager);
1220 Eina_Bool ewk_context_web_database_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1222 #if ENABLE(TIZEN_SQL_DATABASE)
1223 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1224 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1226 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1227 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1228 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1229 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1230 WKDatabaseManagerDeleteDatabasesForOrigin(databaseManager, originRef.get());
1238 Eina_Bool ewk_context_web_database_origins_get(Ewk_Context* ewkContext, Ewk_Web_Database_Origins_Get_Callback callback, void* userData)
1240 #if ENABLE(TIZEN_SQL_DATABASE)
1241 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1242 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1244 TIZEN_LOGI("callback (%p)", callback);
1245 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1246 context->webDatabaseOriginsCallback = callback;
1247 context->userData = userData;
1249 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1250 WKDatabaseManagerGetDatabaseOrigins(databaseManager, context, didGetWebDatabaseOrigins);
1258 Eina_Bool ewk_context_web_database_path_set(Ewk_Context* ewkContext, const char* path)
1260 #if ENABLE(TIZEN_SQL_DATABASE)
1261 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1262 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1264 TIZEN_LOGI("path (%s)", path);
1265 WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1266 WKContextSetDatabaseDirectory(ewkContext->wkContext(), databasePath.get());
1274 Eina_Bool ewk_context_web_database_path_get(Ewk_Context* ewkContext, Ewk_Web_Database_Path_Get_Callback callback, void* userData)
1276 #if ENABLE(TIZEN_WEB_STORAGE)
1277 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1278 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1280 TIZEN_LOGI("callback (%p)", callback);
1281 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1282 context->webDatabasePathCallback= callback;
1283 context->userData = userData;
1285 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1286 WKDatabaseManagerGetDatabasePath(databaseManager, context, didGetWebDatabasePath);
1292 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)
1294 #if ENABLE(TIZEN_SQL_DATABASE)
1295 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1296 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1297 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1299 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1300 context->webDatabaseQuotaCallback = callback;
1301 context->userData = userData;
1303 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1304 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1305 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1306 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1307 WKDatabaseManagerGetQuotaForOrigin(databaseManager, context, didGetWebDatabaseQuota, originRef.get());
1315 Eina_Bool ewk_context_web_database_default_quota_set(Ewk_Context* ewkContext, uint64_t quota)
1317 #if ENABLE(TIZEN_SQL_DATABASE)
1318 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1320 TIZEN_LOGI("quota (%d)", quota);
1321 ewkContext->setDefaultDatabaseQuota(quota);
1329 Eina_Bool ewk_context_web_database_quota_for_origin_set(Ewk_Context* ewkContext, Ewk_Security_Origin* origin, uint64_t quota)
1331 #if ENABLE(TIZEN_SQL_DATABASE)
1332 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1333 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1335 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1336 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1337 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1338 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1339 WKDatabaseManagerSetQuotaForOrigin(databaseManager, originRef.get(), quota);
1347 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)
1349 #if ENABLE(TIZEN_SQL_DATABASE)
1350 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1351 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1352 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1354 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1355 context->webDatabaseQuotaCallback = callback;
1356 context->userData = userData;
1358 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1359 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1360 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1361 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1362 WKDatabaseManagerGetUsageForOrigin(databaseManager, context, didGetWebDatabaseUsage, originRef.get());
1370 Eina_Bool ewk_context_web_indexed_database_delete_all(Ewk_Context* ewkContext)
1372 #if ENABLE(TIZEN_INDEXED_DATABASE)
1373 WKContextDeleteIndexedDatabaseAll(ewkContext->wkContext());
1381 Eina_Bool ewk_context_web_storage_delete_all(Ewk_Context* ewkContext)
1383 #if ENABLE(TIZEN_WEB_STORAGE)
1384 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1386 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1387 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1388 WKKeyValueStorageManagerDeleteAllEntries(storageManager);
1396 Eina_Bool ewk_context_web_storage_origin_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1398 #if ENABLE(TIZEN_WEB_STORAGE)
1399 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1400 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1402 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1403 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1404 WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1405 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1406 WKKeyValueStorageManagerDeleteEntriesForOrigin(storageManager, securityOriginRef.get());
1414 Eina_Bool ewk_context_web_storage_origins_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Origins_Get_Callback callback, void* userData)
1416 #if ENABLE(TIZEN_WEB_STORAGE)
1417 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1418 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1420 TIZEN_LOGI("callback (%p)", callback);
1421 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1422 context->webStorageOriginsCallback = callback;
1423 context->userData = userData;
1425 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1426 WKKeyValueStorageManagerGetKeyValueStorageOrigins(storageManager, context, didGetWebStorageOrigins);
1434 Eina_Bool ewk_context_web_storage_path_set(Ewk_Context* ewkContext, const char* path)
1436 #if ENABLE(TIZEN_WEB_STORAGE)
1437 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1438 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1440 TIZEN_LOGI("path (%s)", path);
1441 WKRetainPtr<WKStringRef> webStoragePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1442 WKContextSetLocalStorageDirectory(ewkContext->wkContext(), webStoragePath.get());
1450 Eina_Bool ewk_context_web_storage_path_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Path_Get_Callback callback, void* userData)
1452 #if ENABLE(TIZEN_WEB_STORAGE)
1453 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1454 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1456 TIZEN_LOGI("callback (%p)", callback);
1457 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1458 context->webStoragePathCallback= callback;
1459 context->userData = userData;
1461 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1462 WKKeyValueStorageManagerGetKeyValueStoragePath(storageManager, context, didGetWebStoragePath);
1468 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)
1470 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
1471 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1472 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1473 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1475 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1476 context->webStorageUsageCallback = callback;
1477 context->userData = userData;
1478 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1479 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1480 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1482 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1483 WKKeyValueStorageManagerGetKeyValueStorageUsageForOrigin(storageManager, context, didGetWebStorageUsage, originRef.get());
1491 //#if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
1492 Eina_Bool ewk_context_soup_data_directory_set(Ewk_Context* ewkContext, const char* path)
1494 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1495 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1497 WKRetainPtr<WKStringRef> soupDataDirectory(AdoptWK, WKStringCreateWithUTF8CString(path));
1498 WKContextSetSoupDataDirectory(ewkContext->wkContext(), soupDataDirectory.get());
1503 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_VIEWER, kWKCacheModelDocumentViewer);
1504 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_BROWSER, kWKCacheModelDocumentBrowser);
1505 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, kWKCacheModelPrimaryWebBrowser);
1507 Eina_Bool ewk_context_cache_model_set(Ewk_Context* ewkContext, Ewk_Cache_Model cacheModel)
1509 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1511 ewkContext->setCacheModel(cacheModel);
1516 Ewk_Cache_Model ewk_context_cache_model_get(Ewk_Context* ewkContext)
1518 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, EWK_CACHE_MODEL_DOCUMENT_VIEWER);
1520 return ewkContext->cacheModel();
1523 Eina_Bool ewk_context_cache_disabled_set(Ewk_Context* ewkContext, Eina_Bool cacheDisabled)
1525 #if ENABLE(TIZEN_CACHE_CONTROL)
1526 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1527 WKContextSetCacheDisabled(ewkContext->wkContext(), cacheDisabled);
1533 Eina_Bool ewk_context_cache_disabled_get(Ewk_Context* ewkContext)
1535 #if ENABLE(TIZEN_CACHE_CONTROL)
1536 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1537 return WKContextGetCacheDisabled(ewkContext->wkContext());
1543 Eina_Bool ewk_context_certificate_file_set(Ewk_Context* context, const char* certificateFile)
1545 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
1546 EINA_SAFETY_ON_NULL_RETURN_VAL(certificateFile, false);
1547 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1548 if (!context->setCertificateFile(certificateFile))
1551 if (fileExists(WTF::String::fromUTF8(certificateFile))) {
1552 long long fileSize = -1;
1553 getFileSize(WTF::String::fromUTF8(certificateFile), fileSize);
1554 TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile fileSize [%lld]\n", fileSize);
1556 TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile does not exist!\n");
1558 WKRetainPtr<WKStringRef> certificateFileRef(AdoptWK, WKStringCreateWithUTF8CString(certificateFile));
1559 WKContextSetCertificateFile(context->wkContext(), certificateFileRef.get());
1562 UNUSED_PARAM(context);
1563 UNUSED_PARAM(certificateFile);
1568 const char* ewk_context_certificate_file_get(const Ewk_Context* context)
1570 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1571 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1572 return context->certificateFile();
1574 UNUSED_PARAM(context);
1579 Eina_Bool ewk_context_cache_clear(Ewk_Context* ewkContext)
1581 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1582 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(ewkContext->wkContext());
1583 #if ENABLE(TIZEN_EWK_CONTEXT_CACHE_MANAGER_NULL_CHECK_WORKAROUND)
1587 WKResourceCacheManagerClearCacheForAllOrigins(cacheManager, WKResourceCachesToClearAll);
1592 void ewk_context_message_post_to_injected_bundle(Ewk_Context* ewkContext, const char* name, const char* body)
1594 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1595 EINA_SAFETY_ON_NULL_RETURN(name);
1596 EINA_SAFETY_ON_NULL_RETURN(body);
1598 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString(name));
1599 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithUTF8CString(body));
1600 WKContextPostMessageToInjectedBundle(ewkContext->wkContext(), messageName.get(), messageBody.get());
1603 void ewk_context_message_from_injected_bundle_callback_set(Ewk_Context* ewkContext, Ewk_Context_Message_From_Injected_Bundle_Callback callback, void* userData)
1605 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1607 ewkContext->setMessageFromInjectedBundleCallback(callback, userData);
1610 void ewk_context_did_start_download_callback_set(Ewk_Context* ewkContext, Ewk_Context_Did_Start_Download_Callback callback, void* userData)
1612 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1614 ewkContext->setDidStartDownloadCallback(callback, userData);
1617 #if ENABLE(MEMORY_SAMPLER)
1618 void ewk_context_memory_sampler_start(Ewk_Context* ewkContext, double timerInterval)
1620 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1621 WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(timerInterval));
1622 WKContextStartMemorySampler(ewkContext->wkContext(), interval.get());
1625 void ewk_context_memory_sampler_stop(Ewk_Context* ewkContext)
1627 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1628 WKContextStopMemorySampler(ewkContext->wkContext());
1632 Eina_Bool ewk_context_additional_plugin_path_set(Ewk_Context* ewkContext, const char* path)
1634 #if ENABLE(TIZEN_SUPPORT_PLUGINS)
1635 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1636 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1638 WKRetainPtr<WKStringRef> pluginPath(AdoptWK, WKStringCreateWithUTF8CString(path));
1639 WKContextSetAdditionalPluginsDirectory(ewkContext->wkContext(), pluginPath.get());
1647 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
1648 void ewk_context_memory_saving_mode_set(Ewk_Context* ewkContext, Eina_Bool mode)
1650 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1652 WKContextRef contextRef = ewkContext->wkContext();
1653 toImpl(contextRef)->setMemorySavingMode(mode);
1657 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1658 void ewk_context_form_password_data_clear(Ewk_Context* ewkContext)
1660 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1661 ewkContext->clearPasswordFormData();
1664 void ewk_context_form_candidate_data_clear(Ewk_Context* ewkContext)
1666 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1667 ewkContext->clearCandidateFormData();
1670 #endif // #if OS(TIZEN)
1672 Eina_Bool ewk_context_url_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData)
1674 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1675 EINA_SAFETY_ON_NULL_RETURN_VAL(scheme, false);
1676 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1678 ewkContext->requestManager()->registerURLSchemeHandler(String::fromUTF8(scheme), callback, userData);
1683 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)
1685 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1687 TIZEN_LOGI("vibrate (%p)", vibrate);
1688 #if ENABLE(VIBRATION)
1689 ewkContext->vibrationProvider()->setVibrationClientCallbacks(vibrate, cancel, data);
1693 Eina_Bool ewk_context_tizen_extensible_api_set(Ewk_Context* ewkContext, Ewk_Extensible_API extensibleAPI, Eina_Bool enable)
1695 #if ENABLE(TIZEN_EXTENSIBLE_API)
1696 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1698 TIZEN_LOGI("extensibleAPI (%d) enable (%d)", extensibleAPI, enable);
1699 WKContextSetTizenExtensibleAPI(ewkContext->wkContext(), static_cast<WKTizenExtensibleAPI>(extensibleAPI), enable);
1703 UNUSED_PARAM(ewkContext);
1704 UNUSED_PARAM(extensibleAPI);
1705 UNUSED_PARAM(enable);
1711 void ewk_context_storage_path_reset(Ewk_Context* ewkContext)
1713 #if ENABLE(TIZEN_RESET_PATH)
1714 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1716 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1717 WKContextResetStoragePath(ewkContext->wkContext());
1719 UNUSED_PARAM(ewkContext);
1723 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)
1725 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1727 ewkContext->historyClient()->setCallbacks(navigate, clientRedirect, serverRedirect, titleUpdate, populateVisitedLinks, data);
1730 void ewk_context_visited_link_add(Ewk_Context* ewkContext, const char* visitedURL)
1732 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1733 EINA_SAFETY_ON_NULL_RETURN(visitedURL);
1735 ewkContext->addVisitedLink(visitedURL);