Bug 1411589 - Export ShouldUseFlatpakPortal(); r=stransky

We need to detect the flatpak environment on multiple places.
Making the ShouldUseFlatpakPortal() exported to the nsIGIOService
allows us to reuse it.

MozReview-Commit-ID: 41NJyR3fqZQ

--HG--
extra : rebase_source : 4ebb9ba2ff98d3c6d924223485e028929eb801ed
This commit is contained in:
Jan Horak 2018-03-08 17:39:59 +01:00
parent 1e102399e8
commit bda48ed89f
2 changed files with 14 additions and 3 deletions

View File

@ -37,7 +37,7 @@ static bool GetShouldUseFlatpakPortal() {
return shouldUsePortal;
}
static bool ShouldUseFlatpakPortal() {
static bool ShouldUseFlatpakPortalImpl() {
static bool sShouldUseFlatpakPortal = GetShouldUseFlatpakPortal();
return sShouldUseFlatpakPortal;
}
@ -456,7 +456,7 @@ nsGIOService::GetAppForURIScheme(const nsACString& aURIScheme,
// Application in flatpak sandbox does not have access to the list
// of installed applications on the system. We use generic
// nsFlatpakHandlerApp which forwards launch call to the system.
if (ShouldUseFlatpakPortal()) {
if (ShouldUseFlatpakPortalImpl()) {
nsFlatpakHandlerApp *mozApp = new nsFlatpakHandlerApp();
NS_ADDREF(*aApp = mozApp);
return NS_OK;
@ -515,7 +515,7 @@ nsGIOService::GetAppForMimeType(const nsACString& aMimeType,
// Flatpak does not reveal installed application to the sandbox,
// we need to create generic system handler.
if (ShouldUseFlatpakPortal()) {
if (ShouldUseFlatpakPortalImpl()) {
nsFlatpakHandlerApp *mozApp = new nsFlatpakHandlerApp();
NS_ADDREF(*aApp = mozApp);
return NS_OK;
@ -744,3 +744,10 @@ nsGIOService::CreateAppFromCommand(nsACString const& cmd,
NS_ADDREF(*appInfo = mozApp);
return NS_OK;
}
NS_IMETHODIMP
nsGIOService::ShouldUseFlatpakPortal(bool* aRes)
{
*aRes = ShouldUseFlatpakPortalImpl();
return NS_OK;
}

View File

@ -81,6 +81,10 @@ interface nsIGIOService : nsISupports
/* Open path in file manager using org.freedesktop.FileManager1 interface */
[noscript] void orgFreedesktopFileManager1ShowItems(in ACString path);
/* Check if we're in flatpak runtime or using GTK portals has been enforced */
[noscript] bool shouldUseFlatpakPortal();
};
%{C++