OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.gcdPrivate</code> API to discover GCD APIs and register | 5 // Use the <code>chrome.gcdPrivate</code> API to discover GCD APIs and register |
6 // them. | 6 // them. |
7 namespace gcdPrivate { | 7 namespace gcdPrivate { |
8 | 8 |
9 enum SetupType { mdns, wifi, cloud }; | 9 enum SetupType { mdns, wifi, cloud }; |
10 | 10 |
11 // Represents a GCD device discovered locally or registered to a given user. | 11 // Represents a GCD device discovered locally or registered to a given user. |
12 dictionary GCDDevice { | 12 dictionary GCDDevice { |
| 13 // Opaque device identifier to be passed to API. |
| 14 DOMString deviceId; |
| 15 |
13 // How this device was discovered. | 16 // How this device was discovered. |
14 SetupType setupType; | 17 SetupType setupType; |
15 | 18 |
16 // Opaque device identifier to be passed to API. | |
17 DOMString idString; | |
18 | |
19 // Cloud identifier string. | 19 // Cloud identifier string. |
20 DOMString? cloudId; | 20 DOMString? cloudId; |
21 | 21 |
22 // Device type (camera, printer, etc) | 22 // Device type (camera, printer, etc) |
23 DOMString deviceType; | 23 DOMString deviceType; |
24 | 24 |
25 // Device human readable name | 25 // Device human readable name. |
26 DOMString deviceName; | 26 DOMString deviceName; |
27 | 27 |
28 // Device human readable description | 28 // Device human readable description. |
29 DOMString deviceDescription; | 29 DOMString deviceDescription; |
30 }; | 30 }; |
31 | 31 |
32 // Represents wifi network credentials. | |
33 dictionary WiFiCredentials { | |
34 DOMString ssid; | |
35 DOMString password; | |
36 }; | |
37 | |
38 callback CloudDeviceListCallback = void(GCDDevice[] devices); | 32 callback CloudDeviceListCallback = void(GCDDevice[] devices); |
39 | 33 |
| 34 // |commandDefinitions| : Is "commandDefs" value of device described at |
| 35 // https://developers.google.com/cloud-devices/v1/reference/devices |
| 36 // TODO(vitalybuka): consider to describe object in IDL. |
| 37 callback CommandDefinitionsCallback = void(object commandDefinitions); |
| 38 |
| 39 // |command| : Described at |
| 40 // https://developers.google.com/cloud-devices/v1/reference/commands |
| 41 // TODO(vitalybuka): consider to describe object in IDL. |
| 42 callback CommandCallback = void(object command); |
| 43 |
| 44 // |commands| : Array of commands described at |
| 45 // https://developers.google.com/cloud-devices/v1/reference/commands |
| 46 // TODO(vitalybuka): consider to describe object in IDL. |
| 47 callback CommandListCallback = void(object[] commands); |
| 48 |
40 interface Functions { | 49 interface Functions { |
| 50 // Returns the list of cloud devices visible locally or available in the |
| 51 // cloud for user account. |
41 static void getCloudDeviceList(CloudDeviceListCallback callback); | 52 static void getCloudDeviceList(CloudDeviceListCallback callback); |
42 | 53 |
| 54 // Queries network for local devices. Triggers an onDeviceStateChanged and |
| 55 // onDeviceRemoved events. Call this function *only* after registering for |
| 56 // onDeviceStateChanged and onDeviceRemoved events, or it will do nothing. |
| 57 static void queryForNewLocalDevices(); |
| 58 |
43 // Starts device setup process. Returns id of setup process. Id should be | 59 // Starts device setup process. Returns id of setup process. Id should be |
44 // used as |setupId| in all subsequent setup related calls, and for | 60 // used as |setupId| in all subsequent setup related calls, and for |
45 // filtering setup events. | 61 // filtering setup events. |
46 static long startSetup(GCDDevice device); | 62 static long startSetup(DOMString deviceId); |
47 | 63 |
48 // Sets WiFi network list as reply to |onGetWifiNetworks| event. | 64 // Sets WiFi network as reply to |onGetWifiNetworks| event. |
49 // |setupId| : The value returned by |startSetup|. | 65 // |setupId| : The value returned by |startSetup|. |
50 // |networks| : The list of network device should be registered on. | 66 // |network| : The wifi network for device setup. |
51 static void setWiFiNetworks(long setupId, DOMString[] networks); | 67 static void setWiFiNetwork(long setupId, DOMString network); |
52 | 68 |
53 // Sets WiFi network credentials as reply to |onGetWifiCredentials| | 69 // Sets WiFi network password as reply to |onGetWifiPassword| event. |
54 // event. | |
55 // |setupId| : The value returned by |startSetup|. | 70 // |setupId| : The value returned by |startSetup|. |
56 // |credentials| : The list of ssid with passwoors. The list is not required | 71 // |password| : The password for network selected with |setWiFiNetwork|. |
57 // to match |networks| provided with |setWiFiNetworks| or | 72 static void setWiFiPassword(long setupId, DOMString password); |
58 // |onGetWifiCredentials|. | |
59 static void setWiFiCredentials(long setupId, WiFiCredentials[] credentials); | |
60 | 73 |
61 // Confirms that security code known to application match to the code known | 74 // Confirms that security code known to application match to the code known |
62 // to device. | 75 // to device. |
63 // |setupId| : The value returned by |startSetup|. | 76 // |setupId| : The value returned by |startSetup|. |
64 static void confirmCode(long setupId); | 77 static void confirmCode(long setupId); |
65 | 78 |
66 // Stops registration process. | 79 // Stops registration process. |
67 // This call triggers |onSetupError| event. App should wait this even before | 80 // This call triggers |onSetupError| event. App should wait this even before |
68 // starting new registration. | 81 // starting new registration. |
69 // |setupId| : The value returned by |startSetup|. | 82 // |setupId| : The value returned by |startSetup|. |
70 static void stopSetup(long setupId); | 83 static void stopSetup(long setupId); |
| 84 |
| 85 // Returns command definitions. |
| 86 // |deviceId| : The device to get command definitions for. |
| 87 // |callback| : The result callback. |
| 88 static void getCommandDefinitions(DOMString deviceId, |
| 89 CommandDefinitionsCallback callback); |
| 90 |
| 91 // Creates and sends a new command. |
| 92 // |deviceId| : The device to send the command to. |
| 93 // |expireInMs| : The number of milliseconds since now before the command |
| 94 // expires. Expired command should not be executed by device. Acceptable |
| 95 // values are 10000 to 2592000000, inclusive. All values outside that range |
| 96 // will be replaced by 2592000000. |
| 97 // |command| : Described at |
| 98 // https://developers.google.com/cloud-devices/v1/reference/commands |
| 99 // |callback| : The result callback. |
| 100 static void insertCommand(DOMString deviceId, |
| 101 long expireInMs, |
| 102 object command, |
| 103 CommandCallback callback); |
| 104 |
| 105 // Returns a particular command. |
| 106 // |commandId| : Unique command ID. |
| 107 // |callback| : The result callback. |
| 108 static void getCommand(DOMString commandId, CommandCallback callback); |
| 109 |
| 110 // Cancels a command. |
| 111 // |commandId| : Unique command ID. |
| 112 // |callback| : The result callback. |
| 113 static void cancelCommand(DOMString commandId, CommandCallback callback); |
| 114 |
| 115 // Lists all commands in order of creation. |
| 116 // |deviceId| : The device to get the commands for. |
| 117 // |byUser| : List all the commands issued by the user. Special value 'me' |
| 118 // can be used to list by the current user. |
| 119 // |state| : Command state. |
| 120 // |callback| : The result callback. |
| 121 static void getCommandsList(DOMString deviceId, |
| 122 DOMString byUser, |
| 123 DOMString state, |
| 124 CommandListCallback callback); |
71 }; | 125 }; |
72 | 126 |
73 interface Events { | 127 interface Events { |
74 // Subscribe to this event to start listening to cloud devices. New | 128 // Subscribe to this event to start listening new or updated devices. New |
75 // listeners will get called with all known devices on the network. | 129 // listeners will get called with all known devices on the network, and |
76 static void onCloudDeviceStateChanged(boolean available, GCDDevice device); | 130 // status updates for devices available through the cloud. |
| 131 static void onDeviceStateChanged(GCDDevice device); |
77 | 132 |
78 // Notifies app that setup is waiting for network list. App should reply | 133 // Notifies that device has disappeared. |
79 // with |setWiFiNetworks|. | 134 // |deviceId| : The device has disappeared. |
| 135 static void onDeviceRemoved(DOMString deviceId); |
| 136 |
| 137 // Notifies app that setup is waiting for a wifi network. App should reply |
| 138 // with |setWiFiNetwork|. |
80 // |setupId| : The value returned by |startSetup|. | 139 // |setupId| : The value returned by |startSetup|. |
81 static void onGetWifiNetworks(long setupId); | 140 static void onGetWifiNetwork(long setupId); |
82 | 141 |
83 // Notifies app that setup is waiting for credentions for |networks| list. | 142 // Notifies app that setup is waiting for password for the network provided |
84 // App should reply with |setWiFiCredentials|. | 143 // with |setWiFiNetwork|. Even will be called if setup flow would unable to |
| 144 // get password from the system. |
| 145 // App should reply with |setWiFiPassword|. |
85 // |setupId| : The value returned by |startSetup|. | 146 // |setupId| : The value returned by |startSetup|. |
86 // |networks| : A subset of the list provided in |setWiFiNetworks| for which | 147 static void onGetWifiPassword(long setupId); |
87 // setup flow is unable to find credentials | |
88 static void onGetWifiCredentials(long setupId, DOMString[] networks); | |
89 | 148 |
90 // Notifies app that setup is waiting for confirmation that code is the same | 149 // Notifies app that setup is waiting for confirmation that code is the same |
91 // as code known to device. App should reply with |confirmCode|, or | 150 // as code known to device. App should reply with |confirmCode|, or |
92 // |stopSetup| if code does not match. | 151 // |stopSetup| if code does not match. |
93 // |confirmationCode| : The code to confirm. | 152 // |confirmationCode| : The code to confirm. |
94 // |setupId| : The value returned by |startSetup|. | 153 // |setupId| : The value returned by |startSetup|. |
95 static void onConfirmCode(long setupId, DOMString confirmationCode); | 154 static void onConfirmCode(long setupId, DOMString confirmationCode); |
96 | 155 |
97 // Notifies app that setup is completed successfully. | 156 // Notifies app that setup is completed successfully. |
98 // |setupId| : The value returned by |startSetup|. | 157 // |setupId| : The value returned by |startSetup|. |
99 static void onSetupSuccess(long setupId); | 158 static void onSetupSuccess(long setupId); |
100 | 159 |
101 // Notifies app that setup is failed or stoped. | 160 // Notifies app that setup is failed or stopped. |
102 // |setupId| : The value returned by |startSetup|. | 161 // |setupId| : The value returned by |startSetup|. |
103 static void onSetupError(long setupId); | 162 static void onSetupError(long setupId); |
104 }; | 163 }; |
105 }; | 164 }; |
OLD | NEW |