mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 731875 - Geolocation doorhanger might cause a zombie compartment, GeoPositionOptions part, r=dougt
This commit is contained in:
parent
b6627fbc83
commit
d796636855
@ -53,7 +53,6 @@ XPIDLSRCS = \
|
||||
nsIDOMGeoPositionCallback.idl \
|
||||
nsIDOMGeoPositionError.idl \
|
||||
nsIDOMGeoPositionErrorCallback.idl \
|
||||
nsIDOMGeoPositionOptions.idl \
|
||||
nsIDOMNavigatorGeolocation.idl \
|
||||
$(NULL)
|
||||
|
||||
|
@ -41,16 +41,27 @@ interface nsIDOMGeoPositionOptions;
|
||||
interface nsIDOMGeoPositionCallback;
|
||||
interface nsIDOMGeoPositionErrorCallback;
|
||||
|
||||
[scriptable, uuid(37687DAF-B85F-4E4D-8881-85A0AD24CF78)]
|
||||
dictionary GeoPositionOptions
|
||||
{
|
||||
boolean enableHighAccuracy;
|
||||
long timeout;
|
||||
long maximumAge;
|
||||
};
|
||||
|
||||
[scriptable, uuid(b9a301f7-285b-4be9-b739-fb869019c77a)]
|
||||
interface nsIDOMGeoGeolocation : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
void getCurrentPosition(in nsIDOMGeoPositionCallback successCallback,
|
||||
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
|
||||
[optional] in nsIDOMGeoPositionOptions options);
|
||||
/* GeoPositionOptions */
|
||||
[optional] in jsval options);
|
||||
|
||||
[implicit_jscontext]
|
||||
long watchPosition(in nsIDOMGeoPositionCallback successCallback,
|
||||
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
|
||||
[optional] in nsIDOMGeoPositionOptions options);
|
||||
/* GeoPositionOptions */
|
||||
[optional] in jsval options);
|
||||
|
||||
void clearWatch(in long watchId);
|
||||
};
|
||||
|
@ -1,46 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Geolocation.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doug Turner <dougt@meer.net> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(453B72DE-EA90-4F09-AE16-C2E7EE0DDDC4)]
|
||||
interface nsIDOMGeoPositionOptions : nsISupports
|
||||
{
|
||||
attribute boolean enableHighAccuracy;
|
||||
attribute long timeout;
|
||||
attribute long maximumAge;
|
||||
};
|
@ -1172,7 +1172,8 @@ ContentParent::RecvAddGeolocationListener()
|
||||
if (!geo) {
|
||||
return true;
|
||||
}
|
||||
geo->WatchPosition(this, nsnull, nsnull, &mGeolocationWatchID);
|
||||
jsval dummy = JSVAL_VOID;
|
||||
geo->WatchPosition(this, nsnull, dummy, nsnull, &mGeolocationWatchID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -242,14 +242,12 @@ nsDOMGeoPositionError::NotifyCallback(nsIDOMGeoPositionErrorCallback* aCallback)
|
||||
nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator,
|
||||
nsIDOMGeoPositionCallback* aCallback,
|
||||
nsIDOMGeoPositionErrorCallback* aErrorCallback,
|
||||
nsIDOMGeoPositionOptions* aOptions,
|
||||
bool aWatchPositionRequest)
|
||||
: mAllowed(false),
|
||||
mCleared(false),
|
||||
mIsWatchPositionRequest(aWatchPositionRequest),
|
||||
mCallback(aCallback),
|
||||
mErrorCallback(aErrorCallback),
|
||||
mOptions(aOptions),
|
||||
mLocator(aLocator)
|
||||
{
|
||||
}
|
||||
@ -259,9 +257,13 @@ nsGeolocationRequest::~nsGeolocationRequest()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGeolocationRequest::Init()
|
||||
nsGeolocationRequest::Init(JSContext* aCx, const jsval& aOptions)
|
||||
{
|
||||
// This method is called before the user has given permission for this request.
|
||||
if (aCx && !JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) {
|
||||
mOptions = new mozilla::dom::GeoPositionOptions();
|
||||
nsresult rv = mOptions->Init(aCx, &aOptions);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -274,7 +276,7 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGeolocationRequest)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGeolocationRequest)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_4(nsGeolocationRequest, mCallback, mErrorCallback, mOptions, mLocator)
|
||||
NS_IMPL_CYCLE_COLLECTION_3(nsGeolocationRequest, mCallback, mErrorCallback, mLocator)
|
||||
|
||||
|
||||
void
|
||||
@ -378,16 +380,11 @@ nsGeolocationRequest::Allow()
|
||||
|
||||
PRUint32 maximumAge = 30 * PR_MSEC_PER_SEC;
|
||||
if (mOptions) {
|
||||
PRInt32 tempAge;
|
||||
nsresult rv = mOptions->GetMaximumAge(&tempAge);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (tempAge >= 0)
|
||||
maximumAge = tempAge;
|
||||
if (mOptions->maximumAge >= 0) {
|
||||
maximumAge = mOptions->maximumAge;
|
||||
}
|
||||
bool highAccuracy;
|
||||
rv = mOptions->GetEnableHighAccuracy(&highAccuracy);
|
||||
if (NS_SUCCEEDED(rv) && highAccuracy) {
|
||||
geoService->SetHigherAccuracy(true);
|
||||
if (mOptions->enableHighAccuracy) {
|
||||
geoService->SetHigherAccuracy(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,7 +414,7 @@ nsGeolocationRequest::SetTimeoutTimer()
|
||||
mTimeoutTimer = nsnull;
|
||||
}
|
||||
PRInt32 timeout;
|
||||
if (mOptions && NS_SUCCEEDED(mOptions->GetTimeout(&timeout)) && timeout != 0) {
|
||||
if (mOptions && (timeout = mOptions->timeout) != 0) {
|
||||
|
||||
if (timeout < 0)
|
||||
timeout = 0;
|
||||
@ -487,14 +484,11 @@ nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition)
|
||||
void
|
||||
nsGeolocationRequest::Shutdown()
|
||||
{
|
||||
if (mOptions) {
|
||||
bool highAccuracy;
|
||||
nsresult rv = mOptions->GetEnableHighAccuracy(&highAccuracy);
|
||||
if (NS_SUCCEEDED(rv) && highAccuracy) {
|
||||
nsRefPtr<nsGeolocationService> geoService = nsGeolocationService::GetInstance();
|
||||
if (geoService)
|
||||
geoService->SetHigherAccuracy(false);
|
||||
}
|
||||
if (mOptions && mOptions->enableHighAccuracy) {
|
||||
nsRefPtr<nsGeolocationService> geoService = nsGeolocationService::GetInstance();
|
||||
if (geoService) {
|
||||
geoService->SetHigherAccuracy(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mTimeoutTimer) {
|
||||
@ -941,7 +935,8 @@ nsGeolocation::Update(nsIDOMGeoPosition *aSomewhere)
|
||||
NS_IMETHODIMP
|
||||
nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
|
||||
nsIDOMGeoPositionErrorCallback *errorCallback,
|
||||
nsIDOMGeoPositionOptions *options)
|
||||
const jsval& options,
|
||||
JSContext* cx)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(callback);
|
||||
|
||||
@ -954,13 +949,12 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
|
||||
nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this,
|
||||
callback,
|
||||
errorCallback,
|
||||
options,
|
||||
false);
|
||||
if (!request)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(request->Init()))
|
||||
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft
|
||||
nsresult rv = request->Init(cx, options);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mOwner) {
|
||||
if (!RegisterRequestWithPrompt(request))
|
||||
@ -984,7 +978,8 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
|
||||
NS_IMETHODIMP
|
||||
nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
|
||||
nsIDOMGeoPositionErrorCallback *errorCallback,
|
||||
nsIDOMGeoPositionOptions *options,
|
||||
const jsval& options,
|
||||
JSContext* cx,
|
||||
PRInt32 *_retval NS_OUTPARAM)
|
||||
{
|
||||
|
||||
@ -999,13 +994,12 @@ nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
|
||||
nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this,
|
||||
callback,
|
||||
errorCallback,
|
||||
options,
|
||||
true);
|
||||
if (!request)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(request->Init()))
|
||||
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft
|
||||
nsresult rv = request->Init(cx, options);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mOwner) {
|
||||
if (!RegisterRequestWithPrompt(request))
|
||||
|
@ -57,14 +57,13 @@
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "nsIDOMGeoPositionCallback.h"
|
||||
#include "nsIDOMGeoPositionErrorCallback.h"
|
||||
#include "nsIDOMGeoPositionOptions.h"
|
||||
#include "nsIDOMNavigatorGeolocation.h"
|
||||
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#include "nsIGeolocationProvider.h"
|
||||
#include "nsIContentPermissionPrompt.h"
|
||||
|
||||
#include "DictionaryHelpers.h"
|
||||
#include "PCOMContentPermissionRequestChild.h"
|
||||
|
||||
class nsGeolocationService;
|
||||
@ -85,9 +84,8 @@ class nsGeolocationRequest
|
||||
nsGeolocationRequest(nsGeolocation* locator,
|
||||
nsIDOMGeoPositionCallback* callback,
|
||||
nsIDOMGeoPositionErrorCallback* errorCallback,
|
||||
nsIDOMGeoPositionOptions* options,
|
||||
bool watchPositionRequest = false);
|
||||
nsresult Init();
|
||||
nsresult Init(JSContext* aCx, const jsval& aOptions);
|
||||
void Shutdown();
|
||||
|
||||
// Called by the geolocation device to notify that a location has changed.
|
||||
@ -114,7 +112,7 @@ class nsGeolocationRequest
|
||||
nsCOMPtr<nsITimer> mTimeoutTimer;
|
||||
nsCOMPtr<nsIDOMGeoPositionCallback> mCallback;
|
||||
nsCOMPtr<nsIDOMGeoPositionErrorCallback> mErrorCallback;
|
||||
nsCOMPtr<nsIDOMGeoPositionOptions> mOptions;
|
||||
nsAutoPtr<mozilla::dom::GeoPositionOptions> mOptions;
|
||||
|
||||
nsRefPtr<nsGeolocation> mLocator;
|
||||
};
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "nsIDOMGeoPositionError.h"
|
||||
#include "nsIDOMGeoPositionCallback.h"
|
||||
#include "nsIDOMGeoPositionErrorCallback.h"
|
||||
#include "nsIDOMGeoPositionOptions.h"
|
||||
#include "nsIDOMNavigatorGeolocation.h"
|
||||
#include "nsIDOMGeoPositionCoords.h"
|
||||
|
||||
|
@ -13,7 +13,8 @@ dictionaries = [
|
||||
[ 'StorageEventInit', 'nsIDOMStorageEvent.idl' ],
|
||||
[ 'BlobPropertyBag', 'nsIDOMFile.idl' ],
|
||||
[ 'MutationObserverInit', 'nsIDOMMutationObserver.idl' ],
|
||||
[ 'SettingsEventInit', 'nsIDOMSettingsManager.idl' ]
|
||||
[ 'SettingsEventInit', 'nsIDOMSettingsManager.idl' ],
|
||||
[ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl']
|
||||
]
|
||||
|
||||
# include file names
|
||||
|
Loading…
Reference in New Issue
Block a user