зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1283281 - Remove PB Flag from DOMStorage. r=jdm
This commit is contained in:
Родитель
6f6b9ca3bc
Коммит
3585e16752
|
@ -122,7 +122,7 @@ var SessionStorageInternal = {
|
|||
// There is no need to pass documentURI, it's only used to fill documentURI property of
|
||||
// domstorage event, which in this case has no consumer. Prevention of events in case
|
||||
// of missing documentURI will be solved in a followup bug to bug 600307.
|
||||
let storage = storageManager.createStorage(window, principal, "", aDocShell.usePrivateBrowsing);
|
||||
let storage = storageManager.createStorage(window, principal, "");
|
||||
|
||||
for (let key of Object.keys(data)) {
|
||||
try {
|
||||
|
|
|
@ -565,6 +565,13 @@ BasePrincipal::GetUserContextId(uint32_t* aUserContextId)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId)
|
||||
{
|
||||
*aPrivateBrowsingId = PrivateBrowsingId();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
|
||||
{
|
||||
|
|
|
@ -264,6 +264,7 @@ public:
|
|||
NS_IMETHOD GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement) final;
|
||||
NS_IMETHOD GetUnknownAppId(bool* aUnknownAppId) final;
|
||||
NS_IMETHOD GetUserContextId(uint32_t* aUserContextId) final;
|
||||
NS_IMETHOD GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId) final;
|
||||
|
||||
virtual bool IsOnCSSUnprefixingWhitelist() override { return false; }
|
||||
|
||||
|
@ -277,6 +278,7 @@ public:
|
|||
const PrincipalOriginAttributes& OriginAttributesRef() { return mOriginAttributes; }
|
||||
uint32_t AppId() const { return mOriginAttributes.mAppId; }
|
||||
uint32_t UserContextId() const { return mOriginAttributes.mUserContextId; }
|
||||
uint32_t PrivateBrowsingId() const { return mOriginAttributes.mPrivateBrowsingId; }
|
||||
bool IsInIsolatedMozBrowserElement() const { return mOriginAttributes.mInIsolatedMozBrowser; }
|
||||
|
||||
enum PrincipalKind {
|
||||
|
|
|
@ -307,6 +307,13 @@ interface nsIPrincipal : nsISerializable
|
|||
*/
|
||||
[infallible] readonly attribute unsigned long userContextId;
|
||||
|
||||
/**
|
||||
* Gets the id of the private browsing state of the context containing
|
||||
* this principal. If the principal has a private browsing value of 0, it
|
||||
* is not in private browsing.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long privateBrowsingId;
|
||||
|
||||
/**
|
||||
* Returns true iff the principal is inside an isolated mozbrowser element.
|
||||
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
|
||||
|
|
|
@ -2984,11 +2984,11 @@ nsDocShell::GetSessionStorageForPrincipal(nsIPrincipal* aPrincipal,
|
|||
AssertOriginAttributesMatchPrivateBrowsing();
|
||||
if (aCreate) {
|
||||
return manager->CreateStorage(domWin->GetCurrentInnerWindow(), aPrincipal,
|
||||
aDocumentURI, UsePrivateBrowsing(), aStorage);
|
||||
aDocumentURI, aStorage);
|
||||
}
|
||||
|
||||
return manager->GetStorage(domWin->GetCurrentInnerWindow(), aPrincipal,
|
||||
UsePrivateBrowsing(), aStorage);
|
||||
aStorage);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -10541,7 +10541,6 @@ nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
|
|||
|
||||
nsCOMPtr<nsIDOMStorage> storage;
|
||||
aError = storageManager->CreateStorage(AsInner(), principal, documentURI,
|
||||
IsPrivateBrowsing(),
|
||||
getter_AddRefs(storage));
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
|
@ -10602,7 +10601,6 @@ nsGlobalWindow::GetLocalStorage(ErrorResult& aError)
|
|||
|
||||
nsCOMPtr<nsIDOMStorage> storage;
|
||||
aError = storageManager->CreateStorage(AsInner(), principal, documentURI,
|
||||
IsPrivateBrowsing(),
|
||||
getter_AddRefs(storage));
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
|
@ -11455,7 +11453,14 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (changingStorage->IsPrivate() != IsPrivateBrowsing()) {
|
||||
uint32_t privateBrowsingId = 0;
|
||||
nsIPrincipal *storagePrincipal = changingStorage->GetPrincipal();
|
||||
rv = storagePrincipal->GetPrivateBrowsingId(&privateBrowsingId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((privateBrowsingId > 0) != IsPrivateBrowsing()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ interface nsIDOMStorageManager : nsISupports
|
|||
*/
|
||||
nsIDOMStorage createStorage(in mozIDOMWindow aWindow,
|
||||
in nsIPrincipal aPrincipal,
|
||||
in DOMString aDocumentURI,
|
||||
[optional] in bool aPrivate);
|
||||
in DOMString aDocumentURI);
|
||||
/**
|
||||
* Returns instance of DOM storage object for given principal.
|
||||
* If there is no storage managed for the scope, then null is returned and
|
||||
|
@ -55,8 +54,7 @@ interface nsIDOMStorageManager : nsISupports
|
|||
* Whether the demanding document is running in Private Browsing mode or not.
|
||||
*/
|
||||
nsIDOMStorage getStorage(in mozIDOMWindow aWindow,
|
||||
in nsIPrincipal aPrincipal,
|
||||
[optional] in bool aPrivate);
|
||||
in nsIPrincipal aPrincipal);
|
||||
|
||||
/**
|
||||
* Clones given storage into this storage manager.
|
||||
|
@ -100,6 +98,5 @@ interface nsIDOMStorageManager : nsISupports
|
|||
* or createStorage method instead.
|
||||
*/
|
||||
nsIDOMStorage getLocalStorageForPrincipal(in nsIPrincipal aPrincipal,
|
||||
in DOMString aDocumentURI,
|
||||
[optional] in bool aPrivate);
|
||||
in DOMString aDocumentURI);
|
||||
};
|
||||
|
|
|
@ -44,14 +44,12 @@ DOMStorage::DOMStorage(nsPIDOMWindowInner* aWindow,
|
|||
DOMStorageManager* aManager,
|
||||
DOMStorageCache* aCache,
|
||||
const nsAString& aDocumentURI,
|
||||
nsIPrincipal* aPrincipal,
|
||||
bool aIsPrivate)
|
||||
nsIPrincipal* aPrincipal)
|
||||
: mWindow(aWindow)
|
||||
, mManager(aManager)
|
||||
, mCache(aCache)
|
||||
, mDocumentURI(aDocumentURI)
|
||||
, mPrincipal(aPrincipal)
|
||||
, mIsPrivate(aIsPrivate)
|
||||
, mIsSessionOnly(false)
|
||||
{
|
||||
mCache->Preload();
|
||||
|
@ -231,8 +229,6 @@ bool
|
|||
DOMStorage::CanUseStorage(nsPIDOMWindowInner* aWindow, DOMStorage* aStorage)
|
||||
{
|
||||
// This method is responsible for correct setting of mIsSessionOnly.
|
||||
// It doesn't work with mIsPrivate flag at all, since it is checked
|
||||
// regardless mIsSessionOnly flag in DOMStorageCache code.
|
||||
|
||||
if (!mozilla::Preferences::GetBool(kStorageEnabled)) {
|
||||
return false;
|
||||
|
@ -282,6 +278,17 @@ DOMStorage::PrincipalEquals(nsIPrincipal* aPrincipal)
|
|||
return PrincipalsEqual(mPrincipal, aPrincipal);
|
||||
}
|
||||
|
||||
bool
|
||||
DOMStorage::IsPrivate() const
|
||||
{
|
||||
uint32_t privateBrowsingId = 0;
|
||||
nsresult rv = mPrincipal->GetPrivateBrowsingId(&privateBrowsingId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
return privateBrowsingId > 0;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMStorage::CanAccess(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
|
|
|
@ -54,17 +54,12 @@ public:
|
|||
nsIPrincipal* GetPrincipal();
|
||||
bool PrincipalEquals(nsIPrincipal* aPrincipal);
|
||||
bool CanAccess(nsIPrincipal* aPrincipal);
|
||||
bool IsPrivate()
|
||||
{
|
||||
return mIsPrivate;
|
||||
}
|
||||
|
||||
DOMStorage(nsPIDOMWindowInner* aWindow,
|
||||
DOMStorageManager* aManager,
|
||||
DOMStorageCache* aCache,
|
||||
const nsAString& aDocumentURI,
|
||||
nsIPrincipal* aPrincipal,
|
||||
bool aIsPrivate);
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
// WebIDL
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
@ -119,7 +114,7 @@ public:
|
|||
static bool CanUseStorage(nsPIDOMWindowInner* aWindow,
|
||||
DOMStorage* aStorage = nullptr);
|
||||
|
||||
bool IsPrivate() const { return mIsPrivate; }
|
||||
bool IsPrivate() const;
|
||||
bool IsSessionOnly() const { return mIsSessionOnly; }
|
||||
|
||||
bool IsForkOf(const DOMStorage* aOther) const
|
||||
|
@ -143,9 +138,6 @@ private:
|
|||
// been created for
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
||||
// Whether this storage is running in private-browsing window.
|
||||
bool mIsPrivate : 1;
|
||||
|
||||
// Whether storage is set to persist data only per session, may change
|
||||
// dynamically and is set by CanUseStorage function that is called
|
||||
// before any operation on the storage.
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
|
||||
// The set of methods that are invoked by DOM storage web API.
|
||||
// We are passing the DOMStorage object just to let the cache
|
||||
// read properties like mPrivate and mSessionOnly.
|
||||
// read properties like mPrincipal and mSessionOnly.
|
||||
// Get* methods return error when load from the database has failed.
|
||||
nsresult GetLength(const DOMStorage* aStorage, uint32_t* aRetval);
|
||||
nsresult GetKey(const DOMStorage* aStorage, uint32_t index, nsAString& aRetval);
|
||||
|
|
|
@ -310,7 +310,6 @@ DOMStorageManager::GetStorageInternal(bool aCreate,
|
|||
mozIDOMWindow* aWindow,
|
||||
nsIPrincipal* aPrincipal,
|
||||
const nsAString& aDocumentURI,
|
||||
bool aPrivate,
|
||||
nsIDOMStorage** aRetval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -361,7 +360,7 @@ DOMStorageManager::GetStorageInternal(bool aCreate,
|
|||
nsCOMPtr<nsPIDOMWindowInner> inner = nsPIDOMWindowInner::From(aWindow);
|
||||
|
||||
nsCOMPtr<nsIDOMStorage> storage = new DOMStorage(
|
||||
inner, this, cache, aDocumentURI, aPrincipal, aPrivate);
|
||||
inner, this, cache, aDocumentURI, aPrincipal);
|
||||
storage.forget(aRetval);
|
||||
}
|
||||
|
||||
|
@ -371,29 +370,24 @@ DOMStorageManager::GetStorageInternal(bool aCreate,
|
|||
NS_IMETHODIMP
|
||||
DOMStorageManager::PrecacheStorage(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
return GetStorageInternal(true, nullptr, aPrincipal, EmptyString(), false,
|
||||
nullptr);
|
||||
return GetStorageInternal(true, nullptr, aPrincipal, EmptyString(), nullptr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMStorageManager::CreateStorage(mozIDOMWindow* aWindow,
|
||||
nsIPrincipal* aPrincipal,
|
||||
const nsAString& aDocumentURI,
|
||||
bool aPrivate,
|
||||
nsIDOMStorage** aRetval)
|
||||
{
|
||||
return GetStorageInternal(true, aWindow, aPrincipal, aDocumentURI, aPrivate,
|
||||
aRetval);
|
||||
return GetStorageInternal(true, aWindow, aPrincipal, aDocumentURI, aRetval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMStorageManager::GetStorage(mozIDOMWindow* aWindow,
|
||||
nsIPrincipal* aPrincipal,
|
||||
bool aPrivate,
|
||||
nsIDOMStorage** aRetval)
|
||||
{
|
||||
return GetStorageInternal(false, aWindow, aPrincipal, EmptyString(), aPrivate,
|
||||
aRetval);
|
||||
return GetStorageInternal(false, aWindow, aPrincipal, EmptyString(), aRetval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -473,14 +467,13 @@ DOMStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
|
|||
NS_IMETHODIMP
|
||||
DOMStorageManager::GetLocalStorageForPrincipal(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aDocumentURI,
|
||||
bool aPrivate,
|
||||
nsIDOMStorage** aRetval)
|
||||
{
|
||||
if (mType != LocalStorage) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return CreateStorage(nullptr, aPrincipal, aDocumentURI, aPrivate, aRetval);
|
||||
return CreateStorage(nullptr, aPrincipal, aDocumentURI, aRetval);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -93,7 +93,6 @@ private:
|
|||
mozIDOMWindow* aWindow,
|
||||
nsIPrincipal* aPrincipal,
|
||||
const nsAString& aDocumentURI,
|
||||
bool aPrivate,
|
||||
nsIDOMStorage** aRetval);
|
||||
|
||||
// Suffix->origin->cache map
|
||||
|
|
|
@ -1244,7 +1244,6 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
nsCOMPtr<nsPIDOMWindowInner> pInnerWin = parentWindow->GetCurrentInnerWindow();
|
||||
|
||||
parentStorageManager->GetStorage(pInnerWin, subjectPrincipal,
|
||||
isPrivateBrowsingWindow,
|
||||
getter_AddRefs(storage));
|
||||
if (storage) {
|
||||
newStorageManager->CloneStorage(storage);
|
||||
|
|
Загрузка…
Ссылка в новой задаче