Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/browser/resources/settings/site_settings/usb_devices.js

Issue 2891163002: [MD settings] explain when no usb devices are shown in site settings (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * @private {!Array<!UsbDeviceEntry>} 19 * @private {!Array<!UsbDeviceEntry>}
20 */ 20 */
21 devices_: Array, 21 devices_: Array,
22 22
23 /** 23 /**
24 * The targetted object for menu operations. 24 * The targeted object for menu operations.
25 * @private {?Object} 25 * @private {?Object}
26 */ 26 */
27 actionMenuModel_: Object 27 actionMenuModel_: Object
28 }, 28 },
29 29
30 /** @override */ 30 /** @override */
31 ready: function() { 31 ready: function() {
32 this.fetchUsbDevices_(); 32 this.fetchUsbDevices_();
33 }, 33 },
34 34
35 /** 35 /**
36 * Fetch the list of USB devices and update the list. 36 * Fetch the list of USB devices and update the list.
37 * @private 37 * @private
38 */ 38 */
39 fetchUsbDevices_: function() { 39 fetchUsbDevices_: function() {
40 this.browserProxy.fetchUsbDevices().then(function(deviceList) { 40 this.browserProxy.fetchUsbDevices().then(function(deviceList) {
41 this.devices_ = deviceList; 41 this.devices_ = deviceList;
42 }.bind(this)); 42 }.bind(this));
43 }, 43 },
44 44
45 /** 45 /**
46 * @return {boolean}
47 * @private
48 */
49 hasDevices_: function() {
50 return !!(this.devices_ && this.devices_.length);
51 },
52
53 /**
46 * A handler when an action is selected in the action menu. 54 * A handler when an action is selected in the action menu.
47 * @private 55 * @private
48 */ 56 */
49 onRemoveTap_: function() { 57 onRemoveTap_: function() {
50 this.$$('dialog[is=cr-action-menu]').close(); 58 this.$$('dialog[is=cr-action-menu]').close();
51 59
52 var item = this.actionMenuModel_; 60 var item = this.actionMenuModel_;
53 this.browserProxy.removeUsbDevice( 61 this.browserProxy.removeUsbDevice(
54 item.origin, item.embeddingOrigin, item.object); 62 item.origin, item.embeddingOrigin, item.object);
55 this.actionMenuModel_ = null; 63 this.actionMenuModel_ = null;
56 this.fetchUsbDevices_(); 64 this.fetchUsbDevices_();
57 }, 65 },
58 66
59 /** 67 /**
60 * A handler to show the action menu next to the clicked menu button. 68 * A handler to show the action menu next to the clicked menu button.
61 * @param {!{model: !{item: UsbDeviceEntry}}} event 69 * @param {!{model: !{item: UsbDeviceEntry}}} event
62 * @private 70 * @private
63 */ 71 */
64 showMenu_: function(event) { 72 showMenu_: function(event) {
65 this.actionMenuModel_ = event.model.item; 73 this.actionMenuModel_ = event.model.item;
66 /** @type {!CrActionMenuElement} */ ( 74 /** @type {!CrActionMenuElement} */ (
67 this.$$('dialog[is=cr-action-menu]')).showAt( 75 this.$$('dialog[is=cr-action-menu]')).showAt(
68 /** @type {!Element} */ ( 76 /** @type {!Element} */ (
69 Polymer.dom(/** @type {!Event} */ (event)).localTarget)); 77 Polymer.dom(/** @type {!Event} */ (event)).localTarget));
70 } 78 }
71 }); 79 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698