chrome.vpnProvider (original) (raw)

Skip to main content

chrome.vpnProvider

Description

Use the chrome.vpnProvider API to implement a VPN client.

Permissions

vpnProvider

Availability

Concepts and usage

Typical usage of chrome.vpnProvider is as follows:

Types

Parameters

Properties

PlatformMessage

The enum is used by the platform to notify the client of the VPN session status.

Enum

"connected"
Indicates that the VPN configuration connected.

"disconnected"
Indicates that the VPN configuration disconnected.

"error"
Indicates that an error occurred in VPN connection, for example a timeout. A description of the error is given as the error argument to onPlatformMessage.

"linkDown"
Indicates that the default physical network connection is down.

"linkUp"
Indicates that the default physical network connection is back up.

"linkChanged"
Indicates that the default physical network connection changed, e.g. wifi->mobile.

"suspend"
Indicates that the OS is preparing to suspend, so the VPN should drop its connection. The extension is not guaranteed to receive this event prior to suspending.

"resume"
Indicates that the OS has resumed and the user has logged back in, so the VPN should try to reconnect.

UIEvent

The enum is used by the platform to indicate the event that triggered onUIEvent.

Enum

"showAddDialog"
Requests that the VPN client show the add configuration dialog box to the user.

"showConfigureDialog"
Requests that the VPN client show the configuration settings dialog box to the user.

VpnConnectionState

The enum is used by the VPN client to inform the platform of its current state. This helps provide meaningful messages to the user.

Enum

"connected"
Specifies that VPN connection was successful.

"failure"
Specifies that VPN connection has failed.

Methods

createConfig()

chrome.vpnProvider.createConfig(
  name: string,
): Promise

Creates a new VPN configuration that persists across multiple login sessions of the user.

Parameters

Returns

destroyConfig()

chrome.vpnProvider.destroyConfig(
  id: string,
): Promise

Destroys a VPN configuration created by the extension.

Parameters

Returns

notifyConnectionStateChanged()

chrome.vpnProvider.notifyConnectionStateChanged(
  state: VpnConnectionState,
): Promise

Notifies the VPN session state to the platform. This will succeed only when the VPN session is owned by the extension.

Parameters

Returns

sendPacket()

chrome.vpnProvider.sendPacket(
  data: ArrayBuffer,
): Promise

Sends an IP packet through the tunnel created for the VPN session. This will succeed only when the VPN session is owned by the extension.

Parameters

Returns

setParameters()

chrome.vpnProvider.setParameters(
  parameters: Parameters,
): Promise

Sets the parameters for the VPN session. This should be called immediately after "connected" is received from the platform. This will succeed only when the VPN session is owned by the extension.

Parameters

Returns

Events

onConfigCreated

chrome.vpnProvider.onConfigCreated.addListener(
  callback: function,
)

Triggered when a configuration is created by the platform for the extension.

Parameters

onConfigRemoved

chrome.vpnProvider.onConfigRemoved.addListener(
  callback: function,
)

Triggered when a configuration created by the extension is removed by the platform.

Parameters

onPacketReceived

chrome.vpnProvider.onPacketReceived.addListener(
  callback: function,
)

Triggered when an IP packet is received via the tunnel for the VPN session owned by the extension.

Parameters

onPlatformMessage

chrome.vpnProvider.onPlatformMessage.addListener(
  callback: function,
)

Triggered when a message is received from the platform for a VPN configuration owned by the extension.

Parameters

onUIEvent

chrome.vpnProvider.onUIEvent.addListener(
  callback: function,
)

Triggered when there is a UI event for the extension. UI events are signals from the platform that indicate to the app that a UI dialog needs to be shown to the user.

Parameters

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-11 UTC.