Chromium Code Reviews| 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 var item = this.actionMenuModel_; | |
| 50 this.browserProxy.removeUsbDevice( | |
| 51 item.origin, item.embeddingOrigin, item.object); | |
|
dpapad
2016/11/09 21:37:42
How does the dialog get closed after we tap the re
dpapad
2016/11/10 17:35:09
^^ Also can we ensure that the test checks that th
scottchen
2016/11/10 19:17:48
Done.
scottchen
2016/11/10 19:17:48
Done.
| |
| 52 this.actionMenuModel_ = null; | |
| 53 this.fetchUsbDevices_(); | |
| 54 }, | |
| 55 | |
| 56 /** | |
| 57 * A handler to show the action menu next to the clicked menu button. | |
| 40 * @param {!{model: !{item: UsbDeviceEntry}}} event | 58 * @param {!{model: !{item: UsbDeviceEntry}}} event |
| 41 * @private | 59 * @private |
| 42 */ | 60 */ |
| 43 onActionMenuIronActivate_: function(event) { | 61 showMenu_: function(event) { |
| 44 var item = event.model.item; | 62 this.actionMenuModel_ = event.model.item; |
| 45 this.browserProxy.removeUsbDevice( | 63 /** @type {!CrActionMenuElement} */ ( |
| 46 item.origin, item.embeddingOrigin, item.object); | 64 this.$$('dialog[is=cr-action-menu]')).showAt( |
| 47 this.fetchUsbDevices_(); | 65 /** @type {!Element} */ ( |
| 48 }, | 66 Polymer.dom(/** @type {!Event} */ (event)).localTarget)); |
| 67 } | |
| 49 }); | 68 }); |
| OLD | NEW |