2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * Created on: Apr 1, 2014
26 #if defined(USE_EWEBKIT)
27 #include <ewk_chromium.h>
30 #include <boost/format.hpp>
31 #include <boost/regex.hpp>
32 #include <boost/algorithm/string/regex.hpp>
33 #include <boost/algorithm/string/classification.hpp>
34 #include <boost/algorithm/string/split.hpp>
35 #include <Elementary.h>
38 #include "AbstractWebEngine/AbstractWebEngine.h"
39 #include "AbstractWebEngine/TabThumbCache.h"
40 #include "BrowserAssert.h"
41 #include "BrowserLogger.h"
43 #include "GeneralTools.h"
44 #include "Tools/WorkQueue.h"
45 #include "ServiceManager.h"
47 #define certificate_crt_path CERTS_DIR
48 #define APPLICATION_NAME_FOR_USER_AGENT "SamsungBrowser/1.0"
50 using namespace tizen_browser::tools;
52 namespace tizen_browser {
53 namespace basic_webengine {
54 namespace webkitengine_service {
56 WebView::WebView(Evas_Object * obj, TabId tabId)
63 config.load("whatever");
68 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
71 unregisterCallbacks();
75 void WebView::init(Evas_Object * opener)
77 #if defined(USE_EWEBKIT)
78 m_ewkView = ewk_view_add(evas_object_evas_get(m_parent));
80 evas_object_data_set(m_ewkView, "_container", this);
81 BROWSER_LOGD("%s:%d %s self=%p", __FILE__, __LINE__, __func__, this);
83 evas_object_color_set(m_ewkView, 255, 255, 255, 255);
84 evas_object_size_hint_weight_set(m_ewkView, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
85 evas_object_size_hint_align_set(m_ewkView, EVAS_HINT_FILL, EVAS_HINT_FILL);
86 ewk_view_application_name_for_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT);
87 //\todo: when value is other than 1.0, scroller is located improperly
88 // ewk_view_device_pixel_ratio_set(m_ewkView, 1.0f);
91 ewk_view_resume(m_ewkView);
93 // set local storage, favion, cookies
94 std::string webkit_path = boost::any_cast <std::string> (config.get("webkit/dir"));
98 Ewk_Context *context = ewk_view_context_get(m_ewkView);
101 ewk_context_cache_model_set(context, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER);
102 ewk_context_favicon_database_directory_set(context, (webkit_path + std::string("/favicon")).c_str());
103 ewk_cookie_manager_persistent_storage_set(ewk_context_cookie_manager_get(context)
104 , (webkit_path + std::string("/cookies.db")).c_str()
105 , EWK_COOKIE_PERSISTENT_STORAGE_SQLITE);
109 ///\note Odroid modification - not exists in WebKit API
110 // ewk_cookie_manager_widget_cookie_directory_set(ewk_context_cookie_manager_get(context), webkit_path.c_str());
114 m_ewkView = evas_object_rectangle_add(evas_object_evas_get(m_parent));
118 void WebView::registerCallbacks()
120 #if defined(USE_EWEBKIT)
121 evas_object_smart_callback_add(m_ewkView, "load,started", __loadStarted, this);
122 evas_object_smart_callback_add(m_ewkView, "load,stop", __loadStop, this);
123 evas_object_smart_callback_add(m_ewkView, "load,finished", __loadFinished, this);
124 evas_object_smart_callback_add(m_ewkView, "load,progress", __loadProgress, this);
125 evas_object_smart_callback_add(m_ewkView, "load,error", __loadError, this);
127 evas_object_smart_callback_add(m_ewkView, "title,changed", __titleChanged, this);
128 evas_object_smart_callback_add(m_ewkView, "url,changed", __urlChanged, this);
130 evas_object_smart_callback_add(m_ewkView, "back,forward,list,changed", __backForwardListChanged, this);
132 evas_object_smart_callback_add(m_ewkView, "create,window", __newWindowRequest, this);
133 evas_object_smart_callback_add(m_ewkView, "close,window", __closeWindowRequest, this);
135 evas_object_smart_callback_add(m_ewkView, "geolocation,permission,request", __geolocationPermissionRequest, this);
136 evas_object_smart_callback_add(m_ewkView, "usermedia,permission,request", __usermediaPermissionRequest, this);
137 evas_object_smart_callback_add(m_ewkView, "notification,permission,request", __notificationPermissionRequest, this);
138 evas_object_smart_callback_add(m_ewkView, "authentication,request", __authenticationRequest, this);
139 evas_object_smart_callback_add(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this);
141 evas_object_event_callback_add(m_ewkView, EVAS_CALLBACK_MOUSE_DOWN, __setFocusToEwkView, this);
142 evas_object_smart_callback_add(m_ewkView, "icon,received", __faviconChanged, this);
144 evas_object_smart_callback_add(m_ewkView, "editorclient,ime,closed", __IMEClosed, this);
145 evas_object_smart_callback_add(m_ewkView, "editorclient,ime,opened", __IMEOpened, this);
149 void WebView::unregisterCallbacks()
151 #if defined(USE_EWEBKIT)
152 evas_object_smart_callback_del_full(m_ewkView, "load,started", __loadStarted, this);
153 evas_object_smart_callback_del_full(m_ewkView, "load,stop", __loadStop, this);
154 evas_object_smart_callback_del_full(m_ewkView, "load,finished", __loadFinished, this);
155 evas_object_smart_callback_del_full(m_ewkView, "load,progress", __loadProgress, this);
156 evas_object_smart_callback_del_full(m_ewkView, "load,error", __loadError, this);
158 evas_object_smart_callback_del_full(m_ewkView, "title,changed", __titleChanged, this);
159 evas_object_smart_callback_del_full(m_ewkView, "url,changed", __urlChanged, this);
161 evas_object_smart_callback_del_full(m_ewkView, "back,forward,list,changed", __backForwardListChanged, this);
163 evas_object_smart_callback_del_full(m_ewkView, "create,window", __newWindowRequest, this);
164 evas_object_smart_callback_del_full(m_ewkView, "close,window", __closeWindowRequest, this);
166 evas_object_smart_callback_del_full(m_ewkView, "geolocation,permission,request", __geolocationPermissionRequest, this);
167 evas_object_smart_callback_del_full(m_ewkView, "usermedia,permission,request", __usermediaPermissionRequest, this);
168 evas_object_smart_callback_del_full(m_ewkView, "notification,permission,request", __notificationPermissionRequest, this);
169 evas_object_smart_callback_del_full(m_ewkView, "authentication,request", __authenticationRequest, this);
170 evas_object_smart_callback_del_full(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this);
172 evas_object_event_callback_del(m_ewkView, EVAS_CALLBACK_MOUSE_DOWN, __setFocusToEwkView);
173 evas_object_smart_callback_del_full(m_ewkView, "icon,received", __faviconChanged, this);
175 evas_object_smart_callback_del_full(m_ewkView, "editorclient,ime,closed", __IMEClosed, this);
176 evas_object_smart_callback_del_full(m_ewkView, "editorclient,ime,opened", __IMEOpened, this);
180 void WebView::setupEwkSettings()
182 #if defined(USE_EWEBKIT)
184 Ewk_Settings * settings = ewk_view_settings_get(m_ewkView);
185 ewk_settings_uses_keypad_without_user_action_set(settings, EINA_FALSE);
190 Evas_Object * WebView::getLayout()
195 void WebView::setURI(const std::string & uri)
197 BROWSER_LOGD("%s:%d %s uri=%s", __FILE__, __LINE__, __func__, uri.c_str());
198 #if defined(USE_EWEBKIT)
199 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
200 ewk_view_url_set(m_ewkView, uri.c_str());
205 std::string WebView::getURI(void)
207 #if defined(USE_EWEBKIT)
208 BROWSER_LOGD("%s:%d %s uri=%s", __FILE__, __LINE__, __func__, ewk_view_url_get(m_ewkView));
209 return tizen_browser::tools::fromChar(ewk_view_url_get(m_ewkView));
211 return std::string();
215 std::string WebView::getTitle(void)
220 void WebView::stopLoading(void)
222 #if defined(USE_EWEBKIT)
223 ewk_view_stop(m_ewkView);
228 void WebView::reload(void)
230 #if defined(USE_EWEBKIT)
234 ewk_view_url_set(m_ewkView, ewk_view_url_get(m_ewkView));
237 ewk_view_reload(m_ewkView);
241 void WebView::back(void)
243 #if defined(USE_EWEBKIT)
245 ewk_view_back(m_ewkView);
249 void WebView::forward(void)
251 #if defined(USE_EWEBKIT)
253 ewk_view_forward(m_ewkView);
257 bool WebView::isBackEnabled(void)
259 #if defined(USE_EWEBKIT)
260 return ewk_view_back_possible(m_ewkView);
266 bool WebView::isForwardEnabled(void)
268 #if defined(USE_EWEBKIT)
269 return ewk_view_forward_possible(m_ewkView);
275 bool WebView::isLoading()
280 bool WebView::isLoadError() const
285 void WebView::setPrivateMode(bool state)
287 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
290 #if defined(USE_EWEBKIT)
292 Ewk_Settings * settings = ewk_view_settings_get(m_ewkView);
294 Ewk_Settings * settings = ewk_page_group_settings_get(ewk_view_page_group_get(m_ewkView));
296 ewk_settings_private_browsing_enabled_set(settings, state);
299 Ewk_Context *context = ewk_view_context_get(m_ewkView);
304 ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_NEVER);
308 ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
315 void WebView::confirmationResult(WebConfirmationPtr confirmation)
317 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
319 #if defined(USE_EWEBKIT)
321 switch(confirmation->getConfirmationType()) {
322 case WebConfirmation::ConfirmationType::Geolocation: {
323 Ewk_Geolocation_Permission_Request *request = m_confirmationGeolocationMap[confirmation];
325 if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
327 else if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Rejected)
330 BROWSER_LOGE("Wrong ConfirmationResult");
333 // set geolocation permission
334 ewk_geolocation_permission_reply(request, result);
335 ewk_view_resume(m_ewkView);
338 m_confirmationGeolocationMap.erase(confirmation);
341 case WebConfirmation::ConfirmationType::UserMedia: {
342 Ewk_User_Media_Permission_Request *request = m_confirmationUserMediaMap[confirmation];
344 if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
346 else if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Rejected)
349 BROWSER_LOGE("Wrong ConfirmationResult");
353 // set usermedia permission
354 ewk_user_media_permission_reply(request, result);
355 ewk_view_resume(m_ewkView);
358 m_confirmationUserMediaMap.erase(confirmation);
361 case WebConfirmation::ConfirmationType::Notification: {
362 Ewk_Notification_Permission_Request *request = m_confirmationNotificationMap[confirmation];
364 if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
366 else if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Rejected)
369 BROWSER_LOGE("Wrong ConfirmationResult");
373 // set notification permission
374 ewk_notification_permission_reply(request, result);
375 ewk_view_resume(m_ewkView);
378 m_confirmationNotificationMap.erase(confirmation);
381 case WebConfirmation::ConfirmationType::CertificateConfirmation: {
382 CertificateConfirmationPtr cert = std::dynamic_pointer_cast<CertificateConfirmation, WebConfirmation>(confirmation);
383 Ewk_Certificate_Policy_Decision *request = m_confirmationCertificatenMap[cert];
385 if (cert->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
387 else if (cert->getResult() == WebConfirmation::ConfirmationResult::Rejected)
390 BROWSER_LOGE("Wrong ConfirmationResult");
394 // set certificate confirmation
395 BROWSER_LOGE("NOT IMPLEMENTED: Certificate Confirmation handling!");
398 m_confirmationCertificatenMap.erase(cert);
401 case WebConfirmation::ConfirmationType::Authentication: {
402 AuthenticationConfirmationPtr auth = std::dynamic_pointer_cast<AuthenticationConfirmation, WebConfirmation>(confirmation);
403 Ewk_Auth_Request *request = m_confirmationAuthenticationMap[auth];
404 if (auth->getResult() == WebConfirmation::ConfirmationResult::Confirmed) {
405 BROWSER_LOGE("NOT IMPLEMENTED: Autenthication Request Confirmation handling!");
406 } else if (auth->getResult() == WebConfirmation::ConfirmationResult::Rejected) {
407 BROWSER_LOGE("NOT IMPLEMENTED: Autenthication Request Rejection handling!");
409 BROWSER_LOGE("Wrong ConfirmationResult");
414 m_confirmationAuthenticationMap.erase(auth);
426 std::shared_ptr<tizen_browser::tools::BrowserImage> WebView::captureSnapshot(int targetWidth, int targetHeight)
428 BROWSER_LOGD("%s:%d %s NOT IMPLEMENTED, returning empty BrowserImage object", __FILE__, __LINE__, __func__);
430 M_ASSERT(targetWidth);
431 M_ASSERT(targetHeight);
433 std::shared_ptr<tizen_browser::tools::BrowserImage> noImage = std::make_shared<tizen_browser::tools::BrowserImage>();
434 evas_object_geometry_get(m_ewkView, NULL, NULL, &vw, &vh);
435 if (vw == 0 || vh == 0)
439 double snapshotProportions = (double)(targetWidth) /(double)(targetHeight);
440 double webkitProportions = (double)(vw) /(double)(vh);
441 if (webkitProportions >= snapshotProportions) {
442 // centring position of screenshot
443 area.x = (vw*getZoomFactor()/2) - (vh*getZoomFactor()*snapshotProportions/2);
445 area.w = vh*getZoomFactor()*snapshotProportions;
446 area.h = vh*getZoomFactor();
451 area.w = vw*getZoomFactor();
452 area.h = vw*getZoomFactor()/snapshotProportions;
454 if (area.w == 0 || area.h == 0)
457 double scaleW = (double)targetWidth / (double)(area.w);
458 double scaleH = (double)targetHeight / (double)(area.h);
460 #if defined(USE_EWEBKIT)
462 Evas_Object *snapshot = nullptr;
463 // TODO use ewk_view_screenshot_contents_get_async API here
465 return tizen_browser::tools::EflTools::getBrowserImage(snapshot);
472 #if defined(USE_EWEBKIT)
473 void WebView::__setFocusToEwkView(void * data, Evas * /* e */, Evas_Object * /* obj */, void * /* event_info */)
475 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
477 WebView * self = reinterpret_cast<WebView *>(data);
479 if(!self->hasFocus())
480 self->ewkViewClicked();
483 void WebView::__newWindowRequest(void *data, Evas_Object *, void *out)
485 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
487 WebView * self = reinterpret_cast<WebView *>(data);
488 BROWSER_LOGD("%s:%d %s self=%p", __FILE__, __LINE__, __func__, self);
489 BROWSER_LOGD("Window creating in tab: %s", self->getTabId().toString().c_str());
490 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
491 m_webEngine = std::dynamic_pointer_cast
493 basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService
495 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice"));
496 M_ASSERT(m_webEngine);
498 /// \todo: Choose newly created tab.
499 TabId id = m_webEngine->addTab(std::string(), &self->getTabId());
500 BROWSER_LOGD("Created tab: %s", id.toString().c_str());
502 Evas_Object* tab_ewk_view = m_webEngine->getTabView(id);
503 *static_cast<Evas_Object**>(out) = tab_ewk_view;
506 void WebView::__closeWindowRequest(void *data, Evas_Object *, void *)
508 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
509 WebView * self = reinterpret_cast<WebView *>(data);
510 std::shared_ptr<AbstractWebEngine<Evas_Object>> m_webEngine =
511 std::dynamic_pointer_cast
512 <basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService>
513 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice"));
514 m_webEngine->closeTab(self->getTabId());
517 void WebView::__loadStarted(void * data, Evas_Object * /* obj */, void * /* event_info */)
519 WebView * self = reinterpret_cast<WebView *>(data);
521 BROWSER_LOGD("%s:%d\n\t %s", __func__, __LINE__, ewk_view_url_get(self->m_ewkView));
523 self->m_isLoading = true;
525 tizen_browser::services::TabThumbCache* cache = tizen_browser::services::TabThumbCache::getInstance();
526 cache->clearThumb(self->m_tabId);
529 void WebView::__loadStop(void * data, Evas_Object * /* obj */, void * /* event_info */)
531 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
533 WebView * self = reinterpret_cast<WebView *>(data);
534 self->m_isLoading = false;
539 void WebView::__loadFinished(void * data, Evas_Object * /* obj */, void * /* event_info */)
541 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
543 WebView * self = reinterpret_cast<WebView *>(data);
544 self->m_isLoading = false;
545 self->m_loadProgress = 1;
547 self->loadFinished();
548 self->loadProgress(self->m_loadProgress);
549 tizen_browser::services::TabThumbCache* cache = tizen_browser::services::TabThumbCache::getInstance();
550 cache->updateThumb(self->m_tabId);
553 void WebView::__loadProgress(void * data, Evas_Object * /* obj */, void * event_info)
555 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
557 WebView * self = reinterpret_cast<WebView *>(data);
558 self->m_loadProgress = *(double *)event_info;
560 self->loadProgress(self->m_loadProgress);
563 void WebView::__loadError(void* data, Evas_Object * obj, void* ewkError)
565 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
567 WebView *self = reinterpret_cast<WebView*>(data);
568 Ewk_Error *error = reinterpret_cast<Ewk_Error*>(ewkError);
569 Ewk_Error_Type errorType = ewk_error_type_get(error);
571 BROWSER_LOGD("[%s:%d] ewk_error_type: %d ",
572 __PRETTY_FUNCTION__, __LINE__, errorType);
574 BROWSER_LOGD("[%s:%d] emiting signal ", __PRETTY_FUNCTION__, __LINE__);
575 int errorCode = ewk_error_code_get(error);
576 if(errorCode == EWK_ERROR_NETWORK_STATUS_CANCELLED)
578 BROWSER_LOGD("Stop signal emitted");
579 BROWSER_LOGD("Error description: %s", ewk_error_description_get(error));
580 evas_object_smart_callback_call(obj, "load,stop", NULL);
585 self->m_loadError=true;
589 void WebView::__titleChanged(void * data, Evas_Object * obj, void * /* event_info */)
591 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
593 WebView * self = reinterpret_cast<WebView *>(data);
594 self->m_title = tizen_browser::tools::fromChar(ewk_view_title_get(obj));
596 self->titleChanged(self->m_title);
599 void WebView::__urlChanged(void * data, Evas_Object * /* obj */, void * event_info)
601 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
603 WebView * self = reinterpret_cast<WebView *>(data);
604 BROWSER_LOGD("URL changed for tab: %s", self->getTabId().toString().c_str());
605 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
606 m_webEngine = std::dynamic_pointer_cast<basic_webengine::AbstractWebEngine<Evas_Object>, tizen_browser::core::AbstractService>(
607 tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice"));
608 M_ASSERT(m_webEngine);
609 self->uriChanged(tizen_browser::tools::fromChar(reinterpret_cast<const char *>(event_info)));
610 self->tabIdChecker(self->m_tabId);
613 void WebView::__backForwardListChanged(void * data, Evas_Object * /* obj */, void * /* event_info */)
615 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
617 WebView * self = reinterpret_cast<WebView *>(data);
618 self->backwardEnableChanged(self->isBackEnabled());
619 self->forwardEnableChanged(self->isForwardEnabled());
622 void WebView::__faviconChanged(void* data, Evas_Object*, void*)
626 WebView * self = static_cast<WebView *>(data);
627 Evas_Object * favicon = ewk_context_icon_database_icon_object_add(ewk_view_context_get(self->m_ewkView), ewk_view_url_get(self->m_ewkView),evas_object_evas_get(self->m_ewkView));
629 BROWSER_LOGD("[%s:%d] Favicon received", __PRETTY_FUNCTION__, __LINE__);
630 self->faviconImage = tizen_browser::tools::EflTools::getBrowserImage(favicon);
631 evas_object_unref(favicon);
632 self->favIconChanged(self->faviconImage);
637 void WebView::__IMEClosed(void* data, Evas_Object*, void*)
639 BROWSER_LOGD("%s", __func__);
640 WebView * self = reinterpret_cast<WebView *>(data);
641 self->IMEStateChanged(false);
644 void WebView::__IMEOpened(void* data, Evas_Object*, void*)
646 BROWSER_LOGD("%s", __func__);
647 WebView * self = reinterpret_cast<WebView *>(data);
648 self->IMEStateChanged(true);
651 std::string WebView::securityOriginToUri(const Ewk_Security_Origin *origin)
653 std::string protocol = tizen_browser::tools::fromChar(ewk_security_origin_protocol_get(origin));
654 std::string uri = tizen_browser::tools::fromChar(ewk_security_origin_host_get(origin));
655 std::string url = (boost::format("%1%://%2%") % protocol % uri).str();
659 void WebView::__geolocationPermissionRequest(void * data, Evas_Object * /* obj */, void * event_info)
661 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
663 WebView * self = reinterpret_cast<WebView *>(data);
665 Ewk_Geolocation_Permission_Request *request = reinterpret_cast<Ewk_Geolocation_Permission_Request *>(event_info);
670 ewk_view_suspend(self->m_ewkView);
672 std::string url = WebView::securityOriginToUri(ewk_geolocation_permission_request_origin_get(request));
674 ///\todo add translations
675 std::string message = (boost::format("%1% Requests your location") % url).str();
677 WebConfirmationPtr c = std::make_shared<WebConfirmation>(WebConfirmation::ConfirmationType::Geolocation, self->m_tabId, url, message);
680 self->m_confirmationGeolocationMap[c] = request;
682 self->cofirmationRequest(c);
686 void WebView::__usermediaPermissionRequest(void * data, Evas_Object * /* obj */, void * event_info)
688 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
690 WebView * self = reinterpret_cast<WebView *>(data);
692 Ewk_User_Media_Permission_Request *request = reinterpret_cast<Ewk_User_Media_Permission_Request *>(event_info);
697 ewk_view_suspend(self->m_ewkView);
699 ///\todo add translations
700 std::string message = "User media permission request";
702 WebConfirmationPtr c = std::make_shared<WebConfirmation>(WebConfirmation::ConfirmationType::UserMedia, self->m_tabId, std::string(), message);
705 self->m_confirmationUserMediaMap[c] = request;
707 self->cofirmationRequest(c);
711 void WebView::__notificationPermissionRequest(void * data, Evas_Object * /* obj */, void * event_info)
713 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
715 WebView * self = reinterpret_cast<WebView *>(data);
717 Ewk_Notification_Permission_Request *request = reinterpret_cast<Ewk_Notification_Permission_Request *>(event_info);
722 ewk_view_suspend(self->m_ewkView);
724 ///\todo add translations
725 std::string message = (boost::format("%1% wants to display notifications") % self->getURI()).str();
727 WebConfirmationPtr c = std::make_shared<WebConfirmation>(WebConfirmation::ConfirmationType::Notification, self->m_tabId, self->getURI(), message);
730 self->m_confirmationNotificationMap[c] = request;
732 self->cofirmationRequest(c);
736 void WebView::__authenticationRequest(void * data, Evas_Object * /* obj */, void * event_info)
738 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
740 WebView * self = reinterpret_cast<WebView *>(data);
742 Ewk_Auth_Request *request = reinterpret_cast<Ewk_Auth_Request *>(event_info);
743 EINA_SAFETY_ON_NULL_RETURN(request);
745 std::string url = self->getURI();
746 std::string message = (boost::format("A username and password are being requested by %1%.") % url).str();
748 AuthenticationConfirmationPtr c = std::make_shared<AuthenticationConfirmation>(self->m_tabId, url, message);
750 self->m_confirmationAuthenticationMap[c] = request;
752 self->cofirmationRequest(c);
756 void WebView::__requestCertificationConfirm(void * data , Evas_Object * /* obj */, void * event_info)
758 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
760 WebView * self = reinterpret_cast<WebView *>(data);
762 Ewk_Certificate_Policy_Decision *request = reinterpret_cast<Ewk_Certificate_Policy_Decision *>(event_info);
767 ewk_view_suspend(self->m_ewkView);
769 std::string url = self->getURI();
771 ///\todo add translations
772 std::string message = (boost::format("There are problems with the security certificate for this site.<br>%1%") % url).str();
774 CertificateConfirmationPtr c = std::make_shared<CertificateConfirmation>(self->m_tabId, url, message);
776 c->setResult(tizen_browser::basic_webengine::WebConfirmation::ConfirmationResult::Confirmed);
779 self->m_confirmationCertificatenMap[c] = request;
781 self->cofirmationRequest(c);
786 void WebView::setFocus()
788 elm_object_focus_set(m_ewkView, EINA_TRUE);
791 void WebView::clearFocus()
793 elm_object_focus_set(m_ewkView, EINA_FALSE);
796 bool WebView::hasFocus() const
798 return elm_object_focus_get(m_ewkView) == EINA_TRUE ? true : false;
801 double WebView::getZoomFactor() const
803 if(EINA_UNLIKELY(m_ewkView == NULL)){
807 #if defined(USE_EWEBKIT)
808 return ewk_view_page_zoom_get(m_ewkView);
814 void WebView::setZoomFactor(double zoomFactor)
816 #if defined(USE_EWEBKIT)
818 //using zoomFactor = 0 sets zoom "fit to screen"
820 ewk_view_page_zoom_set(m_ewkView, zoomFactor);
826 const TabId& WebView::getTabId(){
831 std::shared_ptr<tizen_browser::tools::BrowserImage> WebView::getFavicon() {
832 BROWSER_LOGD("%s:%d, TabId: %s", __PRETTY_FUNCTION__, __LINE__, m_tabId.toString().c_str());
835 #if defined(USE_EWEBKIT)
836 if (faviconImage.get() == NULL) {
840 Ewk_Context *context = ewk_view_context_get(m_ewkView);
843 Evas_Object * favicon = ewk_context_icon_database_icon_object_add(context, ewk_view_url_get(m_ewkView), evas_object_evas_get(m_ewkView));
847 evas_object_image_size_get(favicon, &w, &h);
848 BROWSER_LOGD("[%s]: Info about favicon: w:%d h:%d, type: %s", __func__, w, h, evas_object_type_get(favicon));
851 std::shared_ptr<tizen_browser::tools::BrowserImage>
852 image = tizen_browser::tools::EflTools::getBrowserImage(favicon);
854 evas_object_unref(favicon);
865 BROWSER_LOGE("[%s:%d]: Returned favicon is empty!", __PRETTY_FUNCTION__, __LINE__);
866 return std::make_shared<tizen_browser::tools::BrowserImage>();
869 void WebView::clearPrivateData()
871 BROWSER_LOGD("Clearing private data");
872 #if defined(USE_EWEBKIT)
875 Ewk_Context *context = ewk_view_context_get(m_ewkView);
878 ewk_context_web_storage_delete_all(context);
879 ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get(context));
885 void WebView::searchOnWebsite(const std::string & searchString, int flags)
887 ///\todo: it should be "0" instead of "1024" for unlimited match count but it doesn't work properly in WebKit
888 Eina_Bool result = ewk_view_text_find(m_ewkView, searchString.c_str(), static_cast<Ewk_Find_Options>(flags), 1024);
889 BROWSER_LOGD("Ewk search; word: %s, result: %d", searchString.c_str(), result);
892 } /* namespace webkitengine_service */
893 } /* end of basic_webengine */
894 } /* end of tizen_browser */