Backing out 8c3bd23a1567 due to X orange. r=me a=me

This commit is contained in:
Doug Turner 2013-01-02 15:36:26 -08:00
parent 0305d05122
commit 9572a0b416
5 changed files with 8 additions and 61 deletions

View File

@ -1943,49 +1943,8 @@ ContentParent::RecvAsyncMessage(const nsString& aMsg,
}
bool
ContentParent::RecvAddGeolocationListener(const IPC::Principal& aPrincipal)
ContentParent::RecvAddGeolocationListener()
{
#ifdef MOZ_PERMISSIONS
nsIPrincipal* principal = aPrincipal;
uint32_t principalAppId;
nsresult rv = principal->GetAppId(&principalAppId);
if (NS_FAILED(rv)) {
return true;
}
bool found = false;
const InfallibleTArray<PBrowserParent*>& browsers = ManagedPBrowserParent();
for (uint32_t i = 0; i < browsers.Length(); ++i) {
TabParent* tab = static_cast<TabParent*>(browsers[i]);
nsCOMPtr<mozIApplication> app = tab->GetOwnOrContainingApp();
uint32_t appId;
app->GetLocalId(&appId);
if (appId == principalAppId) {
found = true;
break;
}
}
if (!found) {
return true;
}
// We need to ensure that this permission has been set.
// If it hasn't, just noop
nsCOMPtr<nsIPermissionManager> pm = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
if (!pm) {
return false;
}
uint32_t permission = nsIPermissionManager::UNKNOWN_ACTION;
rv = pm->TestPermissionFromPrincipal(principal, "geolocation", &permission);
if (NS_FAILED(rv) || permission != nsIPermissionManager::ALLOW_ACTION) {
KillHard();
return true;
}
#endif
if (mGeolocationWatchID == -1) {
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
if (!geo) {

View File

@ -26,7 +26,6 @@
#include "nsCOMArray.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "PermissionMessageUtils.h"
#define CHILD_PROCESS_SHUTDOWN_MESSAGE NS_LITERAL_STRING("child-process-shutdown")
@ -301,7 +300,7 @@ private:
virtual bool RecvAsyncMessage(const nsString& aMsg,
const ClonedMessageData& aData);
virtual bool RecvAddGeolocationListener(const IPC::Principal& aPrincipal);
virtual bool RecvAddGeolocationListener();
virtual bool RecvRemoveGeolocationListener();
virtual bool RecvSetGeolocationHigherAccuracy(const bool& aEnable);

View File

@ -23,10 +23,10 @@ include DOMTypes;
include URIParams;
include "mozilla/chrome/RegistryMessageUtils.h";
include "mozilla/dom/PermissionMessageUtils.h";
include "mozilla/dom/TabMessageUtils.h";
include "mozilla/layout/RenderFrameUtils.h";
include "mozilla/net/NeckoMessageUtils.h";
include "nsGeoPositionIPCSerialiser.h";
using GeoPosition;
@ -36,7 +36,6 @@ using ChromePackage;
using ResourceMapping;
using OverrideMapping;
using IPC::Permission;
using IPC::Principal;
using mozilla::null_t;
using mozilla::void_t;
using mozilla::dom::AudioChannelType;
@ -396,7 +395,7 @@ parent:
nsCString aContentDisposition, bool aForceSave,
int64_t aContentLength, OptionalURIParams aReferrer);
AddGeolocationListener(Principal principal);
AddGeolocationListener();
RemoveGeolocationListener();
SetGeolocationHigherAccuracy(bool enable);

View File

@ -424,7 +424,7 @@ nsGeolocationRequest::Allow()
// Kick off the geo device, if it isn't already running
nsRefPtr<nsGeolocationService> gs = nsGeolocationService::GetGeolocationService();
nsresult rv = gs->StartDevice(GetPrincipal(), isPrivate);
nsresult rv = gs->StartDevice(isPrivate);
if (NS_FAILED(rv)) {
// Location provider error
@ -541,15 +541,6 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
}
}
nsIPrincipal*
nsGeolocationRequest::GetPrincipal()
{
if (!mLocator) {
return nullptr;
}
return mLocator->GetPrincipal();
}
bool
nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition, bool aIsBetter)
{
@ -961,7 +952,7 @@ nsGeolocationService::GetCachedPosition()
}
nsresult
nsGeolocationService::StartDevice(nsIPrincipal *aPrincipal, bool aRequestPrivate)
nsGeolocationService::StartDevice(bool aRequestPrivate)
{
if (!sGeoEnabled || sGeoInitPending) {
return NS_ERROR_NOT_AVAILABLE;
@ -974,7 +965,7 @@ nsGeolocationService::StartDevice(nsIPrincipal *aPrincipal, bool aRequestPrivate
if (XRE_GetProcessType() == GeckoProcessType_Content) {
ContentChild* cpc = ContentChild::GetSingleton();
cpc->SendAddGeolocationListener(IPC::Principal(aPrincipal));
cpc->SendAddGeolocationListener();
return NS_OK;
}

View File

@ -67,7 +67,6 @@ class nsGeolocationRequest
bool IsActive() {return !mCleared;}
bool Allowed() {return mAllowed;}
void SetTimeoutTimer();
nsIPrincipal* GetPrincipal();
~nsGeolocationRequest();
@ -126,7 +125,7 @@ public:
PRBool IsBetterPosition(nsIDOMGeoPosition *aSomewhere);
// Find and startup a geolocation device (gps, nmea, etc.)
nsresult StartDevice(nsIPrincipal* aPrincipal, bool aRequestPrivate);
nsresult StartDevice(bool aRequestPrivate);
// Stop the started geolocation device (gps, nmea, etc.)
void StopDevice();