summaryrefslogtreecommitdiffstats
path: root/extensions/common/api/networking_config.idl
blob: 78b5bc6653efb27770ec5bd806a591e4cc18ff63 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Use the <code>networking.config</code> API to authenticate to captive
// portals.
namespace networking.config {
  // Indicator for the type of network used in $(ref:NetworkInfo).
  enum NetworkType { WiFi };

  // A dictionary identifying filtered networks. One of <code>GUID</code>,
  // <code>SSID</code> or <code>HexSSID</code> must be set. <code>BSSID</code>
  // and <code>Security</code> are ignored when filtering networks.
  dictionary NetworkInfo {
    // Currently only WiFi supported.
    NetworkType Type;

    // A unique identifier of the network.
    DOMString? GUID;

    // A hex-encoded byte sequence.
    DOMString? HexSSID;

    // The decoded SSID of the network (default encoding is UTF-8). To filter
    // for non-UTF-8 SSIDs, use HexSSID instead.
    DOMString? SSID;

    // The basic service set identification (BSSID) uniquely identifying the
    // basic service set. <code>BSSID</code> is represented as a human readable,
    // hex-encoded string with bytes separated by colons, e.g.
    // 45:67:89:ab:cd:ef.
    DOMString? BSSID;

    // Identifier indicating the security type of the network. Valid values are
    // <code>None</code>, <code>WEP-PSK</code>, <code>WPA-PSK</code> and
    // <code>WPA-EAP</code>.
    DOMString? Security;
  };

  // Argument to $(ref:finishAuthentication) indicating the result of the
  // captive portal authentication attempt.
  enum AuthenticationResult {
    // The extension does not handle this network or captive portal (e.g. server
    // end-point not found or not compatible).
    unhandled,

    // The extension handled this network and authenticated successfully.
    succeeded,

    // The extension handled this network, tried to authenticate, however was
    // rejected by the server.
    rejected,

    // The extension handled this network, tried to authenticate, however failed
    // due to an unspecified error.
    failed
  };

  // Invoked by $(ref:setNetworkFilter) when the respective operation is
  // finished.
  callback SetNetworkFilterCallback = void();

  // Invoked by $(ref:finishAuthentication) when the respective operation is
  // finished.
  callback FinishAuthenticationCallback = void();

  interface Functions {
    // Allows an extension to define network filters for the networks it can
    // handle. A call to this function will remove all filters previously
    // installed by the extension before setting the new list.
    // |networks|: Network filters to set. Every <code>NetworkInfo</code> must
    //             either have the <code>SSID</code> or <code>HexSSID</code>
    //             set. Other fields will be ignored.
    // |callback|: Called back when this operation is finished.
    void setNetworkFilter(NetworkInfo[] networks,
                          SetNetworkFilterCallback callback);

    // Called by the extension to notify the network config API that it finished
    // a captive portal authentication attempt and hand over the result of the
    // attempt. This function must only be called with the GUID of the latest
    // $(ref:onCaptivePortalDetected) event.
    // |GUID|: Unique network identifier obtained from
    //         $(ref:onCaptivePortalDetected).
    // |result|: The result of the authentication attempt.
    // |callback|: Called back when this operation is finished.
    void finishAuthentication(DOMString GUID, AuthenticationResult result,
                              optional FinishAuthenticationCallback callback);
  };

  interface Events {
    // This event fires everytime a captive portal is detected on a network
    // matching any of the currently registered network filters and the user
    // consents to use the extension for authentication. Network filters may be
    // set using the $(ref:setNetworkFilter).
    // Upon receiving this event the extension should start its authentication
    // attempt with the captive portal. When the extension finishes its attempt,
    // it must call $(ref:finishAuthentication) with the <code>GUID</code>
    // received with this event and the appropriate authentication result.
    // |networkInfo|: Information about the network on which a captive portal
    // was detected.
    static void onCaptivePortalDetected(NetworkInfo networkInfo);
  };
};