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

Side by Side Diff: remoting/webapp/crd/js/host_list_api_impl.js

Issue 1161813006: Updated handling of GCD devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for review; fixed broken host reg. algorithm Created 5 years, 6 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
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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * REST API for host-list management. 7 * REST API for host-list management.
8 */ 8 */
9 9
10 /** @suppress {duplicate} */ 10 /** @suppress {duplicate} */
11 var remoting = remoting || {}; 11 var remoting = remoting || {};
12 12
13 (function() { 13 (function() {
14 14
15 'use strict'; 15 'use strict';
16 16
17 /** 17 /**
18 * @constructor 18 * @constructor
19 * @implements {remoting.HostListApi} 19 * @implements {remoting.HostListApi}
20 */ 20 */
21 remoting.HostListApiImpl = function() { 21 remoting.HostListApiImpl = function() {
22 }; 22 };
23 23
24 /** @override */ 24 /** @override */
25 remoting.HostListApiImpl.prototype.register = function( 25 remoting.HostListApiImpl.prototype.register = function(
26 newHostId, hostName, publicKey, hostClientId) { 26 hostName, publicKey, hostClientId) {
27 var newHostId = base.generateUuid();
27 var newHostDetails = { data: { 28 var newHostDetails = { data: {
28 hostId: newHostId, 29 hostId: newHostId,
29 hostName: hostName, 30 hostName: hostName,
30 publicKey: publicKey 31 publicKey: publicKey
31 } }; 32 } };
32 33
33 return new remoting.Xhr({ 34 return new remoting.Xhr({
34 method: 'POST', 35 method: 'POST',
35 url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts', 36 url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
36 urlParams: { 37 urlParams: {
37 hostClientId: hostClientId 38 hostClientId: hostClientId
38 }, 39 },
39 jsonContent: newHostDetails, 40 jsonContent: newHostDetails,
40 acceptJson: true, 41 acceptJson: true,
41 useIdentity: true 42 useIdentity: true
42 }).start().then(function(response) { 43 }).start().then(function(response) {
43 if (response.status == 200) { 44 if (response.status == 200) {
44 var result = /** @type {!Object} */ (response.getJson()); 45 var result = /** @type {!Object} */ (response.getJson());
45 var data = base.getObjectAttr(result, 'data'); 46 var data = base.getObjectAttr(result, 'data');
46 var authCode = base.getStringAttr(data, 'authorizationCode'); 47 var authCode = base.getStringAttr(data, 'authorizationCode');
47 return { authCode: authCode, email: '', gcdId: '' }; 48 return {
49 authCode: authCode,
50 email: '',
51 hostId: newHostId,
52 isLegacy: true
53 };
48 } else { 54 } else {
49 console.log( 55 console.log(
50 'Failed to register the host. Status: ' + response.status + 56 'Failed to register the host. Status: ' + response.status +
51 ' response: ' + response.getText()); 57 ' response: ' + response.getText());
52 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); 58 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED);
53 } 59 }
54 }); 60 });
55 }; 61 };
56 62
57 /** @override */ 63 /** @override */
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 188 }
183 } else if (xhrResponse.status == 404) { 189 } else if (xhrResponse.status == 404) {
184 throw new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE); 190 throw new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE);
185 } else { 191 } else {
186 throw remoting.Error.fromHttpStatus(xhrResponse.status); 192 throw remoting.Error.fromHttpStatus(xhrResponse.status);
187 } 193 }
188 }); 194 });
189 }; 195 };
190 196
191 })(); 197 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698