const char* kFullscreenFeature = "fullscreen";
const char* kNotificationPrivilege =
"http://tizen.org/privilege/notification";
+ const char* kLocationPrivilege =
+ "http://tizen.org/privilege/location";
bool FindPrivilege(wrt::ApplicationData* app_data,
const std::string& privilege) {
// TODO(sngn.lee): create popup and show
}
+void WebApplication::OnGeolocationPermissionRequest(
+ WebView* view,
+ const std::string& url,
+ std::function<void(bool)> result_handler) {
+ // TODO(sngn.lee): check from DB url was already allowed
+ // if(check already allow or denied) {
+ // result_handler(true);
+ // return;
+ // }
+ // Local Domain: Grant permission if defined, otherwise block execution.
+ // Remote Domain: Popup user prompt if defined, otherwise block execution.
+ if (!FindPrivilege(app_data_.get(), kLocationPrivilege)) {
+ result_handler(false);
+ return;
+ }
+
+ if (utils::StartsWith(url, "file://")) {
+ result_handler(true);
+ return;
+ }
+
+ // TODO(sngn.lee): create popup and show
+}
+
} // namespace wrt
WebView* /*view*/,
const std::string& /*url*/,
std::function<void(bool)> /*result_handler*/) {}
+ virtual void OnGeolocationPermissionRequest(
+ WebView* /*view*/,
+ const std::string& /*url*/,
+ std::function<void(bool)> /*result_handler*/) {}
};
WebView(wrt::NativeWindow* window, Ewk_Context* context);
InitWindowCreateCallback();
InitFullscreenCallback();
InitNotificationPermissionCallback();
+ InitGeolocationPermissionCallback();
// TODO(sngn.lee): "request,certificate,confirm" certification popup
// TODO(sngn.lee): "notification,show"
// TODO(sngn.lee): "notification,cancel"
// TODO(sngn.lee): "protocolhandler,registration,requested"
// custom protocol handler
- // TODO(sngn.lee): ewk_view_geolocation_permission_callback_set
// TODO(sngn.lee): ewk_view_user_media_permission_callback_set
// Show webview
ewk_view_,
NULL,
NULL);
+ ewk_view_geolocation_permission_callback_set(
+ ewk_view_,
+ NULL,
+ NULL);
window_->RemoveRotationHandler(rotation_handler_id_);
}
this);
}
+void WebViewImpl::InitGeolocationPermissionCallback() {
+ auto permission_callback = [](
+ Evas_Object*,
+ Ewk_Geolocation_Permission_Request* request,
+ void* user_data) {
+ LoggerD("Geolocation Permission Request");
+ WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+ if (self == NULL || self->listener_ == NULL) {
+ ewk_geolocation_permission_reply(request, EINA_FALSE);
+ return EINA_TRUE;
+ }
+ ewk_geolocation_permission_request_suspend(request);
+
+ const Ewk_Security_Origin* ewk_origin =
+ ewk_geolocation_permission_request_origin_get(request);
+ auto result_handler = [request](bool result) {
+ LoggerD("Geolocation Permission Result : %d", result);
+ ewk_geolocation_permission_reply(request, result);
+ };
+
+ std::stringstream url;
+ url << ewk_security_origin_protocol_get(ewk_origin)
+ << "://"
+ << ewk_security_origin_host_get(ewk_origin)
+ << ":"
+ << ewk_security_origin_port_get(ewk_origin);
+
+ self->listener_->OnGeolocationPermissionRequest(
+ self->view_,
+ url.str(),
+ result_handler);
+ return EINA_TRUE;
+ };
+ ewk_view_geolocation_permission_callback_set(ewk_view_,
+ permission_callback,
+ this);
+}
std::string WebViewImpl::GetUrl() {
return std::string(ewk_view_url_get(ewk_view_));