Bug 1756083 - Cleanup snap name handling and enable portal when running under either flatpak or snap. r=stransky
Differential Revision: https://phabricator.services.mozilla.com/D139474
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "imgIContainer.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
#include "mozilla/WidgetUtilsGtk.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
# include "nsImageToPixbuf.h"
|
||||
@@ -72,18 +73,6 @@ static const MimeTypeAssociation appTypes[] = {
|
||||
#define kDesktopDrawBGGSKey "draw-background"
|
||||
#define kDesktopColorGSKey "primary-color"
|
||||
|
||||
static bool IsRunningAsASnap() {
|
||||
const char* snapName = mozilla::widget::WidgetUtils::GetSnapInstanceName();
|
||||
|
||||
// return early if not set.
|
||||
if (snapName == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// snapName as defined on https://snapcraft.io/firefox
|
||||
return (strcmp(snapName, "firefox") == 0);
|
||||
}
|
||||
|
||||
nsresult nsGNOMEShellService::Init() {
|
||||
nsresult rv;
|
||||
|
||||
@@ -200,9 +189,9 @@ nsGNOMEShellService::IsDefaultBrowser(bool aForAllTypes,
|
||||
bool* aIsDefaultBrowser) {
|
||||
*aIsDefaultBrowser = false;
|
||||
|
||||
if (IsRunningAsASnap()) {
|
||||
if (widget::IsRunningUnderSnap()) {
|
||||
const gchar* argv[] = {"xdg-settings", "check", "default-web-browser",
|
||||
"firefox.desktop", nullptr};
|
||||
(SNAP_INSTANCE_NAME ".desktop"), nullptr};
|
||||
GSpawnFlags flags = static_cast<GSpawnFlags>(G_SPAWN_SEARCH_PATH |
|
||||
G_SPAWN_STDERR_TO_DEV_NULL);
|
||||
gchar* output = nullptr;
|
||||
@@ -280,9 +269,9 @@ nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) {
|
||||
"Setting the default browser for all users is not yet supported");
|
||||
#endif
|
||||
|
||||
if (IsRunningAsASnap()) {
|
||||
if (widget::IsRunningUnderSnap()) {
|
||||
const gchar* argv[] = {"xdg-settings", "set", "default-web-browser",
|
||||
"firefox.desktop", nullptr};
|
||||
(SNAP_INSTANCE_NAME ".desktop"), nullptr};
|
||||
GSpawnFlags flags = static_cast<GSpawnFlags>(G_SPAWN_SEARCH_PATH |
|
||||
G_SPAWN_STDOUT_TO_DEV_NULL |
|
||||
G_SPAWN_STDERR_TO_DEV_NULL);
|
||||
|
||||
Reference in New Issue
Block a user