зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1466213 part 2. Remove nsIDOMGeoPositionError. r=qdot
This commit is contained in:
Родитель
01f73b98d9
Коммит
c53f7f15b1
|
@ -11,15 +11,10 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PositionError)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionError)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionError)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PositionError, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(PositionError)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(PositionError)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PositionError, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PositionError, Release)
|
||||
|
||||
PositionError::PositionError(Geolocation* aParent, int16_t aCode)
|
||||
: mCode(aCode)
|
||||
|
@ -29,33 +24,23 @@ PositionError::PositionError(Geolocation* aParent, int16_t aCode)
|
|||
|
||||
PositionError::~PositionError() = default;
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
PositionError::GetCode(int16_t *aCode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCode);
|
||||
*aCode = Code();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PositionError::GetMessage(nsAString& aMessage)
|
||||
void
|
||||
PositionError::GetMessage(nsAString& aMessage) const
|
||||
{
|
||||
switch (mCode)
|
||||
{
|
||||
case nsIDOMGeoPositionError::PERMISSION_DENIED:
|
||||
case PositionErrorBinding::PERMISSION_DENIED:
|
||||
aMessage = NS_LITERAL_STRING("User denied geolocation prompt");
|
||||
break;
|
||||
case nsIDOMGeoPositionError::POSITION_UNAVAILABLE:
|
||||
case PositionErrorBinding::POSITION_UNAVAILABLE:
|
||||
aMessage = NS_LITERAL_STRING("Unknown error acquiring position");
|
||||
break;
|
||||
case nsIDOMGeoPositionError::TIMEOUT:
|
||||
case PositionErrorBinding::TIMEOUT:
|
||||
aMessage = NS_LITERAL_STRING("Position acquisition timed out");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsWrapperCache*
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef mozilla_dom_PositionError_h
|
||||
#define mozilla_dom_PositionError_h
|
||||
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
@ -21,14 +20,11 @@ class PositionErrorCallback;
|
|||
class Geolocation;
|
||||
typedef CallbackObjectHolder<PositionErrorCallback, nsIDOMGeoPositionErrorCallback> GeoPositionErrorCallback;
|
||||
|
||||
class PositionError final : public nsIDOMGeoPositionError,
|
||||
public nsWrapperCache
|
||||
class PositionError final : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PositionError)
|
||||
|
||||
NS_DECL_NSIDOMGEOPOSITIONERROR
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PositionError)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PositionError)
|
||||
|
||||
PositionError(Geolocation* aParent, int16_t aCode);
|
||||
|
||||
|
@ -40,6 +36,8 @@ public:
|
|||
return mCode;
|
||||
}
|
||||
|
||||
void GetMessage(nsAString& aMessage) const;
|
||||
|
||||
void NotifyCallback(const GeoPositionErrorCallback& callback);
|
||||
private:
|
||||
~PositionError();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/PositionError.h"
|
||||
#include "mozilla/dom/PositionErrorBinding.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
@ -22,7 +23,6 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "nsINamed.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIScriptError.h"
|
||||
|
@ -270,7 +270,7 @@ void
|
|||
nsGeolocationRequest::Notify()
|
||||
{
|
||||
SetTimeoutTimer();
|
||||
NotifyErrorAndShutdown(nsIDOMGeoPositionError::TIMEOUT);
|
||||
NotifyErrorAndShutdown(PositionErrorBinding::TIMEOUT);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -346,7 +346,7 @@ nsGeolocationRequest::Cancel()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NotifyError(nsIDOMGeoPositionError::PERMISSION_DENIED);
|
||||
NotifyError(PositionErrorBinding::PERMISSION_DENIED);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ nsGeolocationRequest::Allow(JS::HandleValue aChoices)
|
|||
// if it is not a watch request and timeout is 0,
|
||||
// invoke the errorCallback (if present) with TIMEOUT code
|
||||
if (mOptions && mOptions->mTimeout == 0 && !mIsWatchPositionRequest) {
|
||||
NotifyError(nsIDOMGeoPositionError::TIMEOUT);
|
||||
NotifyError(PositionErrorBinding::TIMEOUT);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ nsGeolocationRequest::Allow(JS::HandleValue aChoices)
|
|||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Location provider error
|
||||
NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE);
|
||||
NotifyError(PositionErrorBinding::POSITION_UNAVAILABLE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -504,7 +504,7 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
|
|||
}
|
||||
|
||||
if (!wrapped) {
|
||||
NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE);
|
||||
NotifyError(PositionErrorBinding::POSITION_UNAVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -789,7 +789,7 @@ nsGeolocationService::StartDevice(nsIPrincipal *aPrincipal)
|
|||
if (NS_FAILED(rv = mProvider->Startup()) ||
|
||||
NS_FAILED(rv = mProvider->Watch(this))) {
|
||||
|
||||
NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE);
|
||||
NotifyError(PositionErrorBinding::POSITION_UNAVAILABLE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ XPIDL_SOURCES += [
|
|||
'nsIDOMGeoPosition.idl',
|
||||
'nsIDOMGeoPositionCallback.idl',
|
||||
'nsIDOMGeoPositionCoords.idl',
|
||||
'nsIDOMGeoPositionError.idl',
|
||||
'nsIDOMGeoPositionErrorCallback.idl',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
// undef the GetMessage macro defined in winuser.h from the MS Platform SDK
|
||||
%{C++
|
||||
#ifdef GetMessage
|
||||
#undef GetMessage
|
||||
#endif
|
||||
%}
|
||||
|
||||
[shim(PositionError), uuid(85255CC3-07BA-49FD-BC9B-18D2963DAF7F)]
|
||||
interface nsIDOMGeoPositionError : nsISupports
|
||||
{
|
||||
const unsigned short PERMISSION_DENIED = 1;
|
||||
const unsigned short POSITION_UNAVAILABLE = 2;
|
||||
const unsigned short TIMEOUT = 3;
|
||||
|
||||
readonly attribute short code;
|
||||
readonly attribute AString message;
|
||||
};
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIDOMGeoPositionError;
|
||||
webidl PositionError;
|
||||
|
||||
[scriptable, function, uuid(7D9B09D9-4843-43EB-A7A7-67F7DDA6B3C4)]
|
||||
interface nsIDOMGeoPositionErrorCallback : nsISupports {
|
||||
void handleEvent(in nsIDOMGeoPositionError positionError);
|
||||
void handleEvent(in PositionError positionError);
|
||||
};
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "mozilla/dom/PContentBridgeParent.h"
|
||||
#include "mozilla/dom/PContentPermissionRequestParent.h"
|
||||
#include "mozilla/dom/PCycleCollectWithLogsParent.h"
|
||||
#include "mozilla/dom/PositionError.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrar.h"
|
||||
#include "mozilla/dom/power/PowerManagerService.h"
|
||||
#include "mozilla/dom/Permissions.h"
|
||||
|
@ -123,7 +124,6 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMGeoGeolocation.h"
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "nsIDragService.h"
|
||||
#include "mozilla/dom/WakeLock.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
@ -3895,13 +3895,9 @@ ContentParent::HandleEvent(nsIDOMGeoPosition* postion)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContentParent::HandleEvent(nsIDOMGeoPositionError* postionError)
|
||||
ContentParent::HandleEvent(PositionError* positionError)
|
||||
{
|
||||
int16_t errorCode;
|
||||
nsresult rv;
|
||||
rv = postionError->GetCode(&errorCode);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
Unused << SendGeolocationError(errorCode);
|
||||
Unused << SendGeolocationError(positionError->Code());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
Cu.importGlobalProperties(["XMLHttpRequest"]);
|
||||
|
||||
const POSITION_UNAVAILABLE = Ci.nsIDOMGeoPositionError.POSITION_UNAVAILABLE;
|
||||
// PositionError has no interface object, so we can't use that here.
|
||||
const POSITION_UNAVAILABLE = 2;
|
||||
|
||||
var gLoggingEnabled = false;
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/LazyIdleThread.h"
|
||||
#include "mozilla/dom/PositionErrorBinding.h"
|
||||
#include "nsGeoPosition.h"
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
|
@ -185,7 +185,7 @@ public:
|
|||
err = PollLoop5();
|
||||
break;
|
||||
default:
|
||||
err = nsIDOMGeoPositionError::POSITION_UNAVAILABLE;
|
||||
err = PositionErrorBinding::POSITION_UNAVAILABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ protected:
|
|||
|
||||
return err;
|
||||
#else
|
||||
return nsIDOMGeoPositionError::POSITION_UNAVAILABLE;
|
||||
return PositionErrorBinding::POSITION_UNAVAILABLE;
|
||||
#endif // GPSD_MAJOR_API_VERSION
|
||||
}
|
||||
|
||||
|
@ -313,13 +313,13 @@ protected:
|
|||
case EPERM:
|
||||
MOZ_FALLTHROUGH;
|
||||
case EROFS:
|
||||
return nsIDOMGeoPositionError::PERMISSION_DENIED;
|
||||
return PositionErrorBinding::PERMISSION_DENIED;
|
||||
case ETIME:
|
||||
MOZ_FALLTHROUGH;
|
||||
case ETIMEDOUT:
|
||||
return nsIDOMGeoPositionError::TIMEOUT;
|
||||
return PositionErrorBinding::TIMEOUT;
|
||||
default:
|
||||
return nsIDOMGeoPositionError::POSITION_UNAVAILABLE;
|
||||
return PositionErrorBinding::POSITION_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
#include "nsGeoPosition.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "CoreLocationLocationProvider.h"
|
||||
#include "nsCocoaFeatures.h"
|
||||
#include "prtime.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/PositionErrorBinding.h"
|
||||
#include "MLSFallback.h"
|
||||
|
||||
#include <CoreLocation/CLError.h>
|
||||
|
@ -67,7 +67,7 @@ static const CLLocationAccuracy kDEFAULT_ACCURACY = kCLLocationAccuracyNearestTe
|
|||
console->LogStringMessage(NS_ConvertUTF8toUTF16([message UTF8String]).get());
|
||||
|
||||
if ([aError code] == kCLErrorDenied) {
|
||||
mProvider->NotifyError(nsIDOMGeoPositionError::PERMISSION_DENIED);
|
||||
mProvider->NotifyError(dom::PositionErrorBinding::PERMISSION_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#include "WindowsLocationProvider.h"
|
||||
#include "nsGeoPosition.h"
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "prtime.h"
|
||||
#include "MLSFallback.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/PositionErrorBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -129,11 +129,11 @@ LocationEvent::OnStatusChanged(REFIID aReportType,
|
|||
uint16_t err;
|
||||
switch (aStatus) {
|
||||
case REPORT_ACCESS_DENIED:
|
||||
err = nsIDOMGeoPositionError::PERMISSION_DENIED;
|
||||
err = PositionErrorBinding::PERMISSION_DENIED;
|
||||
break;
|
||||
case REPORT_NOT_SUPPORTED:
|
||||
case REPORT_ERROR:
|
||||
err = nsIDOMGeoPositionError::POSITION_UNAVAILABLE;
|
||||
err = PositionErrorBinding::POSITION_UNAVAILABLE;
|
||||
break;
|
||||
default:
|
||||
return S_OK;
|
||||
|
|
|
@ -30,8 +30,11 @@ function test1() {
|
|||
}
|
||||
|
||||
function errorCallback(error) {
|
||||
is(error.code,
|
||||
SpecialPowers.Ci.nsIDOMGeoPositionError.POSITION_UNAVAILABLE, "Geolocation error handler fired");
|
||||
// PositionError has no interface object, so we can't get constants off that.
|
||||
is(error.code, error.POSITION_UNAVAILABLE,
|
||||
"Geolocation error handler fired");
|
||||
is(error.POSITION_UNAVAILABLE, 2,
|
||||
"Value of POSITION_UNAVAILABLE should be correct");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ function successCallback() {
|
|||
}
|
||||
|
||||
function errorCallback(err) {
|
||||
Assert.equal(Ci.nsIDOMGeoPositionError.POSITION_UNAVAILABLE, err.code);
|
||||
// PositionError has no interface object, so we can't get constants off that.
|
||||
Assert.equal(err.POSITION_UNAVAILABLE, err.code);
|
||||
Assert.equal(2, err.code);
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче