Bug 1940476 - Add triggers for "Tab group created" and "Tab group closed" events; and targeting for counting tab groups r=dao,omc-reviewers,aminomancer,negin

Differential Revision: https://phabricator.services.mozilla.com/D233953
This commit is contained in:
Emily McMinn
2025-01-20 21:31:06 +00:00
parent c28b0b7d3f
commit 3748e6bed5
6 changed files with 217 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
// eslint-disable-next-line mozilla/no-browser-refs-in-toolkit
SelectableProfileService:
"resource:///modules/profiles/SelectableProfileService.sys.mjs",
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs",
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
TelemetrySession: "resource://gre/modules/TelemetrySession.sys.mjs",
@@ -748,6 +749,18 @@ const TargetingGetters = {
get needsUpdate() {
return QueryCache.queries.CheckBrowserNeedsUpdate.get();
},
get savedTabGroups() {
return lazy.SessionStore.getSavedTabGroups().length;
},
get currentTabGroups() {
let win = lazy.BrowserWindowTracker.getTopWindow();
// If there's no window, there can't be any current tab groups.
if (!win) {
return 0;
}
let totalTabGroups = win.gBrowser.getAllTabGroups().length;
return totalTabGroups;
},
get hasPinnedTabs() {
for (let win of Services.wm.getEnumerator("navigator:browser")) {
if (win.closed || !win.ownerGlobal.gBrowser) {