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 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
86 void* EflAssistHandle = 0;
89 using namespace WebCore;
90 using namespace WebKit;
92 typedef HashMap<WKContextRef, Ewk_Context*> ContextMap;
94 static inline ContextMap& contextMap()
96 DEFINE_STATIC_LOCAL(ContextMap, map, ());
100 Ewk_Context::Ewk_Context(WKContextRef context)
102 , m_historyClient(ContextHistoryClientEfl::create(context))
104 ContextMap::AddResult result = contextMap().add(context, this);
105 ASSERT_UNUSED(result, result.isNewEntry);
107 #if ENABLE(BATTERY_STATUS)
108 m_batteryProvider = BatteryProvider::create(context);
111 #if ENABLE(NETWORK_INFO)
112 m_networkInfoProvider = NetworkInfoProvider::create(context);
115 #if ENABLE(VIBRATION)
116 m_vibrationProvider = VibrationProvider::create(context);
119 #if ENABLE(MEMORY_SAMPLER)
120 static bool initializeMemorySampler = false;
121 static const char environmentVariable[] = "SAMPLE_MEMORY";
123 if (!initializeMemorySampler && getenv(environmentVariable)) {
124 WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(0.0));
125 WKContextStartMemorySampler(context, interval.get());
126 initializeMemorySampler = true;
130 #if ENABLE(SPELLCHECK)
131 Ewk_Text_Checker::initialize();
132 if (ewk_settings_continuous_spell_checking_enabled_get()) {
133 // Load the default language.
134 ewk_settings_spell_checking_languages_set(0);
138 // Initialize WKContext clients.
139 m_downloadManager = DownloadManagerEfl::create(this);
140 m_requestManagerClient = RequestManagerClientEfl::create(this);
143 #if ENABLE(TIZEN_SQL_DATABASE)
144 m_defaultDatabaseQuota = 5 * 1024 * 1024;
146 m_messageFromInjectedBundle.callback = 0;
147 m_messageFromInjectedBundle.userData = 0;
148 m_didStartDownload.callback = 0;
149 m_didStartDownload.userData = 0;
150 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
151 m_formDatabase = FormDatabase::create();
152 m_formDatabase->open(FormDatabase::defaultDatabaseDirectoryPath(), FormDatabase::defaultDatabaseFilename());
156 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
157 if (!EflAssistHandle)
158 EflAssistHandle = dlopen("/usr/lib/libefl-assist.so.0", RTLD_LAZY);
162 Ewk_Context::~Ewk_Context()
164 ASSERT(contextMap().get(m_context.get()) == this);
165 contextMap().remove(m_context.get());
166 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
171 PassRefPtr<Ewk_Context> Ewk_Context::create(WKContextRef context)
173 if (contextMap().contains(context))
174 return contextMap().get(context); // Will be ref-ed automatically.
176 return adoptRef(new Ewk_Context(context));
179 PassRefPtr<Ewk_Context> Ewk_Context::create()
181 return create(adoptWK(WKContextCreate()).get());
184 PassRefPtr<Ewk_Context> Ewk_Context::create(const String& injectedBundlePath)
186 if (!fileExists(injectedBundlePath))
189 WKRetainPtr<WKStringRef> injectedBundlePathWK = adoptWK(toCopiedAPI(injectedBundlePath));
190 WKRetainPtr<WKContextRef> contextWK = adoptWK(WKContextCreateWithInjectedBundlePath(injectedBundlePathWK.get()));
192 return create(contextWK.get());
195 PassRefPtr<Ewk_Context> Ewk_Context::defaultContext()
197 static RefPtr<Ewk_Context> defaultInstance = create(adoptWK(WKContextCreate()).get());
199 return defaultInstance;
202 Ewk_Cookie_Manager* Ewk_Context::cookieManager()
204 if (!m_cookieManager)
205 m_cookieManager = Ewk_Cookie_Manager::create(WKContextGetCookieManager(m_context.get()));
207 return m_cookieManager.get();
210 Ewk_Favicon_Database* Ewk_Context::faviconDatabase()
212 #if ENABLE(TIZEN_ICON_DATABASE)
215 if (!m_faviconDatabase) {
216 WKRetainPtr<WKIconDatabaseRef> iconDatabase = WKContextGetIconDatabase(m_context.get());
217 // Set the database path if it is not open yet.
218 if (!toImpl(iconDatabase.get())->isOpen()) {
219 WebContext* webContext = toImpl(m_context.get());
220 String databasePath = webContext->iconDatabasePath() + "/" + WebCore::IconDatabase::defaultDatabaseFilename();
221 webContext->setIconDatabasePath(databasePath);
223 m_faviconDatabase = Ewk_Favicon_Database::create(iconDatabase.get());
226 return m_faviconDatabase.get();
229 RequestManagerClientEfl* Ewk_Context::requestManager()
231 return m_requestManagerClient.get();
234 #if ENABLE(VIBRATION)
235 PassRefPtr<VibrationProvider> Ewk_Context::vibrationProvider()
237 return m_vibrationProvider;
241 void Ewk_Context::addVisitedLink(const String& visitedURL)
243 toImpl(m_context.get())->addVisitedLink(visitedURL);
246 void Ewk_Context::setCacheModel(Ewk_Cache_Model cacheModel)
248 WKContextSetCacheModel(m_context.get(), static_cast<Ewk_Cache_Model>(cacheModel));
251 Ewk_Cache_Model Ewk_Context::cacheModel() const
253 return static_cast<Ewk_Cache_Model>(WKContextGetCacheModel(m_context.get()));
256 Ewk_Context* ewk_context_ref(Ewk_Context* ewkContext)
258 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
265 void ewk_context_unref(Ewk_Context* ewkContext)
267 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
272 Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext)
274 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
276 return const_cast<Ewk_Context*>(ewkContext)->cookieManager();
279 Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext)
281 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
283 return const_cast<Ewk_Context*>(ewkContext)->faviconDatabase();
286 WKContextRef Ewk_Context::wkContext()
288 return m_context.get();
291 DownloadManagerEfl* Ewk_Context::downloadManager() const
293 return m_downloadManager.get();
296 ContextHistoryClientEfl* Ewk_Context::historyClient()
298 return m_historyClient.get();
302 bool Ewk_Context::setProxyAddress(const char* proxyAddress)
304 if (m_proxyAddress == proxyAddress)
307 m_proxyAddress = proxyAddress;
311 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
312 bool Ewk_Context::setCertificateFile(const char* certificateFile)
314 if (m_certificateFile == certificateFile)
317 m_certificateFile = certificateFile;
322 void Ewk_Context::setDefaultDatabaseQuota(uint64_t defaultDatabaseQuota)
324 m_defaultDatabaseQuota = defaultDatabaseQuota;
327 void Ewk_Context::setMessageFromInjectedBundleCallback(Ewk_Context_Message_From_Injected_Bundle_Callback callback, void* userData)
329 m_messageFromInjectedBundle.callback = callback;
330 m_messageFromInjectedBundle.userData = userData;
333 void Ewk_Context::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData)
335 if (!m_messageFromInjectedBundle.callback)
338 CString name = toImpl(messageName)->string().utf8();
340 if (messageBody && WKStringGetTypeID() == WKGetTypeID(messageBody))
341 body = toImpl(static_cast<WKStringRef>(messageBody))->string().utf8();
344 char* returnString = 0;
345 m_messageFromInjectedBundle.callback(name.data(), body.data(), &returnString,
346 m_messageFromInjectedBundle.userData);
348 *returnData = WKStringCreateWithUTF8CString(returnString);
351 *returnData = WKStringCreateWithUTF8CString("");
353 m_messageFromInjectedBundle.callback(name.data(), body.data(), 0, m_messageFromInjectedBundle.userData);
356 void Ewk_Context::setDidStartDownloadCallback(Ewk_Context_Did_Start_Download_Callback callback, void* userData)
358 m_didStartDownload.callback = callback;
359 m_didStartDownload.userData = userData;
362 void Ewk_Context::didStartDownload(WKStringRef downloadURL)
364 EINA_SAFETY_ON_NULL_RETURN(m_didStartDownload.callback);
366 m_didStartDownload.callback(toImpl(downloadURL)->string().utf8().data(), m_didStartDownload.userData);
369 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
370 void Ewk_Context::clearAllDecodedData()
372 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(wkContext());
373 WKResourceCacheManagerClearCacheForAllOrigins(cacheManager, WKResourceCachesToClearInDecodedDataOnly);
377 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
378 Ecore_X_Window Ewk_Context::xWindow()
383 void Ewk_Context::setXWindow(Ecore_X_Window xWindow)
385 toImpl(wkContext())->setXWindow(xWindow);
389 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
390 void Ewk_Context::addFormData(const char* url, WKDictionaryRef& formData, bool isPasswordForm)
392 EINA_SAFETY_ON_NULL_RETURN(url);
393 if (!m_formDatabase->isOpen())
396 Vector<std::pair<String, String> > formDataVector;
397 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(formData));
398 size_t numKeys = WKArrayGetSize(wkKeys.get());
399 for (size_t i = 0; i < numKeys; ++i) {
400 WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
401 WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(formData, wkKey));
403 formDataVector.append(pair<String, String>(toImpl(wkKey)->string(), toImpl(wkValue)->string()));
406 m_formDatabase->addFormDataForURL(String::fromUTF8(url), formDataVector, isPasswordForm);
409 void Ewk_Context::passwordFormData(const char* url, Vector<std::pair<String, String> >& passwordFormData)
411 EINA_SAFETY_ON_NULL_RETURN(url);
412 if (!m_formDatabase->isOpen())
414 m_formDatabase->getPasswordFormDataForURL(String::fromUTF8(url), passwordFormData);
417 void Ewk_Context::candidateFormData(const String& name, Vector<String>& candidates)
419 if (!m_formDatabase->isOpen())
421 m_formDatabase->getCandidateFormDataForName(name, candidates);
424 void Ewk_Context::clearPasswordFormData()
426 m_formDatabase->clearPasswordFormData();
429 void Ewk_Context::clearCandidateFormData()
431 m_formDatabase->clearCandidateFormData();
436 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
439 * Request WebProcess to dump cache.
441 * This sends sync message to WebProcess to dump memory cache, that is, soup cache.
443 * @param context context object
445 * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
447 * @note This can effect UIProcess's performance because it calls to sync IPC message eventually.
449 void Ewk_Context::dumpCache()
451 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(wkContext());
452 toImpl(cacheManager)->dumpCache();
457 Ewk_Context* ewk_context_default_get()
459 return Ewk_Context::defaultContext().get();
463 typedef struct Ewk_Context_Callback_Context
466 #if ENABLE(TIZEN_FILE_SYSTEM)
467 Ewk_Local_File_System_Origins_Get_Callback localFileSystemOriginsCallback;
469 Ewk_Web_Application_Cache_Origins_Get_Callback webApplicationCacheOriginsCallback;
470 Ewk_Web_Application_Cache_Quota_Get_Callback webApplicationCacheQuotaCallback;
471 Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback webApplicationCacheUsageForOriginCallback;
472 Ewk_Web_Application_Cache_Path_Get_Callback webApplicationCachePathCallback;
473 Ewk_Web_Database_Origins_Get_Callback webDatabaseOriginsCallback;
474 Ewk_Web_Database_Quota_Get_Callback webDatabaseQuotaCallback;
475 Ewk_Web_Database_Usage_Get_Callback webDatabaseUsageCallback;
476 Ewk_Web_Database_Path_Get_Callback webDatabasePathCallback;
477 Ewk_Web_Storage_Origins_Get_Callback webStorageOriginsCallback;
478 Ewk_Web_Storage_Usage_Get_Callback webStorageUsageCallback;
479 Ewk_Web_Storage_Path_Get_Callback webStoragePathCallback;
482 } Ewk_Context_Callback_Context;
484 #if ENABLE(TIZEN_SQL_DATABASE)
485 struct Ewk_Context_Exceeded_Quota
487 Ewk_Security_Origin* origin;
488 const char* databaseName;
489 const char* displayName;
490 unsigned long long currentQuota;
491 unsigned long long currentOriginUsage;
492 unsigned long long currentDatabaseUsage;
493 unsigned long long expectedUsage;
494 unsigned long long newQuota;
498 #if ENABLE(TIZEN_SQL_DATABASE)
499 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)
501 Ewk_Context_Exceeded_Quota* exceededQuota = new Ewk_Context_Exceeded_Quota();
503 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
504 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
505 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
507 length = WKStringGetMaximumUTF8CStringSize(displayName);
508 OwnArrayPtr<char> displayNameBuffer = adoptArrayPtr(new char[length]);
509 WKStringGetUTF8CString(displayName, displayNameBuffer.get(), length);
511 exceededQuota->origin = createSecurityOrigin(origin);
512 exceededQuota->databaseName = eina_stringshare_add(databaseNameBuffer.get());
513 exceededQuota->displayName = eina_stringshare_add(displayNameBuffer.get());
514 exceededQuota->currentQuota = currentQuota;
515 exceededQuota->currentOriginUsage = currentOriginUsage;
516 exceededQuota->currentDatabaseUsage = currentDatabaseUsage;
517 exceededQuota->expectedUsage = expectedUsage;
519 return exceededQuota;
522 void ewkContextDeleteExceededQuota(Ewk_Context_Exceeded_Quota* exceededQuota)
524 deleteSecurityOrigin(exceededQuota->origin);
525 eina_stringshare_del(exceededQuota->databaseName);
526 eina_stringshare_del(exceededQuota->displayName);
527 delete exceededQuota;
530 unsigned long long ewkContextGetNewQuotaForExceededQuota(Ewk_Context* ewkContext, Ewk_Context_Exceeded_Quota* exceededQuota)
532 if (exceededQuota->newQuota)
533 return exceededQuota->newQuota + exceededQuota->currentQuota;
535 if (exceededQuota->currentQuota)
536 return exceededQuota->currentQuota;
538 return ewkContext->defaultDatabaseQuota();
541 uint64_t ewkContextGetDatabaseQuota(Ewk_Context* ewkContext)
543 return ewkContext->defaultDatabaseQuota();
548 Ewk_Context* ewk_context_new()
551 Ewk_Context* ewk_context = Ewk_Context::create().leakRef();
552 ewkContextInjectedBundleClientAttachClient(ewk_context);
555 return Ewk_Context::create().leakRef();
558 Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path)
560 EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
562 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
563 // FIXME : OpenGL check code for WRT before launching WebProcess.
564 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
565 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
570 #if ENABLE(TIZEN_WRT_LAUNCHING_PERFORMANCE)
571 char* wrtLaunchingPerformance = getenv("WRT_LAUNCHING_PERFORMANCE");
572 if (wrtLaunchingPerformance && !strcmp(wrtLaunchingPerformance, "1")) {
573 static bool firstTime = true;
577 if (ProcessLauncher::isInitialFork())
578 ProcessLauncher::setSkipExec(true);
580 ProcessLauncher::setSkipExec(false);
582 ProcessLauncher::forkProcess();
584 if (ProcessLauncher::isParentProcess()) {
585 Ewk_Context* ewkContext = ewk_context_new_with_injected_bundle_path(path);
586 WKContextRef contextRef = ewkContext->wkContext();
587 toImpl(contextRef)->ensureWebProcess();
590 else if (ProcessLauncher::isChildProcess()) {
591 ProcessLauncher::callWebProcessMain();
595 ASSERT_NOT_REACHED();
602 Ewk_Context* ewk_context = Ewk_Context::create(String::fromUTF8(path)).leakRef();
603 ewkContextInjectedBundleClientAttachClient(ewk_context);
606 return Ewk_Context::create(String::fromUTF8(path)).leakRef();
609 void ewk_context_delete(Ewk_Context* ewkContext)
611 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
612 if (ewkContext == ewk_context_default_get() && ewkContext->hasOneRef())
618 void ewk_context_proxy_uri_set(Ewk_Context* ewkContext, const char* proxy)
620 if (ewkContext && ewkContext->setProxyAddress(proxy)) {
621 WKRetainPtr<WKURLRef> proxyAddress(AdoptWK, WKURLCreateWithUTF8CString(proxy));
623 WKContextRef contextRef = ewkContext->wkContext();
624 toImpl(contextRef)->setProxy(toWTFString(proxyAddress.get()));
628 const char* ewk_context_proxy_uri_get(Ewk_Context* ewkContext)
630 #if ENABLE(TIZEN_WEBKIT2_PATCH_FOR_TC)
631 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
633 return ewkContext->proxyAddress();
636 void ewk_context_network_session_requests_cancel(Ewk_Context* ewkContext)
638 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
640 WKContextRef contextRef = ewkContext->wkContext();
641 toImpl(contextRef)->abortSession();
644 Eina_Bool ewk_context_notify_low_memory(Ewk_Context* ewkContext)
646 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
648 WKContextRef contextRef = ewkContext->wkContext();
649 toImpl(contextRef)->notifyLowMemory();
653 #if ENABLE(TIZEN_FILE_SYSTEM)
654 static void didGetLocalFileSystemOrigins(WKArrayRef origins, WKErrorRef error, void* context)
656 Eina_List* originList = 0;
657 for (size_t i = 0; i < WKArrayGetSize(origins); ++i) {
658 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
659 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
660 originList = eina_list_append(originList, origin);
663 Ewk_Context_Callback_Context* locaFileSystemContext = static_cast<Ewk_Context_Callback_Context*>(context);
664 locaFileSystemContext->localFileSystemOriginsCallback(originList, locaFileSystemContext->userData);
665 delete locaFileSystemContext;
669 #if ENABLE(TIZEN_APPLICATION_CACHE)
670 static void didGetWebApplicationOrigins(WKArrayRef origins, WKErrorRef error, void* context)
672 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
673 Eina_List* originList = 0;
675 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
676 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
677 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
678 originList = eina_list_append(originList, origin);
681 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
682 applicationCacheContext->webApplicationCacheOriginsCallback(originList, applicationCacheContext->userData);
683 delete applicationCacheContext;
686 static void didGetWebApplicationPath(WKStringRef path, WKErrorRef error, void* context)
688 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
690 int length = WKStringGetMaximumUTF8CStringSize(path);
691 OwnArrayPtr<char> applicationCachePath = adoptArrayPtr(new char[length]);
692 WKStringGetUTF8CString(path, applicationCachePath.get(), length);
694 TIZEN_LOGI("path (%s)", applicationCachePath.get());
695 applicationCacheContext->webApplicationCachePathCallback(eina_stringshare_add(applicationCachePath.get()), applicationCacheContext->userData);
696 delete applicationCacheContext;
699 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
700 static void didGetWebApplicationQuota(WKInt64Ref quota, WKErrorRef error, void* context)
702 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
703 TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
704 applicationCacheContext->webApplicationCacheQuotaCallback(toImpl(quota)->value(), applicationCacheContext->userData);
705 delete applicationCacheContext;
708 static void didGetWebApplicationUsageForOrigin(WKInt64Ref usage, WKErrorRef error, void* context)
710 Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
711 TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
712 applicationCacheContext->webApplicationCacheUsageForOriginCallback(toImpl(usage)->value(), applicationCacheContext->userData);
713 delete applicationCacheContext;
718 #if ENABLE(TIZEN_SQL_DATABASE)
719 static void didGetWebDatabaseOrigins(WKArrayRef origins, WKErrorRef error, void* context)
721 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
722 Eina_List* originList = 0;
724 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
725 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
726 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
727 originList = eina_list_append(originList, origin);
730 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
731 webDatabaseContext->webDatabaseOriginsCallback(originList, webDatabaseContext->userData);
732 delete webDatabaseContext;
735 static void didGetWebDatabaseQuota(WKUInt64Ref quota, WKErrorRef error, void* context)
737 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
738 TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
739 webDatabaseContext->webDatabaseQuotaCallback(toImpl(quota)->value(), webDatabaseContext->userData);
740 delete webDatabaseContext;
743 static void didGetWebDatabaseUsage(WKUInt64Ref usage, WKErrorRef error, void* context)
745 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
746 TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
747 webDatabaseContext->webDatabaseUsageCallback(toImpl(usage)->value(), webDatabaseContext->userData);
748 delete webDatabaseContext;
751 static void didGetWebDatabasePath(WKStringRef path, WKErrorRef error, void * context)
753 Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
755 int length = WKStringGetMaximumUTF8CStringSize(path);
756 OwnArrayPtr<char> databasePath = adoptArrayPtr(new char[length]);
757 WKStringGetUTF8CString(path, databasePath.get(), length);
759 TIZEN_LOGI("path (%s)", databasePath.get());
760 webDatabaseContext->webDatabasePathCallback(eina_stringshare_add(databasePath.get()), webDatabaseContext->userData);
761 delete webDatabaseContext;
765 #if ENABLE(TIZEN_WEB_STORAGE)
766 static void didGetWebStorageOrigins(WKArrayRef origins, WKErrorRef error, void* context)
768 TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
769 Eina_List* originList = 0;
771 for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
772 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
773 Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
774 originList = eina_list_append(originList, origin);
777 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
778 webStorageContext->webStorageOriginsCallback(originList, webStorageContext->userData);
779 delete webStorageContext;
782 static void didGetWebStoragePath(WKStringRef path, WKErrorRef error, void * context)
784 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
786 int length = WKStringGetMaximumUTF8CStringSize(path);
787 OwnArrayPtr<char> storagePath = adoptArrayPtr(new char[length]);
788 WKStringGetUTF8CString(path, storagePath.get(), length);
790 TIZEN_LOGI("path (%s)", storagePath.get());
791 webStorageContext->webStoragePathCallback(eina_stringshare_add(storagePath.get()), webStorageContext->userData);
792 delete webStorageContext;
795 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
796 static void didGetWebStorageUsage(WKInt64Ref usage, WKErrorRef error, void* context)
798 Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
800 TIZEN_LOGI("usage (%s)", toImpl(usage)->value());
801 webStorageContext->webStorageUsageCallback(toImpl(usage)->value(), webStorageContext->userData);
802 delete webStorageContext;
808 Eina_Bool ewk_context_origins_free(Eina_List* originList)
810 EINA_SAFETY_ON_NULL_RETURN_VAL(originList, false);
813 EINA_LIST_FREE(originList, currentOrigin) {
814 Ewk_Security_Origin* origin = static_cast<Ewk_Security_Origin*>(currentOrigin);
815 deleteSecurityOrigin(origin);
821 Eina_Bool ewk_context_application_cache_delete_all(Ewk_Context* ewkContext)
823 #if ENABLE(TIZEN_APPLICATION_CACHE)
824 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
826 TIZEN_LOGI("ewkContext (%p)", ewkContext);
827 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
828 WKApplicationCacheManagerDeleteAllEntries(applicationCache);
836 Eina_Bool ewk_context_application_cache_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
838 #if ENABLE(TIZEN_APPLICATION_CACHE)
839 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
840 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
842 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
843 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
844 WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
845 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
846 WKApplicationCacheManagerDeleteEntriesForOrigin(applicationCacheRef, securityOriginRef.get());
854 Eina_Bool ewk_context_application_cache_origins_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Origins_Get_Callback callback, void *userData)
856 #if ENABLE(TIZEN_APPLICATION_CACHE)
857 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
858 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
860 TIZEN_LOGI("ewkContext (%p)", ewkContext);
861 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
862 context->webApplicationCacheOriginsCallback = callback;
863 context->userData = userData;
865 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
866 WKApplicationCacheManagerGetApplicationCacheOrigins(applicationCacheRef, context, didGetWebApplicationOrigins);
874 Eina_Bool ewk_context_application_cache_path_set(Ewk_Context* ewkContext, const char* path)
876 #if ENABLE(TIZEN_APPLICATION_CACHE)
877 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
878 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
881 TIZEN_LOGE("Path value is invalid");
885 TIZEN_LOGI("path (%s)", path);
886 WKRetainPtr<WKStringRef> applicationCachePathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
887 WKContextSetApplicationCacheDirectory(ewkContext->wkContext(), applicationCachePathRef.get());
895 Eina_Bool ewk_context_application_cache_path_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Path_Get_Callback callback, void* userData)
897 #if ENABLE(TIZEN_APPLICATION_CACHE)
898 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
899 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
901 TIZEN_LOGI("callback (%p)", callback);
902 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
903 context->webApplicationCachePathCallback= callback;
904 context->userData = userData;
906 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
907 WKApplicationCacheManagerGetApplicationCachePath(applicationCacheRef, context, didGetWebApplicationPath);
914 Eina_Bool ewk_context_application_cache_quota_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Quota_Get_Callback callback, void* userData)
916 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
917 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
918 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
920 TIZEN_LOGI("callback (%p)", callback);
921 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
922 context->webApplicationCacheQuotaCallback = callback;
923 context->userData = userData;
925 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
926 WKApplicationCacheManagerGetApplicationCacheQuota(applicationCacheRef, context, didGetWebApplicationQuota);
934 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)
936 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
937 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
938 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
939 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
941 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
942 context->webApplicationCacheUsageForOriginCallback = callback;
943 context->userData = userData;
944 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
945 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
946 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
948 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
949 WKApplicationCacheManagerGetApplicationCacheUsageForOrigin(applicationCache, context, originRef.get(), didGetWebApplicationUsageForOrigin);
957 Eina_Bool ewk_context_application_cache_quota_set(Ewk_Context* ewkContext, int64_t quota)
959 #if ENABLE(TIZEN_APPLICATION_CACHE)
960 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
962 TIZEN_LOGE("Quota value is invalid");
966 TIZEN_LOGI("quota (%d)", quota);
967 WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
968 WKApplicationCacheManagerSetApplicationCacheQuota(applicationCacheRef, quota);
976 Eina_Bool ewk_context_application_cache_quota_for_origin_set(Ewk_Context* ewkContext, const Ewk_Security_Origin* origin, int64_t quota)
978 #if ENABLE(TIZEN_APPLICATION_CACHE)
979 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
980 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
982 TIZEN_LOGE("Quota value is invalid");
986 TIZEN_LOGI("quota (%d)", quota);
987 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
988 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
989 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
991 WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
992 WKApplicationCacheManagerSetApplicationCacheQuotaForOrigin(applicationCache, originRef.get(), quota);
1001 Eina_Bool ewk_context_icon_database_path_set(Ewk_Context* ewkContext, const char* path)
1003 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1004 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1006 WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1007 WKContextSetIconDatabasePath(ewkContext->wkContext(), databasePath.get());
1012 Evas_Object* ewk_context_icon_database_icon_object_add(Ewk_Context* ewkContext, const char* uri, Evas* canvas)
1014 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
1015 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, 0);
1016 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1018 WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1019 WKRetainPtr<WKURLRef> urlString(AdoptWK, WKURLCreateWithUTF8CString(uri));
1021 return WKIconDatabaseTryGetImageForURL(iconDatabase, canvas, urlString.get());
1024 void ewk_context_icon_database_delete_all(Ewk_Context* ewkContext)
1026 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1028 WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1029 WKIconDatabaseRemoveAllIcons(iconDatabase);
1032 Eina_Bool ewk_context_local_file_system_path_set(Ewk_Context* ewkContext, const char* path)
1034 #if ENABLE(TIZEN_FILE_SYSTEM)
1035 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1036 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1038 TIZEN_LOGI("path (%s)", path);
1039 WKRetainPtr<WKStringRef> localFileSystemPathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
1040 WKContextSetLocalFileSystemDirectory(ewkContext->wkContext(), localFileSystemPathRef.get());
1048 Eina_Bool ewk_context_local_file_system_all_delete(Ewk_Context* ewkContext)
1050 #if ENABLE(TIZEN_FILE_SYSTEM)
1051 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1053 TIZEN_LOGI("ewkContex (%p)", ewkContext);
1054 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1055 WKLocalFileSystemManagerDeleteAllLocalFileSystem(localFileSystemManager);
1059 UNUSED_PARAM(ewkContext);
1065 Eina_Bool ewk_context_local_file_system_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1067 #if ENABLE(TIZEN_FILE_SYSTEM)
1068 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1069 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1071 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1072 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1073 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1074 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1076 WKLocalFileSystemManagerDeleteLocalFileSystem(localFileSystemManager, originRef.get());
1080 UNUSED_PARAM(ewkContext);
1081 UNUSED_PARAM(origin);
1087 Eina_Bool ewk_context_local_file_system_origins_get(const Ewk_Context* ewkContext, Ewk_Local_File_System_Origins_Get_Callback callback, void* userData)
1089 #if ENABLE(TIZEN_FILE_SYSTEM)
1090 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1091 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1093 TIZEN_LOGI("callback (%p)", callback);
1094 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1095 context->localFileSystemOriginsCallback= callback;
1096 context->userData = userData;
1097 WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(const_cast<Ewk_Context*>(ewkContext)->wkContext());
1099 WKLocalFileSystemManagerGetLocalFileSystemOrigins(localFileSystemManager, context, didGetLocalFileSystemOrigins);
1103 UNUSED_PARAM(ewkContext);
1104 UNUSED_PARAM(callback);
1105 UNUSED_PARAM(userData);
1111 Ewk_Security_Origin* ewk_context_web_database_exceeded_quota_security_origin_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1113 #if ENABLE(TIZEN_SQL_DATABASE)
1114 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1116 return exceededQuota->origin;
1122 const char* ewk_context_web_database_exceeded_quota_database_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1124 #if ENABLE(TIZEN_SQL_DATABASE)
1125 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1127 TIZEN_LOGI("name (%s)", exceededQuota->databaseName);
1128 return exceededQuota->databaseName;
1134 const char* ewk_context_web_database_exceeded_quota_display_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1136 #if ENABLE(TIZEN_SQL_DATABASE)
1137 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1139 TIZEN_LOGI("displayName (%s)", exceededQuota->displayName);
1140 return exceededQuota->displayName;
1146 unsigned long long ewk_context_web_database_exceeded_quota_current_quota_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1148 #if ENABLE(TIZEN_SQL_DATABASE)
1149 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1151 TIZEN_LOGI("quota (%d)", exceededQuota->currentQuota);
1152 return exceededQuota->currentQuota;
1158 unsigned long long ewk_context_web_database_exceeded_quota_current_origin_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1160 #if ENABLE(TIZEN_SQL_DATABASE)
1161 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1163 TIZEN_LOGI("currentOriginUsage (%d)", exceededQuota->currentOriginUsage);
1164 return exceededQuota->currentOriginUsage;
1170 unsigned long long ewk_context_web_database_exceeded_quota_current_database_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1172 #if ENABLE(TIZEN_SQL_DATABASE)
1173 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1175 TIZEN_LOGI("currentDatabaseUsage (%d)", exceededQuota->currentDatabaseUsage);
1176 return exceededQuota->currentDatabaseUsage;
1182 unsigned long long ewk_context_web_database_exceeded_quota_expected_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1184 #if ENABLE(TIZEN_SQL_DATABASE)
1185 EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1187 TIZEN_LOGI("expectedUsage (%d)", exceededQuota->expectedUsage);
1188 return exceededQuota->expectedUsage;
1194 void ewk_context_web_database_exceeded_quota_new_quota_set(Ewk_Context_Exceeded_Quota* exceededQuota, unsigned long long quota)
1196 #if ENABLE(TIZEN_SQL_DATABASE)
1197 EINA_SAFETY_ON_NULL_RETURN(exceededQuota);
1199 TIZEN_LOGI("quota (%d)", quota);
1200 exceededQuota->newQuota = quota;
1204 Eina_Bool ewk_context_web_database_delete_all(Ewk_Context* ewkContext)
1206 #if ENABLE(TIZEN_SQL_DATABASE)
1207 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1209 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1210 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1211 WKDatabaseManagerDeleteAllDatabases(databaseManager);
1219 Eina_Bool ewk_context_web_database_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1221 #if ENABLE(TIZEN_SQL_DATABASE)
1222 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1223 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1225 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1226 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1227 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1228 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1229 WKDatabaseManagerDeleteDatabasesForOrigin(databaseManager, originRef.get());
1237 Eina_Bool ewk_context_web_database_origins_get(Ewk_Context* ewkContext, Ewk_Web_Database_Origins_Get_Callback callback, void* userData)
1239 #if ENABLE(TIZEN_SQL_DATABASE)
1240 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1241 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1243 TIZEN_LOGI("callback (%p)", callback);
1244 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1245 context->webDatabaseOriginsCallback = callback;
1246 context->userData = userData;
1248 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1249 WKDatabaseManagerGetDatabaseOrigins(databaseManager, context, didGetWebDatabaseOrigins);
1257 Eina_Bool ewk_context_web_database_path_set(Ewk_Context* ewkContext, const char* path)
1259 #if ENABLE(TIZEN_SQL_DATABASE)
1260 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1261 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1263 TIZEN_LOGI("path (%s)", path);
1264 WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1265 WKContextSetDatabaseDirectory(ewkContext->wkContext(), databasePath.get());
1273 Eina_Bool ewk_context_web_database_path_get(Ewk_Context* ewkContext, Ewk_Web_Database_Path_Get_Callback callback, void* userData)
1275 #if ENABLE(TIZEN_WEB_STORAGE)
1276 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1277 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1279 TIZEN_LOGI("callback (%p)", callback);
1280 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1281 context->webDatabasePathCallback= callback;
1282 context->userData = userData;
1284 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1285 WKDatabaseManagerGetDatabasePath(databaseManager, context, didGetWebDatabasePath);
1291 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)
1293 #if ENABLE(TIZEN_SQL_DATABASE)
1294 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1295 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1296 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1298 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1299 context->webDatabaseQuotaCallback = callback;
1300 context->userData = userData;
1302 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1303 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1304 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1305 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1306 WKDatabaseManagerGetQuotaForOrigin(databaseManager, context, didGetWebDatabaseQuota, originRef.get());
1314 Eina_Bool ewk_context_web_database_default_quota_set(Ewk_Context* ewkContext, uint64_t quota)
1316 #if ENABLE(TIZEN_SQL_DATABASE)
1317 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1319 TIZEN_LOGI("quota (%d)", quota);
1320 ewkContext->setDefaultDatabaseQuota(quota);
1328 Eina_Bool ewk_context_web_database_quota_for_origin_set(Ewk_Context* ewkContext, Ewk_Security_Origin* origin, uint64_t quota)
1330 #if ENABLE(TIZEN_SQL_DATABASE)
1331 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1332 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1334 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1335 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1336 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1337 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1338 WKDatabaseManagerSetQuotaForOrigin(databaseManager, originRef.get(), quota);
1346 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)
1348 #if ENABLE(TIZEN_SQL_DATABASE)
1349 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1350 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1351 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1353 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1354 context->webDatabaseQuotaCallback = callback;
1355 context->userData = userData;
1357 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1358 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1359 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1360 WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1361 WKDatabaseManagerGetUsageForOrigin(databaseManager, context, didGetWebDatabaseUsage, originRef.get());
1369 Eina_Bool ewk_context_web_indexed_database_delete_all(Ewk_Context* ewkContext)
1371 #if ENABLE(TIZEN_INDEXED_DATABASE)
1372 WKContextDeleteIndexedDatabaseAll(ewkContext->wkContext());
1380 Eina_Bool ewk_context_web_storage_delete_all(Ewk_Context* ewkContext)
1382 #if ENABLE(TIZEN_WEB_STORAGE)
1383 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1385 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1386 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1387 WKKeyValueStorageManagerDeleteAllEntries(storageManager);
1395 Eina_Bool ewk_context_web_storage_origin_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1397 #if ENABLE(TIZEN_WEB_STORAGE)
1398 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1399 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1401 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1402 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1403 WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1404 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1405 WKKeyValueStorageManagerDeleteEntriesForOrigin(storageManager, securityOriginRef.get());
1413 Eina_Bool ewk_context_web_storage_origins_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Origins_Get_Callback callback, void* userData)
1415 #if ENABLE(TIZEN_WEB_STORAGE)
1416 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1417 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1419 TIZEN_LOGI("callback (%p)", callback);
1420 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1421 context->webStorageOriginsCallback = callback;
1422 context->userData = userData;
1424 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1425 WKKeyValueStorageManagerGetKeyValueStorageOrigins(storageManager, context, didGetWebStorageOrigins);
1433 Eina_Bool ewk_context_web_storage_path_set(Ewk_Context* ewkContext, const char* path)
1435 #if ENABLE(TIZEN_WEB_STORAGE)
1436 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1437 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1439 TIZEN_LOGI("path (%s)", path);
1440 WKRetainPtr<WKStringRef> webStoragePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1441 WKContextSetLocalStorageDirectory(ewkContext->wkContext(), webStoragePath.get());
1449 Eina_Bool ewk_context_web_storage_path_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Path_Get_Callback callback, void* userData)
1451 #if ENABLE(TIZEN_WEB_STORAGE)
1452 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1453 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1455 TIZEN_LOGI("callback (%p)", callback);
1456 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1457 context->webStoragePathCallback= callback;
1458 context->userData = userData;
1460 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1461 WKKeyValueStorageManagerGetKeyValueStoragePath(storageManager, context, didGetWebStoragePath);
1467 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)
1469 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
1470 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1471 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1472 EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1474 Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1475 context->webStorageUsageCallback = callback;
1476 context->userData = userData;
1477 WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1478 WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1479 WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1481 WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1482 WKKeyValueStorageManagerGetKeyValueStorageUsageForOrigin(storageManager, context, didGetWebStorageUsage, originRef.get());
1490 //#if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
1491 Eina_Bool ewk_context_soup_data_directory_set(Ewk_Context* ewkContext, const char* path)
1493 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1494 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1496 WKRetainPtr<WKStringRef> soupDataDirectory(AdoptWK, WKStringCreateWithUTF8CString(path));
1497 WKContextSetSoupDataDirectory(ewkContext->wkContext(), soupDataDirectory.get());
1502 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_VIEWER, kWKCacheModelDocumentViewer);
1503 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_BROWSER, kWKCacheModelDocumentBrowser);
1504 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, kWKCacheModelPrimaryWebBrowser);
1506 Eina_Bool ewk_context_cache_model_set(Ewk_Context* ewkContext, Ewk_Cache_Model cacheModel)
1508 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1510 ewkContext->setCacheModel(cacheModel);
1515 Ewk_Cache_Model ewk_context_cache_model_get(Ewk_Context* ewkContext)
1517 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, EWK_CACHE_MODEL_DOCUMENT_VIEWER);
1519 return ewkContext->cacheModel();
1522 Eina_Bool ewk_context_cache_disabled_set(Ewk_Context* ewkContext, Eina_Bool cacheDisabled)
1524 #if ENABLE(TIZEN_CACHE_CONTROL)
1525 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1526 WKContextSetCacheDisabled(ewkContext->wkContext(), cacheDisabled);
1532 Eina_Bool ewk_context_cache_disabled_get(Ewk_Context* ewkContext)
1534 #if ENABLE(TIZEN_CACHE_CONTROL)
1535 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1536 return WKContextGetCacheDisabled(ewkContext->wkContext());
1542 Eina_Bool ewk_context_certificate_file_set(Ewk_Context* context, const char* certificateFile)
1544 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
1545 EINA_SAFETY_ON_NULL_RETURN_VAL(certificateFile, false);
1546 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1547 if (!context->setCertificateFile(certificateFile))
1550 if (fileExists(WTF::String::fromUTF8(certificateFile))) {
1551 long long fileSize = -1;
1552 getFileSize(WTF::String::fromUTF8(certificateFile), fileSize);
1553 TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile fileSize [%lld]\n", fileSize);
1555 TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile does not exist!\n");
1557 WKRetainPtr<WKStringRef> certificateFileRef(AdoptWK, WKStringCreateWithUTF8CString(certificateFile));
1558 WKContextSetCertificateFile(context->wkContext(), certificateFileRef.get());
1561 UNUSED_PARAM(context);
1562 UNUSED_PARAM(certificateFile);
1567 const char* ewk_context_certificate_file_get(const Ewk_Context* context)
1569 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1570 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1571 return context->certificateFile();
1573 UNUSED_PARAM(context);
1578 Eina_Bool ewk_context_cache_clear(Ewk_Context* ewkContext)
1580 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1581 WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(ewkContext->wkContext());
1582 #if ENABLE(TIZEN_EWK_CONTEXT_CACHE_MANAGER_NULL_CHECK_WORKAROUND)
1586 WKResourceCacheManagerClearCacheForAllOrigins(cacheManager, WKResourceCachesToClearAll);
1591 void ewk_context_message_post_to_injected_bundle(Ewk_Context* ewkContext, const char* name, const char* body)
1593 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1594 EINA_SAFETY_ON_NULL_RETURN(name);
1595 EINA_SAFETY_ON_NULL_RETURN(body);
1597 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString(name));
1598 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithUTF8CString(body));
1599 WKContextPostMessageToInjectedBundle(ewkContext->wkContext(), messageName.get(), messageBody.get());
1602 void ewk_context_message_from_injected_bundle_callback_set(Ewk_Context* ewkContext, Ewk_Context_Message_From_Injected_Bundle_Callback callback, void* userData)
1604 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1606 ewkContext->setMessageFromInjectedBundleCallback(callback, userData);
1609 void ewk_context_did_start_download_callback_set(Ewk_Context* ewkContext, Ewk_Context_Did_Start_Download_Callback callback, void* userData)
1611 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1613 ewkContext->setDidStartDownloadCallback(callback, userData);
1616 #if ENABLE(MEMORY_SAMPLER)
1617 void ewk_context_memory_sampler_start(Ewk_Context* ewkContext, double timerInterval)
1619 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1620 WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(timerInterval));
1621 WKContextStartMemorySampler(ewkContext->wkContext(), interval.get());
1624 void ewk_context_memory_sampler_stop(Ewk_Context* ewkContext)
1626 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1627 WKContextStopMemorySampler(ewkContext->wkContext());
1631 Eina_Bool ewk_context_additional_plugin_path_set(Ewk_Context* ewkContext, const char* path)
1633 #if ENABLE(TIZEN_SUPPORT_PLUGINS)
1634 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1635 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1637 WKRetainPtr<WKStringRef> pluginPath(AdoptWK, WKStringCreateWithUTF8CString(path));
1638 WKContextSetAdditionalPluginsDirectory(ewkContext->wkContext(), pluginPath.get());
1646 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
1647 void ewk_context_memory_saving_mode_set(Ewk_Context* ewkContext, Eina_Bool mode)
1649 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1651 WKContextRef contextRef = ewkContext->wkContext();
1652 toImpl(contextRef)->setMemorySavingMode(mode);
1656 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1657 void ewk_context_form_password_data_clear(Ewk_Context* ewkContext)
1659 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1660 ewkContext->clearPasswordFormData();
1663 void ewk_context_form_candidate_data_clear(Ewk_Context* ewkContext)
1665 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1666 ewkContext->clearCandidateFormData();
1669 #endif // #if OS(TIZEN)
1671 Eina_Bool ewk_context_url_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData)
1673 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1674 EINA_SAFETY_ON_NULL_RETURN_VAL(scheme, false);
1675 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1677 ewkContext->requestManager()->registerURLSchemeHandler(String::fromUTF8(scheme), callback, userData);
1682 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)
1684 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1686 TIZEN_LOGI("vibrate (%p)", vibrate);
1687 #if ENABLE(VIBRATION)
1688 ewkContext->vibrationProvider()->setVibrationClientCallbacks(vibrate, cancel, data);
1692 Eina_Bool ewk_context_tizen_extensible_api_set(Ewk_Context* ewkContext, Ewk_Extensible_API extensibleAPI, Eina_Bool enable)
1694 #if ENABLE(TIZEN_EXTENSIBLE_API)
1695 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1697 TIZEN_LOGI("extensibleAPI (%d) enable (%d)", extensibleAPI, enable);
1698 WKContextSetTizenExtensibleAPI(ewkContext->wkContext(), static_cast<WKTizenExtensibleAPI>(extensibleAPI), enable);
1702 UNUSED_PARAM(ewkContext);
1703 UNUSED_PARAM(extensibleAPI);
1704 UNUSED_PARAM(enable);
1710 void ewk_context_storage_path_reset(Ewk_Context* ewkContext)
1712 #if ENABLE(TIZEN_RESET_PATH)
1713 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1715 TIZEN_LOGI("ewkContext (%p)", ewkContext);
1716 WKContextResetStoragePath(ewkContext->wkContext());
1718 UNUSED_PARAM(ewkContext);
1722 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)
1724 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1726 ewkContext->historyClient()->setCallbacks(navigate, clientRedirect, serverRedirect, titleUpdate, populateVisitedLinks, data);
1729 void ewk_context_visited_link_add(Ewk_Context* ewkContext, const char* visitedURL)
1731 EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1732 EINA_SAFETY_ON_NULL_RETURN(visitedURL);
1734 ewkContext->addVisitedLink(visitedURL);