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

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
36 // populateWifiPassword was true and the message cannot be parsed as a setup
37 // message.
38 setupParseError,
39
40 // Could not connect to the device.
41 connectionError,
42
43 // Error in establishing session.
44 sessionError,
45
46 // Success.
47 success
48 };
49
50 enum ConfirmationType {
51 displayCode,
52 audio
53 };
54
32 callback CloudDeviceListCallback = void(GCDDevice[] devices); 55 callback CloudDeviceListCallback = void(GCDDevice[] devices);
33 56
34 // |commandDefinitions| : Is "commandDefs" value of device described at 57 // |commandDefinitions| : Is "commandDefs" value of device described at
35 // https://developers.google.com/cloud-devices/v1/reference/devices 58 // https://developers.google.com/cloud-devices/v1/reference/devices
36 // TODO(vitalybuka): consider to describe object in IDL. 59 // TODO(vitalybuka): consider to describe object in IDL.
37 callback CommandDefinitionsCallback = void(object commandDefinitions); 60 callback CommandDefinitionsCallback = void(object commandDefinitions);
38 61
39 // |command| : Described at 62 // |command| : Described at
40 // https://developers.google.com/cloud-devices/v1/reference/commands 63 // https://developers.google.com/cloud-devices/v1/reference/commands
41 // TODO(vitalybuka): consider to describe object in IDL. 64 // TODO(vitalybuka): consider to describe object in IDL.
42 callback CommandCallback = void(object command); 65 callback CommandCallback = void(object command);
43 66
44 // |commands| : Array of commands described at 67 // |commands| : Array of commands described at
45 // https://developers.google.com/cloud-devices/v1/reference/commands 68 // https://developers.google.com/cloud-devices/v1/reference/commands
46 // TODO(vitalybuka): consider to describe object in IDL. 69 // TODO(vitalybuka): consider to describe object in IDL.
47 callback CommandListCallback = void(object[] commands); 70 callback CommandListCallback = void(object[] commands);
48 71
72 // Called when the confirmation code is available or on error.
73 // |sessionId| is the session ID (identifies the session for future calls)
74 // |status| is the status (success or type of error)
75 // |code| is the confirmation code or empty on error
76 // |confirmationType| is the type of confirmation required
77 callback ConfirmationCodeCallback = void(long sessionId,
78 Status status,
79 DOMString code,
80 ConfirmationType type);
81
82 // Called to indicated the session is established.
83 // |status| is the status (success or type of error)
84 callback SessionEstablishedCallback = void(Status status);
85
86 // Called when the response to the message sent is available or on error.
87 // |status| is the status (success or type of error)
88 // |response| is the response object or null on error
89 callback MessageResponseCallback = void(Status status,
90 object response);
91
92 // Called as a response to |prefetchWifiPassword|
93 // |success| Denotes whether the password fetch has succeeded or failed.
94 callback SuccessCallback = void(boolean success);
95
96
49 interface Functions { 97 interface Functions {
50 // Returns the list of cloud devices visible locally or available in the 98 // Returns the list of cloud devices visible locally or available in the
51 // cloud for user account. 99 // cloud for user account.
52 static void getCloudDeviceList(CloudDeviceListCallback callback); 100 static void getCloudDeviceList(CloudDeviceListCallback callback);
53 101
54 // Queries network for local devices. Triggers an onDeviceStateChanged and 102 // Queries network for local devices. Triggers an onDeviceStateChanged and
55 // onDeviceRemoved events. Call this function *only* after registering for 103 // onDeviceRemoved events. Call this function *only* after registering for
56 // onDeviceStateChanged and onDeviceRemoved events, or it will do nothing. 104 // onDeviceStateChanged and onDeviceRemoved events, or it will do nothing.
57 static void queryForNewLocalDevices(); 105 static void queryForNewLocalDevices();
58 106
59 // Starts device setup process. Returns id of setup process. Id should be 107 // Cache the WiFi password in the browser process for use during
60 // used as |setupId| in all subsequent setup related calls, and for 108 // provisioning. This is done to allow the gathering of the wifi password to
61 // filtering setup events. 109 // not be done while connected to the device's network. Callback is called
62 static long startSetup(DOMString deviceId); 110 // with true if wifi password was cached and false if it was unavailable.
111 static void prefetchWifiPassword(DOMString ssid, SuccessCallback callback);
63 112
64 // Sets WiFi network as reply to |onGetWifiNetworks| event. 113 // Establish the session.
65 // |setupId| : The value returned by |startSetup|. 114 static void establishSession(DOMString ipAddress,
66 // |network| : The wifi network for device setup. 115 long port,
67 static void setWiFiNetwork(long setupId, DOMString network); 116 ConfirmationCodeCallback callback);
68 117
69 // Sets WiFi network password as reply to |onGetWifiPassword| event. 118 // Confirm that the code is correct. Device will still need to confirm.
70 // |setupId| : The value returned by |startSetup|. 119 static void confirmCode(long sessionId,
71 // |password| : The password for network selected with |setWiFiNetwork|. 120 SessionEstablishedCallback callback);
72 static void setWiFiPassword(long setupId, DOMString password);
73 121
74 // Confirms that security code known to application match to the code known 122 // Send an encrypted message to the device. |api| is the API path and
75 // to device. 123 // |input| is the input object. If the message is a setup message with a
76 // |setupId| : The value returned by |startSetup|. 124 // wifi ssid specified but no password, the password cached from
77 static void confirmCode(long setupId); 125 // |prefetchWifiPassword| will be used and the call will fail if it's not
126 // available. For open networks use an empty string as the password.
127 static void sendMessage(long sessionId,
128 DOMString api,
129 object input,
130 MessageResponseCallback callback);
78 131
79 // Stops registration process. 132 // Terminate the session with the device.
80 // This call triggers |onSetupError| event. App should wait this even before 133 static void terminateSession(long sessionId);
81 // starting new registration.
82 // |setupId| : The value returned by |startSetup|.
83 static void stopSetup(long setupId);
84 134
85 // Returns command definitions. 135 // Returns command definitions.
86 // |deviceId| : The device to get command definitions for. 136 // |deviceId| : The device to get command definitions for.
87 // |callback| : The result callback. 137 // |callback| : The result callback.
88 static void getCommandDefinitions(DOMString deviceId, 138 static void getCommandDefinitions(DOMString deviceId,
89 CommandDefinitionsCallback callback); 139 CommandDefinitionsCallback callback);
90 140
91 // Creates and sends a new command. 141 // Creates and sends a new command.
92 // |deviceId| : The device to send the command to. 142 // |deviceId| : The device to send the command to.
93 // |expireInMs| : The number of milliseconds since now before the command 143 // |expireInMs| : The number of milliseconds since now before the command
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 176
127 interface Events { 177 interface Events {
128 // Subscribe to this event to start listening new or updated devices. New 178 // 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 179 // listeners will get called with all known devices on the network, and
130 // status updates for devices available through the cloud. 180 // status updates for devices available through the cloud.
131 static void onDeviceStateChanged(GCDDevice device); 181 static void onDeviceStateChanged(GCDDevice device);
132 182
133 // Notifies that device has disappeared. 183 // Notifies that device has disappeared.
134 // |deviceId| : The device has disappeared. 184 // |deviceId| : The device has disappeared.
135 static void onDeviceRemoved(DOMString deviceId); 185 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 }; 186 };
164 }; 187 };
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/gcd_private/gcd_private_api.cc ('k') | extensions/browser/extension_function_histogram_value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698