| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * 'usb-devices' is the polymer element for showing the USB Devices category | 7 * 'usb-devices' is the polymer element for showing the USB Devices category |
| 8 * under Site Settings. | 8 * under Site Settings. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 Polymer({ | 11 Polymer({ |
| 12 is: 'usb-devices', | 12 is: 'usb-devices', |
| 13 | 13 |
| 14 behaviors: [SiteSettingsBehavior], | 14 behaviors: [SiteSettingsBehavior], |
| 15 | 15 |
| 16 properties: { | 16 properties: { |
| 17 /** | 17 /** |
| 18 * A list of all USB devices. | 18 * A list of all USB devices. |
| 19 * @type {Array<UsbDeviceEntry>} | 19 * @private {!Array<!UsbDeviceEntry>} |
| 20 */ | 20 */ |
| 21 devices: Array, | 21 devices_: Array, |
| 22 |
| 23 /** |
| 24 * The targetted object for menu operations. |
| 25 * @private {?Object} |
| 26 */ |
| 27 actionMenuModel_: Object |
| 22 }, | 28 }, |
| 23 | 29 |
| 24 ready: function() { | 30 ready: function() { |
| 25 this.fetchUsbDevices_(); | 31 this.fetchUsbDevices_(); |
| 26 }, | 32 }, |
| 27 | 33 |
| 28 /** | 34 /** |
| 29 * Fetch the list of USB devices and update the list. | 35 * Fetch the list of USB devices and update the list. |
| 30 * @private | 36 * @private |
| 31 */ | 37 */ |
| 32 fetchUsbDevices_: function() { | 38 fetchUsbDevices_: function() { |
| 33 this.browserProxy.fetchUsbDevices().then(function(deviceList) { | 39 this.browserProxy.fetchUsbDevices().then(function(deviceList) { |
| 34 this.devices = deviceList; | 40 this.devices_ = deviceList; |
| 35 }.bind(this)); | 41 }.bind(this)); |
| 36 }, | 42 }, |
| 37 | 43 |
| 38 /** | 44 /** |
| 39 * A handler when an action is selected in the action menu. | 45 * A handler when an action is selected in the action menu. |
| 46 * @private |
| 47 */ |
| 48 onRemoveTap_: function() { |
| 49 this.$$('dialog[is=cr-action-menu]').close(); |
| 50 |
| 51 var item = this.actionMenuModel_; |
| 52 this.browserProxy.removeUsbDevice( |
| 53 item.origin, item.embeddingOrigin, item.object); |
| 54 this.actionMenuModel_ = null; |
| 55 this.fetchUsbDevices_(); |
| 56 }, |
| 57 |
| 58 /** |
| 59 * A handler to show the action menu next to the clicked menu button. |
| 40 * @param {!{model: !{item: UsbDeviceEntry}}} event | 60 * @param {!{model: !{item: UsbDeviceEntry}}} event |
| 41 * @private | 61 * @private |
| 42 */ | 62 */ |
| 43 onActionMenuIronActivate_: function(event) { | 63 showMenu_: function(event) { |
| 44 var item = event.model.item; | 64 this.actionMenuModel_ = event.model.item; |
| 45 this.browserProxy.removeUsbDevice( | 65 /** @type {!CrActionMenuElement} */ ( |
| 46 item.origin, item.embeddingOrigin, item.object); | 66 this.$$('dialog[is=cr-action-menu]')).showAt( |
| 47 this.fetchUsbDevices_(); | 67 /** @type {!Element} */ ( |
| 48 }, | 68 Polymer.dom(/** @type {!Event} */ (event)).localTarget)); |
| 69 } |
| 49 }); | 70 }); |
| OLD | NEW |