chrome.loginState

Description

Use the chrome.loginState API to read and monitor the login state.

Permissions

loginState

Availability

Chrome 78+ ChromeOS only

Types

ProfileType

Enum

"SIGNIN_PROFILE"
Specifies that the extension is in the signin profile.

"USER_PROFILE"
Specifies that the extension is in the user profile.

SessionState

Enum

"UNKNOWN"
Specifies that the session state is unknown.

"IN_OOBE_SCREEN"
Specifies that the user is in the out-of-box-experience screen.

"IN_LOGIN_SCREEN"
Specifies that the user is in the login screen.

"IN_SESSION"
Specifies that the user is in the session.

"IN_LOCK_SCREEN"
Specifies that the user is in the lock screen.

"IN_RMA_SCREEN"
Specifies that the device is in RMA mode, finalizing repairs.

Methods

getProfileType()

Promise
chrome.loginState.getProfileType(
  callback?: function,
)

Gets the type of the profile the extension is in.

Parameters

  • callback

    function optional

    The callback parameter looks like:

    (result: ProfileType) => void

Returns

  • Promise<ProfileType>

    Chrome 96+

    Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

getSessionState()

Promise
chrome.loginState.getSessionState(
  callback?: function,
)

Gets the current session state.

Parameters

Returns

  • Promise<SessionState>

    Chrome 96+

    Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

Events

onSessionStateChanged

chrome.loginState.onSessionStateChanged.addListener(
  callback: function,
)

Dispatched when the session state changes. sessionState is the new session state.

Parameters

  • callback

    function

    The callback parameter looks like:

    (sessionState: SessionState) => void