Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: chrome/common/extensions/api/gcd_private.idl

Issue 391413002: Replace setup APIs with session APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 11 matching lines...) Expand all
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 enum Status {
33 // populateWifiPassword was true and the password has not been prefetched.
34 wifiPasswordError,
35 // populateWifiPassword was true and the message cannot be parsed as a setup
36 // message.
37 setupParseError,
38 // Could not connect to the device.
39 connectionError,
40 // Error in establishing session.
41 sessionError,
42 // Success.
43 success
44 };
45
46 enum ConfirmationType {
47 displayCode,
48 audio
49 };
50
32 callback CloudDeviceListCallback = void(GCDDevice[] devices); 51 callback CloudDeviceListCallback = void(GCDDevice[] devices);
33 52
34 // |commandDefinitions| : Is "commandDefs" value of device described at 53 // |commandDefinitions| : Is "commandDefs" value of device described at
35 // https://developers.google.com/cloud-devices/v1/reference/devices 54 // https://developers.google.com/cloud-devices/v1/reference/devices
36 // TODO(vitalybuka): consider to describe object in IDL. 55 // TODO(vitalybuka): consider to describe object in IDL.
37 callback CommandDefinitionsCallback = void(object commandDefinitions); 56 callback CommandDefinitionsCallback = void(object commandDefinitions);
38 57
39 // |command| : Described at 58 // |command| : Described at
40 // https://developers.google.com/cloud-devices/v1/reference/commands 59 // https://developers.google.com/cloud-devices/v1/reference/commands
41 // TODO(vitalybuka): consider to describe object in IDL. 60 // TODO(vitalybuka): consider to describe object in IDL.
42 callback CommandCallback = void(object command); 61 callback CommandCallback = void(object command);
43 62
44 // |commands| : Array of commands described at 63 // |commands| : Array of commands described at
45 // https://developers.google.com/cloud-devices/v1/reference/commands 64 // https://developers.google.com/cloud-devices/v1/reference/commands
46 // TODO(vitalybuka): consider to describe object in IDL. 65 // TODO(vitalybuka): consider to describe object in IDL.
47 callback CommandListCallback = void(object[] commands); 66 callback CommandListCallback = void(object[] commands);
48 67
68 // Called when the confirmation code is available or on error.
69 // |sessionId| is the session ID (identifies the session for future calls)
70 // |status| is the status (success or type of error)
71 // |code| is the confirmation code or empty on error
72 // |confirmationType| is the type of confirmation required
73 callback ConfirmationCodeCallback = void(long sessionId,
74 Status status,
75 DOMString code,
76 ConfirmationType type);
77 // Called to indicated the session is established.
78 // |status| is the status (success or type of error)
79 callback SessionEstablishedCallback = void(Status status);
80 // Called when the response to the message sent is available or on error.
81 // |status| is the status (success or type of error)
82 // |response| is the response object or null on error
83 callback MessageResponseCallback = void(Status status,
84 object response);
85 // Called as a response to |prefetchWifiPassword|
86 // |success| Denotes whether the password fetch has succeeded or failed.
87 callback SuccessCallback = void(boolean success);
88
89
49 interface Functions { 90 interface Functions {
50 // Returns the list of cloud devices visible locally or available in the 91 // Returns the list of cloud devices visible locally or available in the
51 // cloud for user account. 92 // cloud for user account.
52 static void getCloudDeviceList(CloudDeviceListCallback callback); 93 static void getCloudDeviceList(CloudDeviceListCallback callback);
53 94
54 // Queries network for local devices. Triggers an onDeviceStateChanged and 95 // Queries network for local devices. Triggers an onDeviceStateChanged and
55 // onDeviceRemoved events. Call this function *only* after registering for 96 // onDeviceRemoved events. Call this function *only* after registering for
56 // onDeviceStateChanged and onDeviceRemoved events, or it will do nothing. 97 // onDeviceStateChanged and onDeviceRemoved events, or it will do nothing.
57 static void queryForNewLocalDevices(); 98 static void queryForNewLocalDevices();
58 99
59 // Starts device setup process. Returns id of setup process. Id should be 100 // Cache the WiFi password in the browser process for use during
60 // used as |setupId| in all subsequent setup related calls, and for 101 // provisioning. This is done to allow the gathering of the wifi password to
61 // filtering setup events. 102 // not be done while connected to the device's network. Callback is called
62 static long startSetup(DOMString deviceId); 103 // with true if wifi password was cached and false if it was unavailable.
104 static void prefetchWifiPassword(DOMString ssid, SuccessCallback callback);
63 105
64 // Sets WiFi network as reply to |onGetWifiNetworks| event. 106 // Establish the session.
65 // |setupId| : The value returned by |startSetup|. 107 static void establishSession(DOMString ipAddress,
66 // |network| : The wifi network for device setup. 108 long port,
67 static void setWiFiNetwork(long setupId, DOMString network); 109 ConfirmationCodeCallback callback);
68 110
69 // Sets WiFi network password as reply to |onGetWifiPassword| event. 111 // Confirm that the code is correct. Device will still need to confirm.
70 // |setupId| : The value returned by |startSetup|. 112 static void confirmCode(long sessionId,
71 // |password| : The password for network selected with |setWiFiNetwork|. 113 SessionEstablishedCallback callback);
72 static void setWiFiPassword(long setupId, DOMString password);
73 114
74 // Confirms that security code known to application match to the code known 115 // Send an encrypted message to the device. |api| is the API path and
75 // to device. 116 // |input| is the input object. If the message is a setup message with a
76 // |setupId| : The value returned by |startSetup|. 117 // wifi ssid specified but no password, the password cached from
77 static void confirmCode(long setupId); 118 // |prefetchWifiPassword| will be used and the call will fail if it's not
Vitaly Buka (NO REVIEWS) 2014/07/16 21:10:25 doc about prefetchWifiPassword still here
119 // available. For open networks use an empty string as the password.
120 static void sendMessage(long sessionId,
121 DOMString api,
122 object input,
123 MessageResponseCallback callback);
78 124
79 // Stops registration process. 125 // Terminate the session with the device.
80 // This call triggers |onSetupError| event. App should wait this even before 126 static void terminateSession(long sessionId);
81 // starting new registration.
82 // |setupId| : The value returned by |startSetup|.
83 static void stopSetup(long setupId);
84 127
85 // Returns command definitions. 128 // Returns command definitions.
86 // |deviceId| : The device to get command definitions for. 129 // |deviceId| : The device to get command definitions for.
87 // |callback| : The result callback. 130 // |callback| : The result callback.
88 static void getCommandDefinitions(DOMString deviceId, 131 static void getCommandDefinitions(DOMString deviceId,
89 CommandDefinitionsCallback callback); 132 CommandDefinitionsCallback callback);
90 133
91 // Creates and sends a new command. 134 // Creates and sends a new command.
92 // |deviceId| : The device to send the command to. 135 // |deviceId| : The device to send the command to.
93 // |expireInMs| : The number of milliseconds since now before the command 136 // |expireInMs| : The number of milliseconds since now before the command
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 169
127 interface Events { 170 interface Events {
128 // Subscribe to this event to start listening new or updated devices. New 171 // Subscribe to this event to start listening new or updated devices. New
129 // listeners will get called with all known devices on the network, and 172 // listeners will get called with all known devices on the network, and
130 // status updates for devices available through the cloud. 173 // status updates for devices available through the cloud.
131 static void onDeviceStateChanged(GCDDevice device); 174 static void onDeviceStateChanged(GCDDevice device);
132 175
133 // Notifies that device has disappeared. 176 // Notifies that device has disappeared.
134 // |deviceId| : The device has disappeared. 177 // |deviceId| : The device has disappeared.
135 static void onDeviceRemoved(DOMString deviceId); 178 static void onDeviceRemoved(DOMString deviceId);
136
137 // Notifies app that setup is waiting for a wifi network. App should reply
138 // with |setWiFiNetwork|.
139 // |setupId| : The value returned by |startSetup|.
140 static void onGetWifiNetwork(long setupId);
141
142 // Notifies app that setup is waiting for password for the network provided
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
149 // 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
151 // |stopSetup| if code does not match.
152 // |confirmationCode| : The code to confirm.
153 // |setupId| : The value returned by |startSetup|.
154 static void onConfirmCode(long setupId, DOMString confirmationCode);
155
156 // Notifies app that setup is completed successfully.
157 // |setupId| : The value returned by |startSetup|.
158 static void onSetupSuccess(long setupId);
159
160 // Notifies app that setup is failed or stopped.
161 // |setupId| : The value returned by |startSetup|.
162 static void onSetupError(long setupId);
163 }; 179 };
164 }; 180 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698