| OLD | NEW |
| 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} */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts', | 35 url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts', |
| 36 urlParams: { | 36 urlParams: { |
| 37 hostClientId: hostClientId | 37 hostClientId: hostClientId |
| 38 }, | 38 }, |
| 39 jsonContent: newHostDetails, | 39 jsonContent: newHostDetails, |
| 40 acceptJson: true, | 40 acceptJson: true, |
| 41 useIdentity: true | 41 useIdentity: true |
| 42 }).start().then(function(response) { | 42 }).start().then(function(response) { |
| 43 if (response.status == 200) { | 43 if (response.status == 200) { |
| 44 var result = response.getJson(); | 44 var result = response.getJson(); |
| 45 var authCode = ''; |
| 45 if (result['data']) { | 46 if (result['data']) { |
| 46 return base.getStringAttr(result['data'], 'authorizationCode', ''); | 47 authCode = base.getStringAttr(result['data'], 'authorizationCode', ''); |
| 47 } else { | |
| 48 return ''; | |
| 49 } | 48 } |
| 49 return { authCode: authCode, email: '' }; |
| 50 } else { | 50 } else { |
| 51 console.log( | 51 console.log( |
| 52 'Failed to register the host. Status: ' + response.status + | 52 'Failed to register the host. Status: ' + response.status + |
| 53 ' response: ' + response.getText()); | 53 ' response: ' + response.getText()); |
| 54 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); | 54 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); |
| 55 } | 55 } |
| 56 }); | 56 }); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 /** @override */ | 59 /** @override */ |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (opt_ignoreErrors && error.hasTag.apply(error, opt_ignoreErrors)) { | 153 if (opt_ignoreErrors && error.hasTag.apply(error, opt_ignoreErrors)) { |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 | 156 |
| 157 throw error; | 157 throw error; |
| 158 }; | 158 }; |
| 159 return result; | 159 return result; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 })(); | 162 })(); |
| OLD | NEW |