Bug 1363541 - Modernize the PermissionManager - part 4 - mozilla namespace, r=timhuang

Differential Revision: https://phabricator.services.mozilla.com/D70040

--HG--
rename : extensions/permissions/nsPermissionManager.cpp => extensions/permissions/PermissionManager.cpp
rename : extensions/permissions/nsPermissionManager.h => extensions/permissions/PermissionManager.h
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2020-04-11 13:42:12 +00:00
Родитель a765ed14dd
Коммит 13481ea877
49 изменённых файлов: 281 добавлений и 313 удалений

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

@ -4,7 +4,7 @@
# * "origin" should be used for matchtype, "host" is supported for legacy reasons
# * type is a string that identifies the type of permission (e.g. "cookie")
# * permission is an integer between 1 and 15
# See nsPermissionManager.cpp for more...
# See PermissionManager.cpp for more...
# UITour
# Bug 1557153: www.mozilla.org gets a special workaround in UITourChild.jsm

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

@ -174,9 +174,9 @@
#include "nsIAuthPrompt.h"
#include "nsIAuthPrompt2.h"
#include "mozilla/PermissionManager.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPermission.h"
#include "nsPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsIPrivateBrowsingChannel.h"
#include "ExpandedPrincipal.h"
@ -15899,7 +15899,7 @@ bool Document::AutomaticStorageAccessCanBeGranted(nsIPrincipal* aPrincipal) {
nsAutoCString prefix;
AntiTrackingUtils::CreateStoragePermissionKey(aPrincipal, prefix);
nsPermissionManager* permManager = nsPermissionManager::GetInstance();
PermissionManager* permManager = PermissionManager::GetInstance();
if (NS_WARN_IF(!permManager)) {
return false;
}

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

@ -510,7 +510,6 @@ LOCAL_INCLUDES += [
'/dom/xml',
'/dom/xslt/xpath',
'/dom/xul',
'/extensions/permissions',
'/gfx/2d',
'/image',
'/js/xpconnect/loader',

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

@ -398,7 +398,7 @@ interface nsIContentPolicy : nsISupports
* NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective,
* DoContentSecurityChecks, all nsIContentPolicy implementations, the
* static_assert in dom/cache/DBSchema.cpp, ChannelWrapper.webidl,
* ChannelWrapper.cpp, nsPermissionManager.cpp, and other things that are not
* ChannelWrapper.cpp, PermissionManager.cpp, and other things that are not
* listed here that are related to nsIContentPolicy. */
//////////////////////////////////////////////////////////////////////

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

@ -210,7 +210,7 @@
#endif
#include "mozilla/Permission.h"
#include "nsPermissionManager.h"
#include "mozilla/PermissionManager.h"
#include "PermissionMessageUtils.h"
@ -2469,8 +2469,8 @@ mozilla::ipc::IPCResult ContentChild::RecvAddPermission(
const IPC::Permission& permission) {
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
services::GetPermissionManager();
nsPermissionManager* permissionManager =
static_cast<nsPermissionManager*>(permissionManagerIface.get());
PermissionManager* permissionManager =
static_cast<PermissionManager*>(permissionManagerIface.get());
MOZ_ASSERT(permissionManager,
"We have no permissionManager in the Content process !");
@ -2494,7 +2494,7 @@ mozilla::ipc::IPCResult ContentChild::RecvAddPermission(
permissionManager->AddInternal(
principal, nsCString(permission.type), permission.capability, 0,
permission.expireType, permission.expireTime, modificationTime,
nsPermissionManager::eNotify, nsPermissionManager::eNoDBOperation);
PermissionManager::eNotify, PermissionManager::eNoDBOperation);
return IPC_OK();
}
@ -2502,8 +2502,8 @@ mozilla::ipc::IPCResult ContentChild::RecvAddPermission(
mozilla::ipc::IPCResult ContentChild::RecvRemoveAllPermissions() {
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
services::GetPermissionManager();
nsPermissionManager* permissionManager =
static_cast<nsPermissionManager*>(permissionManagerIface.get());
PermissionManager* permissionManager =
static_cast<PermissionManager*>(permissionManagerIface.get());
MOZ_ASSERT(permissionManager,
"We have no permissionManager in the Content process !");
@ -3346,7 +3346,7 @@ nsresult ContentChild::AsyncOpenAnonymousTemporaryFile(
mozilla::ipc::IPCResult ContentChild::RecvSetPermissionsWithKey(
const nsCString& aPermissionKey, nsTArray<IPC::Permission>&& aPerms) {
RefPtr<nsPermissionManager> permManager = nsPermissionManager::GetInstance();
RefPtr<PermissionManager> permManager = PermissionManager::GetInstance();
if (permManager) {
permManager->SetPermissionsWithKey(aPermissionKey, aPerms);
}

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

@ -251,7 +251,7 @@
# include "gfxAndroidPlatform.h"
#endif
#include "nsPermissionManager.h"
#include "mozilla/PermissionManager.h"
#ifdef MOZ_WIDGET_ANDROID
# include "AndroidBridge.h"
@ -5456,7 +5456,7 @@ nsresult ContentParent::TransmitPermissionsForPrincipal(
nsIPrincipal* aPrincipal) {
// Create the key, and send it down to the content process.
nsTArray<std::pair<nsCString, nsCString>> pairs =
nsPermissionManager::GetAllKeysForPrincipal(aPrincipal);
PermissionManager::GetAllKeysForPrincipal(aPrincipal);
MOZ_ASSERT(pairs.Length() >= 1);
for (auto& pair : pairs) {
EnsurePermissionsByKey(pair.first, pair.second);
@ -5506,7 +5506,7 @@ void ContentParent::EnsurePermissionsByKey(const nsCString& aKey,
// by this call to GetPermissionManager, and we've added the key to
// mActivePermissionKeys, then the permission manager will send down a
// SendAddPermission before receiving the SendSetPermissionsWithKey message.
RefPtr<nsPermissionManager> permManager = nsPermissionManager::GetInstance();
RefPtr<PermissionManager> permManager = PermissionManager::GetInstance();
if (!permManager) {
return;
}

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

@ -189,7 +189,6 @@ LOCAL_INCLUDES += [
'/dom/media/webspeech/synth/ipc',
'/dom/security',
'/dom/storage',
'/extensions/permissions',
'/extensions/spellcheck/src',
'/gfx/2d',
'/hal/sandbox',

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

@ -19,10 +19,6 @@ UNIFIED_SOURCES += [
'PermissionUtils.cpp',
]
LOCAL_INCLUDES += [
'/extensions/permissions',
]
MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
FINAL_LIBRARY = 'xul'

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

@ -53,12 +53,12 @@
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/PermissionManager.h"
#include "mozilla/Unused.h"
#include "mozilla/EnumSet.h"
#include "nsContentUtils.h"
#include "nsNetUtil.h"
#include "nsPermissionManager.h"
#include "nsProxyRelease.h"
#include "nsQueryObject.h"
#include "nsTArray.h"
@ -2287,8 +2287,7 @@ void ServiceWorkerManager::DispatchFetchEvent(nsIInterceptedChannel* aChannel,
// wait for them if they have not.
nsCOMPtr<nsIRunnable> permissionsRunnable = NS_NewRunnableFunction(
"dom::ServiceWorkerManager::DispatchFetchEvent", [=]() {
RefPtr<nsPermissionManager> permMgr =
nsPermissionManager::GetInstance();
RefPtr<PermissionManager> permMgr = PermissionManager::GetInstance();
if (permMgr) {
permMgr->WhenPermissionsAvailable(serviceWorker->Principal(),
continueRunnable);

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

@ -107,7 +107,6 @@ include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/extensions/permissions',
'/js/xpconnect/loader',
]

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

@ -15,7 +15,6 @@
#include "nsIInterfaceRequestor.h"
#include "nsIPrincipal.h"
#include "nsNetUtil.h"
#include "nsPermissionManager.h"
#include "nsProxyRelease.h"
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
@ -47,6 +46,7 @@
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/PermissionManager.h"
namespace mozilla {
@ -465,8 +465,8 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
}
});
RefPtr<nsPermissionManager> permissionManager =
nsPermissionManager::GetInstance();
RefPtr<PermissionManager> permissionManager =
PermissionManager::GetInstance();
if (!permissionManager) {
return NS_ERROR_FAILURE;
}

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

@ -29,7 +29,6 @@ UNIFIED_SOURCES += [
LOCAL_INCLUDES += [
'/dom/serviceworkers',
'/extensions/permissions',
'/xpcom/build',
]

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

@ -8,7 +8,6 @@
#include "nsGlobalWindowInner.h"
#include "nsPIDOMWindow.h"
#include "nsPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsContentPermissionHelper.h"
@ -16,6 +15,7 @@
#include "mozilla/StaticPrefs_permissions.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/PermissionManager.h"
using namespace mozilla::dom;
@ -135,7 +135,7 @@ nsresult PermissionDelegateHandler::GetDelegatePrincipal(
bool PermissionDelegateHandler::Initialize() {
MOZ_ASSERT(mDocument);
mPermissionManager = nsPermissionManager::GetInstance();
mPermissionManager = PermissionManager::GetInstance();
if (!mPermissionManager) {
return false;
}

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

@ -11,8 +11,8 @@
#include "mozilla/ContentPrincipal.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Permission.h"
#include "mozilla/PermissionManager.h"
#include "mozilla/Services.h"
#include "nsPermissionManager.h"
#include "nsCRT.h"
#include "nsNetUtil.h"
#include "nsTArray.h"
@ -46,11 +46,12 @@
#include "mozilla/ClearOnShutdown.h"
#include "nsEffectiveTLDService.h"
static mozilla::StaticRefPtr<nsPermissionManager> gPermissionManager;
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
static StaticRefPtr<PermissionManager> gPermissionManager;
static bool IsChildProcess() { return XRE_IsContentProcess(); }
static void LogToConsole(const nsAString& aMsg) {
@ -193,7 +194,7 @@ nsresult GetOriginFromPrincipal(nsIPrincipal* aPrincipal, bool aForceStripOA,
rv = aPrincipal->GetOriginSuffix(suffix);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::OriginAttributes attrs;
OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_FAILURE;
}
@ -220,7 +221,7 @@ nsresult GetOriginFromURIAndOA(nsIURI* aURI,
nsresult GetPrincipalFromOrigin(const nsACString& aOrigin, bool aForceStripOA,
nsIPrincipal** aPrincipal) {
nsAutoCString originNoSuffix;
mozilla::OriginAttributes attrs;
OriginAttributes attrs;
if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
return NS_ERROR_FAILURE;
}
@ -232,16 +233,16 @@ nsresult GetPrincipalFromOrigin(const nsACString& aOrigin, bool aForceStripOA,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal =
mozilla::BasePrincipal::CreateContentPrincipal(uri, attrs);
BasePrincipal::CreateContentPrincipal(uri, attrs);
principal.forget(aPrincipal);
return NS_OK;
}
nsresult GetPrincipal(nsIURI* aURI, bool aIsInIsolatedMozBrowserElement,
nsIPrincipal** aPrincipal) {
mozilla::OriginAttributes attrs(aIsInIsolatedMozBrowserElement);
OriginAttributes attrs(aIsInIsolatedMozBrowserElement);
nsCOMPtr<nsIPrincipal> principal =
mozilla::BasePrincipal::CreateContentPrincipal(aURI, attrs);
BasePrincipal::CreateContentPrincipal(aURI, attrs);
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
principal.forget(aPrincipal);
@ -249,9 +250,9 @@ nsresult GetPrincipal(nsIURI* aURI, bool aIsInIsolatedMozBrowserElement,
}
nsresult GetPrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal) {
mozilla::OriginAttributes attrs;
OriginAttributes attrs;
nsCOMPtr<nsIPrincipal> principal =
mozilla::BasePrincipal::CreateContentPrincipal(aURI, attrs);
BasePrincipal::CreateContentPrincipal(aURI, attrs);
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
principal.forget(aPrincipal);
@ -314,15 +315,15 @@ already_AddRefed<nsIPrincipal> GetNextSubDomainPrincipal(
}
// Copy the attributes over
mozilla::OriginAttributes attrs = aPrincipal->OriginAttributesRef();
OriginAttributes attrs = aPrincipal->OriginAttributesRef();
if (!StaticPrefs::permissions_isolateBy_userContext()) {
// Disable userContext for permissions.
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID);
attrs.StripAttributes(OriginAttributes::STRIP_USER_CONTEXT_ID);
}
nsCOMPtr<nsIPrincipal> principal =
mozilla::BasePrincipal::CreateContentPrincipal(newURI, attrs);
BasePrincipal::CreateContentPrincipal(newURI, attrs);
return principal.forget();
}
@ -575,9 +576,10 @@ static bool IsPersistentExpire(uint32_t aExpire, const nsACString& aType) {
////////////////////////////////////////////////////////////////////////////////
nsPermissionManager::PermissionKey*
nsPermissionManager::PermissionKey::CreateFromPrincipal(
nsIPrincipal* aPrincipal, bool aForceStripOA, nsresult& aResult) {
PermissionManager::PermissionKey*
PermissionManager::PermissionKey::CreateFromPrincipal(nsIPrincipal* aPrincipal,
bool aForceStripOA,
nsresult& aResult) {
nsAutoCString origin;
aResult = GetOriginFromPrincipal(aPrincipal, aForceStripOA, origin);
if (NS_WARN_IF(NS_FAILED(aResult))) {
@ -587,8 +589,8 @@ nsPermissionManager::PermissionKey::CreateFromPrincipal(
return new PermissionKey(origin);
}
nsPermissionManager::PermissionKey*
nsPermissionManager::PermissionKey::CreateFromURIAndOriginAttributes(
PermissionManager::PermissionKey*
PermissionManager::PermissionKey::CreateFromURIAndOriginAttributes(
nsIURI* aURI, const OriginAttributes* aOriginAttributes, bool aForceStripOA,
nsresult& aResult) {
nsAutoCString origin;
@ -601,9 +603,9 @@ nsPermissionManager::PermissionKey::CreateFromURIAndOriginAttributes(
return new PermissionKey(origin);
}
nsPermissionManager::PermissionKey*
nsPermissionManager::PermissionKey::CreateFromURI(nsIURI* aURI,
nsresult& aResult) {
PermissionManager::PermissionKey*
PermissionManager::PermissionKey::CreateFromURI(nsIURI* aURI,
nsresult& aResult) {
nsAutoCString origin;
aResult = ContentPrincipal::GenerateOriginNoSuffixFromURI(aURI, origin);
if (NS_WARN_IF(NS_FAILED(aResult))) {
@ -614,13 +616,13 @@ nsPermissionManager::PermissionKey::CreateFromURI(nsIURI* aURI,
}
/* static */
void nsPermissionManager::Startup() {
void PermissionManager::Startup() {
nsCOMPtr<nsIPermissionManager> permManager =
do_GetService("@mozilla.org/permissionmanager;1");
}
////////////////////////////////////////////////////////////////////////////////
// nsPermissionManager Implementation
// PermissionManager Implementation
#define PERMISSIONS_FILE_NAME "permissions.sqlite"
#define HOSTS_SCHEMA_VERSION 11
@ -631,16 +633,16 @@ static const char kDefaultsUrlPrefName[] = "permissions.manager.defaultsUrl";
static const char kPermissionChangeNotification[] = PERM_CHANGE_NOTIFICATION;
NS_IMPL_ISUPPORTS(nsPermissionManager, nsIPermissionManager, nsIObserver,
NS_IMPL_ISUPPORTS(PermissionManager, nsIPermissionManager, nsIObserver,
nsISupportsWeakReference)
nsPermissionManager::nsPermissionManager()
: mMonitor("nsPermissionManager::mMonitor"),
PermissionManager::PermissionManager()
: mMonitor("PermissionManager::mMonitor"),
mState(eInitializing),
mMemoryOnlyDB(false),
mLargestID(0) {}
nsPermissionManager::~nsPermissionManager() {
PermissionManager::~PermissionManager() {
// NOTE: Make sure to reject each of the promises in mPermissionKeyPromiseMap
// before destroying.
for (auto iter = mPermissionKeyPromiseMap.Iter(); !iter.Done(); iter.Next()) {
@ -663,21 +665,20 @@ nsPermissionManager::~nsPermissionManager() {
}
// static
already_AddRefed<nsIPermissionManager>
nsPermissionManager::GetXPCOMSingleton() {
already_AddRefed<nsIPermissionManager> PermissionManager::GetXPCOMSingleton() {
if (gPermissionManager) {
return do_AddRef(gPermissionManager);
}
// Create a new singleton nsPermissionManager.
// Create a new singleton PermissionManager.
// We AddRef only once since XPCOM has rules about the ordering of module
// teardowns - by the time our module destructor is called, it's too late to
// Release our members, since GC cycles have already been completed and
// would result in serious leaks.
// See bug 209571.
auto permManager = MakeRefPtr<nsPermissionManager>();
auto permManager = MakeRefPtr<PermissionManager>();
if (NS_SUCCEEDED(permManager->Init())) {
// Note: This is cleared in the nsPermissionManager destructor.
// Note: This is cleared in the PermissionManager destructor.
gPermissionManager = permManager.get();
ClearOnShutdown(&gPermissionManager);
return permManager.forget();
@ -687,7 +688,7 @@ nsPermissionManager::GetXPCOMSingleton() {
}
// static
nsPermissionManager* nsPermissionManager::GetInstance() {
PermissionManager* PermissionManager::GetInstance() {
if (!gPermissionManager) {
// Hand off the creation of the permission manager to GetXPCOMSingleton.
nsCOMPtr<nsIPermissionManager> permManager = GetXPCOMSingleton();
@ -696,11 +697,10 @@ nsPermissionManager* nsPermissionManager::GetInstance() {
return gPermissionManager;
}
nsresult nsPermissionManager::Init() {
nsresult PermissionManager::Init() {
// If the 'permissions.memory_only' pref is set to true, then don't write any
// permission settings to disk, but keep them in a memory-only database.
mMemoryOnlyDB =
mozilla::Preferences::GetBool("permissions.memory_only", false);
mMemoryOnlyDB = Preferences::GetBool("permissions.memory_only", false);
nsresult rv;
nsCOMPtr<nsIPrefService> prefService =
@ -718,8 +718,7 @@ nsresult nsPermissionManager::Init() {
return NS_OK;
}
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
if (observerService) {
observerService->AddObserver(this, "profile-before-change", true);
observerService->AddObserver(this, "profile-do-change", true);
@ -744,7 +743,7 @@ nsresult nsPermissionManager::Init() {
return NS_OK;
}
nsresult nsPermissionManager::OpenDatabase(nsIFile* aPermissionsFile) {
nsresult PermissionManager::OpenDatabase(nsIFile* aPermissionsFile) {
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ACCESS_THREAD_BOUND(mThreadBoundData, data);
@ -763,7 +762,7 @@ nsresult nsPermissionManager::OpenDatabase(nsIFile* aPermissionsFile) {
return rv;
}
void nsPermissionManager::InitDB(bool aRemoveFile) {
void PermissionManager::InitDB(bool aRemoveFile) {
mState = eInitializing;
{
@ -796,9 +795,9 @@ void nsPermissionManager::InitDB(bool aRemoveFile) {
nsCOMPtr<nsIInputStream> defaultsInputStream = GetDefaultsInputStream();
RefPtr<nsPermissionManager> self = this;
RefPtr<PermissionManager> self = this;
mThread->Dispatch(NS_NewRunnableFunction(
"nsPermissionManager::InitDB", [self, aRemoveFile, defaultsInputStream] {
"PermissionManager::InitDB", [self, aRemoveFile, defaultsInputStream] {
nsresult rv = self->TryInitDB(aRemoveFile, defaultsInputStream);
Unused << NS_WARN_IF(NS_FAILED(rv));
@ -806,7 +805,7 @@ void nsPermissionManager::InitDB(bool aRemoveFile) {
// initialization. If there is something blocked by the monitor, it will
// be NOP.
NS_DispatchToMainThread(
NS_NewRunnableFunction("nsPermissionManager::InitDB-MainThread",
NS_NewRunnableFunction("PermissionManager::InitDB-MainThread",
[self] { self->EnsureReadCompleted(); }));
self->mMonitor.Notify();
@ -815,8 +814,8 @@ void nsPermissionManager::InitDB(bool aRemoveFile) {
readyIfFailed.release();
}
nsresult nsPermissionManager::TryInitDB(bool aRemoveFile,
nsIInputStream* aDefaultsInputStream) {
nsresult PermissionManager::TryInitDB(bool aRemoveFile,
nsIInputStream* aDefaultsInputStream) {
MOZ_ASSERT(!NS_IsMainThread());
MonitorAutoLock lock(mMonitor);
@ -847,8 +846,7 @@ nsresult nsPermissionManager::TryInitDB(bool aRemoveFile,
NS_LITERAL_STRING("permissions.sqlite is corrupted! Try again!"));
// Add telemetry probe
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::PERMISSIONS_SQL_CORRUPTED, 1);
Telemetry::Accumulate(Telemetry::PERMISSIONS_SQL_CORRUPTED, 1);
// delete corrupted permissions.sqlite and try again
rv = mPermissionsFile->Remove(false);
@ -881,8 +879,7 @@ nsresult nsPermissionManager::TryInitDB(bool aRemoveFile,
NS_LITERAL_STRING("Defective permissions.sqlite has been removed."));
// Add telemetry probe
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::DEFECTIVE_PERMISSIONS_SQL_REMOVED, 1);
Telemetry::Accumulate(Telemetry::DEFECTIVE_PERMISSIONS_SQL_REMOVED, 1);
rv = OpenDatabase(mPermissionsFile);
NS_ENSURE_SUCCESS(rv, rv);
@ -1440,11 +1437,10 @@ nsresult nsPermissionManager::TryInitDB(bool aRemoveFile,
return NS_OK;
}
void nsPermissionManager::AddIdleDailyMaintenanceJob() {
void PermissionManager::AddIdleDailyMaintenanceJob() {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
NS_ENSURE_TRUE_VOID(observerService);
nsresult rv =
@ -1452,11 +1448,10 @@ void nsPermissionManager::AddIdleDailyMaintenanceJob() {
NS_ENSURE_SUCCESS_VOID(rv);
}
void nsPermissionManager::RemoveIdleDailyMaintenanceJob() {
void PermissionManager::RemoveIdleDailyMaintenanceJob() {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
NS_ENSURE_TRUE_VOID(observerService);
nsresult rv =
@ -1464,12 +1459,12 @@ void nsPermissionManager::RemoveIdleDailyMaintenanceJob() {
NS_ENSURE_SUCCESS_VOID(rv);
}
void nsPermissionManager::PerformIdleDailyMaintenance() {
void PermissionManager::PerformIdleDailyMaintenance() {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<nsPermissionManager> self = this;
RefPtr<PermissionManager> self = this;
mThread->Dispatch(NS_NewRunnableFunction(
"nsPermissionManager::PerformIdleDailyMaintenance", [self] {
"PermissionManager::PerformIdleDailyMaintenance", [self] {
MOZ_ACCESS_THREAD_BOUND(self->mThreadBoundData, data);
if (self->mState == eClosed || !data->mDBConn) {
@ -1496,7 +1491,7 @@ void nsPermissionManager::PerformIdleDailyMaintenance() {
}
// sets the schema version and creates the moz_perms table.
nsresult nsPermissionManager::CreateTable() {
nsresult PermissionManager::CreateTable() {
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ACCESS_THREAD_BOUND(mThreadBoundData, data);
@ -1535,11 +1530,10 @@ nsresult nsPermissionManager::CreateTable() {
}
NS_IMETHODIMP
nsPermissionManager::AddFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t aPermission,
uint32_t aExpireType,
int64_t aExpireTime) {
PermissionManager::AddFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t aPermission, uint32_t aExpireType,
int64_t aExpireTime) {
ENSURE_NOT_CHILD_PROCESS;
NS_ENSURE_ARG_POINTER(aPrincipal);
NS_ENSURE_TRUE(aExpireType == nsIPermissionManager::EXPIRE_NEVER ||
@ -1581,7 +1575,7 @@ nsPermissionManager::AddFromPrincipal(nsIPrincipal* aPrincipal,
aExpireTime, modificationTime, eNotify, eWriteToDB);
}
nsresult nsPermissionManager::AddInternal(
nsresult PermissionManager::AddInternal(
nsIPrincipal* aPrincipal, const nsACString& aType, uint32_t aPermission,
int64_t aID, uint32_t aExpireType, int64_t aExpireTime,
int64_t aModificationTime, NotifyOperationType aNotifyOperation,
@ -1882,8 +1876,8 @@ nsresult nsPermissionManager::AddInternal(
}
NS_IMETHODIMP
nsPermissionManager::RemoveFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType) {
PermissionManager::RemoveFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType) {
ENSURE_NOT_CHILD_PROCESS;
NS_ENSURE_ARG_POINTER(aPrincipal);
@ -1904,7 +1898,7 @@ nsPermissionManager::RemoveFromPrincipal(nsIPrincipal* aPrincipal,
}
NS_IMETHODIMP
nsPermissionManager::RemovePermission(nsIPermission* aPerm) {
PermissionManager::RemovePermission(nsIPermission* aPerm) {
if (!aPerm) {
return NS_OK;
}
@ -1922,19 +1916,19 @@ nsPermissionManager::RemovePermission(nsIPermission* aPerm) {
}
NS_IMETHODIMP
nsPermissionManager::RemoveAll() {
PermissionManager::RemoveAll() {
ENSURE_NOT_CHILD_PROCESS;
return RemoveAllInternal(true);
}
NS_IMETHODIMP
nsPermissionManager::RemoveAllSince(int64_t aSince) {
PermissionManager::RemoveAllSince(int64_t aSince) {
ENSURE_NOT_CHILD_PROCESS;
return RemoveAllModifiedSince(aSince);
}
template <class T>
nsresult nsPermissionManager::RemovePermissionEntries(T aCondition) {
nsresult PermissionManager::RemovePermissionEntries(T aCondition) {
Vector<Tuple<nsCOMPtr<nsIPrincipal>, nsCString, nsCString>, 10> array;
for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
PermissionHashKey* entry = iter.Get();
@ -1963,7 +1957,7 @@ nsresult nsPermissionManager::RemovePermissionEntries(T aCondition) {
// AddInternal handles removal, so let it do the work...
AddInternal(Get<0>(i), Get<1>(i), nsIPermissionManager::UNKNOWN_ACTION, 0,
nsIPermissionManager::EXPIRE_NEVER, 0, 0,
nsPermissionManager::eNotify, nsPermissionManager::eWriteToDB,
PermissionManager::eNotify, PermissionManager::eWriteToDB,
false, &Get<2>(i));
}
@ -1974,7 +1968,7 @@ nsresult nsPermissionManager::RemovePermissionEntries(T aCondition) {
}
NS_IMETHODIMP
nsPermissionManager::RemoveByType(const nsACString& aType) {
PermissionManager::RemoveByType(const nsACString& aType) {
ENSURE_NOT_CHILD_PROCESS;
int32_t typeIndex = GetTypeIndex(aType, false);
@ -1991,8 +1985,8 @@ nsPermissionManager::RemoveByType(const nsACString& aType) {
}
NS_IMETHODIMP
nsPermissionManager::RemoveByTypeSince(const nsACString& aType,
int64_t aModificationTime) {
PermissionManager::RemoveByTypeSince(const nsACString& aType,
int64_t aModificationTime) {
ENSURE_NOT_CHILD_PROCESS;
int32_t typeIndex = GetTypeIndex(aType, false);
@ -2009,7 +2003,7 @@ nsPermissionManager::RemoveByTypeSince(const nsACString& aType,
});
}
void nsPermissionManager::CloseDB(bool aRebuildOnSuccess) {
void PermissionManager::CloseDB(bool aRebuildOnSuccess) {
EnsureReadCompleted();
mState = eClosed;
@ -2019,9 +2013,9 @@ void nsPermissionManager::CloseDB(bool aRebuildOnSuccess) {
defaultsInputStream = GetDefaultsInputStream();
}
RefPtr<nsPermissionManager> self = this;
RefPtr<PermissionManager> self = this;
mThread->Dispatch(NS_NewRunnableFunction(
"nsPermissionManager::CloseDB",
"PermissionManager::CloseDB",
[self, aRebuildOnSuccess, defaultsInputStream] {
MOZ_ACCESS_THREAD_BOUND(self->mThreadBoundData, data);
// Null the statements, this will finalize them.
@ -2029,7 +2023,7 @@ void nsPermissionManager::CloseDB(bool aRebuildOnSuccess) {
data->mStmtDelete = nullptr;
data->mStmtUpdate = nullptr;
if (data->mDBConn) {
mozilla::DebugOnly<nsresult> rv = data->mDBConn->Close();
DebugOnly<nsresult> rv = data->mDBConn->Close();
MOZ_ASSERT(NS_SUCCEEDED(rv));
data->mDBConn = nullptr;
@ -2040,7 +2034,7 @@ void nsPermissionManager::CloseDB(bool aRebuildOnSuccess) {
}));
}
nsresult nsPermissionManager::RemoveAllFromIPC() {
nsresult PermissionManager::RemoveAllFromIPC() {
MOZ_ASSERT(IsChildProcess());
// Remove from memory and notify immediately. Since the in-memory
@ -2051,7 +2045,7 @@ nsresult nsPermissionManager::RemoveAllFromIPC() {
return NS_OK;
}
nsresult nsPermissionManager::RemoveAllInternal(bool aNotifyObservers) {
nsresult PermissionManager::RemoveAllInternal(bool aNotifyObservers) {
ENSURE_NOT_CHILD_PROCESS;
EnsureReadCompleted();
@ -2075,9 +2069,9 @@ nsresult nsPermissionManager::RemoveAllInternal(bool aNotifyObservers) {
NotifyObservers(nullptr, u"cleared");
}
RefPtr<nsPermissionManager> self = this;
RefPtr<PermissionManager> self = this;
mThread->Dispatch(
NS_NewRunnableFunction("nsPermissionManager::RemoveAllInternal", [self] {
NS_NewRunnableFunction("PermissionManager::RemoveAllInternal", [self] {
MOZ_ACCESS_THREAD_BOUND(self->mThreadBoundData, data);
if (self->mState == eClosed || !data->mDBConn) {
@ -2089,7 +2083,7 @@ nsresult nsPermissionManager::RemoveAllInternal(bool aNotifyObservers) {
NS_LITERAL_CSTRING("DELETE FROM moz_perms"));
if (NS_WARN_IF(NS_FAILED(rv))) {
NS_DispatchToMainThread(NS_NewRunnableFunction(
"nsPermissionManager::RemoveAllInternal-Failure",
"PermissionManager::RemoveAllInternal-Failure",
[self] { self->CloseDB(true); }));
}
}));
@ -2098,25 +2092,25 @@ nsresult nsPermissionManager::RemoveAllInternal(bool aNotifyObservers) {
}
NS_IMETHODIMP
nsPermissionManager::TestExactPermissionFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t* aPermission) {
PermissionManager::TestExactPermissionFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t* aPermission) {
return CommonTestPermission(aPrincipal, -1, aType, aPermission,
nsIPermissionManager::UNKNOWN_ACTION, false, true,
true);
}
NS_IMETHODIMP
nsPermissionManager::TestExactPermanentPermission(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t* aPermission) {
PermissionManager::TestExactPermanentPermission(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t* aPermission) {
return CommonTestPermission(aPrincipal, -1, aType, aPermission,
nsIPermissionManager::UNKNOWN_ACTION, false, true,
false);
}
nsresult nsPermissionManager::LegacyTestPermissionFromURI(
nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
nsresult PermissionManager::LegacyTestPermissionFromURI(
nsIURI* aURI, const OriginAttributes* aOriginAttributes,
const nsACString& aType, uint32_t* aPermission) {
return CommonTestPermission(aURI, aOriginAttributes, -1, aType, aPermission,
nsIPermissionManager::UNKNOWN_ACTION, false,
@ -2124,19 +2118,19 @@ nsresult nsPermissionManager::LegacyTestPermissionFromURI(
}
NS_IMETHODIMP
nsPermissionManager::TestPermissionFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t* aPermission) {
PermissionManager::TestPermissionFromPrincipal(nsIPrincipal* aPrincipal,
const nsACString& aType,
uint32_t* aPermission) {
return CommonTestPermission(aPrincipal, -1, aType, aPermission,
nsIPermissionManager::UNKNOWN_ACTION, false,
false, true);
}
NS_IMETHODIMP
nsPermissionManager::GetPermissionObject(nsIPrincipal* aPrincipal,
const nsACString& aType,
bool aExactHostMatch,
nsIPermission** aResult) {
PermissionManager::GetPermissionObject(nsIPrincipal* aPrincipal,
const nsACString& aType,
bool aExactHostMatch,
nsIPermission** aResult) {
NS_ENSURE_ARG_POINTER(aPrincipal);
*aResult = nullptr;
@ -2188,7 +2182,7 @@ nsPermissionManager::GetPermissionObject(nsIPrincipal* aPrincipal,
return NS_OK;
}
nsresult nsPermissionManager::CommonTestPermissionInternal(
nsresult PermissionManager::CommonTestPermissionInternal(
nsIPrincipal* aPrincipal, nsIURI* aURI,
const OriginAttributes* aOriginAttributes, int32_t aTypeIndex,
const nsACString& aType, uint32_t* aPermission, bool aExactHostMatch,
@ -2205,8 +2199,7 @@ nsresult nsPermissionManager::CommonTestPermissionInternal(
nsCOMPtr<nsIPrincipal> prin = aPrincipal;
if (!prin) {
if (aURI) {
prin = mozilla::BasePrincipal::CreateContentPrincipal(
aURI, OriginAttributes());
prin = BasePrincipal::CreateContentPrincipal(aURI, OriginAttributes());
}
}
MOZ_ASSERT(prin);
@ -2236,10 +2229,8 @@ nsresult nsPermissionManager::CommonTestPermissionInternal(
// in case of |host| contains sub-domains. Returns null if nothing found. Also
// accepts host on the format "<foo>". This will perform an exact match lookup
// as the string doesn't contain any dots.
nsPermissionManager::PermissionHashKey*
nsPermissionManager::GetPermissionHashKey(nsIPrincipal* aPrincipal,
uint32_t aType,
bool aExactHostMatch) {
PermissionManager::PermissionHashKey* PermissionManager::GetPermissionHashKey(
nsIPrincipal* aPrincipal, uint32_t aType, bool aExactHostMatch) {
EnsureReadCompleted();
MOZ_ASSERT(PermissionAvailable(aPrincipal, mTypeArray[aType]));
@ -2291,8 +2282,7 @@ nsPermissionManager::GetPermissionHashKey(nsIPrincipal* aPrincipal,
// in case of |host| contains sub-domains. Returns null if nothing found. Also
// accepts host on the format "<foo>". This will perform an exact match lookup
// as the string doesn't contain any dots.
nsPermissionManager::PermissionHashKey*
nsPermissionManager::GetPermissionHashKey(
PermissionManager::PermissionHashKey* PermissionManager::GetPermissionHashKey(
nsIURI* aURI, const OriginAttributes* aOriginAttributes, uint32_t aType,
bool aExactHostMatch) {
MOZ_ASSERT(aURI);
@ -2372,17 +2362,17 @@ nsPermissionManager::GetPermissionHashKey(
return nullptr;
}
NS_IMETHODIMP nsPermissionManager::GetAll(
NS_IMETHODIMP PermissionManager::GetAll(
nsTArray<RefPtr<nsIPermission>>& aResult) {
return GetAllWithTypePrefix(NS_LITERAL_CSTRING(""), aResult);
}
NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(
NS_IMETHODIMP PermissionManager::GetAllWithTypePrefix(
const nsACString& aPrefix, nsTArray<RefPtr<nsIPermission>>& aResult) {
aResult.Clear();
if (XRE_IsContentProcess()) {
NS_WARNING(
"nsPermissionManager's getAllWithTypePrefix is not available in the "
"PermissionManager's getAllWithTypePrefix is not available in the "
"content process, as not all permissions may be available.");
return NS_ERROR_NOT_AVAILABLE;
}
@ -2427,7 +2417,7 @@ NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(
return NS_OK;
}
nsresult nsPermissionManager::GetStripPermsForPrincipal(
nsresult PermissionManager::GetStripPermsForPrincipal(
nsIPrincipal* aPrincipal, nsTArray<PermissionEntry>& aResult) {
aResult.Clear();
aResult.SetCapacity(kStripOAPermissions.size());
@ -2467,7 +2457,7 @@ nsresult nsPermissionManager::GetStripPermsForPrincipal(
}
NS_IMETHODIMP
nsPermissionManager::GetAllForPrincipal(
PermissionManager::GetAllForPrincipal(
nsIPrincipal* aPrincipal, nsTArray<RefPtr<nsIPermission>>& aResult) {
aResult.Clear();
@ -2532,9 +2522,9 @@ nsPermissionManager::GetAllForPrincipal(
return NS_OK;
}
NS_IMETHODIMP nsPermissionManager::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* someData) {
NS_IMETHODIMP PermissionManager::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* someData) {
ENSURE_NOT_CHILD_PROCESS;
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
@ -2564,8 +2554,7 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports* aSubject,
return NS_OK;
}
nsresult nsPermissionManager::RemoveAllModifiedSince(
int64_t aModificationTime) {
nsresult PermissionManager::RemoveAllModifiedSince(int64_t aModificationTime) {
ENSURE_NOT_CHILD_PROCESS;
return RemovePermissionEntries(
@ -2575,10 +2564,9 @@ nsresult nsPermissionManager::RemoveAllModifiedSince(
}
NS_IMETHODIMP
nsPermissionManager::RemovePermissionsWithAttributes(
const nsAString& aPattern) {
PermissionManager::RemovePermissionsWithAttributes(const nsAString& aPattern) {
ENSURE_NOT_CHILD_PROCESS;
mozilla::OriginAttributesPattern pattern;
OriginAttributesPattern pattern;
if (!pattern.Init(aPattern)) {
return NS_ERROR_INVALID_ARG;
}
@ -2586,8 +2574,8 @@ nsPermissionManager::RemovePermissionsWithAttributes(
return RemovePermissionsWithAttributes(pattern);
}
nsresult nsPermissionManager::RemovePermissionsWithAttributes(
mozilla::OriginAttributesPattern& aPattern) {
nsresult PermissionManager::RemovePermissionsWithAttributes(
OriginAttributesPattern& aPattern) {
Vector<Tuple<nsCOMPtr<nsIPrincipal>, nsCString, nsCString>, 10> permissions;
for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
PermissionHashKey* entry = iter.Get();
@ -2614,7 +2602,7 @@ nsresult nsPermissionManager::RemovePermissionsWithAttributes(
for (auto& i : permissions) {
AddInternal(Get<0>(i), Get<1>(i), nsIPermissionManager::UNKNOWN_ACTION, 0,
nsIPermissionManager::EXPIRE_NEVER, 0, 0,
nsPermissionManager::eNotify, nsPermissionManager::eWriteToDB,
PermissionManager::eNotify, PermissionManager::eWriteToDB,
false, &Get<2>(i));
}
@ -2622,10 +2610,10 @@ nsresult nsPermissionManager::RemovePermissionsWithAttributes(
}
//*****************************************************************************
//*** nsPermissionManager private methods
//*** PermissionManager private methods
//*****************************************************************************
nsresult nsPermissionManager::RemoveAllFromMemory() {
nsresult PermissionManager::RemoveAllFromMemory() {
mLargestID = 0;
mTypeArray.clear();
mPermissionTable.Clear();
@ -2635,7 +2623,7 @@ nsresult nsPermissionManager::RemoveAllFromMemory() {
// wrapper function for mangling (host,type,perm,expireType,expireTime)
// set into an nsIPermission.
void nsPermissionManager::NotifyObserversWithPermission(
void PermissionManager::NotifyObserversWithPermission(
nsIPrincipal* aPrincipal, const nsACString& aType, uint32_t aPermission,
uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime,
const char16_t* aData) {
@ -2652,16 +2640,15 @@ void nsPermissionManager::NotifyObserversWithPermission(
// permission. "changed" means a permission was altered. aPermission is the new
// permission. "cleared" means the entire permission list was cleared.
// aPermission is null.
void nsPermissionManager::NotifyObservers(nsIPermission* aPermission,
const char16_t* aData) {
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
void PermissionManager::NotifyObservers(nsIPermission* aPermission,
const char16_t* aData) {
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
if (observerService)
observerService->NotifyObservers(aPermission, kPermissionChangeNotification,
aData);
}
nsresult nsPermissionManager::Read(const MonitorAutoLock& aProofOfLock) {
nsresult PermissionManager::Read(const MonitorAutoLock& aProofOfLock) {
ENSURE_NOT_CHILD_PROCESS;
MOZ_ASSERT(!NS_IsMainThread());
@ -2727,7 +2714,7 @@ nsresult nsPermissionManager::Read(const MonitorAutoLock& aProofOfLock) {
return NS_OK;
}
void nsPermissionManager::CompleteMigrations() {
void PermissionManager::CompleteMigrations() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mState == eReady);
@ -2755,7 +2742,7 @@ void nsPermissionManager::CompleteMigrations() {
}
}
void nsPermissionManager::CompleteRead() {
void PermissionManager::CompleteRead() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mState == eReady);
@ -2786,7 +2773,7 @@ void nsPermissionManager::CompleteRead() {
}
}
void nsPermissionManager::MaybeAddReadEntryFromMigration(
void PermissionManager::MaybeAddReadEntryFromMigration(
const nsACString& aOrigin, const nsCString& aType, uint32_t aPermission,
uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime,
int64_t aId) {
@ -2816,12 +2803,11 @@ void nsPermissionManager::MaybeAddReadEntryFromMigration(
static const char kMatchTypeHost[] = "host";
static const char kMatchTypeOrigin[] = "origin";
void nsPermissionManager::UpdateDB(OperationType aOp, int64_t aID,
const nsACString& aOrigin,
const nsACString& aType,
uint32_t aPermission, uint32_t aExpireType,
int64_t aExpireTime,
int64_t aModificationTime) {
void PermissionManager::UpdateDB(OperationType aOp, int64_t aID,
const nsACString& aOrigin,
const nsACString& aType, uint32_t aPermission,
uint32_t aExpireType, int64_t aExpireTime,
int64_t aModificationTime) {
ENSURE_NOT_CHILD_PROCESS_NORET;
MOZ_ASSERT(NS_IsMainThread());
@ -2830,9 +2816,9 @@ void nsPermissionManager::UpdateDB(OperationType aOp, int64_t aID,
nsCString origin(aOrigin);
nsCString type(aType);
RefPtr<nsPermissionManager> self = this;
RefPtr<PermissionManager> self = this;
mThread->Dispatch(NS_NewRunnableFunction(
"nsPermissionManager::UpdateDB",
"PermissionManager::UpdateDB",
[self, aOp, aID, origin, type, aPermission, aExpireType, aExpireTime,
aModificationTime] {
nsresult rv;
@ -2913,7 +2899,7 @@ void nsPermissionManager::UpdateDB(OperationType aOp, int64_t aID,
}));
}
bool nsPermissionManager::GetPermissionsFromOriginOrKey(
bool PermissionManager::GetPermissionsFromOriginOrKey(
const nsACString& aOrigin, const nsACString& aKey,
nsTArray<IPC::Permission>& aPerms) {
EnsureReadCompleted();
@ -2973,7 +2959,7 @@ bool nsPermissionManager::GetPermissionsFromOriginOrKey(
return true;
}
void nsPermissionManager::SetPermissionsWithKey(
void PermissionManager::SetPermissionsWithKey(
const nsACString& aPermissionKey, nsTArray<IPC::Permission>& aPerms) {
if (NS_WARN_IF(XRE_IsParentProcess())) {
return;
@ -3024,9 +3010,8 @@ void nsPermissionManager::SetPermissionsWithKey(
}
/* static */
void nsPermissionManager::GetKeyForOrigin(const nsACString& aOrigin,
bool aForceStripOA,
nsACString& aKey) {
void PermissionManager::GetKeyForOrigin(const nsACString& aOrigin,
bool aForceStripOA, nsACString& aKey) {
aKey.Truncate();
// We only key origins for http, https, and ftp URIs. All origins begin with
@ -3069,9 +3054,9 @@ void nsPermissionManager::GetKeyForOrigin(const nsACString& aOrigin,
}
/* static */
void nsPermissionManager::GetKeyForPrincipal(nsIPrincipal* aPrincipal,
bool aForceStripOA,
nsACString& aKey) {
void PermissionManager::GetKeyForPrincipal(nsIPrincipal* aPrincipal,
bool aForceStripOA,
nsACString& aKey) {
nsAutoCString origin;
nsresult rv = aPrincipal->GetOrigin(origin);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -3082,9 +3067,9 @@ void nsPermissionManager::GetKeyForPrincipal(nsIPrincipal* aPrincipal,
}
/* static */
void nsPermissionManager::GetKeyForPermission(nsIPrincipal* aPrincipal,
const nsACString& aType,
nsACString& aKey) {
void PermissionManager::GetKeyForPermission(nsIPrincipal* aPrincipal,
const nsACString& aType,
nsACString& aKey) {
// Preload permissions have the "" key.
if (IsPreloadPermission(aType)) {
aKey.Truncate();
@ -3096,7 +3081,7 @@ void nsPermissionManager::GetKeyForPermission(nsIPrincipal* aPrincipal,
/* static */
nsTArray<std::pair<nsCString, nsCString>>
nsPermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal) {
PermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal) {
MOZ_ASSERT(aPrincipal);
nsTArray<std::pair<nsCString, nsCString>> pairs;
@ -3121,7 +3106,7 @@ nsPermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal) {
}
NS_IMETHODIMP
nsPermissionManager::BroadcastPermissionsForPrincipalToAllContentProcesses(
PermissionManager::BroadcastPermissionsForPrincipalToAllContentProcesses(
nsIPrincipal* aPrincipal) {
nsTArray<ContentParent*> cps;
ContentParent::GetAll(cps);
@ -3133,8 +3118,8 @@ nsPermissionManager::BroadcastPermissionsForPrincipalToAllContentProcesses(
return NS_OK;
}
bool nsPermissionManager::PermissionAvailable(nsIPrincipal* aPrincipal,
const nsACString& aType) {
bool PermissionManager::PermissionAvailable(nsIPrincipal* aPrincipal,
const nsACString& aType) {
EnsureReadCompleted();
if (XRE_IsContentProcess()) {
@ -3159,8 +3144,8 @@ bool nsPermissionManager::PermissionAvailable(nsIPrincipal* aPrincipal,
return true;
}
void nsPermissionManager::WhenPermissionsAvailable(nsIPrincipal* aPrincipal,
nsIRunnable* aRunnable) {
void PermissionManager::WhenPermissionsAvailable(nsIPrincipal* aPrincipal,
nsIRunnable* aRunnable) {
MOZ_ASSERT(aRunnable);
if (!XRE_IsContentProcess()) {
@ -3201,12 +3186,12 @@ void nsPermissionManager::WhenPermissionsAvailable(nsIPrincipal* aPrincipal,
thread, __func__, [runnable]() { runnable->Run(); },
[]() {
NS_WARNING(
"nsPermissionManager permission promise rejected. We're "
"PermissionManager permission promise rejected. We're "
"probably shutting down.");
});
}
void nsPermissionManager::EnsureReadCompleted() {
void PermissionManager::EnsureReadCompleted() {
MOZ_ASSERT(NS_IsMainThread());
if (mState == eInitializing) {
@ -3241,11 +3226,11 @@ void nsPermissionManager::EnsureReadCompleted() {
}
}
already_AddRefed<nsIInputStream> nsPermissionManager::GetDefaultsInputStream() {
already_AddRefed<nsIInputStream> PermissionManager::GetDefaultsInputStream() {
MOZ_ASSERT(NS_IsMainThread());
nsAutoCString defaultsURL;
mozilla::Preferences::GetCString(kDefaultsUrlPrefName, defaultsURL);
Preferences::GetCString(kDefaultsUrlPrefName, defaultsURL);
if (defaultsURL.IsEmpty()) { // == Don't use built-in permissions.
return nullptr;
}
@ -3268,7 +3253,7 @@ already_AddRefed<nsIInputStream> nsPermissionManager::GetDefaultsInputStream() {
return inputStream.forget();
}
void nsPermissionManager::ConsumeDefaultsInputStream(
void PermissionManager::ConsumeDefaultsInputStream(
nsIInputStream* aInputStream, const MonitorAutoLock& aProofOfLock) {
MOZ_ASSERT(!NS_IsMainThread());
@ -3338,7 +3323,7 @@ void nsPermissionManager::ConsumeDefaultsInputStream(
// ImportLatestDefaults will import the latest default cookies read during the
// last DB initialization.
nsresult nsPermissionManager::ImportLatestDefaults() {
nsresult PermissionManager::ImportLatestDefaults() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mState == eReady);
@ -3364,12 +3349,11 @@ nsresult nsPermissionManager::ImportLatestDefaults() {
getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
return AddInternal(principal, aType, aPermission,
nsPermissionManager::cIDPermissionIsDefault,
aExpireType, aExpireTime, aModificationTime,
nsPermissionManager::eDontNotify,
nsPermissionManager::eNoDBOperation, false,
&aOrigin);
return AddInternal(
principal, aType, aPermission,
PermissionManager::cIDPermissionIsDefault, aExpireType,
aExpireTime, aModificationTime, PermissionManager::eDontNotify,
PermissionManager::eNoDBOperation, false, &aOrigin);
});
if (NS_FAILED(rv)) {
@ -3429,15 +3413,13 @@ nsresult nsPermissionManager::ImportLatestDefaults() {
* @param aIncludingSession whether to include session permissions when
* testing for the permission.
*/
nsPermissionManager::TestPreparationResult
nsPermissionManager::CommonPrepareToTestPermission(
PermissionManager::TestPreparationResult
PermissionManager::CommonPrepareToTestPermission(
nsIPrincipal* aPrincipal, int32_t aTypeIndex, const nsACString& aType,
uint32_t* aPermission, uint32_t aDefaultPermission,
bool aDefaultPermissionIsValid, bool aExactHostMatch,
bool aIncludingSession) {
using mozilla::AsVariant;
auto* basePrin = mozilla::BasePrincipal::Cast(aPrincipal);
auto* basePrin = BasePrincipal::Cast(aPrincipal);
if (basePrin && basePrin->IsSystemPrincipal()) {
*aPermission = ALLOW_ACTION;
return AsVariant(NS_OK);
@ -3451,8 +3433,8 @@ nsPermissionManager::CommonPrepareToTestPermission(
int32_t defaultPermission =
aDefaultPermissionIsValid ? aDefaultPermission : UNKNOWN_ACTION;
if (!aDefaultPermissionIsValid && HasDefaultPref(aType)) {
mozilla::Unused << mDefaultPrefBranch->GetIntPref(
PromiseFlatCString(aType).get(), &defaultPermission);
Unused << mDefaultPrefBranch->GetIntPref(PromiseFlatCString(aType).get(),
&defaultPermission);
}
// Set the default.
@ -3494,3 +3476,5 @@ nsPermissionManager::CommonPrepareToTestPermission(
return AsVariant(typeIndex);
}
} // namespace mozilla

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

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsPermissionManager_h__
#define nsPermissionManager_h__
#ifndef mozilla_PermissionManager_h
#define mozilla_PermissionManager_h
#include "nsIPermissionManager.h"
#include "nsIObserver.h"
@ -33,6 +33,10 @@
#include <utility>
class nsIPermission;
class mozIStorageConnection;
class mozIStorageStatement;
namespace IPC {
struct Permission;
}
@ -42,20 +46,14 @@ class OriginAttributesPattern;
namespace dom {
class ContentChild;
}
} // namespace mozilla
class nsIPermission;
class mozIStorageConnection;
class mozIStorageStatement;
} // namespace dom
////////////////////////////////////////////////////////////////////////////////
class nsPermissionManager final : public nsIPermissionManager,
public nsIObserver,
public nsSupportsWeakReference {
friend class mozilla::dom::ContentChild;
class PermissionManager final : public nsIPermissionManager,
public nsIObserver,
public nsSupportsWeakReference {
friend class dom::ContentChild;
public:
class PermissionEntry {
@ -94,11 +92,11 @@ class nsPermissionManager final : public nsIPermissionManager,
nsresult& aResult);
static PermissionKey* CreateFromURI(nsIURI* aURI, nsresult& aResult);
static PermissionKey* CreateFromURIAndOriginAttributes(
nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
nsIURI* aURI, const OriginAttributes* aOriginAttributes,
bool aForceStripOA, nsresult& aResult);
explicit PermissionKey(const nsACString& aOrigin)
: mOrigin(aOrigin), mHashCode(mozilla::HashString(aOrigin)) {}
: mOrigin(aOrigin), mHashCode(HashString(aOrigin)) {}
bool operator==(const PermissionKey& aKey) const {
return mOrigin.Equals(aKey.mOrigin);
@ -167,9 +165,9 @@ class nsPermissionManager final : public nsIPermissionManager,
NS_DECL_NSIPERMISSIONMANAGER
NS_DECL_NSIOBSERVER
nsPermissionManager();
PermissionManager();
static already_AddRefed<nsIPermissionManager> GetXPCOMSingleton();
static nsPermissionManager* GetInstance();
static PermissionManager* GetInstance();
nsresult Init();
// enums for AddInternal()
@ -203,7 +201,7 @@ class nsPermissionManager final : public nsIPermissionManager,
}
nsresult LegacyTestPermissionFromURI(
nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
nsIURI* aURI, const OriginAttributes* aOriginAttributes,
const nsACString& aType, uint32_t* aPermission);
/**
@ -215,8 +213,7 @@ class nsPermissionManager final : public nsIPermissionManager,
*/
static void Startup();
nsresult RemovePermissionsWithAttributes(
mozilla::OriginAttributesPattern& aAttrs);
nsresult RemovePermissionsWithAttributes(OriginAttributesPattern& aAttrs);
/**
* See `nsIPermissionManager::GetPermissionsWithKey` for more info on
@ -316,7 +313,7 @@ class nsPermissionManager final : public nsIPermissionManager,
* other schemes are sent down at process startup.
*
* Permissions are keyed and grouped by "Permission Key"s.
* `nsPermissionManager::GetKeyForPrincipal` provides the mechanism for
* `PermissionManager::GetKeyForPrincipal` provides the mechanism for
* determining the permission key for a given principal.
*
* This method may only be called in the parent process. It fills the nsTArray
@ -333,7 +330,7 @@ class nsPermissionManager final : public nsIPermissionManager,
nsTArray<IPC::Permission>& aPerms);
/**
* See `nsPermissionManager::GetPermissionsWithKey` for more info on
* See `PermissionManager::GetPermissionsWithKey` for more info on
* Permission keys.
*
* `SetPermissionsWithKey` may only be called in the Child process, and
@ -367,7 +364,7 @@ class nsPermissionManager final : public nsIPermissionManager,
nsIRunnable* aRunnable);
private:
virtual ~nsPermissionManager();
~PermissionManager();
/**
* Get all permissions for a given principal, which should not be isolated
@ -425,12 +422,12 @@ class nsPermissionManager final : public nsIPermissionManager,
PermissionHashKey* GetPermissionHashKey(nsIPrincipal* aPrincipal,
uint32_t aType, bool aExactHostMatch);
PermissionHashKey* GetPermissionHashKey(
nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
uint32_t aType, bool aExactHostMatch);
nsIURI* aURI, const OriginAttributes* aOriginAttributes, uint32_t aType,
bool aExactHostMatch);
// The int32_t is the type index, the nsresult is an early bail-out return
// code.
typedef mozilla::Variant<int32_t, nsresult> TestPreparationResult;
typedef Variant<int32_t, nsresult> TestPreparationResult;
TestPreparationResult CommonPrepareToTestPermission(
nsIPrincipal* aPrincipal, int32_t aTypeIndex, const nsACString& aType,
uint32_t* aPermission, uint32_t aDefaultPermission,
@ -471,11 +468,13 @@ class nsPermissionManager final : public nsIPermissionManager,
nullptr, aURI, nullptr, preparationResult.as<int32_t>(), aType,
aPermission, aExactHostMatch, aIncludingSession);
}
nsresult CommonTestPermission(
nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
int32_t aTypeIndex, const nsACString& aType, uint32_t* aPermission,
uint32_t aDefaultPermission, bool aDefaultPermissionIsValid,
bool aExactHostMatch, bool aIncludingSession) {
nsresult CommonTestPermission(nsIURI* aURI,
const OriginAttributes* aOriginAttributes,
int32_t aTypeIndex, const nsACString& aType,
uint32_t* aPermission,
uint32_t aDefaultPermission,
bool aDefaultPermissionIsValid,
bool aExactHostMatch, bool aIncludingSession) {
auto preparationResult = CommonPrepareToTestPermission(
nullptr, aTypeIndex, aType, aPermission, aDefaultPermission,
aDefaultPermissionIsValid, aExactHostMatch, aIncludingSession);
@ -490,7 +489,7 @@ class nsPermissionManager final : public nsIPermissionManager,
// Only one of aPrincipal or aURI is allowed to be passed in.
nsresult CommonTestPermissionInternal(
nsIPrincipal* aPrincipal, nsIURI* aURI,
const mozilla::OriginAttributes* aOriginAttributes, int32_t aTypeIndex,
const OriginAttributes* aOriginAttributes, int32_t aTypeIndex,
const nsACString& aType, uint32_t* aPermission, bool aExactHostMatch,
bool aIncludingSession);
@ -506,7 +505,7 @@ class nsPermissionManager final : public nsIPermissionManager,
nsresult ImportLatestDefaults();
already_AddRefed<nsIInputStream> GetDefaultsInputStream();
void ConsumeDefaultsInputStream(nsIInputStream* aDefaultsInputStream,
const mozilla::MonitorAutoLock& aProofOfLock);
const MonitorAutoLock& aProofOfLock);
nsresult CreateTable();
void NotifyObserversWithPermission(nsIPrincipal* aPrincipal,
@ -556,8 +555,7 @@ class nsPermissionManager final : public nsIPermissionManager,
uint32_t aExpireType, int64_t aExpireTime,
int64_t aModificationTime, int64_t aId);
nsRefPtrHashtable<nsCStringHashKey,
mozilla::GenericNonExclusivePromise::Private>
nsRefPtrHashtable<nsCStringHashKey, GenericNonExclusivePromise::Private>
mPermissionKeyPromiseMap;
nsCOMPtr<nsIFile> mPermissionsFile;
@ -565,7 +563,7 @@ class nsPermissionManager final : public nsIPermissionManager,
// This monitor is used to ensure the database reading before any other
// operation. The reading of the database happens OMT. See |State| to know the
// steps of the database reading.
mozilla::Monitor mMonitor;
Monitor mMonitor;
enum State {
// Initial state. The database has not been read yet.
@ -587,7 +585,7 @@ class nsPermissionManager final : public nsIPermissionManager,
// will be allowed.
eClosed,
};
mozilla::Atomic<State> mState;
Atomic<State> mState;
// A single entry, from the database.
struct ReadEntry {
@ -663,7 +661,7 @@ class nsPermissionManager final : public nsIPermissionManager,
// This array is protected by the monitor.
nsTArray<DefaultEntry> mDefaultEntries;
nsresult Read(const mozilla::MonitorAutoLock& aProofOfLock);
nsresult Read(const MonitorAutoLock& aProofOfLock);
void CompleteRead();
void CompleteMigrations();
@ -678,7 +676,7 @@ class nsPermissionManager final : public nsIPermissionManager,
// NOTE: Ensure this is the last member since it has a large inline buffer.
// An array to store the strings identifying the different types.
mozilla::Vector<nsCString, 512> mTypeArray;
Vector<nsCString, 512> mTypeArray;
nsCOMPtr<nsIThread> mThread;
@ -689,7 +687,7 @@ class nsPermissionManager final : public nsIPermissionManager,
nsCOMPtr<mozIStorageStatement> mStmtDelete;
nsCOMPtr<mozIStorageStatement> mStmtUpdate;
};
mozilla::ThreadBound<ThreadBoundData> mThreadBoundData;
ThreadBound<ThreadBoundData> mThreadBoundData;
friend class DeleteFromMozHostListener;
friend class CloseDatabaseListener;
@ -703,4 +701,6 @@ class nsPermissionManager final : public nsIPermissionManager,
} \
}
#endif /* nsPermissionManager_h__ */
} // namespace mozilla
#endif // mozilla_PermissionManager_h

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

@ -10,8 +10,8 @@ Classes = [
'contract_ids': ['@mozilla.org/permissionmanager;1'],
'singleton': True,
'type': 'nsIPermissionManager',
'constructor': 'nsPermissionManager::GetXPCOMSingleton',
'headers': ['/extensions/permissions/nsPermissionManager.h'],
'constructor': 'mozilla::PermissionManager::GetXPCOMSingleton',
'headers': ['/extensions/permissions/PermissionManager.h'],
},
{
'cid': '{07611dc6-bf4d-4d8a-a64b-f3a5904dddc7}',

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

@ -13,12 +13,13 @@ TESTING_JS_MODULES += [
EXPORTS.mozilla += [
'Permission.h',
'PermissionDelegateHandler.h',
'PermissionManager.h',
]
UNIFIED_SOURCES += [
'nsPermissionManager.cpp',
'Permission.cpp',
'PermissionDelegateHandler.cpp',
'PermissionManager.cpp',
]
XPCOM_MANIFESTS += [

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

@ -4,7 +4,7 @@
fail-if = fission
# The browser_permmgr_sync test tests e10s specific behavior, and runs code
# paths which would hit the debug only assertion in
# nsPermissionManager::PermissionKey::CreateFromPrincipal. Because of this, it
# PermissionManager::PermissionKey::CreateFromPrincipal. Because of this, it
# is only run in e10s opt builds.
skip-if = debug || !e10s
[browser_permmgr_viewsrc.js]

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

@ -5,8 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsNetUtil.h"
#include "nsPermissionManager.h"
#include "mozilla/OriginAttributes.h"
#include "mozilla/PermissionManager.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Unused.h"
#include "gtest/gtest.h"
@ -14,13 +14,13 @@
using namespace mozilla;
class PermissionManager : public ::testing::Test {
class PermissionManagerTester : public ::testing::Test {
protected:
PermissionManager()
PermissionManagerTester()
: mNonExistentType(
NS_LITERAL_CSTRING("permissionTypeThatIsGuaranteedToNeverExist")) {}
void SetUp() override {
mPermissionManager = nsPermissionManager::GetInstance();
mPermissionManager = PermissionManager::GetInstance();
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(
getter_AddRefs(uri),
@ -38,12 +38,12 @@ class PermissionManager : public ::testing::Test {
static const unsigned kNumIterations = 100000;
nsLiteralCString mNonExistentType;
RefPtr<nsPermissionManager> mPermissionManager;
RefPtr<PermissionManager> mPermissionManager;
nsCOMPtr<nsIPrincipal> mPrincipal;
};
MOZ_GTEST_BENCH_F(PermissionManager, TestNonExistentPermissionFromPrincipal,
[this] {
MOZ_GTEST_BENCH_F(PermissionManagerTester,
TestNonExistentPermissionFromPrincipal, [this] {
for (unsigned i = 0; i < kNumIterations; ++i) {
uint32_t result = 0;
Unused << mPermissionManager->TestPermissionFromPrincipal(

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

@ -8,9 +8,5 @@ UNIFIED_SOURCES += [
'PermissionManagerTest.cpp',
]
LOCAL_INCLUDES += [
'/extensions/permissions',
]
FINAL_LIBRARY = 'xul-gtest'

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

@ -126,7 +126,7 @@ add_task(async function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -200,7 +200,7 @@ add_task(async function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -212,7 +212,7 @@ add_task(function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -267,7 +267,7 @@ add_task(async function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -119,7 +119,7 @@ add_task(function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -268,7 +268,7 @@ add_task(async function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -115,7 +115,7 @@ add_task(function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -255,7 +255,7 @@ add_task(async function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -192,7 +192,7 @@ add_task(async function test() {
// This will force the permission-manager to reload the data.
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
// Force initialization of the nsPermissionManager
// Force initialization of the PermissionManager
for (let permission of Services.perms.all) {
let isExpected = false;

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

@ -7,7 +7,7 @@ const TEST_PERMISSION2 = "test/oastrip2";
const TEST_PERMISSION3 = "test/oastrip3";
// List of permissions which are not isolated by private browsing or user context
// as per array kStripOAPermissions in nsPermissionManager.cpp
// as per array kStripOAPermissions in PermissionManager.cpp
const STRIPPED_PERMS = ["cookie"];
let principal = Services.scriptSecurityManager.createContentPrincipal(

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

@ -29,7 +29,7 @@ add_task(async function test() {
let since = Date.now();
// *sob* - on Windows at least, the now recorded by nsPermissionManager.cpp
// *sob* - on Windows at least, the now recorded by PermissionManager.cpp
// might be a couple of ms *earlier* than what JS sees. So another sleep
// to ensure our |since| is greater than the time of the permissions we
// are now adding. Sadly this means we'll never be able to test when since

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

@ -40,7 +40,7 @@ function* do_run_test() {
let since = Number(Date.now());
// *sob* - on Windows at least, the now recorded by nsPermissionManager.cpp
// *sob* - on Windows at least, the now recorded by PermissionManager.cpp
// might be a couple of ms *earlier* than what JS sees. So another sleep
// to ensure our |since| is greater than the time of the permissions we
// are now adding. Sadly this means we'll never be able to test when since

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

@ -48,7 +48,6 @@ LOCAL_INCLUDES += [
'/dom/xslt/xslt',
'/dom/xul',
'/editor/composer',
'/extensions/permissions',
'/js/xpconnect/loader',
'/js/xpconnect/src',
'/netwerk/base',

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

@ -92,7 +92,7 @@
#include "nsWindowMemoryReporter.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/ProcessPriorityManager.h"
#include "nsPermissionManager.h"
#include "mozilla/PermissionManager.h"
#include "nsApplicationCacheService.h"
#include "mozilla/dom/CustomElementRegistry.h"
#include "mozilla/EventDispatcher.h"
@ -246,7 +246,7 @@ nsresult nsLayoutStatics::Initialize() {
ProcessPriorityManager::Init();
nsPermissionManager::Startup();
PermissionManager::Startup();
UIDirectionManager::Initialize();

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

@ -58,7 +58,7 @@
1192 |nsMainThreadPtrHolder<T> | 20 80| 2253 4|
1222 |nsNodeWeakReference | 16 16| 919 1|
1223 |nsNotifyAddrListener | 112 112| 1 1|
1241 |nsPermissionManager | 136 136| 1 1|
1241 |PermissionManager | 136 136| 1 1|
1248 |nsPrefBranch | 76 76| 63 1|
1257 |nsProxyInfo | 72 72| 1098 1|
1265 |nsRedirectHistoryEntry | 32 32| 69 1|

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

@ -322,7 +322,6 @@ FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/docshell/base',
'/dom/base',
'/extensions/permissions',
'/netwerk/protocol/http',
'/netwerk/socket',
'/netwerk/url-classifier',

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

@ -11,6 +11,7 @@
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "mozilla/Permission.h"
#include "mozilla/PermissionManager.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Unused.h"
@ -18,7 +19,6 @@
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
# include "nsIProtocolHandler.h"
#endif
#include "nsPermissionManager.h"
#include "nsICookieService.h"
namespace mozilla {
@ -207,7 +207,7 @@ CookieJarSettings::CookiePermission(nsIPrincipal* aPrincipal,
}
// Let's ask the permission manager.
nsPermissionManager* pm = nsPermissionManager::GetInstance();
PermissionManager* pm = PermissionManager::GetInstance();
if (NS_WARN_IF(!pm)) {
return NS_ERROR_FAILURE;
}
@ -220,7 +220,7 @@ CookieJarSettings::CookiePermission(nsIPrincipal* aPrincipal,
rv = NS_URIChainHasFlags(uri, nsIProtocolHandler::URI_FORBIDS_COOKIE_ACCESS,
&hasFlags);
if (NS_FAILED(rv) || hasFlags) {
*aCookiePermission = nsPermissionManager::DENY_ACTION;
*aCookiePermission = PermissionManager::DENY_ACTION;
rv = NS_OK; // Reset, so it's not caught as a bad status after the `else`.
} else // Note the tricky `else` which controls the call below.
#endif

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

@ -48,11 +48,11 @@ already_AddRefed<nsICookiePermission> CookiePermission::GetOrCreate() {
}
bool CookiePermission::Init() {
// Initialize nsPermissionManager and fetch relevant prefs. This is only
// Initialize PermissionManager and fetch relevant prefs. This is only
// required for some methods on nsICookiePermission, so it should be done
// lazily.
mPermMgr = nsPermissionManager::GetInstance();
mPermMgr = PermissionManager::GetInstance();
return mPermMgr != nullptr;
}

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

@ -6,7 +6,7 @@
#define mozilla_net_CookiePermission_h
#include "nsICookiePermission.h"
#include "nsPermissionManager.h"
#include "mozilla/PermissionManager.h"
namespace mozilla {
namespace net {
@ -26,7 +26,7 @@ class CookiePermission final : public nsICookiePermission {
bool EnsureInitialized() { return (mPermMgr != nullptr) || Init(); };
RefPtr<nsPermissionManager> mPermMgr;
RefPtr<mozilla::PermissionManager> mPermMgr;
};
} // namespace net

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

@ -61,7 +61,6 @@ IPDL_SOURCES = [
LOCAL_INCLUDES += [
'/dom/base',
'/extensions/permissions',
'/intl/uconv',
'/netwerk/base',
'/netwerk/protocol/http',

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

@ -22,7 +22,7 @@ const EXPIRE_TIME = SpecialPowers.Ci.nsIPermissionManager.EXPIRE_TIME;
// <------------------------>
// PERIOD
var start;
// PR_Now() that called in nsPermissionManager to get the system time
// PR_Now() that called in PermissionManager to get the system time
// is sometimes 100ms~600s more than Date.now() on Android 4.3 API11.
// Thus, the PERIOD should be larger than 600ms in this test.
const PERIOD = 900;
@ -210,7 +210,7 @@ function getPlatformInfo() {
var version = SpecialPowers.Services.sysinfo.getProperty('version');
version = parseFloat(version);
// PR_Now() that called in nsPermissionManager to get the system time and
// PR_Now() that called in PermissionManager to get the system time and
// Date.now() are out of sync on win32 platform(XP/win7). The PR_Now() is
// 15~20ms less than Date.now(). Unfortunately, this time skew can't be
// avoided, so it needs to add a time buffer to compensate.

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

@ -237,7 +237,7 @@ class Permissions(object):
cursor = permDB.cursor()
# SQL copied from
# http://dxr.mozilla.org/mozilla-central/source/extensions/cookie/nsPermissionManager.cpp
# http://dxr.mozilla.org/mozilla-central/source/extensions/permissions/PermissionManager.cpp
cursor.execute("""CREATE TABLE IF NOT EXISTS moz_hosts (
id INTEGER PRIMARY KEY
,origin TEXT

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

@ -13,11 +13,11 @@
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/dom/WindowContext.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "mozilla/PermissionManager.h"
#include "nsIChannel.h"
#include "nsIPermission.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsPermissionManager.h"
#include "nsPIDOMWindow.h"
#include "nsSandboxFlags.h"
#include "nsScriptSecurityManager.h"
@ -138,7 +138,7 @@ bool AntiTrackingUtils::CheckStoragePermission(nsIPrincipal* aPrincipal,
bool aIsInPrivateBrowsing,
uint32_t* aRejectedReason,
uint32_t aBlockedReason) {
nsPermissionManager* permManager = nsPermissionManager::GetInstance();
PermissionManager* permManager = PermissionManager::GetInstance();
if (NS_WARN_IF(!permManager)) {
LOG(("Failed to obtain the permission manager"));
return false;

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

@ -16,6 +16,7 @@
#include "mozilla/dom/WindowContext.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/PermissionManager.h"
#include "mozilla/StaticPrefs_privacy.h"
#include "mozIThirdPartyUtil.h"
#include "nsContentUtils.h"
@ -28,7 +29,6 @@
#include "nsIURI.h"
#include "nsIOService.h"
#include "nsIWebProgressListener.h"
#include "nsPermissionManager.h"
#include "nsScriptSecurityManager.h"
namespace mozilla {
@ -500,7 +500,7 @@ ContentBlocking::SaveAccessForOriginOnParentProcess(
return ParentAccessGrantPromise::CreateAndReject(false, __func__);
}
nsPermissionManager* permManager = nsPermissionManager::GetInstance();
PermissionManager* permManager = PermissionManager::GetInstance();
if (NS_WARN_IF(!permManager)) {
LOG(("Permission manager is null, bailing out early"));
return ParentAccessGrantPromise::CreateAndReject(false, __func__);
@ -1028,7 +1028,7 @@ bool ContentBlocking::ShouldAllowAccessFor(
uint32_t access = nsICookiePermission::ACCESS_DEFAULT;
if (aPrincipal->GetIsContentPrincipal()) {
nsPermissionManager* permManager = nsPermissionManager::GetInstance();
PermissionManager* permManager = PermissionManager::GetInstance();
if (permManager) {
Unused << NS_WARN_IF(NS_FAILED(permManager->TestPermissionFromPrincipal(
aPrincipal, NS_LITERAL_CSTRING("cookie"), &access)));

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

@ -9,10 +9,10 @@
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/Document.h"
#include "mozilla/PermissionManager.h"
#include "mozilla/ScopeExit.h"
#include "nsContentUtils.h"
#include "nsIHttpChannelInternal.h"
#include "nsPermissionManager.h"
using namespace mozilla;
@ -97,7 +97,7 @@ nsresult ContentBlockingAllowList::Check(
_spec),
aContentBlockingAllowListPrincipal);
nsPermissionManager* permManager = nsPermissionManager::GetInstance();
PermissionManager* permManager = PermissionManager::GetInstance();
NS_ENSURE_TRUE(permManager, NS_ERROR_FAILURE);
// Check both the normal mode and private browsing mode user override

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

@ -9,8 +9,8 @@
#include "AntiTrackingUtils.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/PermissionManager.h"
#include "nsIPrincipal.h"
#include "nsPermissionManager.h"
#include "nsXULAppAPI.h"
#include "prtime.h"
@ -26,7 +26,7 @@ void ContentBlockingUserInteraction::Observe(nsIPrincipal* aPrincipal) {
if (XRE_IsParentProcess()) {
LOG_PRIN(("Saving the userInteraction for %s", _spec), aPrincipal);
nsPermissionManager* permManager = nsPermissionManager::GetInstance();
PermissionManager* permManager = PermissionManager::GetInstance();
if (NS_WARN_IF(!permManager)) {
LOG(("Permission manager is null, bailing out early"));
return;
@ -65,7 +65,7 @@ void ContentBlockingUserInteraction::Observe(nsIPrincipal* aPrincipal) {
/* static */
bool ContentBlockingUserInteraction::Exists(nsIPrincipal* aPrincipal) {
nsPermissionManager* permManager = nsPermissionManager::GetInstance();
PermissionManager* permManager = PermissionManager::GetInstance();
if (NS_WARN_IF(!permManager)) {
return false;
}

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

@ -6,8 +6,8 @@
#include "TemporaryAccessGrantObserver.h"
#include "mozilla/PermissionManager.h"
#include "nsIObserverService.h"
#include "nsPermissionManager.h"
#include "nsTHashtable.h"
#include "nsXULAppAPI.h"
@ -17,7 +17,7 @@ UniquePtr<TemporaryAccessGrantObserver::ObserversTable>
TemporaryAccessGrantObserver::sObservers;
TemporaryAccessGrantObserver::TemporaryAccessGrantObserver(
nsPermissionManager* aPM, nsIPrincipal* aPrincipal, const nsACString& aType)
PermissionManager* aPM, nsIPrincipal* aPrincipal, const nsACString& aType)
: mPM(aPM), mPrincipal(aPrincipal), mType(aType) {
MOZ_ASSERT(XRE_IsParentProcess(),
"Enforcing temporary access grant lifetimes can only be done in "
@ -27,7 +27,7 @@ TemporaryAccessGrantObserver::TemporaryAccessGrantObserver(
NS_IMPL_ISUPPORTS(TemporaryAccessGrantObserver, nsIObserver)
// static
void TemporaryAccessGrantObserver::Create(nsPermissionManager* aPM,
void TemporaryAccessGrantObserver::Create(PermissionManager* aPM,
nsIPrincipal* aPrincipal,
const nsACString& aType) {
MOZ_ASSERT(XRE_IsParentProcess());

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

@ -17,11 +17,12 @@
template <class, class>
class nsDataHashtable;
class nsITimer;
class nsPermissionManager;
class TemporaryAccessGrantCacheKey;
namespace mozilla {
class PermissionManager;
class TemporaryAccessGrantCacheKey : public PLDHashEntryHdr {
public:
typedef std::pair<nsCOMPtr<nsIPrincipal>, nsCString> KeyType;
@ -62,14 +63,13 @@ class TemporaryAccessGrantObserver final : public nsIObserver {
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
static void Create(nsPermissionManager* aPM, nsIPrincipal* aPrincipal,
static void Create(PermissionManager* aPM, nsIPrincipal* aPrincipal,
const nsACString& aType);
void SetTimer(nsITimer* aTimer);
private:
TemporaryAccessGrantObserver(nsPermissionManager* aPM,
nsIPrincipal* aPrincipal,
TemporaryAccessGrantObserver(PermissionManager* aPM, nsIPrincipal* aPrincipal,
const nsACString& aType);
~TemporaryAccessGrantObserver() = default;
@ -78,7 +78,7 @@ class TemporaryAccessGrantObserver final : public nsIObserver {
ObserversTable;
static UniquePtr<ObserversTable> sObservers;
nsCOMPtr<nsITimer> mTimer;
RefPtr<nsPermissionManager> mPM;
RefPtr<PermissionManager> mPM;
nsCOMPtr<nsIPrincipal> mPrincipal;
nsCString mType;
};

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

@ -62,7 +62,6 @@ UNIFIED_SOURCES += [
]
LOCAL_INCLUDES += [
'/extensions/permissions',
'/netwerk/base',
'/netwerk/protocol/http',
]