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 "mozilla/dom/PositionError.h"
8 #include "mozilla/dom/PositionErrorBinding.h"
9 #include "mozilla/CycleCollectedJSContext.h" // for nsAutoMicroTask
10 #include "nsGeolocation.h"
16 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PositionError
, mParent
)
17 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PositionError
, AddRef
)
18 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PositionError
, Release
)
20 PositionError::PositionError(Geolocation
* aParent
, int16_t aCode
)
26 PositionError::~PositionError() = default;
29 PositionError::GetMessage(nsAString
& aMessage
) const
33 case PositionError_Binding::PERMISSION_DENIED
:
34 aMessage
= NS_LITERAL_STRING("User denied geolocation prompt");
36 case PositionError_Binding::POSITION_UNAVAILABLE
:
37 aMessage
= NS_LITERAL_STRING("Unknown error acquiring position");
39 case PositionError_Binding::TIMEOUT
:
40 aMessage
= NS_LITERAL_STRING("Position acquisition timed out");
48 PositionError::GetParentObject() const
54 PositionError::WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
)
56 return PositionError_Binding::Wrap(aCx
, this, aGivenProto
);
60 PositionError::NotifyCallback(const GeoPositionErrorCallback
& aCallback
)
63 if (aCallback
.HasWebIDLCallback()) {
64 PositionErrorCallback
* callback
= aCallback
.GetWebIDLCallback();
67 callback
->Call(*this);
70 nsIDOMGeoPositionErrorCallback
* callback
= aCallback
.GetXPCOMCallback();
72 callback
->HandleEvent(this);
77 } // namespace mozilla