2
* Copyright (C) 2008 Holger Hans Peter Freyther <zecke@selfish.org>
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.
22
#include "GeolocationClientGtk.h"
24
#if ENABLE(GEOLOCATION)
27
#include "ChromeClient.h"
28
#include "Geolocation.h"
29
#include "GeolocationController.h"
30
#include "GeolocationError.h"
31
#include "GeolocationPosition.h"
32
#include "webkitgeolocationpolicydecisionprivate.h"
33
#include "webkitwebframeprivate.h"
34
#include "webkitwebviewprivate.h"
35
#include <glib/gi18n-lib.h>
36
#include <wtf/gobject/GRefPtr.h>
40
GeolocationClient::GeolocationClient(WebKitWebView* webView)
46
void GeolocationClient::geolocationDestroyed()
51
void GeolocationClient::startUpdating()
53
m_provider.startUpdating();
56
void GeolocationClient::stopUpdating()
58
m_provider.stopUpdating();
61
void GeolocationClient::setEnableHighAccuracy(bool enable)
63
m_provider.setEnableHighAccuracy(enable);
66
WebCore::GeolocationPosition* GeolocationClient::lastPosition()
68
return m_lastPosition.get();
71
void GeolocationClient::requestPermission(WebCore::Geolocation* geolocation)
73
WebKitWebFrame* webFrame = kit(geolocation->frame());
74
GRefPtr<WebKitGeolocationPolicyDecision> policyDecision(adoptGRef(webkit_geolocation_policy_decision_new(webFrame, geolocation)));
76
gboolean isHandled = FALSE;
77
g_signal_emit_by_name(m_webView, "geolocation-policy-decision-requested", webFrame, policyDecision.get(), &isHandled);
79
webkit_geolocation_policy_deny(policyDecision.get());
82
void GeolocationClient::cancelPermissionRequest(WebCore::Geolocation* geolocation)
84
g_signal_emit_by_name(m_webView, "geolocation-policy-decision-cancelled", kit(geolocation->frame()));
87
void GeolocationClient::notifyPositionChanged(int timestamp, double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy)
89
m_lastPosition = WebCore::GeolocationPosition::create(static_cast<double>(timestamp), latitude, longitude, accuracy,
90
true, altitude, true, altitudeAccuracy, false, 0, false, 0);
91
WebCore::GeolocationController::from(core(m_webView))->positionChanged(m_lastPosition.get());
94
void GeolocationClient::notifyErrorOccurred(const char* message)
96
RefPtr<WebCore::GeolocationError> error = WebCore::GeolocationError::create(WebCore::GeolocationError::PositionUnavailable, message);
97
WebCore::GeolocationController::from(core(m_webView))->errorOccurred(error.get());
102
#endif // ENABLE(GEOLOCATION)