chrome.sessions
- Description
Use the
chrome.sessions
API to query and restore tabs and windows from a browsing session. - Permissions
sessions
Summary
Types
Device
Properties
- deviceNamestring
The name of the foreign device.
- sessionsSession[]
A list of open window sessions for the foreign device, sorted from most recently to least recently modified session.
Filter
Properties
- maxResultsnumber optional
The maximum number of entries to be fetched in the requested list. Omit this parameter to fetch the maximum number of entries (
MAX_SESSION_RESULTS
).
Session
Properties
- lastModifiednumber
The time when the window or tab was closed or modified, represented in milliseconds since the epoch.
- tabtabs.Tab optional
The
tabs.Tab
, if this entry describes a tab. Either this orSession.window
will be set. - windowwindows.Window optional
The
windows.Window
, if this entry describes a window. Either this orSession.tab
will be set.
Properties
MAX_SESSION_RESULTS
The maximum number of Session
that will be included in a requested list.
Value
Methods
getDevices
chrome.sessions.getDevices(filter?: Filter, callback: function)
Retrieves all devices with synced sessions.
Parameters
- filterFilter optional
- callbackfunction
The callback parameter should be a function that looks like this:
(devices: Device[]) => {...}
- devicesDevice[]
The list of
Device
objects for each synced session, sorted in order from device with most recently modified session to device with least recently modified session.tabs.Tab
objects are sorted by recency in thewindows.Window
of theSession
objects.
getRecentlyClosed
chrome.sessions.getRecentlyClosed(filter?: Filter, callback: function)
Gets the list of recently closed tabs and/or windows.
Parameters
- filterFilter optional
- callbackfunction
restore
chrome.sessions.restore(sessionId: string, callback: function)
Reopens a windows.Window
or tabs.Tab
, with an optional callback to run when the entry has been restored.
Parameters
- sessionIdstring
The
windows.Window.sessionId
, ortabs.Tab.sessionId
to restore. If this parameter is not specified, the most recently closed session is restored. - callbackfunction
The callback parameter should be a function that looks like this:
(restoredSession: Session) => {...}
- restoredSession
A
Session
containing the restoredwindows.Window
ortabs.Tab
object.
Events
onChanged
chrome.sessions.onChanged.addListener(listener: function)
Fired when recently closed tabs and/or windows are changed. This event does not monitor synced sessions changes.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
() => {...}