// Copyright 2021 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 "url/mojom/url.mojom";
[Stable]
struct ProxyLocation {
// Host (or IP address) to use for proxy.
string host;
int32 port;
[Stable,Extensible]
enum Scheme {
[Default] kUnknown,
kInvalid,
kDirect,
kHttp,
kSocks4,
kSocks5,
kHttps,
kQuic,
};
// Identifies the scheme which is used to connect to the proxy. This is
// independent of the type of the transmitted requests, e.g. it does not
// have to be kHttps for a proxy which handles https requests. That's why
// it has to be transmitted.
[MinVersion=1] Scheme scheme;
};
// Description of the extension in the primary profile which is controlling the
// OS proxy configuration. It is sent from Lacros' primary profile to Ash and
// from Ash to all profiles in Lacros, the PlayStore and Chrome OS system
// services.
// Note: In the Lacros primary profile, the extension set proxy has priority so
// proxy updates coming from the OS are ignored.
[Stable]
struct ExtensionControllingProxy {
string name;
string id;
[MinVersion=1] bool can_be_disabled;
};
[Stable]
struct ProxySettingsDirect {};
[Stable]
struct ProxySettingsManual {
array<ProxyLocation> http_proxies;
array<ProxyLocation> secure_http_proxies;
array<ProxyLocation> socks_proxies;
// Domains and hosts for which to exclude proxy settings.
array<string> exclude_domains;
};
[Stable]
struct ProxySettingsPac {
url.mojom.Url pac_url;
// If true, network traffic does not fall back to direct connections in
// case the PAC script is not available.
bool pac_mandatory;
};
[Stable]
struct ProxySettingsWpad {
url.mojom.Url pac_url;
};
[Stable]
union ProxySettings {
ProxySettingsDirect direct;
ProxySettingsManual manual;
ProxySettingsPac pac;
ProxySettingsWpad wpad;
};
// TODO(crbug.com/40284947): Add support for proxy chains.
[Stable]
struct ProxyConfig {
ProxySettings proxy_settings;
// Identifies the extension controlling the proxy.
ExtensionControllingProxy? extension;
};
// Implemented by Lacros-Chrome.
[Stable]
interface NetworkSettingsObserver {
// This methods is called when:
// - the observer is added to the `NetworkSettingsService`;
// - the proxy configuration in Ash is updated;
// - the WPAD URL on the default network is updated.
OnProxyChanged@0(ProxyConfig proxy_config);
// Enforcement of the `AlwaysOnVpnPreConnectUrlAllowlist` pref in the
// browser is determined by the network configuration and preference
// settings. This method is called when updates of the network and/or
// prefs settings change whether the `AlwaysOnVpnPreConnectUrlAllowlist`
// pref should be applied or not.
[MinVersion=1]
OnAlwaysOnVpnPreConnectUrlAllowlistEnforcedChanged@1(bool enfoced);
};
// Implemented by Ash-Chrome.
[Stable, Uuid="e8916037-b993-454a-96ef-20f269cace54"]
interface NetworkSettingsService {
// Adds an Ash network settings service observer.
// If a proxy is configured in Ash, the observer will be notified of the
// current proxy configuration as part of this call.
AddNetworkSettingsObserver@0(
pending_remote<NetworkSettingsObserver> observer);
// DEPRECATED. The proxy pref set by a Lacros extension is synced via the
// Prefs mojo service. Please use `SetExtensionControllingProxyMetadata` to
// set the extension metadata.
// Used by the Lacros browser to forward proxy configurations set via
// extensions in the primary profile to Ash. `proxy_config` must specify the
// extension setting the proxy.
[MinVersion=1]
SetExtensionProxy@1(ProxyConfig proxy_config);
// DEPRECATED. The proxy pref set by a Lacros extension is cleared via the
// Prefs mojo service. Please use `ClearExtensionControllingProxyMetadata`
// to clear the extension metadata.
// Used by the Lacros browser to clear proxy configurations set via
// extensions in the primary profile to Ash.
[MinVersion=1]
ClearExtensionProxy@2();
// Used by the Lacros browser to forward metadata about the extension which
// is controlling the proxy settings in the Lacros primary profile.
// TODO(b/268607394): When the Prefs mojo service carries source metadata
// along with the pref value, deprecate this method and rely on the Prefs
// mojo service for this information.
[MinVersion=2]
SetExtensionControllingProxyMetadata@3(ExtensionControllingProxy extension);
// Used by the Lacros browser to clear metadata about the extension which
// used to control the proxy settings in the Lacros primary profile.
[MinVersion=2]
ClearExtensionControllingProxyMetadata@4();
// Returns a boolean which indicates if user traffic should be restricted to
// URL filters configured via the `AlwaysOnVpnPreConnectUrlAllowlist` pref.
[MinVersion=3]
IsAlwaysOnVpnPreConnectUrlAllowlistEnforced@5() => (bool enabled);
};