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 | |
16 // How this device was discovered. | 13 // How this device was discovered. |
17 SetupType setupType; | 14 SetupType setupType; |
18 | 15 |
| 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 |
32 callback CloudDeviceListCallback = void(GCDDevice[] devices); | 38 callback CloudDeviceListCallback = void(GCDDevice[] devices); |
33 | 39 |
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 | |
49 interface Functions { | 40 interface Functions { |
50 // Returns the list of cloud devices visible locally or available in the | |
51 // cloud for user account. | |
52 static void getCloudDeviceList(CloudDeviceListCallback callback); | 41 static void getCloudDeviceList(CloudDeviceListCallback callback); |
53 | 42 |
54 // Queries network for local devices. Triggers an onDeviceStateChanged and | 43 // Call this function *only* after registering for onDeviceStateChanged |
55 // onDeviceRemoved events. Call this function *only* after registering for | 44 // events, or it will do nothing. This will trigger an |
56 // onDeviceStateChanged and onDeviceRemoved events, or it will do nothing. | 45 // onLocalDeviceStateChanged event per device. |
57 static void queryForNewLocalDevices(); | 46 static void queryForNewLocalDevices(); |
58 | 47 |
59 // Starts device setup process. Returns id of setup process. Id should be | 48 // Starts device setup process. Returns id of setup process. Id should be |
60 // used as |setupId| in all subsequent setup related calls, and for | 49 // used as |setupId| in all subsequent setup related calls, and for |
61 // filtering setup events. | 50 // filtering setup events. |
62 static long startSetup(DOMString deviceId); | 51 static long startSetup(GCDDevice device); |
63 | 52 |
64 // Sets WiFi network as reply to |onGetWifiNetworks| event. | 53 // Sets WiFi network list as reply to |onGetWifiNetworks| event. |
65 // |setupId| : The value returned by |startSetup|. | 54 // |setupId| : The value returned by |startSetup|. |
66 // |network| : The wifi network for device setup. | 55 // |networks| : The list of network device should be registered on. |
67 static void setWiFiNetwork(long setupId, DOMString network); | 56 static void setWiFiNetworks(long setupId, DOMString[] networks); |
68 | 57 |
69 // Sets WiFi network password as reply to |onGetWifiPassword| event. | 58 // Sets WiFi network credentials as reply to |onGetWifiCredentials| |
| 59 // event. |
70 // |setupId| : The value returned by |startSetup|. | 60 // |setupId| : The value returned by |startSetup|. |
71 // |password| : The password for network selected with |setWiFiNetwork|. | 61 // |credentials| : The list of ssid with passwoors. The list is not required |
72 static void setWiFiPassword(long setupId, DOMString password); | 62 // to match |networks| provided with |setWiFiNetworks| or |
| 63 // |onGetWifiCredentials|. |
| 64 static void setWiFiCredentials(long setupId, WiFiCredentials[] credentials); |
73 | 65 |
74 // Confirms that security code known to application match to the code known | 66 // Confirms that security code known to application match to the code known |
75 // to device. | 67 // to device. |
76 // |setupId| : The value returned by |startSetup|. | 68 // |setupId| : The value returned by |startSetup|. |
77 static void confirmCode(long setupId); | 69 static void confirmCode(long setupId); |
78 | 70 |
79 // Stops registration process. | 71 // Stops registration process. |
80 // This call triggers |onSetupError| event. App should wait this even before | 72 // This call triggers |onSetupError| event. App should wait this even before |
81 // starting new registration. | 73 // starting new registration. |
82 // |setupId| : The value returned by |startSetup|. | 74 // |setupId| : The value returned by |startSetup|. |
83 static void stopSetup(long setupId); | 75 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); | |
125 }; | 76 }; |
126 | 77 |
127 interface Events { | 78 interface Events { |
128 // Subscribe to this event to start listening new or updated devices. New | 79 // Subscribe to this event to start listening to cloud devices. New |
129 // listeners will get called with all known devices on the network, and | 80 // listeners will get called with all known devices on the network. |
130 // status updates for devices available through the cloud. | 81 static void onCloudDeviceStateChanged(boolean available, GCDDevice device); |
131 static void onDeviceStateChanged(GCDDevice device); | |
132 | 82 |
133 // Notifies that device has disappeared. | 83 // Notifies app that setup is waiting for network list. App should reply |
134 // |deviceId| : The device has disappeared. | 84 // with |setWiFiNetworks|. |
135 static void onDeviceRemoved(DOMString deviceId); | 85 // |setupId| : The value returned by |startSetup|. |
| 86 static void onGetWifiNetworks(long setupId); |
136 | 87 |
137 // Notifies app that setup is waiting for a wifi network. App should reply | 88 // Notifies app that setup is waiting for credentions for |networks| list. |
138 // with |setWiFiNetwork|. | 89 // App should reply with |setWiFiCredentials|. |
139 // |setupId| : The value returned by |startSetup|. | 90 // |setupId| : The value returned by |startSetup|. |
140 static void onGetWifiNetwork(long setupId); | 91 // |networks| : A subset of the list provided in |setWiFiNetworks| for which |
141 | 92 // setup flow is unable to find credentials |
142 // Notifies app that setup is waiting for password for the network provided | 93 static void onGetWifiCredentials(long setupId, DOMString[] networks); |
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|. | |
146 // |setupId| : The value returned by |startSetup|. | |
147 static void onGetWifiPassword(long setupId); | |
148 | 94 |
149 // Notifies app that setup is waiting for confirmation that code is the same | 95 // Notifies app that setup is waiting for confirmation that code is the same |
150 // as code known to device. App should reply with |confirmCode|, or | 96 // as code known to device. App should reply with |confirmCode|, or |
151 // |stopSetup| if code does not match. | 97 // |stopSetup| if code does not match. |
152 // |confirmationCode| : The code to confirm. | 98 // |confirmationCode| : The code to confirm. |
153 // |setupId| : The value returned by |startSetup|. | 99 // |setupId| : The value returned by |startSetup|. |
154 static void onConfirmCode(long setupId, DOMString confirmationCode); | 100 static void onConfirmCode(long setupId, DOMString confirmationCode); |
155 | 101 |
156 // Notifies app that setup is completed successfully. | 102 // Notifies app that setup is completed successfully. |
157 // |setupId| : The value returned by |startSetup|. | 103 // |setupId| : The value returned by |startSetup|. |
158 static void onSetupSuccess(long setupId); | 104 static void onSetupSuccess(long setupId); |
159 | 105 |
160 // Notifies app that setup is failed or stopped. | 106 // Notifies app that setup is failed or stoped. |
161 // |setupId| : The value returned by |startSetup|. | 107 // |setupId| : The value returned by |startSetup|. |
162 static void onSetupError(long setupId); | 108 static void onSetupError(long setupId); |
163 }; | 109 }; |
164 }; | 110 }; |
OLD | NEW |