Bug 1003306 - part 2 - use services::GetPermissionManager everywhere that's appropriate; r=ehsan

This commit is contained in:
Nathan Froyd 2014-04-29 13:27:26 -04:00
parent e616ea9a4c
commit 4c20a67b0d
30 changed files with 46 additions and 42 deletions

View File

@ -2874,8 +2874,7 @@ TestSitePerm(nsIPrincipal* aPrincipal, const char* aType, uint32_t aPerm, bool a
return aPerm != nsIPermissionManager::ALLOW_ACTION;
}
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService("@mozilla.org/permissionmanager;1");
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t perm;

View File

@ -2616,7 +2616,7 @@ nsFrameLoader::ResetPermissionManagerStatus()
return;
}
nsCOMPtr<nsIPermissionManager> permMgr = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
if (!permMgr) {
NS_ERROR("No PermissionManager available!");
return;

View File

@ -3121,8 +3121,8 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIDocument> topDoc = do_QueryInterface(topDocument);
nsCOMPtr<nsIPermissionManager> permissionManager = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIPermissionManager> permissionManager = services::GetPermissionManager();
NS_ENSURE_TRUE(permissionManager, false);
// For now we always say that the system principal uses click-to-play since
// that maintains current behavior and we have tests that expect this.

View File

@ -396,7 +396,7 @@ nsXMLHttpRequest::InitParameters(bool aAnon, bool aSystem)
nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permMgr)
return;

View File

@ -2338,7 +2338,7 @@ bool HTMLMediaElement::CheckAudioChannelPermissions(const nsAString& aString)
}
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permissionManager) {
return false;
}

View File

@ -418,7 +418,7 @@ nsGenericHTMLFrameElement::GetReallyIsBrowserOrApp(bool *aOut)
// Fail if the node principal isn't trusted.
nsIPrincipal *principal = NodePrincipal();
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, NS_OK);
uint32_t permission = nsIPermissionManager::DENY_ACTION;
@ -464,7 +464,7 @@ nsGenericHTMLFrameElement::GetAppManifestURL(nsAString& aOut)
// Check permission.
nsIPrincipal *principal = NodePrincipal();
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, NS_OK);
uint32_t permission = nsIPermissionManager::DENY_ACTION;

View File

@ -7,6 +7,7 @@
#include "AudioDestinationNode.h"
#include "mozilla/dom/AudioDestinationNodeBinding.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "AudioChannelAgent.h"
#include "AudioChannelService.h"
#include "AudioNodeEngine.h"
@ -482,7 +483,7 @@ AudioDestinationNode::CheckAudioChannelPermissions(AudioChannel aValue)
}
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permissionManager) {
return false;
}

View File

@ -36,6 +36,7 @@
#include "nsXULAppAPI.h"
#include "prio.h"
#include "private/pprio.h"
#include "mozilla/Services.h"
#define ASMJSCACHE_METADATA_FILE_NAME "metadata"
#define ASMJSCACHE_ENTRY_FILE_NAME_BASE "module"
@ -688,7 +689,7 @@ MainProcessRunnable::InitOnMainThread()
MOZ_ASSERT(isApp);
nsCOMPtr<nsIPermissionManager> pm =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(pm, NS_ERROR_UNEXPECTED);
uint32_t permission;

View File

@ -1793,7 +1793,7 @@ Navigator::CheckPermission(nsPIDOMWindow* aWindow, const char* aType)
}
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;
@ -2189,7 +2189,7 @@ Navigator::HasWifiManagerSupport(JSContext* /* unused */,
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aGlobal);
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;

View File

@ -13653,7 +13653,7 @@ nsGlobalWindow::EnableNetworkEvent(uint32_t aType)
MOZ_ASSERT(IsInnerWindow());
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permMgr) {
NS_ERROR("No PermissionManager available!");
return;

View File

@ -18,6 +18,7 @@
#include "nsThreadUtils.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/dom/BluetoothManagerBinding.h"
#include "mozilla/Services.h"
using namespace mozilla;
@ -199,8 +200,7 @@ BluetoothManager::CheckPermission(nsPIDOMWindow* aWindow)
{
NS_ASSERTION(aWindow, "Null pointer!");
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission;

View File

@ -90,7 +90,7 @@ bool
nsDOMCameraManager::CheckPermission(nsPIDOMWindow* aWindow)
{
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;

View File

@ -3140,7 +3140,7 @@ nsDOMDeviceStorage::Init(nsPIDOMWindow* aWindow, const nsAString &aType,
// if the caller has the "webapps-manage" permission.
if (aType.EqualsLiteral(DEVICESTORAGE_APPS)) {
nsCOMPtr<nsIPermissionManager> permissionManager
= do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
= services::GetPermissionManager();
NS_ENSURE_TRUE(permissionManager, NS_ERROR_FAILURE);
uint32_t permission;

View File

@ -63,8 +63,7 @@ GetIndexedDBPermissions(nsIDOMWindow* aWindow)
return PERMISSION_DENIED;
}
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
nsCOMPtr<nsIPermissionManager> permissionManager = GetPermissionManager();
NS_ENSURE_TRUE(permissionManager, PERMISSION_DENIED);
uint32_t permission;
@ -108,8 +107,7 @@ CheckPermissionsHelper::Run()
nsIPrincipal* windowPrincipal = sop->GetPrincipal();
NS_ASSERTION(windowPrincipal, "Null principal!");
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
nsCOMPtr<nsIPermissionManager> permissionManager = GetPermissionManager();
NS_ENSURE_STATE(permissionManager);
rv = permissionManager->AddFromPrincipal(windowPrincipal,

View File

@ -225,7 +225,7 @@ CheckPermission(PContentParent* aActor,
}
nsCOMPtr<nsIPermissionManager> pm =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(pm, nsIPermissionManager::DENY_ACTION);
// Make sure that `aPermission' is an app permission before checking the origin.

View File

@ -1406,7 +1406,7 @@ ContentChild::RecvAddPermission(const IPC::Permission& permission)
{
#if MOZ_PERMISSIONS
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
nsPermissionManager* permissionManager =
static_cast<nsPermissionManager*>(permissionManagerIface.get());
NS_ABORT_IF_FALSE(permissionManager,

View File

@ -1705,7 +1705,7 @@ ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissio
{
#ifdef MOZ_PERMISSIONS
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
nsPermissionManager* permissionManager =
static_cast<nsPermissionManager*>(permissionManagerIface.get());
NS_ABORT_IF_FALSE(permissionManager,

View File

@ -157,7 +157,7 @@ MobileConnection::CheckPermission(const char* aType)
NS_ENSURE_TRUE(window, false);
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
mozilla::services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;

View File

@ -17,6 +17,7 @@
#include "nsServiceManagerUtils.h"
#include "nsError.h"
#include "mozilla/dom/MozPowerManagerBinding.h"
#include "mozilla/Services.h"
namespace mozilla {
namespace dom {
@ -185,7 +186,7 @@ bool
PowerManager::CheckPermission(nsPIDOMWindow* aWindow)
{
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;

View File

@ -122,7 +122,7 @@ CheckQuotaHelper::GetQuotaPermission(nsIPrincipal* aPrincipal)
"Chrome windows shouldn't track quota!");
nsCOMPtr<nsIPermissionManager> pm =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(pm, nsIPermissionManager::DENY_ACTION);
uint32_t permission;
@ -161,7 +161,7 @@ CheckQuotaHelper::Run()
NS_ENSURE_TRUE(sop, NS_ERROR_FAILURE);
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_STATE(permissionManager);
rv = permissionManager->AddFromPrincipal(sop->GetPrincipal(),

View File

@ -11,6 +11,7 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDocShell.h"
#include "AudioChannelService.h"
#include "mozilla/Services.h"
namespace mozilla {
namespace dom {
@ -147,8 +148,7 @@ SpeakerManager::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
return nullptr;
}
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, nullptr);
uint32_t permission = nsIPermissionManager::DENY_ACTION;

View File

@ -23,6 +23,7 @@
#include "nsDOMJSUtils.h"
#include "nsIScriptSecurityManager.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/Services.h"
#include "nsContentPermissionHelper.h"
#ifdef MOZ_B2G
#include "nsIDOMDesktopNotification.h"
@ -674,7 +675,7 @@ Notification::GetPermissionInternal(nsISupports* aGlobal, ErrorResult& aRv)
uint32_t permission = nsIPermissionManager::UNKNOWN_ACTION;
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
permissionManager->TestPermissionFromPrincipal(principal,
"desktop-notification",

View File

@ -254,7 +254,7 @@ DOMStorage::CanUseStorage(DOMStorage* aStorage)
// IsCallerChrome().
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permissionManager) {
return false;
}

View File

@ -11,6 +11,7 @@
#include "nsIInterfaceRequestorUtils.h"
#include "AudioChannelManager.h"
#include "mozilla/dom/AudioChannelManagerBinding.h"
#include "mozilla/Services.h"
using namespace mozilla::hal;
@ -85,7 +86,7 @@ AudioChannelManager::SetVolumeControlChannel(const nsAString& aChannel)
// Only normal channel doesn't need permission.
if (newChannel != AudioChannel::Normal) {
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permissionManager) {
return false;
}

View File

@ -17,6 +17,7 @@
#include "GeneratedEvents.h"
#include "mozilla/Preferences.h"
#include "mozilla/Attributes.h"
#include "mozilla/Services.h"
#include "nsIPermissionManager.h"
#include "mozilla/dom/DeviceLightEvent.h"
#include "mozilla/dom/DeviceProximityEvent.h"
@ -181,7 +182,7 @@ WindowCannotReceiveSensorEvent (nsPIDOMWindow* aWindow)
if (aWindow->GetOuterWindow()->IsBackground()) {
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromWindow(aWindow, "background-sensors", &permission);

View File

@ -11,6 +11,7 @@
#include "nsIPrefBranch.h"
#include "nsIPrincipal.h"
#include "nsIURI.h"
#include "mozilla/Services.h"
/**
* The Popup Window Manager maintains popup window permissions by website.
@ -40,7 +41,7 @@ nsresult
nsPopupWindowManager::Init()
{
nsresult rv;
mPermissionManager = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
mPermissionManager = mozilla::services::GetPermissionManager();
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);

View File

@ -239,7 +239,7 @@ nsSubDocumentFrame::PassPointerEventsToChildren()
}
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (permMgr) {
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromPrincipal(GetContent()->NodePrincipal(),

View File

@ -618,7 +618,7 @@ nsHttpChannel::RetrieveSSLOptions()
return;
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permMgr)
return;
@ -1180,7 +1180,7 @@ nsHttpChannel::ProcessSSLInformation()
// use via RetrieveSSLOptions(()
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permMgr)
return;

View File

@ -1270,7 +1270,7 @@ nsUrlClassifierDBService::LookupURI(nsIPrincipal* aPrincipal,
if (!clean) {
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (permissionManager) {
uint32_t perm;

View File

@ -695,7 +695,7 @@ OfflineAppPermForPrincipal(nsIPrincipal *aPrincipal,
}
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permissionManager) {
return NS_OK;
}
@ -767,7 +767,7 @@ nsOfflineCacheUpdateService::AllowOfflineApp(nsIDOMWindow *aWindow,
}
else {
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
services::GetPermissionManager();
if (!permissionManager)
return NS_ERROR_NOT_AVAILABLE;