From bda48ed89f01ff4ad066ed1a932c3359b0b8866d Mon Sep 17 00:00:00 2001 From: Jan Horak Date: Thu, 8 Mar 2018 17:39:59 +0100 Subject: [PATCH] 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 --- toolkit/system/gnome/nsGIOService.cpp | 13 ++++++++++--- xpcom/system/nsIGIOService.idl | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/toolkit/system/gnome/nsGIOService.cpp b/toolkit/system/gnome/nsGIOService.cpp index d1048bfab699..b91d676dbfcf 100644 --- a/toolkit/system/gnome/nsGIOService.cpp +++ b/toolkit/system/gnome/nsGIOService.cpp @@ -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; +} diff --git a/xpcom/system/nsIGIOService.idl b/xpcom/system/nsIGIOService.idl index ebb1c8f0d89d..c63d6a57bbdc 100644 --- a/xpcom/system/nsIGIOService.idl +++ b/xpcom/system/nsIGIOService.idl @@ -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++