From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../components/aboutthirdparty/AboutThirdParty.h | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 toolkit/components/aboutthirdparty/AboutThirdParty.h (limited to 'toolkit/components/aboutthirdparty/AboutThirdParty.h') diff --git a/toolkit/components/aboutthirdparty/AboutThirdParty.h b/toolkit/components/aboutthirdparty/AboutThirdParty.h new file mode 100644 index 0000000000..9aa8310a1f --- /dev/null +++ b/toolkit/components/aboutthirdparty/AboutThirdParty.h @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __AboutThirdParty_h__ +#define __AboutThirdParty_h__ + +#include "mozilla/MozPromise.h" +#include "nsIAboutThirdParty.h" +#include "nsInterfaceHashtable.h" +#include "nsTArray.h" +#include "nsTHashMap.h" +#include "nsTHashSet.h" + +namespace mozilla { + +class DynamicBlocklistWriter; + +using InstallLocationT = + CompactPair>; +using ComponentPathMapT = nsInterfaceHashtable; + +enum class KnownModuleType : uint32_t { + Ime = 0, + IconOverlay, + ContextMenuHandler, + CopyHookHandler, + DragDropHandler, + PropertySheetHandler, + DataHandler, + DropHandler, + IconHandler, + InfotipHandler, + PropertyHandler, + + Last, +}; + +struct InstallLocationComparator { + const nsAString& mFilePath; + + explicit InstallLocationComparator(const nsAString& aFilePath); + int operator()(const InstallLocationT& aLocation) const; +}; + +class InstalledApplication final : public nsIInstalledApplication { + nsString mName; + nsString mPublisher; + + ~InstalledApplication() = default; + + public: + InstalledApplication() = default; + InstalledApplication(nsString&& aAppName, nsString&& aPublisher); + + InstalledApplication(InstalledApplication&&) = delete; + InstalledApplication& operator=(InstalledApplication&&) = delete; + InstalledApplication(const InstalledApplication&) = delete; + InstalledApplication& operator=(const InstalledApplication&) = delete; + + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSIINSTALLEDAPPLICATION +}; + +using BackgroundThreadPromise = + MozPromise; + +class AboutThirdParty final : public nsIAboutThirdParty { + // Atomic only supports 32-bit or 64-bit types. + enum class WorkerState : uint32_t { + Init, + Running, + Done, + }; + Atomic mWorkerState; + RefPtr mPromise; + nsTHashMap mKnownModules; + ComponentPathMapT mComponentPaths; + nsTArray mLocations; + +#if defined(MOZ_LAUNCHER_PROCESS) + Atomic mPendingWriter; + // The current blocklist. May differ from mDynamicBlocklistAtLaunch + // if the user has blocked/unblocked modules. Note that this does not + // take effect until restart. + nsTHashSet mDynamicBlocklist; + // The blocklist that was used at launch, which is currently in effect. + nsTHashSet mDynamicBlocklistAtLaunch; +#endif + + ~AboutThirdParty() = default; + void BackgroundThread(); + void AddKnownModule(const nsString& aPath, KnownModuleType aType); + + public: + static already_AddRefed GetSingleton(); + + AboutThirdParty(); + + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSIABOUTTHIRDPARTY + + // Have a function separated from dom::Promise so that + // both JS method and GTest can use. + RefPtr CollectSystemInfoAsync(); +}; + +} // namespace mozilla + +#endif // __AboutThirdParty_h__ -- cgit v1.2.3