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

Unified Diff: remoting/webapp/host_controller.js

Issue 10152007: Get host id via getDaemonConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't bother checking for the existence of 'host-id'. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/host_controller.js
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index ab76339dc179382e21b6bcae80a26443a96c7947..c907dcff75292f08a946cc4a042e361c7d6d6a56 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -120,9 +120,6 @@ remoting.HostController.prototype.start = function(hostPin, callback) {
};
var newHostId = generateUuid();
- // TODO(jamiewalch): Create an unprivileged API to get the host id from the
- // plugin instead of storing it locally (crbug.com/121518).
- window.localStorage.setItem('me2me-host-id', newHostId);
/** @param {function(remoting.HostController.AsyncResult):void} callback
* @param {remoting.HostController.AsyncResult} result
@@ -224,7 +221,6 @@ remoting.HostController.prototype.stop = function(callback) {
function onStopped(result) {
if (that.localHost && that.localHost.hostId)
remoting.HostList.unregisterHostById(that.localHost.hostId);
- window.localStorage.removeItem('me2me-host-id');
callback(result);
};
this.plugin_.stopDaemon(onStopped);
@@ -304,20 +300,24 @@ remoting.HostController.prototype.setHost = function(host) {
*
* @param {remoting.HostList} hostList The new host list, returned by the
* Chromoting service.
- * @param {function():void} onDone Completion callback. TODO(jamiewalch): For
- * now, this is synchronous and reads the host id from local storage. In
- * the future, it will asynchronously read the host id from the plugin
- * (crbug.com/121518).
+ * @param {function():void} onDone Completion callback.
*/
remoting.HostController.prototype.onHostListRefresh =
function(hostList, onDone) {
- var hostId = window.localStorage.getItem('me2me-host-id');
- if (hostId && typeof(hostId) == 'string') {
- this.setHost(hostList.getHostForId(/** @type{string} */(hostId)));
- } else {
- this.setHost(null);
- }
- onDone();
+ /** @type {remoting.HostController} */
+ var that = this;
+ /** @param {string} configStr */
+ function onConfig(configStr) {
+ var config = /** @type {Object.<string,string>} */ JSON.parse(configStr);
+ if (typeof config['host_id'] == 'string') {
+ var hostId = config['host_id'];
+ that.setHost(hostList.getHostForId(hostId));
+ } else {
+ that.setHost(null);
+ }
+ onDone();
+ };
+ this.plugin_.getDaemonConfig(onConfig);
};
/** @type {remoting.HostController} */
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698