Bug 622381 - Fail geolocation operations if we can't do cross-process operations. r=dougt a=jst

This commit is contained in:
Josh Matthews 2011-01-06 12:50:10 -05:00
Родитель 7f000ad3e2
Коммит 25417e468b
2 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -1040,7 +1040,9 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft
if (mOwner) {
RegisterRequestWithPrompt(request);
if (!RegisterRequestWithPrompt(request))
return NS_ERROR_NOT_AVAILABLE;
mPendingCallbacks.AppendElement(request);
return NS_OK;
}
@ -1083,7 +1085,8 @@ nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft
if (mOwner) {
RegisterRequestWithPrompt(request);
if (!RegisterRequestWithPrompt(request))
return NS_ERROR_NOT_AVAILABLE;
// need to hand back an index/reference.
mWatchingCallbacks.AppendElement(request);
@ -1141,18 +1144,20 @@ nsGeolocation::WindowOwnerStillExists()
return PR_TRUE;
}
void
bool
nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
{
#ifdef MOZ_IPC
if (XRE_GetProcessType() == GeckoProcessType_Content) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mOwner);
if (!window)
return;
return true;
// because owner implements nsITabChild, we can assume that it is
// the one and only TabChild.
TabChild* child = GetTabChildFrom(window->GetDocShell());
if (!child)
return false;
// Retain a reference so the object isn't deleted without IPDL's knowledge.
// Corresponding release occurs in DeallocPContentPermissionRequest.
@ -1162,7 +1167,7 @@ nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
child->SendPContentPermissionRequestConstructor(request, type, IPC::URI(mURI));
request->Sendprompt();
return;
return true;
}
#endif
@ -1170,10 +1175,11 @@ nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
{
nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(nsContentUtils::GetBoolPref("geo.prompt.testing.allow", PR_FALSE), request);
NS_DispatchToMainThread(ev);
return;
return true;
}
nsCOMPtr<nsIRunnable> ev = new RequestPromptEvent(request);
NS_DispatchToMainThread(ev);
return true;
}

Просмотреть файл

@ -233,7 +233,7 @@ private:
~nsGeolocation();
void RegisterRequestWithPrompt(nsGeolocationRequest* request);
bool RegisterRequestWithPrompt(nsGeolocationRequest* request);
// Two callback arrays. The first |mPendingCallbacks| holds objects for only
// one callback and then they are released/removed from the array. The second