910e62b5创建于 1月15日历史提交
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module crosapi.mojom;

import "mojo/public/mojom/base/values.mojom";

struct VpnErrorResponse {
  string? name@0;
  string? message@1;
};

// Listens to events dispatched by VpnServiceForExtension.
// See
//   * chrome.vpnProvider.onPlatformMessage
//   * chrome.vpnProvider.onPacketReceived
//   * chrome.vpnProvider.onConfigRemoved
//   * chrome.vpnProvider.onUIEvent
// Next version: 1
// Next method id: 1
[Uuid="76ed414e-1710-4b5c-895d-181714376511"]
interface EventObserverForExtension {
  // OnAddDialog@0 was removed.
  // OnConfigureDialog@1 was removed.

  // Dispatches OnConfigRemoved event.
  OnConfigRemoved@2(string configuration_name);

  // Dispatches OnPlatformMessage event.
  OnPlatformMessage@3(string configuration_name, int32 platform_message);

  // Dispatches OnPacketReceived event.
  OnPacketReceived@4(array<uint8> data);
};

// VpnServiceForExtension manages VPN configurations for a specific extension.
// Next version: 1
// Next method id: 8
[Uuid="6743d9c7-e6c1-4f12-8f6c-571264044dea"]
interface VpnServiceForExtension {
  // Creates a new VPN configuration with |configuration_name| as the name and
  // attaches it to the extension.
  // See chrome.vpnProvider.createConfiguration(...)
  CreateConfiguration@0(string configuration_name)
      => (VpnErrorResponse? error);

  // Destroys the VPN configuration with |configuration_name| after verifying
  // that it belongs to the extension.
  // See chrome.vpnProvider.destroyConfiguration(...)
  DestroyConfiguration@1(string configuration_name)
      => (VpnErrorResponse? error);

  // SetParameters@2 was removed.
  // SendPacket@3 was removed.
  // NotifyConnectionStateChanged@4 was removed.
  // BindPepperVpnProxyObserver@5 was removed.
  // DispatchAddDialogEvent@6 was removed.
  // DispatchConfigureDialogEvent@7 was removed.
};

// VpnService manages VPN connections on the ash side.
// Next version: 1
// Next method id: 2
[Uuid="52659296-1b2a-4b8d-a219-0ca57710fe03"]
interface VpnService {
  // Registers a service for the given extension and allows ash to send events
  // via |observer|.
  RegisterVpnServiceForExtension@0(string extension_id,
      pending_receiver<VpnServiceForExtension> receiver,
      pending_remote<EventObserverForExtension> observer);

  // Updates current Vpn connection state to FAILURE if the active configuration
  // belongs to extension with id |extension_id|. If |destroy_configurations| is
  // true, also destroys all configurations owned by this extension.
  MaybeFailActiveConnectionAndDestroyConfigurations@1(string extension_id,
      bool destroy_configurations);
};