Skip to content

Commit

Permalink
🔥 Remove now-dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr committed Apr 26, 2024
1 parent 60c8a41 commit 3e1a9b3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 79 deletions.
24 changes: 1 addition & 23 deletions apps/extensions/lib/parent/ext-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const lazy = lazyESModuleGetters({
class TabTracker extends TabTrackerBase {
get activeTab() {
const window = lazy.WindowTracker.getActiveWindow()
return window?.activeTab()
return window?.activeTab() || null
}

init() {
Expand Down Expand Up @@ -50,28 +50,6 @@ class TabTracker extends TabTrackerBase {
return tab
}

/**
* @param {import('resource://gre/modules/Extension.sys.mjs').Extension} extension
* @param {import('@browser/tabs').WindowTab} tab
* @param {Window} window
*
* @returns {tabs__tabs.Tab}
*/
serializeTab(extension, tab, window) {
// TODO: Active tab & host permissions
const hasTabPermission = extension.hasPermission('tabs')

return {
id: tab.view.browserId,
index: window.windowTabs().findIndex((wTab) => wTab === tab),
active: window.activeTab() === tab,
highlighted: false, // TODO
title: (hasTabPermission && tab.view.title) || undefined,
url: (hasTabPermission && tab.view.uri.asciiSpec) || undefined,
windowId: window.windowId,
}
}

/**
* @param {XULBrowserElement} browser
*/
Expand Down
56 changes: 0 additions & 56 deletions apps/extensions/lib/parent/ext-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,6 @@
/// <reference path="./ext-browser.js" />
/// <reference types="@browser/link" />

/**
* @param {tabs__tabs.QueryInfo} queryInfo
* @returns {[import("@browser/tabs").WindowTab, Window][]}
*/
function query(queryInfo) {
const windows = [...lazy.WindowTracker.registeredWindows.entries()]

const urlMatchSet =
(queryInfo.url &&
(Array.isArray(queryInfo.url)
? new MatchPatternSet(queryInfo.url)
: new MatchPatternSet([queryInfo.url]))) ||
null

return windows.flatMap(([windowId, window]) => {
const tabs = window.windowTabs()
const activeTab = window.activeTab()

return tabs
.filter((tab) => {
const active =
queryInfo.active !== null
? queryInfo.active
? tab === activeTab
: tab !== activeTab
: true
const title = queryInfo.title
? queryInfo.title === tab.view.title
: true
const url =
urlMatchSet === null
? true
: urlMatchSet.matches(tab.view.uri.asciiSpec)
const window =
queryInfo.windowId === null ? true : queryInfo.windowId === windowId

return active && title && url && window
})
.map(
/** @returns {[import("@browser/tabs").WindowTab, Window]} */ (tab) => [
tab,
window,
],
)
})
}

const serialize =
(extension) =>
/**
* @param {[import("@browser/tabs").WindowTab, Window]} in
* @returns {tabs__tabs.Tab}
*/
([tab, window]) =>
tabTracker.serializeTab(extension, tab, window)

this.tabs = class extends ExtensionAPIPersistent {
PERSISTENT_EVENTS = {}

Expand Down

0 comments on commit 3e1a9b3

Please sign in to comment.