[M34-Merge] Implementation of "geolocation,valid" smart callback
authorchaoren.li <chaoren.li@samsung.com>
Tue, 21 Oct 2014 03:08:06 +0000 (11:08 +0800)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Patch implements "geolocation,valid" smart callback.
This allows the browser to grant a given webview
permission to start off the geolocation path before
GeolocationPermissionRequest object is created.

This is code migration from m34 beta to DEV.
Original patch : http://suprem.sec.samsung.net/gerrit/#/c/6962/

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=7871
Reviewed by: Antonio Gomes, SeungSeop Park

Change-Id: I26ffb8ebf54b3ea4eb7cdfb6f7c38912ee5e8d2f
Signed-off-by: chaoren.li <chaoren.li@samsung.com>
tizen_src/impl/browser/geolocation/geolocation_permission_context_efl.cc
tizen_src/impl/eweb_view_callbacks.h

index 86ad56f745b1e20bb52466deaa00139d14af09b3..3fc55d0c66924dd9a66a5f0d1fccf024e186ce36 100644 (file)
@@ -37,15 +37,27 @@ void GeolocationPermissionContextEfl::RequestGeolocationPermissionOnUIThread(int
   if (!web_view)
     return;
 
-  std::string host = requesting_frame.host();
-  std::string port = requesting_frame.port();
-  std::string protocol = requesting_frame.scheme();
-  _Ewk_Geolocation_Permission_Request *request = new _Ewk_Geolocation_Permission_Request(web_view->evas_object(),
-                                                                                         host.c_str(),
-                                                                                         protocol.c_str(),
-                                                                                         atoi(port.c_str()),
-                                                                                         callback);
-  web_view->SmartCallback<EWebViewCallbacks::GeoLocationPermissionRequest>().call(request);
+  // Permission request is sent before even creating location provider -
+  // it's the only place where we can clearly ask certain view if
+  // we can enable it.
+  Eina_Bool geolocation_valid = EINA_TRUE;
+  web_view->SmartCallback<EWebViewCallbacks::GeoLocationValid>().call(
+      &geolocation_valid);
+  if (EINA_TRUE == geolocation_valid) {
+    std::string host = requesting_frame.host();
+    std::string port = requesting_frame.port();
+    std::string protocol = requesting_frame.scheme();
+    _Ewk_Geolocation_Permission_Request *request =
+    new _Ewk_Geolocation_Permission_Request(web_view->evas_object(),
+                                                host.c_str(),
+                                                protocol.c_str(),
+                                                atoi(port.c_str()),
+                                                callback);
+    web_view->SmartCallback<EWebViewCallbacks::GeoLocationPermissionRequest>().call(
+        request);
+  } else {
+    callback.Run(false);
+  }
 }
 
 void GeolocationPermissionContextEfl::RequestGeolocationPermission(int render_process_id,
index b7712e190e455a5a3ad483b84dc1eda7eb62fbdf..a469f424b6c3ef6ae313a9f0e0387248da598950 100644 (file)
@@ -97,6 +97,7 @@ enum CallbackType {
   IMECandidatePanelHide,
   IMEInputMethodChanged,
   GeoLocationPermissionRequest,
+  GeoLocationValid,
   RequestCertificateConfirm,
   AuthChallenge,
   NotificationShow,
@@ -254,6 +255,7 @@ DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadStarted, "load,provisional,started", vo
 DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadRedirect, "load,provisional,redirect", void);
 DECLARE_EWK_VIEW_CALLBACK(LoadCommitted, "load,committed", void);
 DECLARE_EWK_VIEW_CALLBACK(GeoLocationPermissionRequest, "geolocation,permission,request", _Ewk_Geolocation_Permission_Request*);
+DECLARE_EWK_VIEW_CALLBACK(GeoLocationValid, "geolocation,valid", Eina_Bool*);
 DECLARE_EWK_VIEW_CALLBACK(RequestCertificateConfirm, "request,certificate,confirm", _Ewk_Certificate_Policy_Decision*);
 DECLARE_EWK_VIEW_CALLBACK(AuthChallenge, "authentication,challenge", _Ewk_Auth_Challenge*);
 DECLARE_EWK_VIEW_CALLBACK(NotificationShow, "notification,show", tizen_webview::Notification*);