Welcome Getting started API Reference Samples
Welcome Getting started API Reference Samples

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

  • deviceName
    string

    The name of the foreign device.

  • sessions

    A list of open window sessions for the foreign device, sorted from most recently to least recently modified session.

Filter

Properties

  • maxResults
    number 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

  • lastModified
    number

    The time when the window or tab was closed or modified, represented in milliseconds since the epoch.

  • tab
    tabs.Tab optional

    The tabs.Tab, if this entry describes a tab. Either this or Session.window will be set.

  • window

    The windows.Window, if this entry describes a window. Either this or Session.tab will be set.

Properties

MAX_SESSION_RESULTS

The maximum number of Session that will be included in a requested list.

Value

number 25

Methods

getDevices

chrome.sessions.getDevices(filter?: Filter, callback: function)

Retrieves all devices with synced sessions.

Parameters

  • filter
    Filter optional
  • callback
    function

    The callback parameter should be a function that looks like this:

    (devices: Device[]) => {...}
    • devices

      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 the windows.Window of the Session objects.

getRecentlyClosed

chrome.sessions.getRecentlyClosed(filter?: Filter, callback: function)

Gets the list of recently closed tabs and/or windows.

Parameters

  • filter
    Filter optional
  • callback
    function

    The callback parameter should be a function that looks like this:

    (sessions: Session[]) => {...}
    • sessions

      The list of closed entries in reverse order that they were closed (the most recently closed tab or window will be at index 0). The entries may contain either tabs or windows.

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

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

  • listener
    function

    The listener parameter should be a function that looks like this:

    () => {...}
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.