*
*/
-#include "ewk_view.h"
+#include "ewk_view_product.h"
#include <Evas.h>
-#include <content/public/browser/navigation_controller.h>
-#include <tizen_webview/public/tw_webview.h>
-// TODO: remove dependency
-#include <ui/events/gesture_detection/gesture_configuration.h>
-#if !defined(EWK_BRINGUP)
-#include <webkit/common/webpreferences.h>
+#if !defined(EWK_BRINGUP) // FIXME: m67 bringup
+#include "webkit/common/webpreferences.h"
#else
-#include <content/public/common/web_preferences.h>
+#include "content/public/common/web_preferences.h"
#endif
-#include <../impl/eweb_view.h>
-#include <../impl/web_contents_delegate_efl.h>
-#include <../impl/cookie_manager.h>
-
+#include "content/public/browser/navigation_controller.h"
+#include "cookie_manager.h"
+#include "eweb_view.h"
+#include "geolocation_permission_popup.h"
+#include "notification_permission_popup.h"
#include "public/ewk_back_forward_list.h"
#include "public/ewk_context.h"
-#include "public/ewk_enums.h"
+#include "public/ewk_enums_internal.h"
#include "public/ewk_settings.h"
#include "private/ewk_context_private.h"
#include "private/ewk_frame_private.h"
#include "private/ewk_hit_test_private.h"
#include "private/ewk_notification_private.h"
#include "private/ewk_private.h"
-#if !defined(EWK_BRINGUP)
#include "private/ewk_quota_permission_request_private.h"
-#endif
-#include "private/chromium_glue.h"
#include "private/ewk_back_forward_list_private.h"
#include "private/ewk_history_private.h"
#include "private/ewk_view_private.h"
+// FIXME: removed on m63
+//#include "third_party/blink/public/web/WebViewModeEnums.h"
+#include "ui/events/gesture_detection/gesture_configuration.h"
+#include "url/gurl.h"
+#include "usermedia_permission_popup.h"
+#include "web_contents_delegate_efl.h"
+
+static Eina_Bool _ewk_view_default_user_media_permission(
+ Evas_Object*, Ewk_User_Media_Permission_Request*, void*);
-using tizen_webview::WebView;
-using tizen_webview::WebContext;
+static Eina_Bool _ewk_view_default_geolocation_permission(
+ Evas_Object*, Ewk_Geolocation_Permission_Request*, void*);
+
+static Eina_Bool _ewk_view_default_notification_permission(
+ Evas_Object*, Ewk_Notification_Permission_Request*, void*);
Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
{
Evas_Object* ret = ewk_view_add(canvas);
- WebView *webView = GetWebViewFromEvasObject(ret);
+ EWebView *webView = GetWebViewFromEvasObject(ret);
if (!webView || !data || !length)
return ret;
Evas_Object* ewk_view_add_with_context(Evas* e, Ewk_Context* context)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
- return CreateWebViewAsEvasObject(context, e);
+ Evas_Object* ewk_view = CreateWebViewAsEvasObject(context, e);
+
+ if (ewk_view) {
+ ewk_view_user_media_permission_callback_set(ewk_view,
+ _ewk_view_default_user_media_permission, 0);
+ ewk_view_geolocation_permission_callback_set(ewk_view,
+ _ewk_view_default_geolocation_permission, 0);
+ ewk_view_notification_permission_callback_set(ewk_view,
+ _ewk_view_default_notification_permission, 0);
+ }
+
+ return ewk_view;
}
Evas_Object* ewk_view_add(Evas* e)
Evas_Object* ewk_view_add_in_incognito_mode(Evas* e)
{
- Ewk_Context* context = static_cast<Ewk_Context*>(WebContext::Create(true));
+ Ewk_Context* context = Ewk_Context::Create(true);
EINA_SAFETY_ON_NULL_RETURN_VAL(context, NULL);
return ewk_view_add_with_context(e, context);
}
Ewk_Context *ewk_view_context_get(const Evas_Object *view)
{
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
- return static_cast<Ewk_Context*>(impl->GetWebContext());
+ return static_cast<Ewk_Context*>(impl->context());
}
-Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url)
+Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url_string)
{
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(url_string, false);
+ GURL url(url_string);
impl->SetURL(url);
return true;
}
const char* ewk_view_url_get(const Evas_Object* view)
{
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
- return impl->GetURL();
+ return impl->GetURL().possibly_invalid_spec().c_str();
}
Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *view)
{
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
- impl->ReloadIgnoringCache();
+ impl->ReloadBypassingCache();
return true;
}
loadtype = content::NavigationController::LOAD_TYPE_DEFAULT;
break;
case EWK_HTTP_METHOD_POST:
- loadtype = content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
+ loadtype = content::NavigationController::LOAD_TYPE_HTTP_POST;
break;
default:
LOG(ERROR) << "Not supported HTTP Method.";
Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State page_visibility_state, Eina_Bool initial_state)
{
- EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,false);
+ // TODO: Should we send initial_state to |Page::setVisibilityState()|?.
+ // isInitialState parameter seems be true only in the constructor of WebViewImpl.
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
+
+ // TODO: We should able to set 'prerender' or 'unloaded' as visibility state.
+ // http://www.w3.org/TR/page-visibility/#dom-document-visibilitystate
switch (page_visibility_state) {
- case EWK_PAGE_VISIBILITY_STATE_VISIBLE :
+ case EWK_PAGE_VISIBILITY_STATE_VISIBLE:
impl->Show();
break;
- case EWK_PAGE_VISIBILITY_STATE_HIDDEN :
+ case EWK_PAGE_VISIBILITY_STATE_HIDDEN:
impl->Hide();
break;
default:
- break;
+ return EINA_FALSE;
}
- return true;
+ return EINA_TRUE;
}
Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
- return impl->GetWebContext()->HTTPCustomHeaderAdd(name, value);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
+ return impl->context()->HTTPCustomHeaderAdd(name, value);
}
Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
- return impl->GetWebContext()->HTTPCustomHeaderRemove(name);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
+ return impl->context()->HTTPCustomHeaderRemove(name);
}
Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
- impl->GetWebContext()->HTTPCustomHeaderClear();
+ EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
+ impl->context()->HTTPCustomHeaderClear();
return EINA_TRUE;
}
Eina_Bool ewk_view_screenshot_contents_get_async(const Evas_Object* view, Eina_Rectangle view_area,
float scale_factor, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(callback, NULL);
- EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
+ EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
// Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
LOG(ERROR) << "We only support scale factor of 1.0."
<< "Scaling option will be supported after hardware acceleration is enabled.";
return EINA_FALSE;
}
- return impl->GetSnapshotAsync(view_area, canvas, callback, user_data) ? EINA_TRUE : EINA_FALSE;
+ return impl->GetSnapshotAsync(view_area, callback, user_data) ? EINA_TRUE : EINA_FALSE;
}
unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hit_test_mode)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
- return chromium_glue::from(impl->RequestHitTestDataAt(x, y,
- chromium_glue::to(static_cast<Ewk_Hit_Test_Mode>(hit_test_mode))));
+ return impl->RequestHitTestDataAt(x, y,
+ static_cast<Ewk_Hit_Test_Mode>(hit_test_mode));
}
Eina_Bool ewk_view_hit_test_request(Evas_Object* o, int x, int y, int hit_test_mode, Ewk_View_Hit_Test_Request_Callback callback, void* user_data)
{
EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE);
- return impl->AsyncRequestHitTestDataAt(x, y, chromium_glue::to(static_cast<Ewk_Hit_Test_Mode>(hit_test_mode)), chromium_glue::to(callback), user_data);
+ return impl->AsyncRequestHitTestDataAt(x, y, static_cast<Ewk_Hit_Test_Mode>(hit_test_mode), callback, user_data);
}
Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
- return chromium_glue::from(impl->GetBackForwardHistory());
+ return impl->GetBackForwardHistory();
}
Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
{
- EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
-
-#if !defined(EWK_BRINGUP)
-#warning "[M38] Fix and re-enable notifications (edit efl_integration/public/ewk_view.cc)"
- // copied from deleted NotificationControllerEfl::RemoveClosedNotifications()
- if (!eina_list_count(notification_list))
- return false;
-
- assert(impl->GetWebContext());
- assert(impl->GetWebContext()->browser_context());
- assert(impl->GetWebContext()->browser_context()->GetNotificationController());
- content::NotificationControllerEfl* controller =
- impl->GetWebContext()->browser_context()->GetNotificationController();
-
- Eina_List* notification_iterator = NULL;
- void* notification_data = NULL;
- EINA_LIST_FOREACH(notification_list, notification_iterator, notification_data) {
- Ewk_Notification* notification =
- static_cast<Ewk_Notification*>(notification_data);
-
- if (notification) {
- controller->DeleteNotification(notification->GetID(), true);
- delete notification;
- }
- }
-#endif
- return true;
-
+ return EINA_FALSE;
}
Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
Eina_Bool ewk_view_text_selection_clear(Evas_Object *view)
{
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
- return impl->ClearSelection() ? EINA_TRUE : EINA_FALSE;
+ return impl->ClearSelection();
}
const char* ewk_view_text_selection_text_get(Evas_Object* view)
void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
{
- EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
- EINA_SAFETY_ON_NULL_RETURN(func);
- impl->SetOrientationLockCallback(func, data);
+ LOG_EWK_API_MOCKUP("This API is deprecated, to use orientation lock/unlock "
+ "API please use functions lock_orientation/unlock_orientation provided "
+ "by Ewk_View_Smart_Class.");
}
{
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
- impl->HandleTouchEvents(chromium_glue::to(type), points, modifiers);
+ impl->HandleTouchEvents(type, points, modifiers);
return true;
}
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
EINA_SAFETY_ON_NULL_RETURN(policy);
- impl->SetContentSecurityPolicy(policy, chromium_glue::to(type));
+ impl->SetContentSecurityPolicy(policy, type);
}
void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(text, EINA_FALSE);
- impl->Find(text, chromium_glue::to(options));
+ impl->Find(text, options);
return EINA_TRUE;
}
void ewk_view_unfocus_allow_callback_set(Evas_Object* ewkView, Ewk_View_Unfocus_Allow_Callback callback, void* user_data)
{
- LOG_EWK_API_MOCKUP();
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
+ impl->SetViewUnfocusAllowCallback(callback, user_data);
}
void ewk_view_geolocation_permission_callback_set(Evas_Object* ewk_view, Ewk_View_Geolocation_Permission_Callback callback, void* user_data)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
- impl->SetViewGeolocationPermissionCallback(
- reinterpret_cast<tizen_webview::View_Geolocation_Permission_Callback>(callback), user_data);
+ impl->SetViewGeolocationPermissionCallback(callback, user_data);
+}
+
+static Eina_Bool _ewk_view_default_geolocation_permission(
+ Evas_Object* ewk_view,
+ Ewk_Geolocation_Permission_Request* request,
+ void* user_data)
+{
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
+
+ std::string value = std::string(ewk_security_origin_host_get(
+ ewk_geolocation_permission_request_origin_get(request)));
+ std::string message = std::string(
+ "Web Page (%s) is requesting permission to access your location.");
+ std::string replace_str = std::string("(%s)");
+
+ size_t pos = message.find(replace_str.c_str());
+ if (pos != std::string::npos)
+ message.replace(pos, replace_str.length(), value.c_str());
+
+ // add for suspending
+ ewk_geolocation_permission_request_suspend(request);
+
+ GeolocationPermissionPopup* popup = new GeolocationPermissionPopup(request,
+ ewk_geolocation_permission_request_origin_get(request), message);
+
+ impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
+
+ return EINA_TRUE;
+}
+
+void ewk_view_user_media_permission_callback_set(Evas_Object* ewk_view,
+ Ewk_View_User_Media_Permission_Callback callback,
+ void* user_data)
+{
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
+ impl->SetViewUserMediaPermissionCallback(callback, user_data);
+}
+
+static Eina_Bool _ewk_view_default_user_media_permission(
+ Evas_Object* ewk_view,
+ Ewk_User_Media_Permission_Request* user_media_permission_request,
+ void* user_data)
+{
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
+
+ std::string value = std::string(ewk_security_origin_host_get(
+ ewk_user_media_permission_request_origin_get(
+ user_media_permission_request)));
+
+ std::string message = std::string(dgettext(
+ "WebKit",
+ "IDS_WEBVIEW_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_USE_YOUR_CAMERA"));
+
+ std::string replace_str = std::string("%1$s");
+ size_t pos = message.find(replace_str.c_str());
+ if (pos != std::string::npos)
+ message.replace(pos, replace_str.length(), value.c_str());
+
+ replace_str = std::string("(%2$s)");
+ pos = message.find(replace_str.c_str());
+ if (pos != std::string::npos)
+ message.replace(pos, replace_str.length(), "");
+
+ // add for suspending
+ ewk_user_media_permission_request_suspend(user_media_permission_request);
+
+ UserMediaPermissionPopup* popup = new UserMediaPermissionPopup(
+ user_media_permission_request,
+ ewk_user_media_permission_request_origin_get(
+ user_media_permission_request), message);
+
+ impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
+
+ return EINA_TRUE;
}
void ewk_view_use_settings_font(Evas_Object* ewkView)
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
std::string cookiesForURL;
- cookiesForURL = impl->GetWebContext()->cookieManager()->GetCookiesForURL(std::string(url));
+ cookiesForURL = impl->context()->cookieManager()->GetCookiesForURL(std::string(url));
if (cookiesForURL.empty())
return NULL;
return strndup(cookiesForURL.c_str(), cookiesForURL.length());
EINA_SAFETY_ON_NULL_RETURN(data);
EINA_SAFETY_ON_NULL_RETURN(length);
- WebView* impl = GetWebViewFromEvasObject(ewkView);
+ EWebView* impl = GetWebViewFromEvasObject(ewkView);
if (!impl) {
*data = NULL;
*length = 0;
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
- if (view_mode == EWK_VIEW_MODE_WINDOWED || view_mode == EWK_VIEW_MODE_FULLSCREEN) {
- tizen_webview::View_Mode tizen_webview_view_mode;
- tizen_webview_view_mode = chromium_glue::to(view_mode);
- impl->SetViewMode(tizen_webview_view_mode);
+ if (view_mode == EWK_VIEW_MODE_WINDOWED) {
+#if !defined(EWK_BRINGUP) // FIXME: m67 bringup
+ impl->SetViewMode(blink::WebViewModeWindowed);
+#endif
+ return EINA_TRUE;
+ } else if (view_mode == EWK_VIEW_MODE_FULLSCREEN) {
+#if !defined(EWK_BRINGUP) // FIXME: m67 bringup
+ impl->SetViewMode(blink::WebViewModeFullscreen);
+#endif
return EINA_TRUE;
} else {
return EINA_FALSE;
Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
- return chromium_glue::from(impl->GetBackForwardList());
+ return impl->GetBackForwardList();
+}
+
+void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
+{
+ EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
+ impl->SetNotificationPermissionCallback(callback, user_data);
+}
+
+static Eina_Bool _ewk_view_default_notification_permission(
+ Evas_Object* ewk_view,
+ Ewk_Notification_Permission_Request* request,
+ void* user_data)
+{
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
+
+ std::string value = std::string(ewk_security_origin_host_get(
+ ewk_notification_permission_request_origin_get(request)));
+ std::string message = std::string(
+ "Web Page (%s) is requesting permission to show notifications.");
+ std::string replace_str = std::string("(%s)");
+
+ size_t pos = message.find(replace_str.c_str());
+ if (pos != std::string::npos)
+ message.replace(pos, replace_str.length(), value.c_str());
+
+ // add for suspending
+ ewk_notification_permission_request_suspend(request);
+
+ NotificationPermissionPopup* popup = new NotificationPermissionPopup(request,
+ ewk_notification_permission_request_origin_get(request), message);
+
+ impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
+
+ return EINA_TRUE;
}
void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
{
-#if defined(OS_TIZEN_TV) && !defined(EWK_BRINGUP)
- EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
- impl->setDrawFocusRing(enable);
-#else
- LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
-#endif
+ LOG_EWK_API_MOCKUP("This API is deprecated");
}
-#if defined(OS_TIZEN_TV)
double ewk_view_page_zoom_get(const Evas_Object* ewkView)
{
- LOG_EWK_API_MOCKUP("for Tizen TV Browser");
- return 0;
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1.0);
+ return impl->GetPageZoomFactor();
}
Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, double zoomFactor)
{
- LOG_EWK_API_MOCKUP("for Tizen TV Browser");
- return false;
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
+ impl->SetPageZoomFactor(zoomFactor);
+ return EINA_TRUE;
}
Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
return CreateWebViewAsEvasObject(context, canvas, smart);
}
-#endif // OS_TIZEN_TV
-#if !defined(EWK_BRINGUP)
void ewk_view_quota_permission_request_callback_set(Evas_Object* ewkView, Ewk_Quota_Permission_Request_Callback callback, void* user_data)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
- impl->SetQuotaPermissionRequestCallback((tizen_webview::QuotaPermissionRequest_Cb)callback, user_data);
+ impl->SetQuotaPermissionRequestCallback(callback, user_data);
}
void ewk_view_quota_permission_request_reply(const Ewk_Quota_Permission_Request* request, const Eina_Bool allow)
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
impl->QuotaRequestCancel(request);
}
-#endif