forked from xvrh/chrome_extension.dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenterprise_networking_attributes.dart
87 lines (67 loc) · 2.5 KB
/
enterprise_networking_attributes.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// ignore_for_file: unnecessary_parenthesis
library;
import 'dart:js_util';
import 'enterprise.dart';
import 'src/internal_helpers.dart';
import 'src/js/enterprise_networking_attributes.dart' as $js;
export 'enterprise.dart' show ChromeEnterprise, ChromeEnterpriseExtension;
export 'src/chrome.dart' show chrome, EventStream;
final _enterpriseNetworkingAttributes =
ChromeEnterpriseNetworkingAttributes._();
extension ChromeEnterpriseNetworkingAttributesExtension on ChromeEnterprise {
/// Use the `chrome.enterprise.networkingAttributes` API to read
/// information about your current network.
/// Note: This API is only available to extensions force-installed by
/// enterprise
/// policy.
ChromeEnterpriseNetworkingAttributes get networkingAttributes =>
_enterpriseNetworkingAttributes;
}
class ChromeEnterpriseNetworkingAttributes {
ChromeEnterpriseNetworkingAttributes._();
bool get isAvailable =>
$js.chrome.enterpriseNullable?.networkingAttributesNullable != null &&
alwaysTrue;
/// Retrieves the network details of the device's default network.
/// If the user is not affiliated or the device is not connected to a
/// network, [runtime.lastError] will be set with a failure reason.
/// |callback| : Called with the device's default network's
/// [NetworkDetails].
Future<NetworkDetails> getNetworkDetails() async {
var $res = await promiseToFuture<$js.NetworkDetails>(
$js.chrome.enterprise.networkingAttributes.getNetworkDetails());
return NetworkDetails.fromJS($res);
}
}
class NetworkDetails {
NetworkDetails.fromJS(this._wrapped);
NetworkDetails({
/// The device's MAC address.
required String macAddress,
/// The device's local IPv4 address (undefined if not configured).
String? ipv4,
/// The device's local IPv6 address (undefined if not configured).
String? ipv6,
}) : _wrapped = $js.NetworkDetails(
macAddress: macAddress,
ipv4: ipv4,
ipv6: ipv6,
);
final $js.NetworkDetails _wrapped;
$js.NetworkDetails get toJS => _wrapped;
/// The device's MAC address.
String get macAddress => _wrapped.macAddress;
set macAddress(String v) {
_wrapped.macAddress = v;
}
/// The device's local IPv4 address (undefined if not configured).
String? get ipv4 => _wrapped.ipv4;
set ipv4(String? v) {
_wrapped.ipv4 = v;
}
/// The device's local IPv6 address (undefined if not configured).
String? get ipv6 => _wrapped.ipv6;
set ipv6(String? v) {
_wrapped.ipv6 = v;
}
}