2 Copyright (C) 2012 Samsung Electronics
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #include "ewk_geolocation.h"
23 #if ENABLE(TIZEN_GEOLOCATION)
24 #include "EwkViewImpl.h"
25 #include "WKAPICast.h"
26 #include "WKGeolocationManager.h"
27 #include "WKGeolocationPermissionRequest.h"
28 #include "WKGeolocationPosition.h"
29 #include "WKRetainPtr.h"
30 #include "ewk_context_private.h"
31 #include "ewk_geolocation_private.h"
32 #include "ewk_view_private.h"
35 #include <location/locations.h>
36 #include <wtf/text/CString.h>
38 using namespace WebKit;
40 struct _Ewk_Geolocation_Permission_Request {
41 WKRetainPtr<WKGeolocationPermissionRequestRef> requestRef;
43 Ewk_Security_Origin* origin;
47 _Ewk_Geolocation_Permission_Request(WKPageRef pageRef, WKRetainPtr<WKGeolocationPermissionRequestRef> geolocationPermissionRequestRef, WKSecurityOriginRef originRef)
48 : requestRef(geolocationPermissionRequestRef)
53 origin = createSecurityOrigin(originRef);
56 ~_Ewk_Geolocation_Permission_Request()
58 deleteSecurityOrigin(origin);
62 Ewk_Geolocation_Permission_Request* ewkGeolocationCreatePermissionRequest(WKPageRef pageRef, WKGeolocationPermissionRequestRef geolocationPermissionRequestRef, WKSecurityOriginRef originRef)
64 return new Ewk_Geolocation_Permission_Request(pageRef, geolocationPermissionRequestRef, originRef);
67 void ewkGeolocationDeletePermissionRequestList(Eina_List* requestList)
70 EINA_LIST_FREE(requestList, data)
71 delete (static_cast<Ewk_Geolocation_Permission_Request*>(data));
74 bool ewkGeolocationIsPermissionRequestSuspended(const Ewk_Geolocation_Permission_Request* permissionRequest)
76 return permissionRequest->isSuspended;
79 bool ewkGeolocationIsPermissionRequestDecided(const Ewk_Geolocation_Permission_Request* permissionRequest)
81 return permissionRequest->isDecided;
85 const Ewk_Security_Origin* ewk_geolocation_permission_request_origin_get(const Ewk_Geolocation_Permission_Request* permissionRequest)
87 #if ENABLE(TIZEN_GEOLOCATION)
88 EINA_SAFETY_ON_NULL_RETURN_VAL(permissionRequest, 0);
90 return permissionRequest->origin;
92 UNUSED_PARAM(permissionRequest);
97 Eina_Bool ewk_geolocation_permission_request_set(Ewk_Geolocation_Permission_Request* permissionRequest, Eina_Bool allow)
99 #if ENABLE(TIZEN_GEOLOCATION)
100 EINA_SAFETY_ON_NULL_RETURN_VAL(permissionRequest, false);
101 TIZEN_LOGI("allow(%d)", allow);
103 permissionRequest->isDecided = true;
105 Evas_Object* ewkView = const_cast<Evas_Object*>(EwkViewImpl::viewFromPageViewMap(permissionRequest->page));
107 allow ? WKGeolocationPermissionRequestAllow(permissionRequest->requestRef.get()) : WKGeolocationPermissionRequestDeny(permissionRequest->requestRef.get());
108 ewkViewDeleteGeolocationPermission(ewkView, permissionRequest);
110 delete permissionRequest;
114 UNUSED_PARAM(permissionRequest);
120 void ewk_geolocation_permission_request_suspend(Ewk_Geolocation_Permission_Request* permissionRequest)
122 #if ENABLE(TIZEN_GEOLOCATION)
123 EINA_SAFETY_ON_NULL_RETURN(permissionRequest);
124 TIZEN_LOGI("request(%d) is suspended", permissionRequest);
126 permissionRequest->isSuspended = true;
128 UNUSED_PARAM(permissionRequest);