Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @suppress {duplicate} */ | 5 /** @suppress {duplicate} */ |
| 6 var remoting = remoting || {}; | 6 var remoting = remoting || {}; |
| 7 | 7 |
| 8 (function() { | 8 (function() { |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 this.hostId_ = normalizedAccessCode.substring(0, SUPPORT_ID_LENGTH); | 81 this.hostId_ = normalizedAccessCode.substring(0, SUPPORT_ID_LENGTH); |
| 82 this.passCode_ = normalizedAccessCode; | 82 this.passCode_ = normalizedAccessCode; |
| 83 | 83 |
| 84 return Promise.resolve(); | 84 return Promise.resolve(); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * Continues an IT2Me connection once an access token has been obtained. | 88 * Continues an IT2Me connection once an access token has been obtained. |
| 89 * | 89 * |
| 90 * @param {string} token An OAuth2 access token. | 90 * @param {string} token An OAuth2 access token. |
| 91 * @return {Promise<XMLHttpRequest>} | 91 * @return {Promise<remoting.Xhr.Response>} |
| 92 * @private | 92 * @private |
| 93 */ | 93 */ |
| 94 remoting.It2MeConnectFlow.prototype.getHostInfo_ = function(token) { | 94 remoting.It2MeConnectFlow.prototype.getHostInfo_ = function(token) { |
| 95 var that = this; | 95 var that = this; |
| 96 return new Promise(function(resolve) { | 96 new remoting.Xhr({ |
|
Jamie
2015/03/16 18:06:34
Don't you need to return this?
John Williams
2015/03/16 23:15:00
Sure, if I was actually calling this method :-) P
John Williams
2015/03/16 23:16:22
Hey, wait, I removed this when I realized this was
| |
| 97 remoting.xhr.start({ | 97 method: 'GET', |
| 98 method: 'GET', | 98 url: remoting.settings.DIRECTORY_API_BASE_URL + '/support-hosts/' + |
| 99 url: remoting.settings.DIRECTORY_API_BASE_URL + '/support-hosts/' + | 99 encodeURIComponent(that.hostId_), |
| 100 encodeURIComponent(that.hostId_), | 100 oauthToken: token |
| 101 onDone: resolve, | 101 }).start(); |
| 102 oauthToken: token | |
| 103 }); | |
| 104 }); | |
| 105 }; | 102 }; |
| 106 | 103 |
| 107 /** | 104 /** |
| 108 * Continues an IT2Me connection once the host JID has been looked up. | 105 * Continues an IT2Me connection once the host JID has been looked up. |
| 109 * | 106 * |
| 110 * @param {XMLHttpRequest} xhr The server response to the support-hosts query. | 107 * @param {XMLHttpRequest} xhr The server response to the support-hosts query. |
| 111 * @return {!Promise<!remoting.Host>} Rejects on error. | 108 * @return {!Promise<!remoting.Host>} Rejects on error. |
| 112 * @private | 109 * @private |
| 113 */ | 110 */ |
| 114 remoting.It2MeConnectFlow.prototype.onHostInfo_ = function(xhr) { | 111 remoting.It2MeConnectFlow.prototype.onHostInfo_ = function(xhr) { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 141 switch (error) { | 138 switch (error) { |
| 142 case 0: return new remoting.Error(remoting.Error.Tag.NETWORK_FAILURE); | 139 case 0: return new remoting.Error(remoting.Error.Tag.NETWORK_FAILURE); |
| 143 case 404: return new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE); | 140 case 404: return new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE); |
| 144 case 502: // No break | 141 case 502: // No break |
| 145 case 503: return new remoting.Error(remoting.Error.Tag.SERVICE_UNAVAILABLE); | 142 case 503: return new remoting.Error(remoting.Error.Tag.SERVICE_UNAVAILABLE); |
| 146 default: return remoting.Error.unexpected(); | 143 default: return remoting.Error.unexpected(); |
| 147 } | 144 } |
| 148 } | 145 } |
| 149 | 146 |
| 150 })(); | 147 })(); |
| OLD | NEW |