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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 // Could not connect to the device. | 40 // Could not connect to the device. |
41 connectionError, | 41 connectionError, |
42 | 42 |
43 // Error in establishing session. | 43 // Error in establishing session. |
44 sessionError, | 44 sessionError, |
45 | 45 |
46 // Unknown session. | 46 // Unknown session. |
47 unknownSessionError, | 47 unknownSessionError, |
48 | 48 |
| 49 // Bad confirmation code. Ask user to retype. |
| 50 badConfirmationCodeError, |
| 51 |
49 // Success. | 52 // Success. |
50 success | 53 success |
51 }; | 54 }; |
52 | 55 |
53 enum ConfirmationType { | 56 enum ConfirmationType { |
54 displayCode, | 57 displayCode, |
55 audio | 58 stickerCode |
| 59 }; |
| 60 |
| 61 // Information regarding the confirmation of a device. |
| 62 dictionary ConfirmationInfo { |
| 63 // Type of confirmation. |
| 64 ConfirmationType type; |
| 65 |
| 66 // Code if available. |
| 67 DOMString? code; |
56 }; | 68 }; |
57 | 69 |
58 callback CloudDeviceListCallback = void(GCDDevice[] devices); | 70 callback CloudDeviceListCallback = void(GCDDevice[] devices); |
59 | 71 |
60 // |commandDefinitions| : Is "commandDefs" value of device described at | 72 // |commandDefinitions| : Is "commandDefs" value of device described at |
61 // https://developers.google.com/cloud-devices/v1/reference/devices | 73 // https://developers.google.com/cloud-devices/v1/reference/devices |
62 // TODO(vitalybuka): consider to describe object in IDL. | 74 // TODO(vitalybuka): consider to describe object in IDL. |
63 callback CommandDefinitionsCallback = void(object commandDefinitions); | 75 callback CommandDefinitionsCallback = void(object commandDefinitions); |
64 | 76 |
65 // |command| : Described at | 77 // |command| : Described at |
66 // https://developers.google.com/cloud-devices/v1/reference/commands | 78 // https://developers.google.com/cloud-devices/v1/reference/commands |
67 // TODO(vitalybuka): consider to describe object in IDL. | 79 // TODO(vitalybuka): consider to describe object in IDL. |
68 callback CommandCallback = void(object command); | 80 callback CommandCallback = void(object command); |
69 | 81 |
70 // |commands| : Array of commands described at | 82 // |commands| : Array of commands described at |
71 // https://developers.google.com/cloud-devices/v1/reference/commands | 83 // https://developers.google.com/cloud-devices/v1/reference/commands |
72 // TODO(vitalybuka): consider to describe object in IDL. | 84 // TODO(vitalybuka): consider to describe object in IDL. |
73 callback CommandListCallback = void(object[] commands); | 85 callback CommandListCallback = void(object[] commands); |
74 | 86 |
75 // Called when the confirmation code is available or on error. | 87 // Called when the confirmation code is available or on error. |
76 // |sessionId| is the session ID (identifies the session for future calls) | 88 // |sessionId| is the session ID (identifies the session for future calls) |
77 // |status| is the status (success or type of error) | 89 // |status| is the status (success or type of error) |
78 // |code| is the confirmation code or empty on error | 90 // |confirmation| is the information about the confirmation. |
79 // |confirmationType| is the type of confirmation required | |
80 callback ConfirmationCodeCallback = void(long sessionId, | 91 callback ConfirmationCodeCallback = void(long sessionId, |
81 Status status, | 92 Status status, |
82 DOMString code, | 93 ConfirmationInfo confirmation); |
83 ConfirmationType type); | |
84 | 94 |
85 // Called to indicated the session is established. | 95 // Called to indicated the session is established. |
86 // |status| is the status (success or type of error) | 96 // |status| is the status (success or type of error) |
87 callback SessionEstablishedCallback = void(Status status); | 97 callback SessionEstablishedCallback = void(Status status); |
88 | 98 |
89 // Called when the response to the message sent is available or on error. | 99 // Called when the response to the message sent is available or on error. |
90 // |status| is the status (success or type of error) | 100 // |status| is the status (success or type of error) |
91 // |response| is the response object or null on error | 101 // |response| is the response object or null on error |
92 callback MessageResponseCallback = void(Status status, | 102 callback MessageResponseCallback = void(Status status, |
93 object response); | 103 object response); |
(...skipping 23 matching lines...) Expand all Loading... |
117 static void prefetchWifiPassword(DOMString ssid, SuccessCallback callback); | 127 static void prefetchWifiPassword(DOMString ssid, SuccessCallback callback); |
118 | 128 |
119 // Get the list of ssids with prefetched callbacks. | 129 // Get the list of ssids with prefetched callbacks. |
120 static void getPrefetchedWifiNameList(SSIDListCallback callback); | 130 static void getPrefetchedWifiNameList(SSIDListCallback callback); |
121 | 131 |
122 // Establish the session. | 132 // Establish the session. |
123 static void establishSession(DOMString ipAddress, | 133 static void establishSession(DOMString ipAddress, |
124 long port, | 134 long port, |
125 ConfirmationCodeCallback callback); | 135 ConfirmationCodeCallback callback); |
126 | 136 |
127 // Confirm that the code is correct. Device will still need to confirm. | 137 // Send confirmation code. Device will still need to confirm. |code| must be |
| 138 // present and must match the code from the device, even when the code is |
| 139 // supplied in the |ConfirmationInfo| object. |
128 static void confirmCode(long sessionId, | 140 static void confirmCode(long sessionId, |
| 141 DOMString code, |
129 SessionEstablishedCallback callback); | 142 SessionEstablishedCallback callback); |
130 | 143 |
131 // Send an encrypted message to the device. |api| is the API path and | 144 // Send an encrypted message to the device. |api| is the API path and |
132 // |input| is the input object. If the message is a setup message with a | 145 // |input| is the input object. If the message is a setup message with a |
133 // wifi ssid specified but no password, the password cached from | 146 // wifi ssid specified but no password, the password cached from |
134 // |prefetchWifiPassword| will be used and the call will fail if it's not | 147 // |prefetchWifiPassword| will be used and the call will fail if it's not |
135 // available. For open networks use an empty string as the password. | 148 // available. For open networks use an empty string as the password. |
136 static void sendMessage(long sessionId, | 149 static void sendMessage(long sessionId, |
137 DOMString api, | 150 DOMString api, |
138 object input, | 151 object input, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // Subscribe to this event to start listening new or updated devices. New | 200 // Subscribe to this event to start listening new or updated devices. New |
188 // listeners will get called with all known devices on the network, and | 201 // listeners will get called with all known devices on the network, and |
189 // status updates for devices available through the cloud. | 202 // status updates for devices available through the cloud. |
190 static void onDeviceStateChanged(GCDDevice device); | 203 static void onDeviceStateChanged(GCDDevice device); |
191 | 204 |
192 // Notifies that device has disappeared. | 205 // Notifies that device has disappeared. |
193 // |deviceId| : The device has disappeared. | 206 // |deviceId| : The device has disappeared. |
194 static void onDeviceRemoved(DOMString deviceId); | 207 static void onDeviceRemoved(DOMString deviceId); |
195 }; | 208 }; |
196 }; | 209 }; |
OLD | NEW |