mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1149420 - Make the IndexedDB permissions prompt work in e10s. r=bent/mfinkle
This commit is contained in:
parent
d3044dc4a3
commit
dbef115db9
@ -6181,20 +6181,13 @@ var IndexedDBPromptHelper = {
|
||||
|
||||
var requestor = subject.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||
|
||||
var contentWindow = requestor.getInterface(Ci.nsIDOMWindow);
|
||||
var contentDocument = contentWindow.document;
|
||||
var browserWindow =
|
||||
OfflineApps._getBrowserWindowForContentWindow(contentWindow);
|
||||
|
||||
if (browserWindow != window) {
|
||||
// Must belong to some other window.
|
||||
var browser = requestor.getInterface(Ci.nsIDOMNode);
|
||||
if (browser.ownerDocument.defaultView != window) {
|
||||
// Only listen for notifications for browsers in our chrome window.
|
||||
return;
|
||||
}
|
||||
|
||||
var browser =
|
||||
OfflineApps._getBrowserForContentWindow(browserWindow, contentWindow);
|
||||
|
||||
var host = contentDocument.documentURIObject.asciiHost;
|
||||
var host = browser.currentURI.asciiHost;
|
||||
|
||||
var message;
|
||||
var responseTopic;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/indexedDB/PBackgroundIDBDatabaseFileChild.h"
|
||||
@ -528,9 +529,9 @@ class PermissionRequestMainProcessHelper final
|
||||
public:
|
||||
PermissionRequestMainProcessHelper(BackgroundFactoryRequestChild* aActor,
|
||||
IDBFactory* aFactory,
|
||||
nsPIDOMWindow* aWindow,
|
||||
Element* aOwnerElement,
|
||||
nsIPrincipal* aPrincipal)
|
||||
: PermissionRequestBase(aWindow, aPrincipal)
|
||||
: PermissionRequestBase(aOwnerElement, aPrincipal)
|
||||
, mActor(aActor)
|
||||
, mFactory(aFactory)
|
||||
{
|
||||
@ -1129,8 +1130,14 @@ BackgroundFactoryRequestChild::RecvPermissionChallenge(
|
||||
nsCOMPtr<nsPIDOMWindow> window = mFactory->GetParentObject();
|
||||
MOZ_ASSERT(window);
|
||||
|
||||
nsCOMPtr<Element> ownerElement =
|
||||
do_QueryInterface(window->GetChromeEventHandler());
|
||||
if (NS_WARN_IF(!ownerElement)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<PermissionRequestMainProcessHelper> helper =
|
||||
new PermissionRequestMainProcessHelper(this, mFactory, window, principal);
|
||||
new PermissionRequestMainProcessHelper(this, mFactory, ownerElement, principal);
|
||||
|
||||
PermissionRequestBase::PermissionValue permission;
|
||||
if (NS_WARN_IF(NS_FAILED(helper->PromptIfNeeded(&permission)))) {
|
||||
|
@ -7489,9 +7489,9 @@ class PermissionRequestHelper final
|
||||
bool mActorDestroyed;
|
||||
|
||||
public:
|
||||
PermissionRequestHelper(nsPIDOMWindow* aWindow,
|
||||
PermissionRequestHelper(Element* aOwnerElement,
|
||||
nsIPrincipal* aPrincipal)
|
||||
: PermissionRequestBase(aWindow, aPrincipal)
|
||||
: PermissionRequestBase(aOwnerElement, aPrincipal)
|
||||
, mActorDestroyed(false)
|
||||
{ }
|
||||
|
||||
@ -8161,13 +8161,13 @@ DeallocPBackgroundIDBFactoryParent(PBackgroundIDBFactoryParent* aActor)
|
||||
}
|
||||
|
||||
PIndexedDBPermissionRequestParent*
|
||||
AllocPIndexedDBPermissionRequestParent(nsPIDOMWindow* aWindow,
|
||||
AllocPIndexedDBPermissionRequestParent(Element* aOwnerElement,
|
||||
nsIPrincipal* aPrincipal)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsRefPtr<PermissionRequestHelper> actor =
|
||||
new PermissionRequestHelper(aWindow, aPrincipal);
|
||||
new PermissionRequestHelper(aOwnerElement, aPrincipal);
|
||||
return actor.forget().take();
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ class nsPIDOMWindow;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Element;
|
||||
class TabParent;
|
||||
|
||||
namespace quota {
|
||||
@ -39,7 +40,7 @@ bool
|
||||
DeallocPBackgroundIDBFactoryParent(PBackgroundIDBFactoryParent* aActor);
|
||||
|
||||
PIndexedDBPermissionRequestParent*
|
||||
AllocPIndexedDBPermissionRequestParent(nsPIDOMWindow* aWindow,
|
||||
AllocPIndexedDBPermissionRequestParent(Element* aOwnerElement,
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
bool
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "MainThreadUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
@ -46,13 +47,13 @@ AssertSanity()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
PermissionRequestBase::PermissionRequestBase(nsPIDOMWindow* aWindow,
|
||||
PermissionRequestBase::PermissionRequestBase(Element* aOwnerElement,
|
||||
nsIPrincipal* aPrincipal)
|
||||
: mWindow(aWindow)
|
||||
: mOwnerElement(aOwnerElement)
|
||||
, mPrincipal(aPrincipal)
|
||||
{
|
||||
AssertSanity();
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aOwnerElement);
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
}
|
||||
|
||||
@ -125,8 +126,8 @@ PermissionRequestBase::PromptIfNeeded(PermissionValue* aCurrentValue)
|
||||
|
||||
// Tricky, we want to release the window and principal in all cases except
|
||||
// when we successfully prompt.
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
mWindow.swap(window);
|
||||
nsCOMPtr<Element> element;
|
||||
mOwnerElement.swap(element);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
mPrincipal.swap(principal);
|
||||
@ -146,7 +147,7 @@ PermissionRequestBase::PromptIfNeeded(PermissionValue* aCurrentValue)
|
||||
}
|
||||
|
||||
// We're about to prompt so swap the members back.
|
||||
window.swap(mWindow);
|
||||
element.swap(mOwnerElement);
|
||||
principal.swap(mPrincipal);
|
||||
|
||||
rv = obsSvc->NotifyObservers(static_cast<nsIObserver*>(this),
|
||||
@ -154,7 +155,7 @@ PermissionRequestBase::PromptIfNeeded(PermissionValue* aCurrentValue)
|
||||
nullptr);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// Finally release if we failed the prompt.
|
||||
mWindow = nullptr;
|
||||
mOwnerElement = nullptr;
|
||||
mPrincipal = nullptr;
|
||||
return rv;
|
||||
}
|
||||
@ -200,8 +201,8 @@ PermissionRequestBase::GetInterface(const nsIID& aIID,
|
||||
return QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)) && mWindow) {
|
||||
return mWindow->QueryInterface(aIID, aResult);
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMNode)) && mOwnerElement) {
|
||||
return mOwnerElement->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
*aResult = nullptr;
|
||||
@ -215,11 +216,11 @@ PermissionRequestBase::Observe(nsISupports* aSubject,
|
||||
{
|
||||
AssertSanity();
|
||||
MOZ_ASSERT(!strcmp(aTopic, kPermissionResponseTopic));
|
||||
MOZ_ASSERT(mWindow);
|
||||
MOZ_ASSERT(mOwnerElement);
|
||||
MOZ_ASSERT(mPrincipal);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
mWindow.swap(window);
|
||||
nsCOMPtr<Element> element;
|
||||
element.swap(mOwnerElement);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
mPrincipal.swap(principal);
|
||||
|
@ -18,13 +18,16 @@ class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Element;
|
||||
|
||||
namespace indexedDB {
|
||||
|
||||
class PermissionRequestBase
|
||||
: public nsIObserver
|
||||
, public nsIInterfaceRequestor
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
nsCOMPtr<Element> mOwnerElement;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
||||
public:
|
||||
@ -51,7 +54,7 @@ public:
|
||||
PromptIfNeeded(PermissionValue* aCurrentValue);
|
||||
|
||||
protected:
|
||||
PermissionRequestBase(nsPIDOMWindow* aWindow,
|
||||
PermissionRequestBase(Element* aOwnerElement,
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
// Reference counted.
|
||||
|
@ -1121,19 +1121,12 @@ TabParent::AllocPIndexedDBPermissionRequestParent(const Principal& aPrincipal)
|
||||
MOZ_CRASH("Figure out security checks for bridged content!");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
nsCOMPtr<nsIContent> frame = do_QueryInterface(mFrameElement);
|
||||
if (frame) {
|
||||
MOZ_ASSERT(frame->OwnerDoc());
|
||||
window = do_QueryInterface(frame->OwnerDoc()->GetWindow());
|
||||
}
|
||||
|
||||
if (!window) {
|
||||
if (NS_WARN_IF(!mFrameElement)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return
|
||||
mozilla::dom::indexedDB::AllocPIndexedDBPermissionRequestParent(window,
|
||||
mozilla::dom::indexedDB::AllocPIndexedDBPermissionRequestParent(mFrameElement,
|
||||
principal);
|
||||
}
|
||||
|
||||
|
@ -6670,13 +6670,12 @@ var IndexedDB = {
|
||||
|
||||
let requestor = subject.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||
|
||||
let contentWindow = requestor.getInterface(Ci.nsIDOMWindow);
|
||||
let contentDocument = contentWindow.document;
|
||||
let tab = BrowserApp.getTabForWindow(contentWindow);
|
||||
let browser = requestor.getInterface(Ci.nsIDOMNode);
|
||||
let tab = BrowserApp.getTabForBrowser(browser);
|
||||
if (!tab)
|
||||
return;
|
||||
|
||||
let host = contentDocument.documentURIObject.asciiHost;
|
||||
let host = browser.currentURI.asciiHost;
|
||||
|
||||
let strings = Strings.browser;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user