1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "Geolocation.h"
8 #include "GeolocationPosition.h"
9 #include "AndroidLocationProvider.h"
10 #include "mozilla/java/GeckoAppShellWrappers.h"
12 using namespace mozilla
;
14 extern nsIGeolocationUpdate
* gLocationCallback
;
16 NS_IMPL_ISUPPORTS(AndroidLocationProvider
, nsIGeolocationProvider
)
18 AndroidLocationProvider::AndroidLocationProvider() {}
20 AndroidLocationProvider::~AndroidLocationProvider() {
21 NS_IF_RELEASE(gLocationCallback
);
25 AndroidLocationProvider::Startup() {
26 if (java::GeckoAppShell::EnableLocationUpdates(true)) {
29 return NS_ERROR_FAILURE
;
33 AndroidLocationProvider::Watch(nsIGeolocationUpdate
* aCallback
) {
34 NS_IF_RELEASE(gLocationCallback
);
35 gLocationCallback
= aCallback
;
36 NS_IF_ADDREF(gLocationCallback
);
41 AndroidLocationProvider::Shutdown() {
42 if (java::GeckoAppShell::EnableLocationUpdates(false)) {
45 return NS_ERROR_FAILURE
;
49 AndroidLocationProvider::SetHighAccuracy(bool enable
) {
50 java::GeckoAppShell::EnableLocationHighAccuracy(enable
);