Skip to content

Commit

Permalink
Bug 1613237 - Call nsIWebBrowserChrome3 for main process pages. r=kma…
Browse files Browse the repository at this point in the history
…g,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
  • Loading branch information
agi committed Feb 20, 2020
1 parent 3243713 commit 26f34cb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions mobile/android/components/geckoview/GeckoViewStartup.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ACTORS = {
child: {
moduleURI: "resource:///actors/WebBrowserChromeChild.jsm",
},
includeChrome: true,
},
};

Expand Down
30 changes: 30 additions & 0 deletions xpfe/appshell/nsContentTreeOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "mozilla/NullPrincipal.h"
#include "nsDocShell.h"
#include "nsDocShellLoadState.h"
#include "nsQueryActor.h"

#include "nsIScriptObjectPrincipal.h"
#include "nsIURI.h"
Expand Down Expand Up @@ -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
//*****************************************************************************
Expand Down Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions xpfe/appshell/nsContentTreeOwner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 26f34cb

Please sign in to comment.