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

Unified Diff: remoting/webapp/crd/js/legacy_host_list_api.js

Issue 1217643002: Added HostListApl implementation to connect to legacy directory and GCD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcd-e2e
Patch Set: yet another rewrite of host merging logic Created 5 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/crd/js/legacy_host_list_api.js
diff --git a/remoting/webapp/crd/js/legacy_host_list_api.js b/remoting/webapp/crd/js/legacy_host_list_api.js
index c2b004ec56edd4d9b8a7faa219753b2f4b4f9d41..1c905c3a943e1da887bfec1f5f9011f0cb6921f9 100644
--- a/remoting/webapp/crd/js/legacy_host_list_api.js
+++ b/remoting/webapp/crd/js/legacy_host_list_api.js
@@ -25,6 +25,22 @@ remoting.LegacyHostListApi = function() {
remoting.LegacyHostListApi.prototype.register = function(
hostName, publicKey, hostClientId) {
var newHostId = base.generateUuid();
+ return remoting.LegacyHostListApi.registerWithHostId(
+ newHostId, hostName, publicKey, hostClientId);
+};
+
+/**
+ * Registers a host with the Chromoting directory using a specified
+ * host ID, which should not be equal to the ID of any existing host.
+ *
+ * @param {string} newHostId The host ID of the new host.
+ * @param {string} hostName The user-visible name of the new host.
+ * @param {string} publicKey The public half of the host's key pair.
+ * @param {?string} hostClientId The OAuth2 client ID of the host.
+ * @return {!Promise<remoting.HostListApi.RegisterResult>}
+ */
+remoting.LegacyHostListApi.registerWithHostId = function(
+ newHostId, hostName, publicKey, hostClientId) {
var newHostDetails = { data: {
hostId: newHostId,
hostName: hostName,
@@ -44,7 +60,9 @@ remoting.LegacyHostListApi.prototype.register = function(
if (response.status == 200) {
var result = /** @type {!Object} */ (response.getJson());
var data = base.getObjectAttr(result, 'data');
- var authCode = base.getStringAttr(data, 'authorizationCode');
+ var authCode = hostClientId ?
+ base.getStringAttr(data, 'authorizationCode') :
+ '';
return {
authCode: authCode,
email: '',

Powered by Google App Engine
This is Rietveld 408576698