tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5dc4700ee7c05826647e9c9ec8e577226acc3a88
parent 96d0e853bc7acd633ebee3fdfbb906c9a41f80a5
Author: stransky <stransky@redhat.com>
Date:   Tue, 25 Nov 2025 07:04:57 +0000

Bug 2002096 [Linux] Add more DBus probes r=emilio

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

Diffstat:
Mdom/system/linux/GeoclueLocationProvider.cpp | 18++++++++++++++++--
Mdom/system/linux/PortalLocationProvider.cpp | 3+++
Mhal/linux/UPowerClient.cpp | 3+++
Mnetwerk/wifi/dbus/DbusWifiScanner.cpp | 5+++++
Mtoolkit/components/extensions/NativeMessagingPortal.cpp | 15+++++++++++++++
Mtoolkit/components/remote/nsDBusRemoteClient.cpp | 2++
Mtoolkit/system/gnome/nsGIOService.cpp | 3+++
Muriloader/exthandler/nsDBusHandlerApp.cpp | 2++
Mwidget/gtk/AsyncDBus.cpp | 9+++++++++
Mwidget/gtk/WidgetUtilsGtk.cpp | 6++++--
Mwidget/gtk/moz.build | 1+
Mwidget/gtk/nsLookAndFeel.cpp | 4++++
12 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/dom/system/linux/GeoclueLocationProvider.cpp b/dom/system/linux/GeoclueLocationProvider.cpp @@ -24,6 +24,7 @@ #include "mozilla/dom/GeolocationPositionErrorBinding.h" #include "mozilla/glean/DomGeolocationMetrics.h" #include "nsAppRunner.h" +#include "nsAppShell.h" #include "nsCOMPtr.h" #include "nsIDOMGeoPosition.h" #include "nsINamed.h" @@ -456,6 +457,7 @@ void GCLocProviderPriv::ConnectClient(const gchar* aClientPath) { MOZ_DIAGNOSTIC_ASSERT(mClientState == ClientState::Initing, "Client in a wrong state"); MOZ_ASSERT(mCancellable, "Watch() wasn't successfully called"); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_new_for_bus( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, kGeoclueBusName, aClientPath, kGCClientInterface, mCancellable, @@ -465,6 +467,7 @@ void GCLocProviderPriv::ConnectClient(const gchar* aClientPath) { void GCLocProviderPriv::ConnectClientResponse(GObject* aObject, GAsyncResult* aResult, gpointer aUserData) { + nsAppShell::DBusConnectionCheck(); GUniquePtr<GError> error; RefPtr<GDBusProxy> proxyClient = dont_AddRef(g_dbus_proxy_new_finish(aResult, getter_Transfers(error))); @@ -498,6 +501,7 @@ void GCLocProviderPriv::SetDesktopID() { nsAutoCString appName; gAppData->GetDBusAppName(appName); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call(mProxyClient, kDBPropertySetMethod, g_variant_new("(ssv)", kGCClientInterface, "DesktopId", g_variant_new_string(appName.get())), @@ -510,7 +514,7 @@ void GCLocProviderPriv::SetDesktopIDResponse(GDBusProxy* aProxy, GAsyncResult* aResult, gpointer aUserData) { GUniquePtr<GError> error; - + nsAppShell::DBusConnectionCheck(); RefPtr<GVariant> variant = dont_AddRef( g_dbus_proxy_call_finish(aProxy, aResult, getter_Transfers(error))); if (!variant) { @@ -547,6 +551,7 @@ void GCLocProviderPriv::SetAccuracy() { mAccuracySet = mAccuracyWanted; GCLP_SETSTATE(this, SettingAccuracyForStart); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call( mProxyClient, kDBPropertySetMethod, g_variant_new("(ssv)", kGCClientInterface, "RequestedAccuracyLevel", @@ -558,6 +563,7 @@ void GCLocProviderPriv::SetAccuracy() { void GCLocProviderPriv::SetAccuracyResponse(GDBusProxy* aProxy, GAsyncResult* aResult, gpointer aUserData) { + nsAppShell::DBusConnectionCheck(); GUniquePtr<GError> error; RefPtr<GVariant> variant = dont_AddRef( g_dbus_proxy_call_finish(aProxy, aResult, getter_Transfers(error))); @@ -591,6 +597,7 @@ void GCLocProviderPriv::StartClient() { MOZ_DIAGNOSTIC_ASSERT(mProxyClient && mCancellable, "Watch() wasn't successfully called"); GCLP_SETSTATE(this, Starting); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call( mProxyClient, "Start", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, mCancellable, reinterpret_cast<GAsyncReadyCallback>(StartClientResponse), this); @@ -600,7 +607,7 @@ void GCLocProviderPriv::StartClientResponse(GDBusProxy* aProxy, GAsyncResult* aResult, gpointer aUserData) { GUniquePtr<GError> error; - + nsAppShell::DBusConnectionCheck(); RefPtr<GVariant> variant = dont_AddRef( g_dbus_proxy_call_finish(aProxy, aResult, getter_Transfers(error))); if (!variant) { @@ -646,6 +653,7 @@ void GCLocProviderPriv::StopClient(bool aForRestart) { GCLP_SETSTATE(this, Stopping); } + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call( mProxyClient, "Stop", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, mCancellable, reinterpret_cast<GAsyncReadyCallback>(StopClientResponse), this); @@ -654,6 +662,7 @@ void GCLocProviderPriv::StopClient(bool aForRestart) { void GCLocProviderPriv::StopClientResponse(GDBusProxy* aProxy, GAsyncResult* aResult, gpointer aUserData) { + nsAppShell::DBusConnectionCheck(); GUniquePtr<GError> error; RefPtr<GVariant> variant = dont_AddRef( g_dbus_proxy_call_finish(aProxy, aResult, getter_Transfers(error))); @@ -685,6 +694,7 @@ void GCLocProviderPriv::StopClientResponse(GDBusProxy* aProxy, void GCLocProviderPriv::StopClientNoWait() { MOZ_DIAGNOSTIC_ASSERT(mProxyClient, "Watch() wasn't successfully called"); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call(mProxyClient, "Stop", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr); } @@ -756,6 +766,7 @@ void GCLocProviderPriv::GCClientSignal(GDBusProxy* aProxy, gchar* aSenderName, void GCLocProviderPriv::ConnectLocation(const gchar* aLocationPath) { MOZ_ASSERT(mCancellable, "Startup() wasn't successfully called"); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_new_for_bus( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, kGeoclueBusName, aLocationPath, kGCLocationInterface, mCancellable, @@ -931,6 +942,7 @@ void GCLocProviderPriv::DoShutdown(bool aDeleteClient, bool aDeleteManager) { MOZ_DIAGNOSTIC_ASSERT( !aDeleteManager || aDeleteClient, "deleting manager proxy requires deleting client one, too"); + nsAppShell::DBusConnectionCheck(); // Invalidate the cached last position StopPositionTimer(); @@ -1000,6 +1012,7 @@ GCLocProviderPriv::Startup() { "Client in a initialized state but no manager"); GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); mProxyManager = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, kGeoclueBusName, kGCManagerPath, kGCManagerInterface, nullptr, getter_Transfers(error))); @@ -1061,6 +1074,7 @@ GCLocProviderPriv::Watch(nsIGeolocationUpdate* aCallback) { StopMLSFallback(); GCLP_SETSTATE(this, Initing); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call(mProxyManager, "GetClient", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, mCancellable, reinterpret_cast<GAsyncReadyCallback>(GetClientResponse), diff --git a/dom/system/linux/PortalLocationProvider.cpp b/dom/system/linux/PortalLocationProvider.cpp @@ -16,6 +16,7 @@ #include "mozilla/Logging.h" #include "mozilla/XREAppData.h" #include "mozilla/dom/GeolocationPositionErrorBinding.h" +#include "nsAppShell.h" #include "prtime.h" extern const mozilla::XREAppData* gAppData; @@ -197,6 +198,7 @@ PortalLocationProvider::Startup() { // Create dbus proxy for the Location portal GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); mDBUSLocationProxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, /* GDBusInterfaceInfo */ @@ -320,6 +322,7 @@ PortalLocationProvider::Shutdown() { } mLastGeoPositionCoords = nullptr; if (mDBUSLocationProxy) { + nsAppShell::DBusConnectionCheck(); g_signal_handler_disconnect(mDBUSLocationProxy, mDBUSSignalHandler); LOG_PORTAL("calling Close method to the session interface...\n"); RefPtr<GDBusMessage> message = dont_AddRef(g_dbus_message_new_method_call( diff --git a/hal/linux/UPowerClient.cpp b/hal/linux/UPowerClient.cpp @@ -12,6 +12,7 @@ #include <cmath> #include <gio/gio.h> #include "mozilla/widget/AsyncDBus.h" +#include "nsAppShell.h" using namespace mozilla::widget; using namespace mozilla::dom::battery; @@ -198,6 +199,7 @@ void UPowerClient::StopListening() { } bool UPowerClient::AddTrackedDevice(const char* aDevicePath) { + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.UPower", aDevicePath, "org.freedesktop.UPower.Device", @@ -240,6 +242,7 @@ void UPowerClient::UpdateTrackedDevices() { mTrackedDevice = nullptr; mTrackedDeviceProxy = nullptr; + nsAppShell::DBusConnectionCheck(); DBusProxyCall(mUPowerProxy, "EnumerateDevices", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, mCancellable) ->Then( diff --git a/netwerk/wifi/dbus/DbusWifiScanner.cpp b/netwerk/wifi/dbus/DbusWifiScanner.cpp @@ -8,6 +8,7 @@ #include "mozilla/GUniquePtr.h" #include "mozilla/RefPtr.h" #include "mozilla/GRefPtr.h" +#include "nsAppShell.h" namespace mozilla { @@ -17,6 +18,7 @@ WifiScannerImpl::~WifiScannerImpl() { MOZ_COUNT_DTOR(WifiScannerImpl); } nsresult WifiScannerImpl::GetAccessPointsFromWLAN( AccessPointArray& aAccessPoints) { + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", @@ -46,6 +48,7 @@ nsresult WifiScannerImpl::GetAccessPointsFromWLAN( bool WifiScannerImpl::AddDevice(const char* aDevicePath, AccessPointArray& aAccessPoints) { + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.NetworkManager", aDevicePath, @@ -68,6 +71,7 @@ bool WifiScannerImpl::AddDevice(const char* aDevicePath, return true; } + nsAppShell::DBusConnectionCheck(); proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.NetworkManager", aDevicePath, @@ -96,6 +100,7 @@ bool WifiScannerImpl::AddDevice(const char* aDevicePath, bool WifiScannerImpl::AddAPProperties(const char* aApPath, AccessPointArray& aAccessPoints) { + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.NetworkManager", aApPath, diff --git a/toolkit/components/extensions/NativeMessagingPortal.cpp b/toolkit/components/extensions/NativeMessagingPortal.cpp @@ -15,6 +15,7 @@ #include "mozilla/WidgetUtilsGtk.h" #include "mozilla/widget/AsyncDBus.h" #include "mozilla/dom/Promise.h" +#include "nsAppShell.h" #include "prlink.h" @@ -106,6 +107,7 @@ struct CallbackData { NativeMessagingPortal::NativeMessagingPortal() { LOG_NMP("NativeMessagingPortal::NativeMessagingPortal()"); mCancellable = dont_AddRef(g_cancellable_new()); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", @@ -124,6 +126,7 @@ NativeMessagingPortal::~NativeMessagingPortal() { continue; } GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.portal.Desktop", it.first.c_str(), @@ -172,6 +175,7 @@ struct NativeMessagingPortal::DelayedCall { void NativeMessagingPortal::OnProxyReady(GObject* source, GAsyncResult* result, gpointer user_data) { NativeMessagingPortal* self = static_cast<NativeMessagingPortal*>(user_data); + nsAppShell::DBusConnectionCheck(); GUniquePtr<GError> error; self->mProxy = dont_AddRef( g_dbus_proxy_new_for_bus_finish(result, getter_Transfers(error))); @@ -267,6 +271,7 @@ void NativeMessagingPortal::MaybeDelayedCreateSession(dom::Promise& aPromise, g_variant_builder_add(&options, "{sv}", "session_handle_token", g_variant_ref_sink(aArgs)); auto callbackData = MakeUnique<CallbackData>(aPromise); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call(mProxy, "CreateSession", g_variant_new("(a{sv})", &options), G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &NativeMessagingPortal::OnCreateSessionDone, @@ -292,6 +297,7 @@ void NativeMessagingPortal::OnCreateSessionDone(GObject* source, RefPtr<NativeMessagingPortal> portal = GetSingleton(); portal->mSessions[value] = SessionState::Active; + nsAppShell::DBusConnectionCheck(); GDBusConnection* connection = g_dbus_proxy_get_connection(proxy); // The "Closed" signal is emitted e.g. when the user denies access to the // native application when the shell prompts them. @@ -340,6 +346,7 @@ NativeMessagingPortal::CloseSession(const nsACString& aHandle, JSContext* aCx, sessionIterator->second = SessionState::Closing; LOG_NMP("closing session %s", sessionHandle.get()); auto callbackData = MakeUnique<CallbackData>(*promise, sessionHandle.get()); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_new_for_bus( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.portal.Desktop", sessionHandle.get(), @@ -365,6 +372,7 @@ void NativeMessagingPortal::OnCloseSessionProxyReady(GObject* source, return RejectPromiseWithErrorMessage(*callbackData->promise, *error); } + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call(proxy, "Close", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &NativeMessagingPortal::OnCloseSessionDone, callbackData.release()); @@ -379,6 +387,7 @@ void NativeMessagingPortal::OnCloseSessionDone(GObject* source, RefPtr<NativeMessagingPortal> portal = GetSingleton(); GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); RefPtr<GVariant> res = dont_AddRef( g_dbus_proxy_call_finish(proxy, result, getter_Transfers(error))); if (res) { @@ -399,6 +408,7 @@ void NativeMessagingPortal::OnSessionClosedSignal( GDBusConnection* bus, const gchar* sender_name, const gchar* object_path, const gchar* interface_name, const gchar* signal_name, GVariant* parameters, gpointer user_data) { + nsAppShell::DBusConnectionCheck(); guint subscription_id = *reinterpret_cast<guint*>(user_data); LOG_NMP("session %s was closed by the portal", object_path); g_dbus_connection_signal_unsubscribe(bus, subscription_id); @@ -443,6 +453,7 @@ NativeMessagingPortal::GetManifest(const nsACString& aHandle, MOZ_TRY(GetPromise(aCx, promise)); auto callbackData = MakeUnique<CallbackData>(*promise, sessionHandle.get()); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call( mProxy, "GetManifest", g_variant_new("(oss)", sessionHandle.get(), name.get(), extension.get()), @@ -525,6 +536,7 @@ NativeMessagingPortal::Start(const nsACString& aHandle, const nsACString& aName, nsAutoCString requestPath; widget::GetPortalRequestPath(mProxy, token, requestPath); + nsAppShell::DBusConnectionCheck(); GDBusConnection* connection = g_dbus_proxy_get_connection(mProxy); releasedCallbackData->subscription_id = g_dbus_connection_signal_subscribe( connection, "org.freedesktop.portal.Desktop", @@ -553,6 +565,7 @@ NativeMessagingPortal::Start(const nsACString& aHandle, const nsACString& aName, /* static */ void NativeMessagingPortal::OnStartDone(GObject* source, GAsyncResult* result, gpointer user_data) { + nsAppShell::DBusConnectionCheck(); GDBusProxy* proxy = G_DBUS_PROXY(source); UniquePtr<CallbackData> callbackData(static_cast<CallbackData*>(user_data)); @@ -579,6 +592,7 @@ void NativeMessagingPortal::OnStartRequestResponseSignal( GDBusConnection* bus, const gchar* sender_name, const gchar* object_path, const gchar* interface_name, const gchar* signal_name, GVariant* parameters, gpointer user_data) { + nsAppShell::DBusConnectionCheck(); UniquePtr<CallbackData> callbackData(static_cast<CallbackData*>(user_data)); LOG_NMP("got response signal for %s in session %s", object_path, @@ -638,6 +652,7 @@ static gint GetFD(const RefPtr<GVariant>& result, GUnixFDList* fds, void NativeMessagingPortal::OnGetPipesDone(GObject* source, GAsyncResult* result, gpointer user_data) { + nsAppShell::DBusConnectionCheck(); GDBusProxy* proxy = G_DBUS_PROXY(source); UniquePtr<CallbackData> callbackData(static_cast<CallbackData*>(user_data)); auto promise = callbackData->promise; diff --git a/toolkit/components/remote/nsDBusRemoteClient.cpp b/toolkit/components/remote/nsDBusRemoteClient.cpp @@ -14,6 +14,7 @@ #include "mozilla/Base64.h" #include "nsPrintfCString.h" #include "mozilla/GUniquePtr.h" +#include "nsAppShell.h" #include <dlfcn.h> @@ -138,6 +139,7 @@ nsresult nsDBusRemoteClient::DoSendDBusCommandLine(const char* aProfile, LOG(" DBus path: %s\n", pathName.get()); LOG(" DBus interface: %s\n", remoteInterfaceName.get()); + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, destinationName.get(), pathName.get(), remoteInterfaceName.get(), nullptr, diff --git a/toolkit/system/gnome/nsGIOService.cpp b/toolkit/system/gnome/nsGIOService.cpp @@ -30,6 +30,7 @@ # include <dlfcn.h> # include "mozilla/widget/AsyncDBus.h" # include "mozilla/WidgetUtilsGtk.h" +# include "nsAppShell.h" #endif using namespace mozilla; @@ -729,6 +730,7 @@ nsGIOService::GetAppForURIScheme(const nsACString& aURIScheme, } GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, OPENURI_BUS_NAME, OPENURI_OBJECT_PATH, OPENURI_INTERFACE_NAME, @@ -1023,6 +1025,7 @@ static nsresult RevealFileViaDBusWithProxy(GDBusProxy* aProxy, nsIFile* aFile, const int32_t timeout = StaticPrefs::widget_gtk_file_manager_show_items_timeout_ms(); + nsAppShell::DBusConnectionCheck(); if (!(strcmp(aMethod, kMethodOpenDirectory) == 0)) { GUniquePtr<gchar> uri(g_filename_to_uri(path.get(), nullptr, nullptr)); if (!uri) { diff --git a/uriloader/exthandler/nsDBusHandlerApp.cpp b/uriloader/exthandler/nsDBusHandlerApp.cpp @@ -12,6 +12,7 @@ #include "nsIClassInfoImpl.h" #include "nsCOMPtr.h" #include "nsCExternalHandlerService.h" +#include "nsAppShell.h" using namespace mozilla; @@ -87,6 +88,7 @@ nsDBusHandlerApp::LaunchWithURI( DBusError err; dbus_error_init(&err); + nsAppShell::DBusConnectionCheck(); mozilla::UniquePtr<DBusConnection, mozilla::DBusConnectionDelete> connection( dbus_bus_get_private(DBUS_BUS_SESSION, &err)); diff --git a/widget/gtk/AsyncDBus.cpp b/widget/gtk/AsyncDBus.cpp @@ -6,6 +6,7 @@ #include "AsyncDBus.h" #include "gio/gio.h" #include "mozilla/XREAppData.h" +#include "nsAppShell.h" namespace mozilla::widget { @@ -21,6 +22,7 @@ static void CreateProxyCallback(GObject*, GAsyncResult* aResult, } else { promise->Reject(std::move(error), __func__); } + nsAppShell::DBusConnectionCheck(); } RefPtr<DBusProxyPromise> CreateDBusProxyForBus( @@ -28,6 +30,7 @@ RefPtr<DBusProxyPromise> CreateDBusProxyForBus( GDBusInterfaceInfo* aInterfaceInfo, const char* aName, const char* aObjectPath, const char* aInterfaceName, GCancellable* aCancellable) { + nsAppShell::DBusConnectionCheck(); auto promise = MakeRefPtr<DBusProxyPromise::Private>(__func__); g_dbus_proxy_new_for_bus(aBusType, aFlags, aInterfaceInfo, aName, aObjectPath, aInterfaceName, aCancellable, CreateProxyCallback, @@ -47,6 +50,7 @@ static void ProxyCallCallback(GObject* aSourceObject, GAsyncResult* aResult, } else { promise->Reject(std::move(error), __func__); } + nsAppShell::DBusConnectionCheck(); } RefPtr<DBusCallPromise> DBusProxyCall(GDBusProxy* aProxy, const char* aMethod, @@ -54,6 +58,7 @@ RefPtr<DBusCallPromise> DBusProxyCall(GDBusProxy* aProxy, const char* aMethod, gint aTimeout, GCancellable* aCancellable) { auto promise = MakeRefPtr<DBusCallPromise::Private>(__func__); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call(aProxy, aMethod, aArgs, aFlags, aTimeout, aCancellable, ProxyCallCallback, do_AddRef(promise).take()); return promise.forget(); @@ -75,6 +80,7 @@ static void ProxyCallWithUnixFDListCallback(GObject* aSourceObject, } else { promise->Reject(std::move(error), __func__); } + nsAppShell::DBusConnectionCheck(); } RefPtr<DBusCallPromise> DBusProxyCallWithUnixFDList( @@ -82,6 +88,7 @@ RefPtr<DBusCallPromise> DBusProxyCallWithUnixFDList( GDBusCallFlags aFlags, gint aTimeout, GUnixFDList* aFDList, GCancellable* aCancellable) { auto promise = MakeRefPtr<DBusCallPromise::Private>(__func__); + nsAppShell::DBusConnectionCheck(); g_dbus_proxy_call_with_unix_fd_list( aProxy, aMethod, aArgs, aFlags, aTimeout, aFDList, aCancellable, ProxyCallWithUnixFDListCallback, do_AddRef(promise).take()); @@ -138,6 +145,7 @@ struct PortalResponseData { const gchar* object_path, const gchar* interface_name, const gchar* signal_name, GVariant* parameters, gpointer user_data) { + nsAppShell::DBusConnectionCheck(); auto* data = static_cast<PortalResponseData*>(user_data); auto callback = std::move(data->mCallback); g_dbus_connection_signal_unsubscribe(connection, data->mSubscriptionId); @@ -148,6 +156,7 @@ struct PortalResponseData { guint OnDBusPortalResponse(GDBusProxy* aProxy, const nsCString& aRequestToken, PortalResponseListener aCallback) { + nsAppShell::DBusConnectionCheck(); auto boxedData = MakeUnique<PortalResponseData>(std::move(aCallback)); nsAutoCString requestPath; diff --git a/widget/gtk/WidgetUtilsGtk.cpp b/widget/gtk/WidgetUtilsGtk.cpp @@ -31,6 +31,7 @@ #ifdef MOZ_ENABLE_DBUS # include "mozilla/ClearOnShutdown.h" # include "mozilla/widget/AsyncDBus.h" +# include "nsAppShell.h" #endif // MOZ_ENABLE_DBUS #ifdef MOZ_WAYLAND @@ -103,14 +104,14 @@ bool IsMainWindowTransparent() { bool GdkIsWaylandDisplay(GdkDisplay* display) { static auto sGdkWaylandDisplayGetType = - (GType(*)())dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_type"); + (GType (*)())dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_type"); return sGdkWaylandDisplayGetType && G_TYPE_CHECK_INSTANCE_TYPE(display, sGdkWaylandDisplayGetType()); } bool GdkIsX11Display(GdkDisplay* display) { static auto sGdkX11DisplayGetType = - (GType(*)())dlsym(RTLD_DEFAULT, "gdk_x11_display_get_type"); + (GType (*)())dlsym(RTLD_DEFAULT, "gdk_x11_display_get_type"); return sGdkX11DisplayGetType && G_TYPE_CHECK_INSTANCE_TYPE(display, sGdkX11DisplayGetType()); } @@ -170,6 +171,7 @@ bool IsRunningUnderFlatpak() { static void DoRegisterHostApp() { GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); RefPtr<GDBusProxy> proxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, sXdpServiceName, sXdpDBusPath, sXdpRegistryInterfaceName, nullptr /* cancellable */, diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build @@ -37,6 +37,7 @@ if CONFIG["MOZ_ENABLE_V4L2"]: EXPORTS += [ "MozContainer.h", + "nsAppShell.h", "nsGTKToolkit.h", "nsGtkUtils.h", "nsImageToPixbuf.h", diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp @@ -36,6 +36,7 @@ #include "mozilla/WidgetUtilsGtk.h" #include "ScreenHelperGTK.h" #include "ScrollbarDrawing.h" +#include "nsAppShell.h" #include "GtkWidgets.h" #include "nsString.h" @@ -244,6 +245,7 @@ bool nsLookAndFeel::RecomputeDBusSettings() { g_variant_builder_add(&namespacesBuilder, "s", "org.freedesktop.appearance"); GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); RefPtr<GVariant> variant = dont_AddRef(g_dbus_proxy_call_sync( mDBusSettingsProxy, "ReadAll", g_variant_new("(as)", &namespacesBuilder), G_DBUS_CALL_FLAGS_NONE, @@ -293,6 +295,7 @@ bool nsLookAndFeel::RecomputeDBusSettings() { void nsLookAndFeel::WatchDBus() { LOGLNF("nsLookAndFeel::WatchDBus"); GUniquePtr<GError> error; + nsAppShell::DBusConnectionCheck(); mDBusSettingsProxy = dont_AddRef(g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", @@ -320,6 +323,7 @@ void nsLookAndFeel::UnwatchDBus() { g_signal_handlers_disconnect_by_func( mDBusSettingsProxy, FuncToGpointer(settings_changed_signal_cb), this); mDBusSettingsProxy = nullptr; + nsAppShell::DBusConnectionCheck(); } nsLookAndFeel::nsLookAndFeel() {