Commit a5e4afa7 authored by noamsml@google.com's avatar noamsml@google.com

Replace setup APIs with session APIs for GCD.

BUG=394441
R=asargent@chromium.org, asvitkine@chromium.org, vitalybuka@chromium.org

Review URL: https://codereview.chromium.org/391413002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284221 0039d316-1c4b-4281-b951-d872f2087c98
parent 50c18664
......@@ -284,53 +284,55 @@ bool GcdPrivateQueryForNewLocalDevicesFunction::RunSync() {
return true;
}
GcdPrivateStartSetupFunction::GcdPrivateStartSetupFunction() {
GcdPrivatePrefetchWifiPasswordFunction::
GcdPrivatePrefetchWifiPasswordFunction() {
}
GcdPrivateStartSetupFunction::~GcdPrivateStartSetupFunction() {
GcdPrivatePrefetchWifiPasswordFunction::
~GcdPrivatePrefetchWifiPasswordFunction() {
}
bool GcdPrivateStartSetupFunction::RunAsync() {
bool GcdPrivatePrefetchWifiPasswordFunction::RunAsync() {
return false;
}
GcdPrivateSetWiFiNetworkFunction::GcdPrivateSetWiFiNetworkFunction() {
GcdPrivateEstablishSessionFunction::GcdPrivateEstablishSessionFunction() {
}
GcdPrivateSetWiFiNetworkFunction::~GcdPrivateSetWiFiNetworkFunction() {
GcdPrivateEstablishSessionFunction::~GcdPrivateEstablishSessionFunction() {
}
bool GcdPrivateSetWiFiNetworkFunction::RunAsync() {
bool GcdPrivateEstablishSessionFunction::RunAsync() {
return false;
}
GcdPrivateSetWiFiPasswordFunction::GcdPrivateSetWiFiPasswordFunction() {
GcdPrivateConfirmCodeFunction::GcdPrivateConfirmCodeFunction() {
}
GcdPrivateSetWiFiPasswordFunction::~GcdPrivateSetWiFiPasswordFunction() {
GcdPrivateConfirmCodeFunction::~GcdPrivateConfirmCodeFunction() {
}
bool GcdPrivateSetWiFiPasswordFunction::RunAsync() {
bool GcdPrivateConfirmCodeFunction::RunAsync() {
return false;
}
GcdPrivateConfirmCodeFunction::GcdPrivateConfirmCodeFunction() {
GcdPrivateSendMessageFunction::GcdPrivateSendMessageFunction() {
}
GcdPrivateConfirmCodeFunction::~GcdPrivateConfirmCodeFunction() {
GcdPrivateSendMessageFunction::~GcdPrivateSendMessageFunction() {
}
bool GcdPrivateConfirmCodeFunction::RunAsync() {
bool GcdPrivateSendMessageFunction::RunAsync() {
return false;
}
GcdPrivateStopSetupFunction::GcdPrivateStopSetupFunction() {
GcdPrivateTerminateSessionFunction::GcdPrivateTerminateSessionFunction() {
}
GcdPrivateStopSetupFunction::~GcdPrivateStopSetupFunction() {
GcdPrivateTerminateSessionFunction::~GcdPrivateTerminateSessionFunction() {
}
bool GcdPrivateStopSetupFunction::RunAsync() {
bool GcdPrivateTerminateSessionFunction::RunAsync() {
return false;
}
......
......@@ -114,47 +114,43 @@ class GcdPrivateQueryForNewLocalDevicesFunction
virtual bool RunSync() OVERRIDE;
};
class GcdPrivateStartSetupFunction : public ChromeAsyncExtensionFunction {
public:
class GcdPrivatePrefetchWifiPasswordFunction
: public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.startSetup", GCDPRIVATE_STARTSETUP)
DECLARE_EXTENSION_FUNCTION("gcdPrivate.prefetchWifiPassword",
GCDPRIVATE_PREFETCHWIFIPASSWORD)
GcdPrivateStartSetupFunction();
GcdPrivatePrefetchWifiPasswordFunction();
protected:
virtual ~GcdPrivateStartSetupFunction();
virtual ~GcdPrivatePrefetchWifiPasswordFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
class GcdPrivateSetWiFiNetworkFunction : public ChromeAsyncExtensionFunction {
class GcdPrivateEstablishSessionFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiNetwork",
GCDPRIVATE_SETWIFINETWORK)
DECLARE_EXTENSION_FUNCTION("gcdPrivate.establishSession",
GCDPRIVATE_ESTABLISHSESSION)
GcdPrivateSetWiFiNetworkFunction();
GcdPrivateEstablishSessionFunction();
protected:
virtual ~GcdPrivateSetWiFiNetworkFunction();
virtual ~GcdPrivateEstablishSessionFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
class GcdPrivateSetWiFiPasswordFunction : public ChromeAsyncExtensionFunction {
class GcdPrivateConfirmCodeFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiPassword",
GCDPRIVATE_SETWIFIPASSWORD)
DECLARE_EXTENSION_FUNCTION("gcdPrivate.confirmCode", GCDPRIVATE_CONFIRMCODE)
GcdPrivateSetWiFiPasswordFunction();
GcdPrivateConfirmCodeFunction();
protected:
virtual ~GcdPrivateSetWiFiPasswordFunction();
virtual ~GcdPrivateConfirmCodeFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
......@@ -162,14 +158,14 @@ class GcdPrivateSetWiFiPasswordFunction : public ChromeAsyncExtensionFunction {
private:
};
class GcdPrivateConfirmCodeFunction : public ChromeAsyncExtensionFunction {
class GcdPrivateSendMessageFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.confirmCode", GCDPRIVATE_CONFIRMCODE)
DECLARE_EXTENSION_FUNCTION("gcdPrivate.sendMessage", GCDPRIVATE_SENDMESSAGE)
GcdPrivateConfirmCodeFunction();
GcdPrivateSendMessageFunction();
protected:
virtual ~GcdPrivateConfirmCodeFunction();
virtual ~GcdPrivateSendMessageFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
......@@ -177,19 +173,18 @@ class GcdPrivateConfirmCodeFunction : public ChromeAsyncExtensionFunction {
private:
};
class GcdPrivateStopSetupFunction : public ChromeAsyncExtensionFunction {
class GcdPrivateTerminateSessionFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.stopSetup", GCDPRIVATE_STOPSETUP)
DECLARE_EXTENSION_FUNCTION("gcdPrivate.terminateSession",
GCDPRIVATE_TERMINATESESSION)
GcdPrivateStopSetupFunction();
GcdPrivateTerminateSessionFunction();
protected:
virtual ~GcdPrivateStopSetupFunction();
virtual ~GcdPrivateTerminateSessionFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
class GcdPrivateGetCommandDefinitionsFunction
......
......@@ -29,6 +29,29 @@ namespace gcdPrivate {
DOMString deviceDescription;
};
enum Status {
// populateWifiPassword was true and the password has not been prefetched.
wifiPasswordError,
// populateWifiPassword was true and the message cannot be parsed as a setup
// message.
setupParseError,
// Could not connect to the device.
connectionError,
// Error in establishing session.
sessionError,
// Success.
success
};
enum ConfirmationType {
displayCode,
audio
};
callback CloudDeviceListCallback = void(GCDDevice[] devices);
// |commandDefinitions| : Is "commandDefs" value of device described at
......@@ -46,6 +69,31 @@ namespace gcdPrivate {
// TODO(vitalybuka): consider to describe object in IDL.
callback CommandListCallback = void(object[] commands);
// Called when the confirmation code is available or on error.
// |sessionId| is the session ID (identifies the session for future calls)
// |status| is the status (success or type of error)
// |code| is the confirmation code or empty on error
// |confirmationType| is the type of confirmation required
callback ConfirmationCodeCallback = void(long sessionId,
Status status,
DOMString code,
ConfirmationType type);
// Called to indicated the session is established.
// |status| is the status (success or type of error)
callback SessionEstablishedCallback = void(Status status);
// Called when the response to the message sent is available or on error.
// |status| is the status (success or type of error)
// |response| is the response object or null on error
callback MessageResponseCallback = void(Status status,
object response);
// Called as a response to |prefetchWifiPassword|
// |success| Denotes whether the password fetch has succeeded or failed.
callback SuccessCallback = void(boolean success);
interface Functions {
// Returns the list of cloud devices visible locally or available in the
// cloud for user account.
......@@ -56,31 +104,33 @@ namespace gcdPrivate {
// onDeviceStateChanged and onDeviceRemoved events, or it will do nothing.
static void queryForNewLocalDevices();
// Starts device setup process. Returns id of setup process. Id should be
// used as |setupId| in all subsequent setup related calls, and for
// filtering setup events.
static long startSetup(DOMString deviceId);
// Sets WiFi network as reply to |onGetWifiNetworks| event.
// |setupId| : The value returned by |startSetup|.
// |network| : The wifi network for device setup.
static void setWiFiNetwork(long setupId, DOMString network);
// Sets WiFi network password as reply to |onGetWifiPassword| event.
// |setupId| : The value returned by |startSetup|.
// |password| : The password for network selected with |setWiFiNetwork|.
static void setWiFiPassword(long setupId, DOMString password);
// Confirms that security code known to application match to the code known
// to device.
// |setupId| : The value returned by |startSetup|.
static void confirmCode(long setupId);
// Stops registration process.
// This call triggers |onSetupError| event. App should wait this even before
// starting new registration.
// |setupId| : The value returned by |startSetup|.
static void stopSetup(long setupId);
// Cache the WiFi password in the browser process for use during
// provisioning. This is done to allow the gathering of the wifi password to
// not be done while connected to the device's network. Callback is called
// with true if wifi password was cached and false if it was unavailable.
static void prefetchWifiPassword(DOMString ssid, SuccessCallback callback);
// Establish the session.
static void establishSession(DOMString ipAddress,
long port,
ConfirmationCodeCallback callback);
// Confirm that the code is correct. Device will still need to confirm.
static void confirmCode(long sessionId,
SessionEstablishedCallback callback);
// Send an encrypted message to the device. |api| is the API path and
// |input| is the input object. If the message is a setup message with a
// wifi ssid specified but no password, the password cached from
// |prefetchWifiPassword| will be used and the call will fail if it's not
// available. For open networks use an empty string as the password.
static void sendMessage(long sessionId,
DOMString api,
object input,
MessageResponseCallback callback);
// Terminate the session with the device.
static void terminateSession(long sessionId);
// Returns command definitions.
// |deviceId| : The device to get command definitions for.
......@@ -133,32 +183,5 @@ namespace gcdPrivate {
// Notifies that device has disappeared.
// |deviceId| : The device has disappeared.
static void onDeviceRemoved(DOMString deviceId);
// Notifies app that setup is waiting for a wifi network. App should reply
// with |setWiFiNetwork|.
// |setupId| : The value returned by |startSetup|.
static void onGetWifiNetwork(long setupId);
// Notifies app that setup is waiting for password for the network provided
// with |setWiFiNetwork|. Even will be called if setup flow would unable to
// get password from the system.
// App should reply with |setWiFiPassword|.
// |setupId| : The value returned by |startSetup|.
static void onGetWifiPassword(long setupId);
// Notifies app that setup is waiting for confirmation that code is the same
// as code known to device. App should reply with |confirmCode|, or
// |stopSetup| if code does not match.
// |confirmationCode| : The code to confirm.
// |setupId| : The value returned by |startSetup|.
static void onConfirmCode(long setupId, DOMString confirmationCode);
// Notifies app that setup is completed successfully.
// |setupId| : The value returned by |startSetup|.
static void onSetupSuccess(long setupId);
// Notifies app that setup is failed or stopped.
// |setupId| : The value returned by |startSetup|.
static void onSetupError(long setupId);
};
};
......@@ -883,11 +883,11 @@ enum HistogramValue {
BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS,
GCDPRIVATE_GETCLOUDDEVICELIST,
GCDPRIVATE_QUERYFORNEWLOCALDEVICES,
GCDPRIVATE_STARTSETUP,
GCDPRIVATE_SETWIFINETWORK,
GCDPRIVATE_SETWIFIPASSWORD,
GCDPRIVATE_PREFETCHWIFIPASSWORD,
GCDPRIVATE_ESTABLISHSESSION,
GCDPRIVATE_SENDMESSAGE,
GCDPRIVATE_CONFIRMCODE,
GCDPRIVATE_STOPSETUP,
GCDPRIVATE_TERMINATESESSION,
TABS_SETZOOM,
TABS_GETZOOM,
TABS_SETZOOMSETTINGS,
......
......@@ -38779,16 +38779,16 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="822" label="BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS"/>
<int value="823" label="GCDPRIVATE_GETCLOUDDEVICELIST"/>
<int value="824" label="GCDPRIVATE_QUERYFORNEWLOCALDEVICES"/>
<int value="825" label="GCDPRIVATE_STARTSETUP"/>
<int value="826" label="GCDPRIVATE_SETWIFINETWORKS"/>
<int value="827" label="GCDPRIVATE_SETWIFICREDENTIALS"/>
<int value="825" label="GCDPRIVATE_PREFETCHWIFIPASSWORD"/>
<int value="826" label="GCDPRIVATE_ESTABLISHSESSION"/>
<int value="827" label="GCDPRIVATE_SENDMESSAGE"/>
<int value="828" label="GCDPRIVATE_CONFIRMCODE"/>
<int value="829" label="GCDPRIVATE_STOPSETUP"/>
<int value="829" label="GCDPRIVATE_TERMINATESESSION"/>
<int value="830" label="TABS_SETZOOM"/>
<int value="831" label="TABS_GETZOOM"/>
<int value="832" label="TABS_SETZOOMSETTINGS"/>
<int value="833" label="TABS_GETZOOMSETTINGS"/>
<int value="834" label="GCDPRIVATE_GETCOMMANDDEFS"/>
<int value="834" label="GCDPRIVATE_GETCOMMANDDEFINITIONS"/>
<int value="835" label="GCDPRIVATE_INSERTCOMMAND"/>
<int value="836" label="GCDPRIVATE_GETCOMMAND"/>
<int value="837" label="GCDPRIVATE_CANCELCOMMAND"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment