summaryrefslogtreecommitdiffstats
path: root/remoting/webapp/host_controller.js
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-20 18:10:37 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-20 18:10:37 +0000
commitce42088b0d04b3abb385f81a067bf33005b0808d (patch)
tree30bdbb966c08121593809048a4346bd29359516d /remoting/webapp/host_controller.js
parent68bc14d0ffd1aefab636650ddd0cc0fe5b30086a (diff)
downloadchromium_src-ce42088b0d04b3abb385f81a067bf33005b0808d.zip
chromium_src-ce42088b0d04b3abb385f81a067bf33005b0808d.tar.gz
chromium_src-ce42088b0d04b3abb385f81a067bf33005b0808d.tar.bz2
[Chromoting] Store a newly registered host's public key in the webapp's host list.
This lets the webapp rename that host. BUG=149051 Review URL: https://codereview.chromium.org/10957019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157800 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp/host_controller.js')
-rw-r--r--remoting/webapp/host_controller.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index b5d6876..0aa7cc2 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -139,18 +139,20 @@ remoting.HostController.prototype.start = function(hostPin, consent, callback) {
/** @param {function(remoting.HostController.AsyncResult):void} callback
* @param {remoting.HostController.AsyncResult} result
- * @param {string} hostName */
- function onStarted(callback, result, hostName) {
+ * @param {string} hostName
+ * @param {string} publicKey */
+ function onStarted(callback, result, hostName, publicKey) {
if (result == remoting.HostController.AsyncResult.OK) {
// Create a dummy remoting.Host instance to represent the local host.
// Refreshing the list is no good in general, because the directory
// information won't be in sync for several seconds. We don't know the
- // host JID or public key, but they can be missing from the cache with
- // no ill effects (it will be refreshed--we hope that the directory
- // will have been updated by that point).
+ // host JID, but it can be missing from the cache with no ill effects.
+ // It will be refreshed if the user tries to connect to the local host,
+ // and we hope that the directory will have been updated by that point.
var localHost = new remoting.Host();
localHost.hostName = hostName;
localHost.hostId = newHostId;
+ localHost.publicKey = publicKey;
localHost.status = 'ONLINE';
that.setHost(localHost);
remoting.hostList.addHost(localHost);
@@ -161,9 +163,10 @@ remoting.HostController.prototype.start = function(hostPin, consent, callback) {
callback(result);
};
- /** @param {string} privateKey
+ /** @param {string} publicKey
+ * @param {string} privateKey
* @param {XMLHttpRequest} xhr */
- function onRegistered(privateKey, xhr) {
+ function onRegistered(publicKey, privateKey, xhr) {
var success = (xhr.status == 200);
if (success) {
@@ -181,7 +184,7 @@ remoting.HostController.prototype.start = function(hostPin, consent, callback) {
});
/** @param {remoting.HostController.AsyncResult} result */
var onStartDaemon = function(result) {
- onStarted(callback, result, hostName);
+ onStarted(callback, result, hostName, publicKey);
};
that.plugin_.startDaemon(hostConfig, consent, onStartDaemon);
} else {
@@ -210,7 +213,7 @@ remoting.HostController.prototype.start = function(hostPin, consent, callback) {
remoting.xhr.post(
'https://www.googleapis.com/chromoting/v1/@me/hosts/',
/** @param {XMLHttpRequest} xhr */
- function (xhr) { onRegistered(privateKey, xhr); },
+ function (xhr) { onRegistered(publicKey, privateKey, xhr); },
JSON.stringify(newHostDetails),
headers);
};