summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/api/dial.idl
blob: d16fdfd6919ea8af27f36f817f86f8c4d509e738 (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
// Copyright (c) 2012 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>chrome.dial</code> API to discover devices that support DIAL.
// Protocol specification: http://www.dial-multiscreen.org/
namespace dial {

  // Represents a unique device that responded to a DIAL discovery request.
  dictionary DialDevice {

    // A label identifying the device within this instance of the browser.
    // Not guaranteed to persist beyond browser instances.
    DOMString deviceLabel;

    // A URL pointing to the device description resource for the device.
    DOMString deviceDescriptionUrl;

    // The uPnP configuration ID reported by the device.  Corresponds to the
    // CONFIGID.UPNP.ORG header in the M-SEARCH response.
    long? configId;
  };

  enum DialErrorCode {
    no_listeners,
    no_valid_network_interfaces,
    network_disconnected,
    cellular_network,
    socket_error,
    unknown
  };

  dictionary DialError {
    DialErrorCode code;
  };

  callback BooleanCallback = void (boolean result);

  interface Functions {

    // Requests that DIAL discovery happen immediately.  The request may not be
    // honored as discovery may already be happening in the background.  The
    // callback is invoked with |true| if discovery was initiated or |false|
    // otherwise.
    static void discoverNow(BooleanCallback callback);
  };

  interface Events {

    // Event fired to inform clients of the current, complete set of responsive
    // devices.  Clients should only need to store the list from the most recent
    // event.  May be fired in response to multiple circumstances:
    //
    // (1) The DIAL service refreshed its device list through periodic polling.
    // (2) A client invoked discoverNow().
    // (3) An event happened that should invalidate the device list
    //     (e.g., a network interface went offline), in which case it is fired
    //     with an empty array.
    static void onDeviceList(DialDevice[] result);

    // Event fired to inform clients on errors during device discovery.
    static void onError(DialError error);
  };
};