Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Find the browser manifests in Chrome's other channels

Țugui Dragoșdbe97831562d
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
index 872e1715..d61d1e90 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
@@ -243,10 +243,16 @@ public struct SearchEnvironment: Sendable {
}
/// Each browser's own documentation: Chrome's and Chromium's "Native messaging", MDN's "Native manifests" for
- /// Firefox, and Microsoft's "Native messaging" for Edge and its Beta, Dev, and Canary channels.
+ /// Firefox, and Microsoft's "Native messaging" for Edge and its Beta, Dev, and Canary channels. Chrome's other
+ /// channels keep theirs in their own user data folder (Chromium's `docs/user_data_dir.md`), and Chrome for
+ /// Testing has its own in `/Library` (`chrome/common/chrome_paths.cc`).
static let nativeMessagingHosts = (
user: [
"Application Support/Google/Chrome/NativeMessagingHosts",
+ "Application Support/Google/Chrome Beta/NativeMessagingHosts",
+ "Application Support/Google/Chrome Dev/NativeMessagingHosts",
+ "Application Support/Google/Chrome Canary/NativeMessagingHosts",
+ "Application Support/Google/Chrome for Testing/NativeMessagingHosts",
"Application Support/Chromium/NativeMessagingHosts",
"Application Support/Mozilla/NativeMessagingHosts",
"Application Support/Microsoft Edge/NativeMessagingHosts",
@@ -256,6 +262,7 @@ public struct SearchEnvironment: Sendable {
],
local: [
"Google/Chrome/NativeMessagingHosts",
+ "Google/ChromeForTesting/NativeMessagingHosts",
"Application Support/Chromium/NativeMessagingHosts",
"Application Support/Mozilla/NativeMessagingHosts",
"Microsoft/Edge/NativeMessagingHosts",
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 463a5a79..3b54668e 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -1610,6 +1610,27 @@ struct LeftoverScannerTests {
#expect(manifests.first?.match.isRecommended == true)
}
+ @Test(arguments: [
+ "home/Library/Application Support/Google/Chrome Beta/NativeMessagingHosts",
+ "home/Library/Application Support/Google/Chrome Dev/NativeMessagingHosts",
+ "home/Library/Application Support/Google/Chrome Canary/NativeMessagingHosts",
+ "home/Library/Application Support/Google/Chrome for Testing/NativeMessagingHosts",
+ "root/Library/Google/ChromeForTesting/NativeMessagingHosts",
+ ])
+ func findsAManifestInEachChromeChannelsFolder(hosts: String) async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("\(hosts)/com.example.bridge.json", contents: Data("""
+ {"name": "com.example.bridge", "path": "/Applications/Tunewell.app/Contents/MacOS/bridge", "type": "stdio"}
+ """.utf8))
+ let scanner = LeftoverScanner(environment: environment(in: directory))
+
+ let scan = await scanner.scan(tunewell, installedApps: [tunewell])
+
+ let manifest = scan.leftovers.first { $0.url.lastPathComponent == "com.example.bridge.json" }
+ #expect(manifest?.match.reason == .nativeMessagingHost)
+ #expect(manifest?.match.isRecommended == true)
+ }
+
/// Only the program a manifest runs says whose it is, wherever its NativeMessagingHosts folder sits: one named
/// after this app's identifier but running another program is not this app's, and one in a browser's folder that
/// is not listed is found by its program all the same.