From efe393e3d2eb0925cc297c1eebc293c435f8a602 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 5 Feb 2019 09:12:11 +0000 Subject: [PATCH] Bug 1524938 - nsContentUtils::StorageAllowedForPrincipal() renamed to nsContentUtils::StorageAllowedForServiceWorker(), r=asuth Differential Revision: https://phabricator.services.mozilla.com/D18535 --HG-- extra : moz-landing-system : lando --- dom/base/nsContentUtils.cpp | 31 ++++++++++----------- dom/base/nsContentUtils.h | 19 +++++++------ dom/serviceworkers/ServiceWorkerPrivate.cpp | 2 +- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index dd0e932bbc2b..724e18c56d23 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -8103,8 +8103,8 @@ nsContentUtils::StorageAccess nsContentUtils::StorageAllowedForWindow( // callee is able to deal with a null channel argument, and if passed null, // will only fail to notify the UI in case storage gets blocked. nsIChannel* channel = document->GetChannel(); - return InternalStorageAllowedForPrincipal(principal, aWindow, nullptr, - channel, *aRejectedReason); + return InternalStorageAllowedCheck(principal, aWindow, nullptr, channel, + *aRejectedReason); } // No document? Let's return a generic rejected reason. @@ -8124,8 +8124,8 @@ nsContentUtils::StorageAccess nsContentUtils::StorageAllowedForDocument( nsIChannel* channel = aDoc->GetChannel(); uint32_t rejectedReason = 0; - return InternalStorageAllowedForPrincipal(principal, inner, nullptr, - channel, rejectedReason); + return InternalStorageAllowedCheck(principal, inner, nullptr, channel, + rejectedReason); } return StorageAccess::eDeny; @@ -8139,8 +8139,8 @@ nsContentUtils::StorageAccess nsContentUtils::StorageAllowedForNewWindow( // parent may be nullptr uint32_t rejectedReason = 0; - return InternalStorageAllowedForPrincipal(aPrincipal, aParent, aURI, nullptr, - rejectedReason); + return InternalStorageAllowedCheck(aPrincipal, aParent, aURI, nullptr, + rejectedReason); } // static, public @@ -8155,18 +8155,18 @@ nsContentUtils::StorageAccess nsContentUtils::StorageAllowedForChannel( NS_ENSURE_TRUE(principal, nsContentUtils::StorageAccess::eDeny); uint32_t rejectedReason = 0; - nsContentUtils::StorageAccess result = InternalStorageAllowedForPrincipal( + nsContentUtils::StorageAccess result = InternalStorageAllowedCheck( principal, nullptr, nullptr, aChannel, rejectedReason); return result; } // static, public -nsContentUtils::StorageAccess nsContentUtils::StorageAllowedForPrincipal( +nsContentUtils::StorageAccess nsContentUtils::StorageAllowedForServiceWorker( nsIPrincipal* aPrincipal) { uint32_t rejectedReason = 0; - return InternalStorageAllowedForPrincipal(aPrincipal, nullptr, nullptr, - nullptr, rejectedReason); + return InternalStorageAllowedCheck(aPrincipal, nullptr, nullptr, nullptr, + rejectedReason); } // static, private @@ -8356,12 +8356,9 @@ bool nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow, } // static, private -nsContentUtils::StorageAccess -nsContentUtils::InternalStorageAllowedForPrincipal(nsIPrincipal* aPrincipal, - nsPIDOMWindowInner* aWindow, - nsIURI* aURI, - nsIChannel* aChannel, - uint32_t& aRejectedReason) { +nsContentUtils::StorageAccess nsContentUtils::InternalStorageAllowedCheck( + nsIPrincipal* aPrincipal, nsPIDOMWindowInner* aWindow, nsIURI* aURI, + nsIChannel* aChannel, uint32_t& aRejectedReason) { MOZ_ASSERT(aPrincipal); aRejectedReason = 0; @@ -8413,7 +8410,7 @@ nsContentUtils::InternalStorageAllowedForPrincipal(nsIPrincipal* aPrincipal, // // This is due to backwards-compatibility and the state of storage access // before the introducton of - // nsContentUtils::InternalStorageAllowedForPrincipal: + // nsContentUtils::InternalStorageAllowedCheck: // // BEFORE: // localStorage, caches: allowed in 3rd-party iframes always diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index b41613a9da39..35ac8a6df4f5 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2967,10 +2967,9 @@ class nsContentUtils { /* * Checks if storage for the given principal is permitted by the user's - * preferences. The caller is assumed to not be a third-party iframe. - * (if that is possible, the caller should use StorageAllowedForWindow) + * preferences. This method should be used only by ServiceWorker loading. */ - static StorageAccess StorageAllowedForPrincipal(nsIPrincipal* aPrincipal); + static StorageAccess StorageAllowedForServiceWorker(nsIPrincipal* aPrincipal); /* * Returns true if this document should disable storages because of the @@ -3356,7 +3355,7 @@ class nsContentUtils { * Gets the current cookie lifetime policy for a given principal by checking * with preferences and the permission manager. * - * Used in the implementation of InternalStorageAllowedForPrincipal. + * Used in the implementation of InternalStorageAllowedCheck. */ static void GetCookieLifetimePolicyForPrincipal(nsIPrincipal* aPrincipal, uint32_t* aLifetimePolicy); @@ -3370,12 +3369,14 @@ class nsContentUtils { * allow a channel instead of the window reference when determining 3rd party * status. * - * Used in the implementation of StorageAllowedForWindow and - * StorageAllowedForPrincipal. + * Used in the implementation of StorageAllowedForWindow, + * StorageAllowedForChannel and StorageAllowedForServiceWorker. */ - static StorageAccess InternalStorageAllowedForPrincipal( - nsIPrincipal* aPrincipal, nsPIDOMWindowInner* aWindow, nsIURI* aURI, - nsIChannel* aChannel, uint32_t& aRejectedReason); + static StorageAccess InternalStorageAllowedCheck(nsIPrincipal* aPrincipal, + nsPIDOMWindowInner* aWindow, + nsIURI* aURI, + nsIChannel* aChannel, + uint32_t& aRejectedReason); static nsINode* GetCommonAncestorHelper(nsINode* aNode1, nsINode* aNode2); static nsIContent* GetCommonFlattenedTreeAncestorHelper( diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/ServiceWorkerPrivate.cpp index 79a51b0d55fc..c43d0f2f03bc 100644 --- a/dom/serviceworkers/ServiceWorkerPrivate.cpp +++ b/dom/serviceworkers/ServiceWorkerPrivate.cpp @@ -1723,7 +1723,7 @@ nsresult ServiceWorkerPrivate::SpawnWorkerIfNeeded(WakeUpReason aWhy, info.mLoadingPrincipal = info.mPrincipal; nsContentUtils::StorageAccess access = - nsContentUtils::StorageAllowedForPrincipal(info.mPrincipal); + nsContentUtils::StorageAllowedForServiceWorker(info.mPrincipal); info.mStorageAllowed = access > nsContentUtils::StorageAccess::ePrivateBrowsing; info.mOriginAttributes = mInfo->GetOriginAttributes();