| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Class representing the host-list portion of the home screen UI. | 7 * Class representing the host-list portion of the home screen UI. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 remoting.xhr.get( | 135 remoting.xhr.get( |
| 136 'https://www.googleapis.com/chromoting/v1/@me/hosts', | 136 'https://www.googleapis.com/chromoting/v1/@me/hosts', |
| 137 parseHostListResponse, '', headers); | 137 parseHostListResponse, '', headers); |
| 138 }; | 138 }; |
| 139 /** @param {remoting.Error} error */ | 139 /** @param {remoting.Error} error */ |
| 140 var onError = function(error) { | 140 var onError = function(error) { |
| 141 that.hosts_ = []; | 141 that.hosts_ = []; |
| 142 that.lastError_ = error; | 142 that.lastError_ = error; |
| 143 onDone(false); | 143 onDone(false); |
| 144 }; | 144 }; |
| 145 remoting.oauth2.callWithToken(getHosts, onError); | 145 remoting.identity.callWithToken(getHosts, onError); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * Handle the results of the host list request. A success response will | 149 * Handle the results of the host list request. A success response will |
| 150 * include a JSON-encoded list of host descriptions, which we display if we're | 150 * include a JSON-encoded list of host descriptions, which we display if we're |
| 151 * able to successfully parse it. | 151 * able to successfully parse it. |
| 152 * | 152 * |
| 153 * @param {function(boolean):void} onDone The callback passed to |refresh|. | 153 * @param {function(boolean):void} onDone The callback passed to |refresh|. |
| 154 * @param {XMLHttpRequest} xhr The XHR object for the host list request. | 154 * @param {XMLHttpRequest} xhr The XHR object for the host list request. |
| 155 * @return {void} Nothing. | 155 * @return {void} Nothing. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 remoting.xhr.put( | 305 remoting.xhr.put( |
| 306 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + | 306 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + |
| 307 hostTableEntry.host.hostId, | 307 hostTableEntry.host.hostId, |
| 308 function(xhr) {}, | 308 function(xhr) {}, |
| 309 JSON.stringify(newHostDetails), | 309 JSON.stringify(newHostDetails), |
| 310 headers); | 310 headers); |
| 311 } else { | 311 } else { |
| 312 console.error('Could not rename host. Authentication failure.'); | 312 console.error('Could not rename host. Authentication failure.'); |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 remoting.oauth2.callWithToken(renameHost, remoting.showErrorMessage); | 315 remoting.identity.callWithToken(renameHost, remoting.showErrorMessage); |
| 316 }; | 316 }; |
| 317 | 317 |
| 318 /** | 318 /** |
| 319 * Unregister a host. | 319 * Unregister a host. |
| 320 * @param {string} hostId The id of the host to be removed. | 320 * @param {string} hostId The id of the host to be removed. |
| 321 * @return {void} Nothing. | 321 * @return {void} Nothing. |
| 322 */ | 322 */ |
| 323 remoting.HostList.unregisterHostById = function(hostId) { | 323 remoting.HostList.unregisterHostById = function(hostId) { |
| 324 /** @param {string} token The OAuth2 token. */ | 324 /** @param {string} token The OAuth2 token. */ |
| 325 var deleteHost = function(token) { | 325 var deleteHost = function(token) { |
| 326 var headers = { 'Authorization': 'OAuth ' + token }; | 326 var headers = { 'Authorization': 'OAuth ' + token }; |
| 327 remoting.xhr.remove( | 327 remoting.xhr.remove( |
| 328 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + hostId, | 328 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + hostId, |
| 329 function() {}, '', headers); | 329 function() {}, '', headers); |
| 330 } | 330 } |
| 331 remoting.oauth2.callWithToken(deleteHost, remoting.showErrorMessage); | 331 remoting.identity.callWithToken(deleteHost, remoting.showErrorMessage); |
| 332 }; | 332 }; |
| 333 | 333 |
| 334 /** | 334 /** |
| 335 * Set tool-tips for the 'connect' action. We can't just set this on the | 335 * Set tool-tips for the 'connect' action. We can't just set this on the |
| 336 * parent element because the button has no tool-tip, and therefore would | 336 * parent element because the button has no tool-tip, and therefore would |
| 337 * inherit connectStr. | 337 * inherit connectStr. |
| 338 * | 338 * |
| 339 * @return {void} Nothing. | 339 * @return {void} Nothing. |
| 340 * @private | 340 * @private |
| 341 */ | 341 */ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 chrome.storage.local.set(items); | 451 chrome.storage.local.set(items); |
| 452 }; | 452 }; |
| 453 | 453 |
| 454 /** | 454 /** |
| 455 * Key name under which Me2Me hosts are cached. | 455 * Key name under which Me2Me hosts are cached. |
| 456 */ | 456 */ |
| 457 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; | 457 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; |
| 458 | 458 |
| 459 /** @type {remoting.HostList} */ | 459 /** @type {remoting.HostList} */ |
| 460 remoting.hostList = null; | 460 remoting.hostList = null; |
| OLD | NEW |