From 17c82478d7002b9bc4284ddb3342f396b87639d7 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 27 Nov 2013 02:28:16 -0200 Subject: [PATCH] Bug 935361 - Use CheckPermission in the PContentParent Geolocation message handlers. r=dougt --- dom/ipc/ContentParent.cpp | 47 +++++---------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index c884181aa6f5..9bd40948329f 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2843,51 +2843,14 @@ ContentParent::RecvAddGeolocationListener(const IPC::Principal& aPrincipal, const bool& aHighAccuracy) { #ifdef MOZ_CHILD_PERMISSIONS - if (Preferences::GetBool("geo.testing.ignore_ipc_principal", false) == false) { - nsIPrincipal* principal = aPrincipal; - if (principal == nullptr) { - KillHard(); - return true; - } - - uint32_t principalAppId; - nsresult rv = principal->GetAppId(&principalAppId); - if (NS_FAILED(rv)) { - return true; - } - - bool found = false; - const InfallibleTArray& browsers = ManagedPBrowserParent(); - for (uint32_t i = 0; i < browsers.Length(); ++i) { - TabParent* tab = static_cast(browsers[i]); - nsCOMPtr 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 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(); + if (!Preferences::GetBool("geo.testing.ignore_ipc_principal", false)) { + uint32_t permission = mozilla::CheckPermission(this, aPrincipal, + "geolocation"); + if (permission != nsIPermissionManager::ALLOW_ACTION) { return true; } } -#endif +#endif /* MOZ_CHILD_PERMISSIONS */ // To ensure no geolocation updates are skipped, we always force the // creation of a new listener.