Bug 1613237 - Call nsIWebBrowserChrome3 for main process pages. r=kmag,esawin

nsContentTreeOwner uses XULBrowserWindow (which is Desktop-only) to get the
current WebBrowserChrome instance.

This patch adds a lookup for the WebBrowserChrome actor to make sure that the
correct instance is queried on all platforms.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Agi Sferro 2020-02-20 19:29:08 +00:00
Родитель b1c5704faa
Коммит 907a5549e7
3 изменённых файлов: 34 добавлений и 0 удалений

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

@ -31,6 +31,7 @@ const ACTORS = {
child: {
moduleURI: "resource:///actors/WebBrowserChromeChild.jsm",
},
includeChrome: true,
},
};

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

@ -33,6 +33,7 @@
#include "mozilla/NullPrincipal.h"
#include "nsDocShell.h"
#include "nsDocShellLoadState.h"
#include "nsQueryActor.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIURI.h"
@ -71,6 +72,28 @@ class nsSiteWindow : public nsIEmbeddingSiteWindow {
nsContentTreeOwner* mAggregator;
};
already_AddRefed<nsIWebBrowserChrome3>
nsContentTreeOwner::GetWebBrowserChrome() {
if (!mAppWindow) {
return nullptr;
}
nsCOMPtr<nsIDocShell> docShell;
mAppWindow->GetDocShell(getter_AddRefs(docShell));
if (!docShell) {
return nullptr;
}
nsCOMPtr<nsPIDOMWindowOuter> outer(docShell->GetWindow());
if (nsCOMPtr<nsIWebBrowserChrome3> chrome =
do_QueryActor(u"WebBrowserChrome", outer)) {
return chrome.forget();
}
return nullptr;
}
//*****************************************************************************
//*** nsContentTreeOwner: Object Management
//*****************************************************************************
@ -151,6 +174,13 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID,
return mAppWindow->QueryInterface(aIID, aSink);
}
if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome3))) {
if (nsCOMPtr<nsIWebBrowserChrome3> chrome = GetWebBrowserChrome()) {
chrome.forget(aSink);
return NS_OK;
}
}
return QueryInterface(aIID, aSink);
}

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

@ -49,6 +49,9 @@ class nsContentTreeOwner final : public nsIDocShellTreeOwner,
void AppWindow(mozilla::AppWindow* aAppWindow);
mozilla::AppWindow* AppWindow();
private:
already_AddRefed<nsIWebBrowserChrome3> GetWebBrowserChrome();
protected:
mozilla::AppWindow* mAppWindow;
nsSiteWindow* mSiteWindow;