зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625845 - Remove GetUri in Navigator.cpp r=ckerschb,baku
Differential Revision: https://phabricator.services.mozilla.com/D68749
This commit is contained in:
Родитель
f94384d121
Коммит
159ab546db
|
@ -34,7 +34,8 @@
|
|||
#include "prnetdb.h"
|
||||
#include "nsIURIFixup.h"
|
||||
#include "mozilla/dom/StorageUtils.h"
|
||||
|
||||
#include "mozilla/ContentBlocking.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIURIMutator.h"
|
||||
|
||||
#include "json/json.h"
|
||||
|
@ -689,6 +690,24 @@ BasePrincipal::GetPrefLightCacheKey(nsIURI* aURI, bool aWithCredentials,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::HasFirstpartyStorageAccess(mozIDOMWindow* aCheckWindow,
|
||||
uint32_t* aRejectedReason,
|
||||
bool* aOutAllowed) {
|
||||
*aRejectedReason = 0;
|
||||
*aOutAllowed = false;
|
||||
|
||||
nsPIDOMWindowInner* win = nsPIDOMWindowInner::From(aCheckWindow);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
*aOutAllowed =
|
||||
ContentBlocking::ShouldAllowAccessFor(win, uri, aRejectedReason);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetIsNullPrincipal(bool* aResult) {
|
||||
*aResult = Kind() == eNullPrincipal;
|
||||
|
|
|
@ -152,6 +152,9 @@ class BasePrincipal : public nsJSPrincipals {
|
|||
bool* aRes) override;
|
||||
NS_IMETHOD GetPrefLightCacheKey(nsIURI* aURI, bool aWithCredentials,
|
||||
nsACString& _retval) override;
|
||||
NS_IMETHOD HasFirstpartyStorageAccess(mozIDOMWindow* aCheckWindow,
|
||||
uint32_t* aRejectedReason,
|
||||
bool* aOutAllowed) override;
|
||||
NS_IMETHOD GetAsciiHost(nsACString& aAsciiHost) override;
|
||||
NS_IMETHOD GetLocalStorageQuotaKey(nsACString& aRes) override;
|
||||
NS_IMETHOD AllowsRelaxStrictFileOriginPolicy(nsIURI* aURI,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "nsIAboutModule.idl"
|
||||
#include "nsIReferrerInfo.idl"
|
||||
interface nsIChannel;
|
||||
|
||||
#include "mozIDOMWindow.idl"
|
||||
|
||||
%{C++
|
||||
struct JSPrincipals;
|
||||
|
@ -330,6 +330,14 @@ interface nsIPrincipal : nsISerializable
|
|||
ACString getPrefLightCacheKey(in nsIURI aURI ,in bool aWithCredentials);
|
||||
|
||||
|
||||
/*
|
||||
* Checks if the Principals URI has first party storage access
|
||||
* when loaded inside the provided 3rd party resource window.
|
||||
* See also: ContentBlocking::ShouldAllowAccessFor
|
||||
*/
|
||||
bool hasFirstpartyStorageAccess(in mozIDOMWindow aWindow, out uint32_t rejectedReason);
|
||||
|
||||
|
||||
/*
|
||||
* Returns a Key for the LocalStorage Manager, used to
|
||||
* check the Principals Origin Storage usage.
|
||||
|
|
|
@ -522,19 +522,16 @@ bool Navigator::CookieEnabled() {
|
|||
return cookieEnabled;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> contentURI;
|
||||
BasePrincipal::Cast(doc->NodePrincipal())->GetURI(getter_AddRefs(contentURI));
|
||||
|
||||
if (!contentURI) {
|
||||
uint32_t rejectedReason = 0;
|
||||
bool granted = false;
|
||||
nsresult rv = doc->NodePrincipal()->HasFirstpartyStorageAccess(
|
||||
mWindow, &rejectedReason, &granted);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Not a content, so technically can't set cookies, but let's
|
||||
// just return the default value.
|
||||
return cookieEnabled;
|
||||
}
|
||||
|
||||
uint32_t rejectedReason = 0;
|
||||
bool granted = ContentBlocking::ShouldAllowAccessFor(mWindow, contentURI,
|
||||
&rejectedReason);
|
||||
|
||||
ContentBlockingNotifier::OnDecision(
|
||||
mWindow,
|
||||
granted ? ContentBlockingNotifier::BlockingDecision::eAllow
|
||||
|
|
Загрузка…
Ссылка в новой задаче