Avoid broken unicode string by String::format()
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / ewk_context.cpp
1 /*
2  * Copyright (C) 2012 Samsung Electronics
3  *
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.
8  *
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.
13  *
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.
18  *
19  */
20
21 #include "config.h"
22 #include "ewk_context.h"
23
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"
32 #include "WKString.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>
43
44 #if OS(TIZEN)
45 #include "WKApplicationCacheManager.h"
46 #include "WKArray.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"
56 #endif
57 #include "WKNumber.h"
58 #include "WKSecurityOrigin.h"
59 #include "WKURL.h"
60 #include "ewk_context_injected_bundle_client.h"
61 #include "ewk_security_origin.h"
62 #include "ewk_private.h"
63 #include <Eina.h>
64
65 #if ENABLE(TIZEN_WRT_LAUNCHING_PERFORMANCE)
66 #include "ProcessLauncher.h"
67 #include <stdlib.h>
68 #endif
69
70 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
71 #include "FormDatabase.h"
72 #include "WKDictionary.h"
73 #endif
74 #endif // #if OS(TIZEN)
75 #if ENABLE(SPELLCHECK)
76 #include "ewk_settings.h"
77 #include "ewk_text_checker_private.h"
78 #endif
79
80 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
81 #include <EGL/egl.h>
82 #endif
83
84 using namespace WebCore;
85 using namespace WebKit;
86
87 typedef HashMap<WKContextRef, Ewk_Context*> ContextMap;
88
89 static inline ContextMap& contextMap()
90 {
91     DEFINE_STATIC_LOCAL(ContextMap, map, ());
92     return map;
93 }
94
95 Ewk_Context::Ewk_Context(WKContextRef context)
96     : m_context(context)
97     , m_historyClient(ContextHistoryClientEfl::create(context))
98 {
99     ContextMap::AddResult result = contextMap().add(context, this);
100     ASSERT_UNUSED(result, result.isNewEntry);
101
102 #if ENABLE(BATTERY_STATUS)
103     m_batteryProvider = BatteryProvider::create(context);
104 #endif
105
106 #if ENABLE(NETWORK_INFO)
107     m_networkInfoProvider = NetworkInfoProvider::create(context);
108 #endif
109
110 #if ENABLE(VIBRATION)
111     m_vibrationProvider = VibrationProvider::create(context);
112 #endif
113
114 #if ENABLE(MEMORY_SAMPLER)
115     static bool initializeMemorySampler = false;
116     static const char environmentVariable[] = "SAMPLE_MEMORY";
117
118     if (!initializeMemorySampler && getenv(environmentVariable)) {
119         WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(0.0));
120         WKContextStartMemorySampler(context, interval.get());
121         initializeMemorySampler = true;
122     }
123 #endif
124
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);
130     }
131 #endif
132
133     // Initialize WKContext clients.
134     m_downloadManager = DownloadManagerEfl::create(this);
135     m_requestManagerClient = RequestManagerClientEfl::create(this);
136
137 #if OS(TIZEN)
138 #if ENABLE(TIZEN_SQL_DATABASE)
139     m_defaultDatabaseQuota = 5 * 1024 * 1024;
140 #endif
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());
148 #endif
149 #endif
150 }
151
152 Ewk_Context::~Ewk_Context()
153 {
154     ASSERT(contextMap().get(m_context.get()) == this);
155     contextMap().remove(m_context.get());
156 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
157     dumpCache();
158 #endif
159 }
160
161 PassRefPtr<Ewk_Context> Ewk_Context::create(WKContextRef context)
162 {
163     if (contextMap().contains(context))
164         return contextMap().get(context); // Will be ref-ed automatically.
165
166     return adoptRef(new Ewk_Context(context));
167 }
168
169 PassRefPtr<Ewk_Context> Ewk_Context::create()
170 {
171     return create(adoptWK(WKContextCreate()).get());
172 }
173
174 PassRefPtr<Ewk_Context> Ewk_Context::create(const String& injectedBundlePath)
175 {   
176     if (!fileExists(injectedBundlePath))
177         return 0;
178
179     WKRetainPtr<WKStringRef> injectedBundlePathWK = adoptWK(toCopiedAPI(injectedBundlePath));
180     WKRetainPtr<WKContextRef> contextWK = adoptWK(WKContextCreateWithInjectedBundlePath(injectedBundlePathWK.get()));
181
182     return create(contextWK.get());
183 }
184
185 PassRefPtr<Ewk_Context> Ewk_Context::defaultContext()
186 {
187     static RefPtr<Ewk_Context> defaultInstance = create(adoptWK(WKContextCreate()).get());
188
189     return defaultInstance;
190 }
191
192 Ewk_Cookie_Manager* Ewk_Context::cookieManager()
193 {
194     if (!m_cookieManager)
195         m_cookieManager = Ewk_Cookie_Manager::create(WKContextGetCookieManager(m_context.get()));
196
197     return m_cookieManager.get();
198 }
199
200 Ewk_Favicon_Database* Ewk_Context::faviconDatabase()
201 {
202 #if ENABLE(TIZEN_ICON_DATABASE)
203     return 0;
204 #endif
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);
212         }
213         m_faviconDatabase = Ewk_Favicon_Database::create(iconDatabase.get());
214     }
215
216     return m_faviconDatabase.get();
217 }
218
219 RequestManagerClientEfl* Ewk_Context::requestManager()
220 {
221     return m_requestManagerClient.get();
222 }
223
224 #if ENABLE(VIBRATION)
225 PassRefPtr<VibrationProvider> Ewk_Context::vibrationProvider()
226 {
227     return m_vibrationProvider;
228 }
229 #endif
230
231 void Ewk_Context::addVisitedLink(const String& visitedURL)
232 {
233     toImpl(m_context.get())->addVisitedLink(visitedURL);
234 }
235
236 void Ewk_Context::setCacheModel(Ewk_Cache_Model cacheModel)
237 {
238     WKContextSetCacheModel(m_context.get(), static_cast<Ewk_Cache_Model>(cacheModel));
239 }
240
241 Ewk_Cache_Model Ewk_Context::cacheModel() const
242 {
243     return static_cast<Ewk_Cache_Model>(WKContextGetCacheModel(m_context.get()));
244 }
245
246 Ewk_Context* ewk_context_ref(Ewk_Context* ewkContext)
247 {
248     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
249
250     ewkContext->ref();
251
252     return ewkContext;
253 }
254
255 void ewk_context_unref(Ewk_Context* ewkContext)
256 {
257     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
258
259     ewkContext->deref();
260 }
261
262 Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext)
263 {
264     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
265
266     return const_cast<Ewk_Context*>(ewkContext)->cookieManager();
267 }
268
269 Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext)
270 {
271     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
272
273     return const_cast<Ewk_Context*>(ewkContext)->faviconDatabase();
274 }
275
276 WKContextRef Ewk_Context::wkContext()
277 {
278     return m_context.get();
279 }
280
281 DownloadManagerEfl* Ewk_Context::downloadManager() const
282 {
283     return m_downloadManager.get();
284 }
285
286 ContextHistoryClientEfl* Ewk_Context::historyClient()
287 {
288     return m_historyClient.get();
289 }
290
291 #if OS(TIZEN)
292 bool Ewk_Context::setProxyAddress(const char* proxyAddress)
293 {
294     if (m_proxyAddress == proxyAddress)
295         return false;
296
297     m_proxyAddress = proxyAddress;
298     return true;
299 }
300
301 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
302 bool Ewk_Context::setCertificateFile(const char* certificateFile)
303 {
304     if (m_certificateFile == certificateFile)
305         return false;
306
307     m_certificateFile = certificateFile;
308     return true;
309 }
310 #endif
311
312 void Ewk_Context::setDefaultDatabaseQuota(uint64_t defaultDatabaseQuota)
313 {
314     m_defaultDatabaseQuota = defaultDatabaseQuota;
315 }
316
317 void Ewk_Context::setMessageFromInjectedBundleCallback(Ewk_Context_Message_From_Injected_Bundle_Callback callback, void* userData)
318 {
319     m_messageFromInjectedBundle.callback = callback;
320     m_messageFromInjectedBundle.userData = userData;
321 }
322
323 void Ewk_Context::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData)
324 {
325     if (!m_messageFromInjectedBundle.callback)
326         return;
327
328     CString name = toImpl(messageName)->string().utf8();
329     CString body;
330     if (messageBody && WKStringGetTypeID() == WKGetTypeID(messageBody))
331         body = toImpl(static_cast<WKStringRef>(messageBody))->string().utf8();
332
333     if (returnData) {
334         char* returnString = 0;
335         m_messageFromInjectedBundle.callback(name.data(), body.data(), &returnString,
336                                                        m_messageFromInjectedBundle.userData);
337         if (returnString) {
338             *returnData = WKStringCreateWithUTF8CString(returnString);
339             free(returnString);
340         } else
341             *returnData = WKStringCreateWithUTF8CString("");
342     } else
343         m_messageFromInjectedBundle.callback(name.data(), body.data(), 0, m_messageFromInjectedBundle.userData);
344 }
345
346 void Ewk_Context::setDidStartDownloadCallback(Ewk_Context_Did_Start_Download_Callback callback, void* userData)
347 {
348     m_didStartDownload.callback = callback;
349     m_didStartDownload.userData = userData;
350 }
351
352 void Ewk_Context::didStartDownload(WKStringRef downloadURL)
353 {
354     EINA_SAFETY_ON_NULL_RETURN(m_didStartDownload.callback);
355
356     m_didStartDownload.callback(toImpl(downloadURL)->string().utf8().data(), m_didStartDownload.userData);
357 }
358
359 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
360 void Ewk_Context::clearAllDecodedData()
361 {
362     WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(wkContext());
363     WKResourceCacheManagerClearCacheForAllOrigins(cacheManager, WKResourceCachesToClearInDecodedDataOnly);
364 }
365 #endif
366
367 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
368 Ecore_X_Window Ewk_Context::xWindow()
369 {
370     return m_xWindow;
371 }
372
373 void Ewk_Context::setXWindow(Ecore_X_Window xWindow)
374 {
375     toImpl(wkContext())->setXWindow(xWindow);
376 }
377 #endif
378
379 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
380 void Ewk_Context::addFormData(const char* url, WKDictionaryRef& formData, bool isPasswordForm)
381 {
382     EINA_SAFETY_ON_NULL_RETURN(url);
383     if (!m_formDatabase->isOpen())
384         return;
385
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));
392
393         formDataVector.append(pair<String, String>(toImpl(wkKey)->string(), toImpl(wkValue)->string()));
394     }
395
396     m_formDatabase->addFormDataForURL(String::fromUTF8(url), formDataVector, isPasswordForm);
397 }
398
399 void Ewk_Context::passwordFormData(const char* url, Vector<std::pair<String, String> >& passwordFormData)
400 {
401     EINA_SAFETY_ON_NULL_RETURN(url);
402     if (!m_formDatabase->isOpen())
403         return;
404     m_formDatabase->getPasswordFormDataForURL(String::fromUTF8(url), passwordFormData);
405 }
406
407 void Ewk_Context::candidateFormData(const String& name, Vector<String>& candidates)
408 {
409     if (!m_formDatabase->isOpen())
410         return;
411     m_formDatabase->getCandidateFormDataForName(name, candidates);
412 }
413
414 void Ewk_Context::clearPasswordFormData()
415 {
416     m_formDatabase->clearPasswordFormData();
417 }
418
419 void Ewk_Context::clearCandidateFormData()
420 {
421     m_formDatabase->clearCandidateFormData();
422 }
423
424 #endif
425
426 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
427 /**
428  * @internal
429  * Request WebProcess to dump cache.
430  *
431  * This sends sync message to WebProcess to dump memory cache, that is, soup cache.
432  *
433  * @param context context object
434  *
435  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
436  *
437  * @note This can effect UIProcess's performance because it calls to sync IPC message eventually.
438  */
439 void Ewk_Context::dumpCache()
440 {
441     WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(wkContext());
442     toImpl(cacheManager)->dumpCache();
443 }
444 #endif
445 #endif
446
447 Ewk_Context* ewk_context_default_get()
448 {
449     return Ewk_Context::defaultContext().get();
450 }
451
452 #if OS(TIZEN)
453 typedef struct Ewk_Context_Callback_Context
454 {
455     union {
456 #if ENABLE(TIZEN_FILE_SYSTEM)
457         Ewk_Local_File_System_Origins_Get_Callback localFileSystemOriginsCallback;
458 #endif
459         Ewk_Web_Application_Cache_Origins_Get_Callback webApplicationCacheOriginsCallback;
460         Ewk_Web_Application_Cache_Quota_Get_Callback webApplicationCacheQuotaCallback;
461         Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback webApplicationCacheUsageForOriginCallback;
462         Ewk_Web_Application_Cache_Path_Get_Callback webApplicationCachePathCallback;
463         Ewk_Web_Database_Origins_Get_Callback webDatabaseOriginsCallback;
464         Ewk_Web_Database_Quota_Get_Callback webDatabaseQuotaCallback;
465         Ewk_Web_Database_Usage_Get_Callback webDatabaseUsageCallback;
466         Ewk_Web_Database_Path_Get_Callback webDatabasePathCallback;
467         Ewk_Web_Storage_Origins_Get_Callback webStorageOriginsCallback;
468         Ewk_Web_Storage_Usage_Get_Callback webStorageUsageCallback;
469         Ewk_Web_Storage_Path_Get_Callback webStoragePathCallback;
470     };
471     void* userData;
472 } Ewk_Context_Callback_Context;
473
474 #if ENABLE(TIZEN_SQL_DATABASE)
475 struct Ewk_Context_Exceeded_Quota
476 {
477     Ewk_Security_Origin* origin;
478     const char* databaseName;
479     const char* displayName;
480     unsigned long long currentQuota;
481     unsigned long long currentOriginUsage;
482     unsigned long long currentDatabaseUsage;
483     unsigned long long expectedUsage;
484     unsigned long long newQuota;
485 };
486 #endif
487
488 #if ENABLE(TIZEN_SQL_DATABASE)
489 Ewk_Context_Exceeded_Quota* ewkContextCreateExceededQuota(WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage)
490 {
491     Ewk_Context_Exceeded_Quota* exceededQuota = new Ewk_Context_Exceeded_Quota();
492
493     int length = WKStringGetMaximumUTF8CStringSize(databaseName);
494     OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
495     WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
496
497     length = WKStringGetMaximumUTF8CStringSize(displayName);
498     OwnArrayPtr<char> displayNameBuffer = adoptArrayPtr(new char[length]);
499     WKStringGetUTF8CString(displayName, displayNameBuffer.get(), length);
500
501     exceededQuota->origin = createSecurityOrigin(origin);
502     exceededQuota->databaseName = eina_stringshare_add(databaseNameBuffer.get());
503     exceededQuota->displayName = eina_stringshare_add(displayNameBuffer.get());
504     exceededQuota->currentQuota = currentQuota;
505     exceededQuota->currentOriginUsage = currentOriginUsage;
506     exceededQuota->currentDatabaseUsage = currentDatabaseUsage;
507     exceededQuota->expectedUsage = expectedUsage;
508
509     return exceededQuota;
510 }
511
512 void ewkContextDeleteExceededQuota(Ewk_Context_Exceeded_Quota* exceededQuota)
513 {
514     deleteSecurityOrigin(exceededQuota->origin);
515     eina_stringshare_del(exceededQuota->databaseName);
516     eina_stringshare_del(exceededQuota->displayName);
517     delete exceededQuota;
518 }
519
520 unsigned long long ewkContextGetNewQuotaForExceededQuota(Ewk_Context* ewkContext, Ewk_Context_Exceeded_Quota* exceededQuota)
521 {
522     if (exceededQuota->newQuota)
523         return exceededQuota->newQuota + exceededQuota->currentQuota;
524
525     if (exceededQuota->currentQuota)
526         return exceededQuota->currentQuota;
527
528     return ewkContext->defaultDatabaseQuota();
529 }
530
531 uint64_t ewkContextGetDatabaseQuota(Ewk_Context* ewkContext)
532 {
533     return ewkContext->defaultDatabaseQuota();
534 }
535 #endif
536
537 /* public */
538 Ewk_Context* ewk_context_new()
539 {
540 #if OS(TIZEN)
541     Ewk_Context* ewk_context = Ewk_Context::create().leakRef();
542     ewkContextInjectedBundleClientAttachClient(ewk_context);
543     return ewk_context;
544 #endif
545     return Ewk_Context::create().leakRef();
546 }
547
548 Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path)
549 {
550     EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
551
552 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
553     // FIXME : OpenGL check code for WRT before launching WebProcess.
554     if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
555         EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
556         return 0;
557     }
558 #endif
559
560 #if ENABLE(TIZEN_WRT_LAUNCHING_PERFORMANCE)
561     char* wrtLaunchingPerformance = getenv("WRT_LAUNCHING_PERFORMANCE");
562     if (wrtLaunchingPerformance && !strcmp(wrtLaunchingPerformance, "1")) {
563         static bool firstTime = true;
564         if (firstTime) {
565             firstTime = false;
566
567             if (ProcessLauncher::isInitialFork())
568                 ProcessLauncher::setSkipExec(true);
569             else
570                 ProcessLauncher::setSkipExec(false);
571
572             ProcessLauncher::forkProcess();
573
574             if (ProcessLauncher::isParentProcess()) {
575                 Ewk_Context* ewkContext = ewk_context_new_with_injected_bundle_path(path);
576                 WKContextRef contextRef = ewkContext->wkContext();
577                 toImpl(contextRef)->ensureWebProcess();
578                 return ewkContext;
579             }
580             else if (ProcessLauncher::isChildProcess()) {
581                 ProcessLauncher::callWebProcessMain();
582                 exit(0);
583             }
584
585             ASSERT_NOT_REACHED();
586             return 0;
587         }
588     }
589 #endif
590
591 #if OS(TIZEN)
592     Ewk_Context* ewk_context = Ewk_Context::create(String::fromUTF8(path)).leakRef();
593     ewkContextInjectedBundleClientAttachClient(ewk_context);
594     return ewk_context;
595 #endif
596     return Ewk_Context::create(String::fromUTF8(path)).leakRef();
597 }
598
599 void ewk_context_delete(Ewk_Context* ewkContext)
600 {
601     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
602     if (ewkContext == ewk_context_default_get() && ewkContext->hasOneRef())
603         return;
604
605     delete ewkContext;
606 }
607
608 void ewk_context_proxy_uri_set(Ewk_Context* ewkContext, const char* proxy)
609 {
610     if (ewkContext && ewkContext->setProxyAddress(proxy)) {
611         WKRetainPtr<WKURLRef> proxyAddress(AdoptWK, WKURLCreateWithUTF8CString(proxy));
612
613         WKContextRef contextRef = ewkContext->wkContext();
614         toImpl(contextRef)->setProxy(toWTFString(proxyAddress.get()));
615     }
616 }
617
618 const char* ewk_context_proxy_uri_get(Ewk_Context* ewkContext)
619 {
620 #if ENABLE(TIZEN_WEBKIT2_PATCH_FOR_TC)
621     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
622 #endif
623     return ewkContext->proxyAddress();
624 }
625
626 void ewk_context_network_session_requests_cancel(Ewk_Context* ewkContext)
627 {
628     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
629
630     WKContextRef contextRef = ewkContext->wkContext();
631     toImpl(contextRef)->abortSession();
632 }
633
634 Eina_Bool ewk_context_notify_low_memory(Ewk_Context* ewkContext)
635 {
636     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
637
638     WKContextRef contextRef = ewkContext->wkContext();
639     toImpl(contextRef)->notifyLowMemory();
640     return true;
641 }
642
643 #if ENABLE(TIZEN_FILE_SYSTEM)
644 static void didGetLocalFileSystemOrigins(WKArrayRef origins, WKErrorRef error, void* context)
645 {
646     Eina_List* originList = 0;
647     for (size_t i = 0; i < WKArrayGetSize(origins); ++i) {
648         WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
649         Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
650         originList = eina_list_append(originList, origin);
651     }
652
653     Ewk_Context_Callback_Context* locaFileSystemContext = static_cast<Ewk_Context_Callback_Context*>(context);
654     locaFileSystemContext->localFileSystemOriginsCallback(originList, locaFileSystemContext->userData);
655     delete locaFileSystemContext;
656 }
657 #endif
658
659 #if ENABLE(TIZEN_APPLICATION_CACHE)
660 static void didGetWebApplicationOrigins(WKArrayRef origins, WKErrorRef error, void* context)
661 {
662     TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
663     Eina_List* originList = 0;
664
665     for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
666         WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
667         Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
668         originList = eina_list_append(originList, origin);
669     }
670
671     Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
672     applicationCacheContext->webApplicationCacheOriginsCallback(originList, applicationCacheContext->userData);
673     delete applicationCacheContext;
674 }
675
676 static void didGetWebApplicationPath(WKStringRef path, WKErrorRef error, void* context)
677 {
678     Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
679
680     int length = WKStringGetMaximumUTF8CStringSize(path);
681     OwnArrayPtr<char> applicationCachePath = adoptArrayPtr(new char[length]);
682     WKStringGetUTF8CString(path, applicationCachePath.get(), length);
683
684     TIZEN_LOGI("path (%s)", applicationCachePath.get());
685     applicationCacheContext->webApplicationCachePathCallback(eina_stringshare_add(applicationCachePath.get()), applicationCacheContext->userData);
686     delete applicationCacheContext;
687 }
688
689 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
690 static void didGetWebApplicationQuota(WKInt64Ref quota, WKErrorRef error, void* context)
691 {
692     Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
693     TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
694     applicationCacheContext->webApplicationCacheQuotaCallback(toImpl(quota)->value(), applicationCacheContext->userData);
695     delete applicationCacheContext;
696 }
697
698 static void didGetWebApplicationUsageForOrigin(WKInt64Ref usage, WKErrorRef error, void* context)
699 {
700     Ewk_Context_Callback_Context* applicationCacheContext = static_cast<Ewk_Context_Callback_Context*>(context);
701     TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
702     applicationCacheContext->webApplicationCacheUsageForOriginCallback(toImpl(usage)->value(), applicationCacheContext->userData);
703     delete applicationCacheContext;
704 }
705 #endif
706 #endif
707
708 #if ENABLE(TIZEN_SQL_DATABASE)
709 static void didGetWebDatabaseOrigins(WKArrayRef origins, WKErrorRef error, void* context)
710 {
711     TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
712     Eina_List* originList = 0;
713
714     for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
715         WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
716         Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
717         originList = eina_list_append(originList, origin);
718     }
719
720     Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
721     webDatabaseContext->webDatabaseOriginsCallback(originList, webDatabaseContext->userData);
722     delete webDatabaseContext;
723 }
724
725 static void didGetWebDatabaseQuota(WKUInt64Ref quota, WKErrorRef error, void* context)
726 {
727     Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
728     TIZEN_LOGI("quota (%d)", toImpl(quota)->value());
729     webDatabaseContext->webDatabaseQuotaCallback(toImpl(quota)->value(), webDatabaseContext->userData);
730     delete webDatabaseContext;
731 }
732
733 static void didGetWebDatabaseUsage(WKUInt64Ref usage, WKErrorRef error, void* context)
734 {
735     Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
736     TIZEN_LOGI("usage (%d)", toImpl(usage)->value());
737     webDatabaseContext->webDatabaseUsageCallback(toImpl(usage)->value(), webDatabaseContext->userData);
738     delete webDatabaseContext;
739 }
740
741 static void didGetWebDatabasePath(WKStringRef path, WKErrorRef error, void * context)
742 {
743     Ewk_Context_Callback_Context* webDatabaseContext = static_cast<Ewk_Context_Callback_Context*>(context);
744
745     int length = WKStringGetMaximumUTF8CStringSize(path);
746     OwnArrayPtr<char> databasePath = adoptArrayPtr(new char[length]);
747     WKStringGetUTF8CString(path, databasePath.get(), length);
748
749     TIZEN_LOGI("path (%s)", databasePath.get());
750     webDatabaseContext->webDatabasePathCallback(eina_stringshare_add(databasePath.get()), webDatabaseContext->userData);
751     delete webDatabaseContext;
752 }
753 #endif
754
755 #if ENABLE(TIZEN_WEB_STORAGE)
756 static void didGetWebStorageOrigins(WKArrayRef origins, WKErrorRef error, void* context)
757 {
758     TIZEN_LOGI("origin size(%d)", WKArrayGetSize(origins));
759     Eina_List* originList = 0;
760
761     for(size_t i = 0; i < WKArrayGetSize(origins); i++) {
762         WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i));
763         Ewk_Security_Origin* origin = createSecurityOrigin(securityOriginRef);
764         originList = eina_list_append(originList, origin);
765     }
766
767     Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
768     webStorageContext->webStorageOriginsCallback(originList, webStorageContext->userData);
769     delete webStorageContext;
770 }
771
772 static void didGetWebStoragePath(WKStringRef path, WKErrorRef error, void * context)
773 {
774     Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
775
776     int length = WKStringGetMaximumUTF8CStringSize(path);
777     OwnArrayPtr<char> storagePath = adoptArrayPtr(new char[length]);
778     WKStringGetUTF8CString(path, storagePath.get(), length);
779
780     TIZEN_LOGI("path (%s)", storagePath.get());
781     webStorageContext->webStoragePathCallback(eina_stringshare_add(storagePath.get()), webStorageContext->userData);
782     delete webStorageContext;
783 }
784
785 #if ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
786 static void didGetWebStorageUsage(WKInt64Ref usage, WKErrorRef error, void* context)
787 {
788     Ewk_Context_Callback_Context* webStorageContext = static_cast<Ewk_Context_Callback_Context*>(context);
789
790     TIZEN_LOGI("usage (%s)", toImpl(usage)->value());
791     webStorageContext->webStorageUsageCallback(toImpl(usage)->value(), webStorageContext->userData);
792     delete webStorageContext;
793 }
794 #endif
795
796 #endif
797
798 Eina_Bool ewk_context_origins_free(Eina_List* originList)
799 {
800     EINA_SAFETY_ON_NULL_RETURN_VAL(originList, false);
801
802     void* currentOrigin;
803     EINA_LIST_FREE(originList, currentOrigin) {
804         Ewk_Security_Origin* origin = static_cast<Ewk_Security_Origin*>(currentOrigin);
805         deleteSecurityOrigin(origin);
806     }
807
808     return true;
809 }
810
811 Eina_Bool ewk_context_application_cache_delete_all(Ewk_Context* ewkContext)
812 {
813 #if ENABLE(TIZEN_APPLICATION_CACHE)
814     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
815
816     TIZEN_LOGI("ewkContext (%p)", ewkContext);
817     WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
818     WKApplicationCacheManagerDeleteAllEntries(applicationCache);
819
820     return true;
821 #else
822     return false;
823 #endif
824 }
825
826 Eina_Bool ewk_context_application_cache_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
827 {
828 #if ENABLE(TIZEN_APPLICATION_CACHE)
829     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
830     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
831
832     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
833     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
834     WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
835     WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
836     WKApplicationCacheManagerDeleteEntriesForOrigin(applicationCacheRef, securityOriginRef.get());
837
838     return true;
839 #else
840     return false;
841 #endif
842 }
843
844 Eina_Bool ewk_context_application_cache_origins_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Origins_Get_Callback callback, void *userData)
845 {
846 #if ENABLE(TIZEN_APPLICATION_CACHE)
847     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
848     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
849
850     TIZEN_LOGI("ewkContext (%p)", ewkContext);
851     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
852     context->webApplicationCacheOriginsCallback = callback;
853     context->userData = userData;
854
855     WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
856     WKApplicationCacheManagerGetApplicationCacheOrigins(applicationCacheRef, context, didGetWebApplicationOrigins);
857
858     return true;
859 #else
860     return false;
861 #endif
862 }
863
864 Eina_Bool ewk_context_application_cache_path_set(Ewk_Context* ewkContext, const char* path)
865 {
866 #if ENABLE(TIZEN_APPLICATION_CACHE)
867     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
868     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
869
870     if (!path) {
871         TIZEN_LOGE("Path value is invalid");
872         return false;
873     }
874
875     TIZEN_LOGI("path (%s)", path);
876     WKRetainPtr<WKStringRef> applicationCachePathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
877     WKContextSetApplicationCacheDirectory(ewkContext->wkContext(), applicationCachePathRef.get());
878
879     return true;
880 #else
881     return false;
882 #endif
883 }
884
885 Eina_Bool ewk_context_application_cache_path_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Path_Get_Callback callback, void* userData)
886 {
887 #if ENABLE(TIZEN_APPLICATION_CACHE)
888     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
889     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
890
891     TIZEN_LOGI("callback (%p)", callback);
892     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
893     context->webApplicationCachePathCallback= callback;
894     context->userData = userData;
895
896     WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
897     WKApplicationCacheManagerGetApplicationCachePath(applicationCacheRef, context, didGetWebApplicationPath);
898     return true;
899 #else
900     return false;
901 #endif
902 }
903
904 Eina_Bool ewk_context_application_cache_quota_get(Ewk_Context* ewkContext, Ewk_Web_Application_Cache_Quota_Get_Callback callback, void* userData)
905 {
906 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
907     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
908     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
909
910     TIZEN_LOGI("callback (%p)", callback);
911     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
912     context->webApplicationCacheQuotaCallback = callback;
913     context->userData = userData;
914
915     WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
916     WKApplicationCacheManagerGetApplicationCacheQuota(applicationCacheRef, context, didGetWebApplicationQuota);
917
918     return true;
919 #else
920     return false;
921 #endif
922 }
923
924 Eina_Bool ewk_context_application_cache_usage_for_origin_get(Ewk_Context* ewkContext, const Ewk_Security_Origin* origin, Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback callback, void* userData)
925 {
926 #if ENABLE(TIZEN_APPLICATION_CACHE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
927     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
928     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
929     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
930
931     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
932     context->webApplicationCacheUsageForOriginCallback = callback;
933     context->userData = userData;
934     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
935     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
936     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
937
938     WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
939     WKApplicationCacheManagerGetApplicationCacheUsageForOrigin(applicationCache, context, originRef.get(), didGetWebApplicationUsageForOrigin);
940
941     return true;
942 #else
943     return false;
944 #endif
945 }
946
947 Eina_Bool ewk_context_application_cache_quota_set(Ewk_Context* ewkContext, int64_t quota)
948 {
949 #if ENABLE(TIZEN_APPLICATION_CACHE)
950     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
951     if (!quota) {
952         TIZEN_LOGE("Quota value is invalid");
953         return false;
954     }
955
956     TIZEN_LOGI("quota (%d)", quota);
957     WKApplicationCacheManagerRef applicationCacheRef = WKContextGetApplicationCacheManager(ewkContext->wkContext());
958     WKApplicationCacheManagerSetApplicationCacheQuota(applicationCacheRef, quota);
959
960     return true;
961 #else
962     return false;
963 #endif
964 }
965
966 Eina_Bool ewk_context_application_cache_quota_for_origin_set(Ewk_Context* ewkContext, const Ewk_Security_Origin* origin, int64_t quota)
967 {
968 #if ENABLE(TIZEN_APPLICATION_CACHE)
969     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
970     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
971     if (!quota) {
972         TIZEN_LOGE("Quota value is invalid");
973         return false;
974     }
975
976     TIZEN_LOGI("quota (%d)", quota);
977     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
978     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
979     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
980
981     WKApplicationCacheManagerRef applicationCache = WKContextGetApplicationCacheManager(ewkContext->wkContext());
982     WKApplicationCacheManagerSetApplicationCacheQuotaForOrigin(applicationCache, originRef.get(), quota);
983
984     return true;
985 #else
986     return false;
987 #endif
988 }
989
990
991 Eina_Bool ewk_context_icon_database_path_set(Ewk_Context* ewkContext, const char* path)
992 {
993     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
994     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
995
996     WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
997     WKContextSetIconDatabasePath(ewkContext->wkContext(), databasePath.get());
998
999     return true;
1000 }
1001
1002 Evas_Object* ewk_context_icon_database_icon_object_add(Ewk_Context* ewkContext, const char* uri, Evas* canvas)
1003 {
1004     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
1005     EINA_SAFETY_ON_NULL_RETURN_VAL(uri, 0);
1006     EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1007
1008     WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1009     WKRetainPtr<WKURLRef> urlString(AdoptWK, WKURLCreateWithUTF8CString(uri));
1010
1011     return WKIconDatabaseTryGetImageForURL(iconDatabase, canvas, urlString.get());
1012 }
1013
1014 void ewk_context_icon_database_delete_all(Ewk_Context* ewkContext)
1015 {
1016     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1017
1018     WKIconDatabaseRef iconDatabase = WKContextGetIconDatabase(ewkContext->wkContext());
1019     WKIconDatabaseRemoveAllIcons(iconDatabase);
1020 }
1021
1022 Eina_Bool ewk_context_local_file_system_path_set(Ewk_Context* ewkContext, const char* path)
1023 {
1024 #if ENABLE(TIZEN_FILE_SYSTEM)
1025     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1026     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1027
1028     TIZEN_LOGI("path (%s)", path);
1029     WKRetainPtr<WKStringRef> localFileSystemPathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
1030     WKContextSetLocalFileSystemDirectory(ewkContext->wkContext(), localFileSystemPathRef.get());
1031
1032     return true;
1033 #else
1034     return false;
1035 #endif
1036 }
1037
1038 Eina_Bool ewk_context_local_file_system_all_delete(Ewk_Context* ewkContext)
1039 {
1040 #if ENABLE(TIZEN_FILE_SYSTEM)
1041     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1042
1043     TIZEN_LOGI("ewkContex (%p)", ewkContext);
1044     WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1045     WKLocalFileSystemManagerDeleteAllLocalFileSystem(localFileSystemManager);
1046
1047     return true;
1048 #else
1049     UNUSED_PARAM(ewkContext);
1050
1051     return false;
1052 #endif
1053 }
1054
1055 Eina_Bool ewk_context_local_file_system_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1056 {
1057 #if ENABLE(TIZEN_FILE_SYSTEM)
1058     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1059     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1060
1061     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1062     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1063     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1064     WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(ewkContext->wkContext());
1065
1066     WKLocalFileSystemManagerDeleteLocalFileSystem(localFileSystemManager, originRef.get());
1067
1068     return true;
1069 #else
1070     UNUSED_PARAM(ewkContext);
1071     UNUSED_PARAM(origin);
1072
1073     return false;
1074 #endif
1075 }
1076
1077 Eina_Bool ewk_context_local_file_system_origins_get(const Ewk_Context* ewkContext, Ewk_Local_File_System_Origins_Get_Callback callback, void* userData)
1078 {
1079 #if ENABLE(TIZEN_FILE_SYSTEM)
1080     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1081     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1082
1083     TIZEN_LOGI("callback (%p)", callback);
1084     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1085     context->localFileSystemOriginsCallback= callback;
1086     context->userData = userData;
1087     WKLocalFileSystemManagerRef localFileSystemManager = WKContextGetLocalFileSystemManager(const_cast<Ewk_Context*>(ewkContext)->wkContext());
1088
1089     WKLocalFileSystemManagerGetLocalFileSystemOrigins(localFileSystemManager, context, didGetLocalFileSystemOrigins);
1090
1091     return true;
1092 #else
1093     UNUSED_PARAM(ewkContext);
1094     UNUSED_PARAM(callback);
1095     UNUSED_PARAM(userData);
1096
1097     return false;
1098 #endif
1099 }
1100
1101 Ewk_Security_Origin* ewk_context_web_database_exceeded_quota_security_origin_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1102 {
1103 #if ENABLE(TIZEN_SQL_DATABASE)
1104     EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1105
1106     return exceededQuota->origin;
1107 #else
1108     return 0;
1109 #endif
1110 }
1111
1112 const char* ewk_context_web_database_exceeded_quota_database_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1113 {
1114 #if ENABLE(TIZEN_SQL_DATABASE)
1115     EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1116
1117     TIZEN_LOGI("name (%s)", exceededQuota->databaseName);
1118     return exceededQuota->databaseName;
1119 #else
1120     return 0;
1121 #endif
1122 }
1123
1124 const char* ewk_context_web_database_exceeded_quota_display_name_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1125 {
1126 #if ENABLE(TIZEN_SQL_DATABASE)
1127     EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1128
1129     TIZEN_LOGI("displayName (%s)", exceededQuota->displayName);
1130     return exceededQuota->displayName;
1131 #else
1132     return 0;
1133 #endif
1134 }
1135
1136 unsigned long long ewk_context_web_database_exceeded_quota_current_quota_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1137 {
1138 #if ENABLE(TIZEN_SQL_DATABASE)
1139     EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1140
1141     TIZEN_LOGI("quota (%d)", exceededQuota->currentQuota);
1142     return exceededQuota->currentQuota;
1143 #else
1144     return 0;
1145 #endif
1146 }
1147
1148 unsigned long long ewk_context_web_database_exceeded_quota_current_origin_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1149 {
1150 #if ENABLE(TIZEN_SQL_DATABASE)
1151     EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1152
1153     TIZEN_LOGI("currentOriginUsage (%d)", exceededQuota->currentOriginUsage);
1154     return exceededQuota->currentOriginUsage;
1155 #else
1156     return 0;
1157 #endif
1158 }
1159
1160 unsigned long long ewk_context_web_database_exceeded_quota_current_database_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1161 {
1162 #if ENABLE(TIZEN_SQL_DATABASE)
1163     EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1164
1165     TIZEN_LOGI("currentDatabaseUsage (%d)", exceededQuota->currentDatabaseUsage);
1166     return exceededQuota->currentDatabaseUsage;
1167 #else
1168     return 0;
1169 #endif
1170 }
1171
1172 unsigned long long ewk_context_web_database_exceeded_quota_expected_usage_get(Ewk_Context_Exceeded_Quota* exceededQuota)
1173 {
1174 #if ENABLE(TIZEN_SQL_DATABASE)
1175     EINA_SAFETY_ON_NULL_RETURN_VAL(exceededQuota, 0);
1176
1177     TIZEN_LOGI("expectedUsage (%d)", exceededQuota->expectedUsage);
1178     return exceededQuota->expectedUsage;
1179 #else
1180     return 0;
1181 #endif
1182 }
1183
1184 void ewk_context_web_database_exceeded_quota_new_quota_set(Ewk_Context_Exceeded_Quota* exceededQuota, unsigned long long quota)
1185 {
1186 #if ENABLE(TIZEN_SQL_DATABASE)
1187     EINA_SAFETY_ON_NULL_RETURN(exceededQuota);
1188
1189     TIZEN_LOGI("quota (%d)", quota);
1190     exceededQuota->newQuota = quota;
1191 #endif
1192 }
1193
1194 Eina_Bool ewk_context_web_database_delete_all(Ewk_Context* ewkContext)
1195 {
1196 #if ENABLE(TIZEN_SQL_DATABASE)
1197     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1198
1199     TIZEN_LOGI("ewkContext (%p)", ewkContext);
1200     WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1201     WKDatabaseManagerDeleteAllDatabases(databaseManager);
1202
1203     return true;
1204 #else
1205     return false;
1206 #endif
1207 }
1208
1209 Eina_Bool ewk_context_web_database_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1210 {
1211 #if ENABLE(TIZEN_SQL_DATABASE)
1212     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1213     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1214
1215     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1216     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1217     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1218     WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1219     WKDatabaseManagerDeleteDatabasesForOrigin(databaseManager, originRef.get());
1220
1221     return true;
1222 #else
1223     return false;
1224 #endif
1225 }
1226
1227 Eina_Bool ewk_context_web_database_origins_get(Ewk_Context* ewkContext, Ewk_Web_Database_Origins_Get_Callback callback, void* userData)
1228 {
1229 #if ENABLE(TIZEN_SQL_DATABASE)
1230     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1231     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1232
1233     TIZEN_LOGI("callback (%p)", callback);
1234     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1235     context->webDatabaseOriginsCallback = callback;
1236     context->userData = userData;
1237
1238     WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1239     WKDatabaseManagerGetDatabaseOrigins(databaseManager, context, didGetWebDatabaseOrigins);
1240
1241     return true;
1242 #else
1243     return false;
1244 #endif
1245 }
1246
1247 Eina_Bool ewk_context_web_database_path_set(Ewk_Context* ewkContext, const char* path)
1248 {
1249 #if ENABLE(TIZEN_SQL_DATABASE)
1250     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1251     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1252
1253     TIZEN_LOGI("path (%s)", path);
1254     WKRetainPtr<WKStringRef> databasePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1255     WKContextSetDatabaseDirectory(ewkContext->wkContext(), databasePath.get());
1256
1257     return true;
1258 #else
1259     return false;
1260 #endif
1261 }
1262
1263 Eina_Bool ewk_context_web_database_path_get(Ewk_Context* ewkContext, Ewk_Web_Database_Path_Get_Callback callback, void* userData)
1264 {
1265 #if ENABLE(TIZEN_WEB_STORAGE)
1266     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1267     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1268
1269     TIZEN_LOGI("callback (%p)", callback);
1270     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1271     context->webDatabasePathCallback= callback;
1272     context->userData = userData;
1273
1274     WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1275     WKDatabaseManagerGetDatabasePath(databaseManager, context, didGetWebDatabasePath);
1276     return true;
1277 #else
1278     return false;
1279 #endif
1280 }
1281 Eina_Bool ewk_context_web_database_quota_for_origin_get(Ewk_Context* ewkContext, Ewk_Web_Database_Quota_Get_Callback callback, void* userData, Ewk_Security_Origin* origin)
1282 {
1283 #if ENABLE(TIZEN_SQL_DATABASE)
1284     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1285     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1286     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1287
1288     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1289     context->webDatabaseQuotaCallback = callback;
1290     context->userData = userData;
1291
1292     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1293     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1294     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1295     WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1296     WKDatabaseManagerGetQuotaForOrigin(databaseManager, context, didGetWebDatabaseQuota, originRef.get());
1297
1298     return true;
1299 #else
1300     return false;
1301 #endif
1302 }
1303
1304 Eina_Bool ewk_context_web_database_default_quota_set(Ewk_Context* ewkContext, uint64_t quota)
1305 {
1306 #if ENABLE(TIZEN_SQL_DATABASE)
1307     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1308
1309     TIZEN_LOGI("quota (%d)", quota);
1310     ewkContext->setDefaultDatabaseQuota(quota);
1311
1312     return true;
1313 #else
1314     return false;
1315 #endif
1316 }
1317
1318 Eina_Bool ewk_context_web_database_quota_for_origin_set(Ewk_Context* ewkContext, Ewk_Security_Origin* origin, uint64_t quota)
1319 {
1320 #if ENABLE(TIZEN_SQL_DATABASE)
1321     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1322     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1323
1324     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1325     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1326     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1327     WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1328     WKDatabaseManagerSetQuotaForOrigin(databaseManager, originRef.get(), quota);
1329
1330     return true;
1331 #else
1332     return false;
1333 #endif
1334 }
1335
1336 Eina_Bool ewk_context_web_database_usage_for_origin_get(Ewk_Context* ewkContext, Ewk_Web_Database_Quota_Get_Callback callback, void* userData, Ewk_Security_Origin* origin)
1337 {
1338 #if ENABLE(TIZEN_SQL_DATABASE)
1339     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1340     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1341     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1342
1343     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1344     context->webDatabaseQuotaCallback = callback;
1345     context->userData = userData;
1346
1347     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1348     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1349     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1350     WKDatabaseManagerRef databaseManager = WKContextGetDatabaseManager(ewkContext->wkContext());
1351     WKDatabaseManagerGetUsageForOrigin(databaseManager, context, didGetWebDatabaseUsage, originRef.get());
1352
1353     return true;
1354 #else
1355     return false;
1356 #endif
1357 }
1358
1359 Eina_Bool ewk_context_web_indexed_database_delete_all(Ewk_Context* ewkContext)
1360 {
1361 #if ENABLE(TIZEN_INDEXED_DATABASE)
1362     WKContextDeleteIndexedDatabaseAll(ewkContext->wkContext());
1363
1364     return true;
1365 #else
1366     return false;
1367 #endif
1368 }
1369
1370 Eina_Bool ewk_context_web_storage_delete_all(Ewk_Context* ewkContext)
1371 {
1372 #if ENABLE(TIZEN_WEB_STORAGE)
1373     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1374
1375     TIZEN_LOGI("ewkContext (%p)", ewkContext);
1376     WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1377     WKKeyValueStorageManagerDeleteAllEntries(storageManager);
1378
1379     return true;
1380 #else
1381     return false;
1382 #endif
1383 }
1384
1385 Eina_Bool ewk_context_web_storage_origin_delete(Ewk_Context* ewkContext, Ewk_Security_Origin* origin)
1386 {
1387 #if ENABLE(TIZEN_WEB_STORAGE)
1388     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1389     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1390
1391     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1392     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1393     WKRetainPtr<WKSecurityOriginRef> securityOriginRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1394     WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1395     WKKeyValueStorageManagerDeleteEntriesForOrigin(storageManager, securityOriginRef.get());
1396
1397     return true;
1398 #else
1399     return false;
1400 #endif
1401 }
1402
1403 Eina_Bool ewk_context_web_storage_origins_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Origins_Get_Callback callback, void* userData)
1404 {
1405 #if ENABLE(TIZEN_WEB_STORAGE)
1406     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1407     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1408
1409     TIZEN_LOGI("callback (%p)", callback);
1410     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1411     context->webStorageOriginsCallback = callback;
1412     context->userData = userData;
1413
1414     WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1415     WKKeyValueStorageManagerGetKeyValueStorageOrigins(storageManager, context, didGetWebStorageOrigins);
1416
1417     return true;
1418 #else
1419     return false;
1420 #endif
1421 }
1422
1423 Eina_Bool ewk_context_web_storage_path_set(Ewk_Context* ewkContext, const char* path)
1424 {
1425 #if ENABLE(TIZEN_WEB_STORAGE)
1426     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1427     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1428
1429     TIZEN_LOGI("path (%s)", path);
1430     WKRetainPtr<WKStringRef> webStoragePath(AdoptWK, WKStringCreateWithUTF8CString(path));
1431     WKContextSetLocalStorageDirectory(ewkContext->wkContext(), webStoragePath.get());
1432
1433     return true;
1434 #else
1435     return false;
1436 #endif
1437 }
1438
1439 Eina_Bool ewk_context_web_storage_path_get(Ewk_Context* ewkContext, Ewk_Web_Storage_Path_Get_Callback callback, void* userData)
1440 {
1441 #if ENABLE(TIZEN_WEB_STORAGE)
1442     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1443     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1444
1445     TIZEN_LOGI("callback (%p)", callback);
1446     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1447     context->webStoragePathCallback= callback;
1448     context->userData = userData;
1449
1450     WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1451     WKKeyValueStorageManagerGetKeyValueStoragePath(storageManager, context, didGetWebStoragePath);
1452     return true;
1453 #else
1454     return false;
1455 #endif
1456 }
1457 Eina_Bool ewk_context_web_storage_usage_for_origin_get(Ewk_Context* ewkContext, Ewk_Security_Origin* origin, Ewk_Web_Storage_Usage_Get_Callback callback, void* userData)
1458 {
1459 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
1460     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1461     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1462     EINA_SAFETY_ON_NULL_RETURN_VAL(origin, false);
1463
1464     Ewk_Context_Callback_Context* context = new Ewk_Context_Callback_Context;
1465     context->webStorageUsageCallback = callback;
1466     context->userData = userData;
1467     WKRetainPtr<WKStringRef> protocolRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_protocol_get(origin)));
1468     WKRetainPtr<WKStringRef> hostRef(AdoptWK, WKStringCreateWithUTF8CString(ewk_security_origin_host_get(origin)));
1469     WKRetainPtr<WKSecurityOriginRef> originRef(AdoptWK, WKSecurityOriginCreate(protocolRef.get(), hostRef.get(), ewk_security_origin_port_get(origin)));
1470
1471     WKKeyValueStorageManagerRef storageManager = WKContextGetKeyValueStorageManager(ewkContext->wkContext());
1472     WKKeyValueStorageManagerGetKeyValueStorageUsageForOrigin(storageManager, context, didGetWebStorageUsage, originRef.get());
1473
1474     return true;
1475 #else
1476     return false;
1477 #endif
1478 }
1479
1480 //#if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
1481 Eina_Bool ewk_context_soup_data_directory_set(Ewk_Context* ewkContext, const char* path)
1482 {
1483     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1484     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1485
1486     WKRetainPtr<WKStringRef> soupDataDirectory(AdoptWK, WKStringCreateWithUTF8CString(path));
1487     WKContextSetSoupDataDirectory(ewkContext->wkContext(), soupDataDirectory.get());
1488     return true;
1489 }
1490 //#endif
1491
1492 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_VIEWER, kWKCacheModelDocumentViewer);
1493 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_BROWSER, kWKCacheModelDocumentBrowser);
1494 COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, kWKCacheModelPrimaryWebBrowser);
1495
1496 Eina_Bool ewk_context_cache_model_set(Ewk_Context* ewkContext, Ewk_Cache_Model cacheModel)
1497 {
1498     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1499
1500     ewkContext->setCacheModel(cacheModel);
1501
1502     return true;
1503 }
1504
1505 Ewk_Cache_Model ewk_context_cache_model_get(Ewk_Context* ewkContext)
1506 {
1507     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, EWK_CACHE_MODEL_DOCUMENT_VIEWER);
1508
1509     return ewkContext->cacheModel();
1510 }
1511
1512 Eina_Bool ewk_context_cache_disabled_set(Ewk_Context* ewkContext, Eina_Bool cacheDisabled)
1513 {
1514 #if ENABLE(TIZEN_CACHE_CONTROL)
1515     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1516     WKContextSetCacheDisabled(ewkContext->wkContext(), cacheDisabled);
1517 #endif
1518
1519     return true;
1520 }
1521
1522 Eina_Bool ewk_context_cache_disabled_get(Ewk_Context* ewkContext)
1523 {
1524 #if ENABLE(TIZEN_CACHE_CONTROL)
1525     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1526     return WKContextGetCacheDisabled(ewkContext->wkContext());
1527 #else
1528     return false;
1529 #endif
1530 }
1531
1532 Eina_Bool ewk_context_certificate_file_set(Ewk_Context* context, const char* certificateFile)
1533 {
1534     EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
1535     EINA_SAFETY_ON_NULL_RETURN_VAL(certificateFile, false);
1536 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1537     if (!context->setCertificateFile(certificateFile))
1538         return true;
1539
1540     if (fileExists(WTF::String::fromUTF8(certificateFile))) {
1541         long long fileSize = -1;
1542         getFileSize(WTF::String::fromUTF8(certificateFile), fileSize);
1543         TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile fileSize [%lld]\n", fileSize);
1544     } else
1545         TIZEN_LOGE("[Network] ewk_context_certificate_file_set certificateFile does not exist!\n");
1546
1547     WKRetainPtr<WKStringRef> certificateFileRef(AdoptWK, WKStringCreateWithUTF8CString(certificateFile));
1548     WKContextSetCertificateFile(context->wkContext(), certificateFileRef.get());
1549     return true;
1550 #else
1551     UNUSED_PARAM(context);
1552     UNUSED_PARAM(certificateFile);
1553     return false;
1554 #endif
1555 }
1556
1557 const char* ewk_context_certificate_file_get(const Ewk_Context* context)
1558 {
1559     EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1560 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1561     return context->certificateFile();
1562 #else
1563     UNUSED_PARAM(context);
1564     return 0;
1565 #endif
1566 }
1567
1568 Eina_Bool ewk_context_cache_clear(Ewk_Context* ewkContext)
1569 {
1570     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1571     WKResourceCacheManagerRef cacheManager = WKContextGetResourceCacheManager(ewkContext->wkContext());
1572 #if ENABLE(TIZEN_EWK_CONTEXT_CACHE_MANAGER_NULL_CHECK_WORKAROUND)
1573     if (!cacheManager)
1574         return false;
1575 #endif
1576     WKResourceCacheManagerClearCacheForAllOrigins(cacheManager, WKResourceCachesToClearAll);
1577
1578     return true;
1579 }
1580
1581 void ewk_context_message_post_to_injected_bundle(Ewk_Context* ewkContext, const char* name, const char* body)
1582 {
1583     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1584     EINA_SAFETY_ON_NULL_RETURN(name);
1585     EINA_SAFETY_ON_NULL_RETURN(body);
1586
1587     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString(name));
1588     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithUTF8CString(body));
1589     WKContextPostMessageToInjectedBundle(ewkContext->wkContext(), messageName.get(), messageBody.get());
1590 }
1591
1592 void ewk_context_message_from_injected_bundle_callback_set(Ewk_Context* ewkContext, Ewk_Context_Message_From_Injected_Bundle_Callback callback, void* userData)
1593 {
1594     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1595
1596     ewkContext->setMessageFromInjectedBundleCallback(callback, userData);
1597 }
1598
1599 void ewk_context_did_start_download_callback_set(Ewk_Context* ewkContext, Ewk_Context_Did_Start_Download_Callback callback, void* userData)
1600 {
1601     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1602
1603     ewkContext->setDidStartDownloadCallback(callback, userData);
1604 }
1605
1606 #if ENABLE(MEMORY_SAMPLER)
1607 void ewk_context_memory_sampler_start(Ewk_Context* ewkContext, double timerInterval)
1608 {
1609     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1610     WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(timerInterval));
1611     WKContextStartMemorySampler(ewkContext->wkContext(), interval.get());
1612 }
1613
1614 void ewk_context_memory_sampler_stop(Ewk_Context* ewkContext)
1615 {
1616     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1617     WKContextStopMemorySampler(ewkContext->wkContext());
1618 }
1619 #endif
1620
1621 Eina_Bool ewk_context_additional_plugin_path_set(Ewk_Context* ewkContext, const char* path)
1622 {
1623 #if ENABLE(TIZEN_SUPPORT_PLUGINS)
1624     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1625     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
1626
1627     WKRetainPtr<WKStringRef> pluginPath(AdoptWK, WKStringCreateWithUTF8CString(path));
1628     WKContextSetAdditionalPluginsDirectory(ewkContext->wkContext(), pluginPath.get());
1629
1630     return true;
1631 #else
1632     return false;
1633 #endif
1634 }
1635
1636 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
1637 void ewk_context_memory_saving_mode_set(Ewk_Context* ewkContext, Eina_Bool mode)
1638 {
1639     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1640
1641     WKContextRef contextRef = ewkContext->wkContext();
1642     toImpl(contextRef)->setMemorySavingMode(mode);
1643 }
1644 #endif
1645
1646 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1647 void ewk_context_form_password_data_clear(Ewk_Context* ewkContext)
1648 {
1649     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1650     ewkContext->clearPasswordFormData();
1651 }
1652
1653 void ewk_context_form_candidate_data_clear(Ewk_Context* ewkContext)
1654 {
1655     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1656     ewkContext->clearCandidateFormData();
1657 }
1658 #endif
1659 #endif // #if OS(TIZEN)
1660
1661 Eina_Bool ewk_context_url_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData)
1662 {
1663     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1664     EINA_SAFETY_ON_NULL_RETURN_VAL(scheme, false);
1665     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
1666
1667     ewkContext->requestManager()->registerURLSchemeHandler(String::fromUTF8(scheme), callback, userData);
1668
1669     return true;
1670 }
1671
1672 void ewk_context_vibration_client_callbacks_set(Ewk_Context* ewkContext, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void* data)
1673 {
1674     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1675
1676     TIZEN_LOGI("vibrate (%p)", vibrate);
1677 #if ENABLE(VIBRATION)
1678     ewkContext->vibrationProvider()->setVibrationClientCallbacks(vibrate, cancel, data);
1679 #endif
1680 }
1681
1682 Eina_Bool ewk_context_tizen_extensible_api_set(Ewk_Context* ewkContext,  Ewk_Extensible_API extensibleAPI, Eina_Bool enable)
1683 {
1684 #if ENABLE(TIZEN_EXTENSIBLE_API)
1685     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
1686
1687     TIZEN_LOGI("extensibleAPI (%d) enable (%d)", extensibleAPI, enable);
1688     WKContextSetTizenExtensibleAPI(ewkContext->wkContext(), static_cast<WKTizenExtensibleAPI>(extensibleAPI), enable);
1689
1690     return true;
1691 #else
1692     UNUSED_PARAM(ewkContext);
1693     UNUSED_PARAM(extensibleAPI);
1694     UNUSED_PARAM(enable);
1695
1696     return false;
1697 #endif
1698 }
1699
1700 void ewk_context_storage_path_reset(Ewk_Context* ewkContext)
1701 {
1702 #if ENABLE(TIZEN_RESET_PATH)
1703     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1704
1705     TIZEN_LOGI("ewkContext (%p)", ewkContext);
1706     WKContextResetStoragePath(ewkContext->wkContext());
1707 #else
1708     UNUSED_PARAM(ewkContext);
1709 #endif
1710 }
1711
1712 void ewk_context_history_callbacks_set(Ewk_Context* ewkContext, Ewk_History_Navigation_Cb navigate, Ewk_History_Client_Redirection_Cb clientRedirect, Ewk_History_Server_Redirection_Cb serverRedirect, Ewk_History_Title_Update_Cb titleUpdate, Ewk_History_Populate_Visited_Links_Cb populateVisitedLinks, void* data)
1713 {
1714     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1715
1716     ewkContext->historyClient()->setCallbacks(navigate, clientRedirect, serverRedirect, titleUpdate, populateVisitedLinks, data);
1717 }
1718
1719 void ewk_context_visited_link_add(Ewk_Context* ewkContext, const char* visitedURL)
1720 {
1721     EINA_SAFETY_ON_NULL_RETURN(ewkContext);
1722     EINA_SAFETY_ON_NULL_RETURN(visitedURL);
1723
1724     ewkContext->addVisitedLink(visitedURL);
1725 }