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
49 #define APPLICATION_NAME_FOR_USER_AGENT "SamsungBrowser/1.0"
51 #define APPLICATION_NAME_FOR_USER_AGENT "Mozilla/5.0 (X11; SMART-TV; Linux) AppleWebkit/538.1 (KHTML, like Gecko) Safari/538.1"
54 using namespace tizen_browser::tools;
56 namespace tizen_browser {
57 namespace basic_webengine {
58 namespace webkitengine_service {
60 WebView::WebView(Evas_Object * obj, TabId tabId)
63 , m_ewkContext(ewk_context_new())
64 , m_title(std::string())
69 config.load("whatever");
74 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
77 unregisterCallbacks();
80 ewk_context_delete(m_ewkContext);
83 void WebView::init(Evas_Object * opener)
85 #if defined(USE_EWEBKIT)
86 m_ewkView = ewk_view_add_with_context(evas_object_evas_get(m_parent), m_ewkContext);
88 evas_object_data_set(m_ewkView, "_container", this);
89 BROWSER_LOGD("%s:%d %s self=%p", __FILE__, __LINE__, __func__, this);
91 evas_object_color_set(m_ewkView, 255, 255, 255, 255);
92 evas_object_size_hint_weight_set(m_ewkView, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
93 evas_object_size_hint_align_set(m_ewkView, EVAS_HINT_FILL, EVAS_HINT_FILL);
94 ewk_view_application_name_for_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT);
95 //\todo: when value is other than 1.0, scroller is located improperly
96 // ewk_view_device_pixel_ratio_set(m_ewkView, 1.0f);
99 ewk_view_resume(m_ewkView);
101 // set local storage, favion, cookies
102 std::string webkit_path = boost::any_cast <std::string> (config.get("webkit/dir"));
106 Ewk_Context *context = ewk_view_context_get(m_ewkView);
109 ewk_context_cache_model_set(context, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER);
113 ///\note Odroid modification - not exists in WebKit API
114 // ewk_cookie_manager_widget_cookie_directory_set(ewk_context_cookie_manager_get(context), webkit_path.c_str());
118 m_ewkView = evas_object_rectangle_add(evas_object_evas_get(m_parent));
122 void WebView::registerCallbacks()
124 #if defined(USE_EWEBKIT)
125 evas_object_smart_callback_add(m_ewkView, "load,started", __loadStarted, this);
126 evas_object_smart_callback_add(m_ewkView, "load,stop", __loadStop, this);
127 evas_object_smart_callback_add(m_ewkView, "load,finished", __loadFinished, this);
128 evas_object_smart_callback_add(m_ewkView, "load,progress", __loadProgress, this);
129 evas_object_smart_callback_add(m_ewkView, "load,error", __loadError, this);
131 evas_object_smart_callback_add(m_ewkView, "title,changed", __titleChanged, this);
132 evas_object_smart_callback_add(m_ewkView, "url,changed", __urlChanged, this);
134 evas_object_smart_callback_add(m_ewkView, "back,forward,list,changed", __backForwardListChanged, this);
136 evas_object_smart_callback_add(m_ewkView, "create,window", __newWindowRequest, this);
137 evas_object_smart_callback_add(m_ewkView, "close,window", __closeWindowRequest, this);
139 evas_object_smart_callback_add(m_ewkView, "geolocation,permission,request", __geolocationPermissionRequest, this);
140 evas_object_smart_callback_add(m_ewkView, "usermedia,permission,request", __usermediaPermissionRequest, this);
141 evas_object_smart_callback_add(m_ewkView, "notification,permission,request", __notificationPermissionRequest, this);
142 evas_object_smart_callback_add(m_ewkView, "authentication,request", __authenticationRequest, this);
143 evas_object_smart_callback_add(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this);
145 evas_object_event_callback_add(m_ewkView, EVAS_CALLBACK_MOUSE_DOWN, __setFocusToEwkView, this);
146 evas_object_smart_callback_add(m_ewkView, "icon,received", __faviconChanged, this);
148 evas_object_smart_callback_add(m_ewkView, "editorclient,ime,closed", __IMEClosed, this);
149 evas_object_smart_callback_add(m_ewkView, "editorclient,ime,opened", __IMEOpened, this);
153 void WebView::unregisterCallbacks()
155 #if defined(USE_EWEBKIT)
156 evas_object_smart_callback_del_full(m_ewkView, "load,started", __loadStarted, this);
157 evas_object_smart_callback_del_full(m_ewkView, "load,stop", __loadStop, this);
158 evas_object_smart_callback_del_full(m_ewkView, "load,finished", __loadFinished, this);
159 evas_object_smart_callback_del_full(m_ewkView, "load,progress", __loadProgress, this);
160 evas_object_smart_callback_del_full(m_ewkView, "load,error", __loadError, this);
162 evas_object_smart_callback_del_full(m_ewkView, "title,changed", __titleChanged, this);
163 evas_object_smart_callback_del_full(m_ewkView, "url,changed", __urlChanged, this);
165 evas_object_smart_callback_del_full(m_ewkView, "back,forward,list,changed", __backForwardListChanged, this);
167 evas_object_smart_callback_del_full(m_ewkView, "create,window", __newWindowRequest, this);
168 evas_object_smart_callback_del_full(m_ewkView, "close,window", __closeWindowRequest, this);
170 evas_object_smart_callback_del_full(m_ewkView, "geolocation,permission,request", __geolocationPermissionRequest, this);
171 evas_object_smart_callback_del_full(m_ewkView, "usermedia,permission,request", __usermediaPermissionRequest, this);
172 evas_object_smart_callback_del_full(m_ewkView, "notification,permission,request", __notificationPermissionRequest, this);
173 evas_object_smart_callback_del_full(m_ewkView, "authentication,request", __authenticationRequest, this);
174 evas_object_smart_callback_del_full(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this);
176 evas_object_event_callback_del(m_ewkView, EVAS_CALLBACK_MOUSE_DOWN, __setFocusToEwkView);
177 evas_object_smart_callback_del_full(m_ewkView, "icon,received", __faviconChanged, this);
179 evas_object_smart_callback_del_full(m_ewkView, "editorclient,ime,closed", __IMEClosed, this);
180 evas_object_smart_callback_del_full(m_ewkView, "editorclient,ime,opened", __IMEOpened, this);
184 void WebView::setupEwkSettings()
186 #if defined(USE_EWEBKIT)
188 Ewk_Settings * settings = ewk_view_settings_get(m_ewkView);
189 ewk_settings_uses_keypad_without_user_action_set(settings, EINA_FALSE);
194 Evas_Object * WebView::getLayout()
199 void WebView::setURI(const std::string & uri)
201 BROWSER_LOGD("%s:%d %s uri=%s", __FILE__, __LINE__, __func__, uri.c_str());
202 #if defined(USE_EWEBKIT)
203 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
204 ewk_view_url_set(m_ewkView, uri.c_str());
209 std::string WebView::getURI(void)
211 #if defined(USE_EWEBKIT)
212 BROWSER_LOGD("%s:%d %s uri=%s", __FILE__, __LINE__, __func__, ewk_view_url_get(m_ewkView));
213 return fromChar(ewk_view_url_get(m_ewkView));
215 return std::string();
219 std::string WebView::getTitle(void)
224 void WebView::stopLoading(void)
226 #if defined(USE_EWEBKIT)
227 ewk_view_stop(m_ewkView);
232 void WebView::reload(void)
234 #if defined(USE_EWEBKIT)
238 ewk_view_url_set(m_ewkView, ewk_view_url_get(m_ewkView));
241 ewk_view_reload(m_ewkView);
245 void WebView::back(void)
247 #if defined(USE_EWEBKIT)
249 ewk_view_back(m_ewkView);
253 void WebView::forward(void)
255 #if defined(USE_EWEBKIT)
257 ewk_view_forward(m_ewkView);
261 bool WebView::isBackEnabled(void)
263 #if defined(USE_EWEBKIT)
264 return ewk_view_back_possible(m_ewkView);
270 bool WebView::isForwardEnabled(void)
272 #if defined(USE_EWEBKIT)
273 return ewk_view_forward_possible(m_ewkView);
279 bool WebView::isLoading()
284 bool WebView::isLoadError() const
289 void WebView::setPrivateMode(bool state)
291 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
294 #if defined(USE_EWEBKIT)
296 Ewk_Settings * settings = ewk_view_settings_get(m_ewkView);
298 Ewk_Settings * settings = ewk_page_group_settings_get(ewk_view_page_group_get(m_ewkView));
300 ewk_settings_private_browsing_enabled_set(settings, state);
303 Ewk_Context *context = ewk_view_context_get(m_ewkView);
308 ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_NEVER);
312 ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
319 void WebView::confirmationResult(WebConfirmationPtr confirmation)
321 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
323 #if defined(USE_EWEBKIT)
325 switch(confirmation->getConfirmationType()) {
326 case WebConfirmation::ConfirmationType::Geolocation: {
327 Ewk_Geolocation_Permission_Request *request = m_confirmationGeolocationMap[confirmation];
329 if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
331 else if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Rejected)
334 BROWSER_LOGE("Wrong ConfirmationResult");
337 // set geolocation permission
338 ewk_geolocation_permission_reply(request, result);
339 ewk_view_resume(m_ewkView);
342 m_confirmationGeolocationMap.erase(confirmation);
345 case WebConfirmation::ConfirmationType::UserMedia: {
346 Ewk_User_Media_Permission_Request *request = m_confirmationUserMediaMap[confirmation];
348 if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
350 else if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Rejected)
353 BROWSER_LOGE("Wrong ConfirmationResult");
357 // set usermedia permission
358 ewk_user_media_permission_reply(request, result);
359 ewk_view_resume(m_ewkView);
362 m_confirmationUserMediaMap.erase(confirmation);
365 case WebConfirmation::ConfirmationType::Notification: {
366 Ewk_Notification_Permission_Request *request = m_confirmationNotificationMap[confirmation];
368 if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
370 else if (confirmation->getResult() == WebConfirmation::ConfirmationResult::Rejected)
373 BROWSER_LOGE("Wrong ConfirmationResult");
377 // set notification permission
378 ewk_notification_permission_reply(request, result);
379 ewk_view_resume(m_ewkView);
382 m_confirmationNotificationMap.erase(confirmation);
385 case WebConfirmation::ConfirmationType::CertificateConfirmation: {
386 CertificateConfirmationPtr cert = std::dynamic_pointer_cast<CertificateConfirmation, WebConfirmation>(confirmation);
387 Ewk_Certificate_Policy_Decision *request = m_confirmationCertificatenMap[cert];
389 if (cert->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
391 else if (cert->getResult() == WebConfirmation::ConfirmationResult::Rejected)
394 BROWSER_LOGE("Wrong ConfirmationResult");
398 // set certificate confirmation
399 BROWSER_LOGE("NOT IMPLEMENTED: Certificate Confirmation handling!");
402 m_confirmationCertificatenMap.erase(cert);
405 case WebConfirmation::ConfirmationType::Authentication: {
406 AuthenticationConfirmationPtr auth = std::dynamic_pointer_cast<AuthenticationConfirmation, WebConfirmation>(confirmation);
407 Ewk_Auth_Request *request = m_confirmationAuthenticationMap[auth];
408 if (auth->getResult() == WebConfirmation::ConfirmationResult::Confirmed) {
409 BROWSER_LOGE("NOT IMPLEMENTED: Autenthication Request Confirmation handling!");
410 } else if (auth->getResult() == WebConfirmation::ConfirmationResult::Rejected) {
411 BROWSER_LOGE("NOT IMPLEMENTED: Autenthication Request Rejection handling!");
413 BROWSER_LOGE("Wrong ConfirmationResult");
418 m_confirmationAuthenticationMap.erase(auth);
430 std::shared_ptr<BrowserImage> WebView::captureSnapshot(int targetWidth, int targetHeight)
432 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
434 M_ASSERT(targetWidth);
435 M_ASSERT(targetHeight);
437 std::shared_ptr<BrowserImage> noImage = std::make_shared<BrowserImage>();
438 evas_object_geometry_get(m_ewkView, nullptr, nullptr, &vw, &vh);
439 if (vw == 0 || vh == 0)
443 double snapshotProportions = (double)(targetWidth) /(double)(targetHeight);
444 double webkitProportions = (double)(vw) /(double)(vh);
445 if (webkitProportions >= snapshotProportions) {
446 // centring position of screenshot
447 area.x = (vw*getZoomFactor()/2) - (vh*getZoomFactor()*snapshotProportions/2);
449 area.w = vh*getZoomFactor()*snapshotProportions;
450 area.h = vh*getZoomFactor();
455 area.w = vw*getZoomFactor();
456 area.h = vw*getZoomFactor()/snapshotProportions;
458 if (area.w == 0 || area.h == 0)
462 BROWSER_LOGD("[%s:%d] Before snapshot (screenshot) - look at the time of taking snapshot below",__func__, __LINE__);
463 #if defined(USE_EWEBKIT)
465 Evas_Object *snapshot = ewk_view_screenshot_contents_get( m_ewkView, area, 1.0, evas_object_evas_get(m_ewkView));
466 BROWSER_LOGD("[%s:%d] Snapshot (screenshot) catched, evas pointer: %p",__func__, __LINE__, snapshot);
468 return EflTools::getBrowserImage(snapshot);
475 #if defined(USE_EWEBKIT)
476 void WebView::__setFocusToEwkView(void * data, Evas * /* e */, Evas_Object * /* obj */, void * /* event_info */)
478 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
480 WebView * self = reinterpret_cast<WebView *>(data);
482 if(!self->hasFocus())
483 self->ewkViewClicked();
486 void WebView::__newWindowRequest(void *data, Evas_Object *, void *out)
488 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
490 WebView * self = reinterpret_cast<WebView *>(data);
491 BROWSER_LOGD("%s:%d %s self=%p", __FILE__, __LINE__, __func__, self);
492 BROWSER_LOGD("Window creating in tab: %s", self->getTabId().toString().c_str());
493 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
494 m_webEngine = std::dynamic_pointer_cast
496 basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService
498 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice"));
499 M_ASSERT(m_webEngine);
501 /// \todo: Choose newly created tab.
502 TabId id = m_webEngine->addTab(std::string(), &self->getTabId());
503 BROWSER_LOGD("Created tab: %s", id.toString().c_str());
505 Evas_Object* tab_ewk_view = m_webEngine->getTabView(id);
506 *static_cast<Evas_Object**>(out) = tab_ewk_view;
509 void WebView::__closeWindowRequest(void *data, Evas_Object *, void *)
511 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
512 WebView * self = reinterpret_cast<WebView *>(data);
513 std::shared_ptr<AbstractWebEngine<Evas_Object>> m_webEngine =
514 std::dynamic_pointer_cast
515 <basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService>
516 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice"));
517 m_webEngine->closeTab(self->getTabId());
520 void WebView::__loadStarted(void * data, Evas_Object * /* obj */, void * /* event_info */)
522 WebView * self = reinterpret_cast<WebView *>(data);
524 BROWSER_LOGD("%s:%d\n\t %s", __func__, __LINE__, ewk_view_url_get(self->m_ewkView));
526 self->m_isLoading = true;
528 tizen_browser::services::TabThumbCache* cache = tizen_browser::services::TabThumbCache::getInstance();
529 cache->clearThumb(self->m_tabId);
532 void WebView::__loadStop(void * data, Evas_Object * /* obj */, void * /* event_info */)
534 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
536 WebView * self = reinterpret_cast<WebView *>(data);
537 self->m_isLoading = false;
542 void WebView::__loadFinished(void * data, Evas_Object * /* obj */, void * /* event_info */)
544 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
546 WebView * self = reinterpret_cast<WebView *>(data);
547 self->m_isLoading = false;
548 self->m_loadProgress = 1;
550 self->loadFinished();
551 self->loadProgress(self->m_loadProgress);
552 tizen_browser::services::TabThumbCache* cache = tizen_browser::services::TabThumbCache::getInstance();
553 cache->updateThumb(self->m_tabId);
556 void WebView::__loadProgress(void * data, Evas_Object * /* obj */, void * event_info)
558 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
560 WebView * self = reinterpret_cast<WebView *>(data);
561 self->m_loadProgress = *(double *)event_info;
563 self->loadProgress(self->m_loadProgress);
566 void WebView::__loadError(void* data, Evas_Object * obj, void* ewkError)
568 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
570 WebView *self = reinterpret_cast<WebView*>(data);
571 Ewk_Error *error = reinterpret_cast<Ewk_Error*>(ewkError);
572 Ewk_Error_Type errorType = ewk_error_type_get(error);
574 BROWSER_LOGD("[%s:%d] ewk_error_type: %d ",
575 __PRETTY_FUNCTION__, __LINE__, errorType);
577 BROWSER_LOGD("[%s:%d] emiting signal ", __PRETTY_FUNCTION__, __LINE__);
578 int errorCode = ewk_error_code_get(error);
579 if(errorCode == EWK_ERROR_NETWORK_STATUS_CANCELLED)
581 BROWSER_LOGD("Stop signal emitted");
582 BROWSER_LOGD("Error description: %s", ewk_error_description_get(error));
583 evas_object_smart_callback_call(obj, "load,stop", nullptr);
588 self->m_loadError=true;
592 void WebView::__titleChanged(void * data, Evas_Object * obj, void * /* event_info */)
594 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
596 WebView * self = reinterpret_cast<WebView *>(data);
597 self->m_title = fromChar(ewk_view_title_get(obj));
599 self->titleChanged(self->m_title);
602 void WebView::__urlChanged(void * data, Evas_Object * /* obj */, void * event_info)
604 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
606 WebView * self = reinterpret_cast<WebView *>(data);
607 BROWSER_LOGD("URL changed for tab: %s", self->getTabId().toString().c_str());
608 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
609 m_webEngine = std::dynamic_pointer_cast<basic_webengine::AbstractWebEngine<Evas_Object>, tizen_browser::core::AbstractService>(
610 tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice"));
611 M_ASSERT(m_webEngine);
612 self->uriChanged(fromChar(reinterpret_cast<const char *>(event_info)));
613 self->tabIdChecker(self->m_tabId);
616 void WebView::__backForwardListChanged(void * data, Evas_Object * /* obj */, void * /* event_info */)
618 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
620 WebView * self = reinterpret_cast<WebView *>(data);
621 self->backwardEnableChanged(self->isBackEnabled());
622 self->forwardEnableChanged(self->isForwardEnabled());
625 void WebView::__faviconChanged(void* data, Evas_Object*, void*)
629 WebView * self = static_cast<WebView *>(data);
630 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));
632 BROWSER_LOGD("[%s:%d] Favicon received", __PRETTY_FUNCTION__, __LINE__);
633 self->faviconImage = EflTools::getBrowserImage(favicon);
634 evas_object_unref(favicon);
635 self->favIconChanged(self->faviconImage);
640 void WebView::__IMEClosed(void* data, Evas_Object*, void*)
642 BROWSER_LOGD("%s", __func__);
643 WebView * self = reinterpret_cast<WebView *>(data);
644 self->IMEStateChanged(false);
647 void WebView::__IMEOpened(void* data, Evas_Object*, void*)
649 BROWSER_LOGD("%s", __func__);
650 WebView * self = reinterpret_cast<WebView *>(data);
651 self->IMEStateChanged(true);
654 std::string WebView::securityOriginToUri(const Ewk_Security_Origin *origin)
656 std::string protocol = fromChar(ewk_security_origin_protocol_get(origin));
657 std::string uri = fromChar(ewk_security_origin_host_get(origin));
658 std::string url = (boost::format("%1%://%2%") % protocol % uri).str();
662 void WebView::__geolocationPermissionRequest(void * data, Evas_Object * /* obj */, void * event_info)
664 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
666 WebView * self = reinterpret_cast<WebView *>(data);
668 Ewk_Geolocation_Permission_Request *request = reinterpret_cast<Ewk_Geolocation_Permission_Request *>(event_info);
673 ewk_view_suspend(self->m_ewkView);
675 std::string url = WebView::securityOriginToUri(ewk_geolocation_permission_request_origin_get(request));
677 ///\todo add translations
678 std::string message = (boost::format("%1% Requests your location") % url).str();
680 WebConfirmationPtr c = std::make_shared<WebConfirmation>(WebConfirmation::ConfirmationType::Geolocation, self->m_tabId, url, message);
683 self->m_confirmationGeolocationMap[c] = request;
685 self->cofirmationRequest(c);
689 void WebView::__usermediaPermissionRequest(void * data, Evas_Object * /* obj */, void * event_info)
691 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
693 WebView * self = reinterpret_cast<WebView *>(data);
695 Ewk_User_Media_Permission_Request *request = reinterpret_cast<Ewk_User_Media_Permission_Request *>(event_info);
700 ewk_view_suspend(self->m_ewkView);
702 ///\todo add translations
703 std::string message = "User media permission request";
705 WebConfirmationPtr c = std::make_shared<WebConfirmation>(WebConfirmation::ConfirmationType::UserMedia, self->m_tabId, std::string(), message);
708 self->m_confirmationUserMediaMap[c] = request;
710 self->cofirmationRequest(c);
714 void WebView::__notificationPermissionRequest(void * data, Evas_Object * /* obj */, void * event_info)
716 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
718 WebView * self = reinterpret_cast<WebView *>(data);
720 Ewk_Notification_Permission_Request *request = reinterpret_cast<Ewk_Notification_Permission_Request *>(event_info);
725 ewk_view_suspend(self->m_ewkView);
727 ///\todo add translations
728 std::string message = (boost::format("%1% wants to display notifications") % self->getURI()).str();
730 WebConfirmationPtr c = std::make_shared<WebConfirmation>(WebConfirmation::ConfirmationType::Notification, self->m_tabId, self->getURI(), message);
733 self->m_confirmationNotificationMap[c] = request;
735 self->cofirmationRequest(c);
739 void WebView::__authenticationRequest(void * data, Evas_Object * /* obj */, void * event_info)
741 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
743 WebView * self = reinterpret_cast<WebView *>(data);
745 Ewk_Auth_Request *request = reinterpret_cast<Ewk_Auth_Request *>(event_info);
746 EINA_SAFETY_ON_NULL_RETURN(request);
748 std::string url = self->getURI();
749 std::string message = (boost::format("A username and password are being requested by %1%.") % url).str();
751 AuthenticationConfirmationPtr c = std::make_shared<AuthenticationConfirmation>(self->m_tabId, url, message);
753 self->m_confirmationAuthenticationMap[c] = request;
755 self->cofirmationRequest(c);
759 void WebView::__requestCertificationConfirm(void * data , Evas_Object * /* obj */, void * event_info)
761 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
763 WebView * self = reinterpret_cast<WebView *>(data);
765 Ewk_Certificate_Policy_Decision *request = reinterpret_cast<Ewk_Certificate_Policy_Decision *>(event_info);
770 ewk_view_suspend(self->m_ewkView);
772 std::string url = self->getURI();
774 ///\todo add translations
775 std::string message = (boost::format("There are problems with the security certificate for this site.<br>%1%") % url).str();
777 CertificateConfirmationPtr c = std::make_shared<CertificateConfirmation>(self->m_tabId, url, message);
779 c->setResult(tizen_browser::basic_webengine::WebConfirmation::ConfirmationResult::Confirmed);
782 self->m_confirmationCertificatenMap[c] = request;
784 self->cofirmationRequest(c);
789 void WebView::setFocus()
791 elm_object_focus_set(m_ewkView, EINA_TRUE);
794 void WebView::clearFocus()
796 elm_object_focus_set(m_ewkView, EINA_FALSE);
799 bool WebView::hasFocus() const
801 return elm_object_focus_get(m_ewkView) == EINA_TRUE ? true : false;
804 double WebView::getZoomFactor() const
806 if(EINA_UNLIKELY(m_ewkView == nullptr)){
810 #if defined(USE_EWEBKIT)
811 return ewk_view_page_zoom_get(m_ewkView);
817 void WebView::setZoomFactor(double zoomFactor)
819 #if defined(USE_EWEBKIT)
821 //using zoomFactor = 0 sets zoom "fit to screen"
823 ewk_view_page_zoom_set(m_ewkView, zoomFactor);
829 const TabId& WebView::getTabId(){
834 std::shared_ptr<BrowserImage> WebView::getFavicon()
836 BROWSER_LOGD("%s:%d, TabId: %s", __PRETTY_FUNCTION__, __LINE__, m_tabId.toString().c_str());
837 if(faviconImage.get())
840 Evas_Object * favicon = ewk_context_icon_database_icon_object_add(ewk_view_context_get(m_ewkView), ewk_view_url_get(m_ewkView),evas_object_evas_get(m_ewkView));
841 faviconImage = EflTools::getBrowserImage(favicon);
842 evas_object_unref(favicon);
844 if(faviconImage.get())
847 BROWSER_LOGD("[%s:%d] Returned favicon is empty!", __PRETTY_FUNCTION__, __LINE__);
848 return std::make_shared<BrowserImage>();
851 void WebView::clearPrivateData()
853 BROWSER_LOGD("Clearing private data");
854 #if defined(USE_EWEBKIT)
857 Ewk_Context *context = ewk_view_context_get(m_ewkView);
860 ewk_context_web_storage_delete_all(context);
861 ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get(context));
867 void WebView::searchOnWebsite(const std::string & searchString, int flags)
869 ///\todo: it should be "0" instead of "1024" for unlimited match count but it doesn't work properly in WebKit
870 Eina_Bool result = ewk_view_text_find(m_ewkView, searchString.c_str(), static_cast<Ewk_Find_Options>(flags), 1024);
871 BROWSER_LOGD("Ewk search; word: %s, result: %d", searchString.c_str(), result);
874 } /* namespace webkitengine_service */
875 } /* end of basic_webengine */
876 } /* end of tizen_browser */