| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.DevicesView = class extends WebInspector.VBox { | 7 Devices.DevicesView = class extends UI.VBox { |
| 8 constructor() { | 8 constructor() { |
| 9 super(true); | 9 super(true); |
| 10 this.registerRequiredCSS('devices/devicesView.css'); | 10 this.registerRequiredCSS('devices/devicesView.css'); |
| 11 this.contentElement.classList.add('devices-view'); | 11 this.contentElement.classList.add('devices-view'); |
| 12 | 12 |
| 13 var hbox = this.contentElement.createChild('div', 'hbox devices-container'); | 13 var hbox = this.contentElement.createChild('div', 'hbox devices-container'); |
| 14 var sidebar = hbox.createChild('div', 'devices-sidebar'); | 14 var sidebar = hbox.createChild('div', 'devices-sidebar'); |
| 15 sidebar.createChild('div', 'devices-view-title').createTextChild(WebInspecto
r.UIString('Devices')); | 15 sidebar.createChild('div', 'devices-view-title').createTextChild(Common.UISt
ring('Devices')); |
| 16 this._sidebarList = sidebar.createChild('div', 'devices-sidebar-list'); | 16 this._sidebarList = sidebar.createChild('div', 'devices-sidebar-list'); |
| 17 | 17 |
| 18 this._discoveryView = new WebInspector.DevicesView.DiscoveryView(); | 18 this._discoveryView = new Devices.DevicesView.DiscoveryView(); |
| 19 this._sidebarListSpacer = this._sidebarList.createChild('div', 'devices-side
bar-spacer'); | 19 this._sidebarListSpacer = this._sidebarList.createChild('div', 'devices-side
bar-spacer'); |
| 20 this._discoveryListItem = this._sidebarList.createChild('div', 'devices-side
bar-item'); | 20 this._discoveryListItem = this._sidebarList.createChild('div', 'devices-side
bar-item'); |
| 21 this._discoveryListItem.textContent = WebInspector.UIString('Settings'); | 21 this._discoveryListItem.textContent = Common.UIString('Settings'); |
| 22 this._discoveryListItem.addEventListener( | 22 this._discoveryListItem.addEventListener( |
| 23 'click', this._selectSidebarListItem.bind(this, this._discoveryListItem,
this._discoveryView)); | 23 'click', this._selectSidebarListItem.bind(this, this._discoveryListItem,
this._discoveryView)); |
| 24 | 24 |
| 25 /** @type {!Map<string, !WebInspector.DevicesView.DeviceView>} */ | 25 /** @type {!Map<string, !Devices.DevicesView.DeviceView>} */ |
| 26 this._viewById = new Map(); | 26 this._viewById = new Map(); |
| 27 /** @type {!Array<!Adb.Device>} */ | 27 /** @type {!Array<!Adb.Device>} */ |
| 28 this._devices = []; | 28 this._devices = []; |
| 29 /** @type {!Map<string, !Element>} */ | 29 /** @type {!Map<string, !Element>} */ |
| 30 this._listItemById = new Map(); | 30 this._listItemById = new Map(); |
| 31 | 31 |
| 32 this._viewContainer = hbox.createChild('div', 'flex-auto vbox'); | 32 this._viewContainer = hbox.createChild('div', 'flex-auto vbox'); |
| 33 | 33 |
| 34 var discoveryFooter = this.contentElement.createChild('div', 'devices-footer
'); | 34 var discoveryFooter = this.contentElement.createChild('div', 'devices-footer
'); |
| 35 this._deviceCountSpan = discoveryFooter.createChild('span'); | 35 this._deviceCountSpan = discoveryFooter.createChild('span'); |
| 36 discoveryFooter.createChild('span').textContent = WebInspector.UIString(' Re
ad '); | 36 discoveryFooter.createChild('span').textContent = Common.UIString(' Read '); |
| 37 discoveryFooter.appendChild(WebInspector.linkifyURLAsNode( | 37 discoveryFooter.appendChild(UI.linkifyURLAsNode( |
| 38 'https://developers.google.com/chrome-developer-tools/docs/remote-debugg
ing', | 38 'https://developers.google.com/chrome-developer-tools/docs/remote-debugg
ing', |
| 39 WebInspector.UIString('remote debugging documentation'), undefined, true
)); | 39 Common.UIString('remote debugging documentation'), undefined, true)); |
| 40 discoveryFooter.createChild('span').textContent = WebInspector.UIString(' fo
r more information.'); | 40 discoveryFooter.createChild('span').textContent = Common.UIString(' for more
information.'); |
| 41 this._updateFooter(); | 41 this._updateFooter(); |
| 42 this._selectSidebarListItem(this._discoveryListItem, this._discoveryView); | 42 this._selectSidebarListItem(this._discoveryListItem, this._discoveryView); |
| 43 | 43 |
| 44 InspectorFrontendHost.events.addEventListener( | 44 InspectorFrontendHost.events.addEventListener( |
| 45 InspectorFrontendHostAPI.Events.DevicesUpdated, this._devicesUpdated, th
is); | 45 InspectorFrontendHostAPI.Events.DevicesUpdated, this._devicesUpdated, th
is); |
| 46 InspectorFrontendHost.events.addEventListener( | 46 InspectorFrontendHost.events.addEventListener( |
| 47 InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._dev
icesDiscoveryConfigChanged, this); | 47 InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._dev
icesDiscoveryConfigChanged, this); |
| 48 InspectorFrontendHost.events.addEventListener( | 48 InspectorFrontendHost.events.addEventListener( |
| 49 InspectorFrontendHostAPI.Events.DevicesPortForwardingStatusChanged, this
._devicesPortForwardingStatusChanged, | 49 InspectorFrontendHostAPI.Events.DevicesPortForwardingStatusChanged, this
._devicesPortForwardingStatusChanged, |
| 50 this); | 50 this); |
| 51 | 51 |
| 52 this.contentElement.tabIndex = 0; | 52 this.contentElement.tabIndex = 0; |
| 53 this.setDefaultFocusedElement(this.contentElement); | 53 this.setDefaultFocusedElement(this.contentElement); |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * @return {!WebInspector.DevicesView} | 57 * @return {!Devices.DevicesView} |
| 58 */ | 58 */ |
| 59 static _instance() { | 59 static _instance() { |
| 60 if (!WebInspector.DevicesView._instanceObject) | 60 if (!Devices.DevicesView._instanceObject) |
| 61 WebInspector.DevicesView._instanceObject = new WebInspector.DevicesView(); | 61 Devices.DevicesView._instanceObject = new Devices.DevicesView(); |
| 62 return WebInspector.DevicesView._instanceObject; | 62 return Devices.DevicesView._instanceObject; |
| 63 } | 63 } |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * @param {!Element} listItem | 66 * @param {!Element} listItem |
| 67 * @param {!WebInspector.Widget} view | 67 * @param {!UI.Widget} view |
| 68 */ | 68 */ |
| 69 _selectSidebarListItem(listItem, view) { | 69 _selectSidebarListItem(listItem, view) { |
| 70 if (this._selectedListItem === listItem) | 70 if (this._selectedListItem === listItem) |
| 71 return; | 71 return; |
| 72 | 72 |
| 73 if (this._selectedListItem) { | 73 if (this._selectedListItem) { |
| 74 this._selectedListItem.classList.remove('selected'); | 74 this._selectedListItem.classList.remove('selected'); |
| 75 this._visibleView.detach(); | 75 this._visibleView.detach(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 this._visibleView = view; | 78 this._visibleView = view; |
| 79 this._selectedListItem = listItem; | 79 this._selectedListItem = listItem; |
| 80 this._visibleView.show(this._viewContainer); | 80 this._visibleView.show(this._viewContainer); |
| 81 this._selectedListItem.classList.add('selected'); | 81 this._selectedListItem.classList.add('selected'); |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * @param {!WebInspector.Event} event | 85 * @param {!Common.Event} event |
| 86 */ | 86 */ |
| 87 _devicesUpdated(event) { | 87 _devicesUpdated(event) { |
| 88 this._devices = | 88 this._devices = |
| 89 /** @type {!Array.<!Adb.Device>} */ (event.data).slice().filter(d => d.a
dbSerial.toUpperCase() !== 'WEBRTC'); | 89 /** @type {!Array.<!Adb.Device>} */ (event.data).slice().filter(d => d.a
dbSerial.toUpperCase() !== 'WEBRTC'); |
| 90 for (var device of this._devices) { | 90 for (var device of this._devices) { |
| 91 if (!device.adbConnected) | 91 if (!device.adbConnected) |
| 92 device.adbModel = WebInspector.UIString('Unknown'); | 92 device.adbModel = Common.UIString('Unknown'); |
| 93 } | 93 } |
| 94 | 94 |
| 95 var ids = new Set(); | 95 var ids = new Set(); |
| 96 for (var device of this._devices) | 96 for (var device of this._devices) |
| 97 ids.add(device.id); | 97 ids.add(device.id); |
| 98 | 98 |
| 99 var selectedRemoved = false; | 99 var selectedRemoved = false; |
| 100 for (var deviceId of this._viewById.keys()) { | 100 for (var deviceId of this._viewById.keys()) { |
| 101 if (!ids.has(deviceId)) { | 101 if (!ids.has(deviceId)) { |
| 102 var listItem = /** @type {!Element} */ (this._listItemById.get(deviceId)
); | 102 var listItem = /** @type {!Element} */ (this._listItemById.get(deviceId)
); |
| 103 this._listItemById.remove(deviceId); | 103 this._listItemById.remove(deviceId); |
| 104 this._viewById.remove(deviceId); | 104 this._viewById.remove(deviceId); |
| 105 listItem.remove(); | 105 listItem.remove(); |
| 106 if (listItem === this._selectedListItem) | 106 if (listItem === this._selectedListItem) |
| 107 selectedRemoved = true; | 107 selectedRemoved = true; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 for (var device of this._devices) { | 111 for (var device of this._devices) { |
| 112 var view = this._viewById.get(device.id); | 112 var view = this._viewById.get(device.id); |
| 113 var listItem = this._listItemById.get(device.id); | 113 var listItem = this._listItemById.get(device.id); |
| 114 | 114 |
| 115 if (!view) { | 115 if (!view) { |
| 116 view = new WebInspector.DevicesView.DeviceView(); | 116 view = new Devices.DevicesView.DeviceView(); |
| 117 this._viewById.set(device.id, view); | 117 this._viewById.set(device.id, view); |
| 118 listItem = this._createSidebarListItem(view); | 118 listItem = this._createSidebarListItem(view); |
| 119 this._listItemById.set(device.id, listItem); | 119 this._listItemById.set(device.id, listItem); |
| 120 this._sidebarList.insertBefore(listItem, this._sidebarListSpacer); | 120 this._sidebarList.insertBefore(listItem, this._sidebarListSpacer); |
| 121 } | 121 } |
| 122 | 122 |
| 123 listItem._title.textContent = device.adbModel; | 123 listItem._title.textContent = device.adbModel; |
| 124 listItem._status.textContent = | 124 listItem._status.textContent = |
| 125 device.adbConnected ? WebInspector.UIString('Connected') : WebInspecto
r.UIString('Pending Authorization'); | 125 device.adbConnected ? Common.UIString('Connected') : Common.UIString('
Pending Authorization'); |
| 126 listItem.classList.toggle('device-connected', device.adbConnected); | 126 listItem.classList.toggle('device-connected', device.adbConnected); |
| 127 view.update(device); | 127 view.update(device); |
| 128 } | 128 } |
| 129 | 129 |
| 130 if (selectedRemoved) | 130 if (selectedRemoved) |
| 131 this._selectSidebarListItem(this._discoveryListItem, this._discoveryView); | 131 this._selectSidebarListItem(this._discoveryListItem, this._discoveryView); |
| 132 | 132 |
| 133 this._updateFooter(); | 133 this._updateFooter(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 /** | 136 /** |
| 137 * @param {!WebInspector.Widget} view | 137 * @param {!UI.Widget} view |
| 138 * @return {!Element} | 138 * @return {!Element} |
| 139 */ | 139 */ |
| 140 _createSidebarListItem(view) { | 140 _createSidebarListItem(view) { |
| 141 var listItem = createElementWithClass('div', 'devices-sidebar-item'); | 141 var listItem = createElementWithClass('div', 'devices-sidebar-item'); |
| 142 listItem.addEventListener('click', this._selectSidebarListItem.bind(this, li
stItem, view)); | 142 listItem.addEventListener('click', this._selectSidebarListItem.bind(this, li
stItem, view)); |
| 143 listItem._title = listItem.createChild('div', 'devices-sidebar-item-title'); | 143 listItem._title = listItem.createChild('div', 'devices-sidebar-item-title'); |
| 144 listItem._status = listItem.createChild('div', 'devices-sidebar-item-status'
); | 144 listItem._status = listItem.createChild('div', 'devices-sidebar-item-status'
); |
| 145 return listItem; | 145 return listItem; |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * @param {!WebInspector.Event} event | 149 * @param {!Common.Event} event |
| 150 */ | 150 */ |
| 151 _devicesDiscoveryConfigChanged(event) { | 151 _devicesDiscoveryConfigChanged(event) { |
| 152 var discoverUsbDevices = /** @type {boolean} */ (event.data['discoverUsbDevi
ces']); | 152 var discoverUsbDevices = /** @type {boolean} */ (event.data['discoverUsbDevi
ces']); |
| 153 var portForwardingEnabled = /** @type {boolean} */ (event.data['portForwardi
ngEnabled']); | 153 var portForwardingEnabled = /** @type {boolean} */ (event.data['portForwardi
ngEnabled']); |
| 154 var portForwardingConfig = /** @type {!Adb.PortForwardingConfig} */ (event.d
ata['portForwardingConfig']); | 154 var portForwardingConfig = /** @type {!Adb.PortForwardingConfig} */ (event.d
ata['portForwardingConfig']); |
| 155 this._discoveryView.discoveryConfigChanged(discoverUsbDevices, portForwardin
gEnabled, portForwardingConfig); | 155 this._discoveryView.discoveryConfigChanged(discoverUsbDevices, portForwardin
gEnabled, portForwardingConfig); |
| 156 } | 156 } |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * @param {!WebInspector.Event} event | 159 * @param {!Common.Event} event |
| 160 */ | 160 */ |
| 161 _devicesPortForwardingStatusChanged(event) { | 161 _devicesPortForwardingStatusChanged(event) { |
| 162 var status = /** @type {!Adb.PortForwardingStatus} */ (event.data); | 162 var status = /** @type {!Adb.PortForwardingStatus} */ (event.data); |
| 163 for (var deviceId in status) { | 163 for (var deviceId in status) { |
| 164 var view = this._viewById.get(deviceId); | 164 var view = this._viewById.get(deviceId); |
| 165 if (view) | 165 if (view) |
| 166 view.portForwardingStatusChanged(status[deviceId]); | 166 view.portForwardingStatusChanged(status[deviceId]); |
| 167 } | 167 } |
| 168 for (var deviceId of this._viewById.keys()) { | 168 for (var deviceId of this._viewById.keys()) { |
| 169 var view = this._viewById.get(deviceId); | 169 var view = this._viewById.get(deviceId); |
| 170 if (view && !(deviceId in status)) | 170 if (view && !(deviceId in status)) |
| 171 view.portForwardingStatusChanged({ports: {}, browserId: ''}); | 171 view.portForwardingStatusChanged({ports: {}, browserId: ''}); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 _updateFooter() { | 175 _updateFooter() { |
| 176 this._deviceCountSpan.textContent = !this._devices.length ? | 176 this._deviceCountSpan.textContent = !this._devices.length ? |
| 177 WebInspector.UIString('No devices detected.') : | 177 Common.UIString('No devices detected.') : |
| 178 this._devices.length === 1 ? WebInspector.UIString('1 device detected.')
: | 178 this._devices.length === 1 ? Common.UIString('1 device detected.') : |
| 179 WebInspector.UIString('%d devices detected.
', this._devices.length); | 179 Common.UIString('%d devices detected.', thi
s._devices.length); |
| 180 } | 180 } |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * @override | 183 * @override |
| 184 */ | 184 */ |
| 185 wasShown() { | 185 wasShown() { |
| 186 super.wasShown(); | 186 super.wasShown(); |
| 187 InspectorFrontendHost.setDevicesUpdatesEnabled(true); | 187 InspectorFrontendHost.setDevicesUpdatesEnabled(true); |
| 188 } | 188 } |
| 189 | 189 |
| 190 /** | 190 /** |
| 191 * @override | 191 * @override |
| 192 */ | 192 */ |
| 193 willHide() { | 193 willHide() { |
| 194 super.wasShown(); | 194 super.wasShown(); |
| 195 InspectorFrontendHost.setDevicesUpdatesEnabled(false); | 195 InspectorFrontendHost.setDevicesUpdatesEnabled(false); |
| 196 } | 196 } |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * @implements {WebInspector.ListWidget.Delegate} | 201 * @implements {UI.ListWidget.Delegate} |
| 202 * @unrestricted | 202 * @unrestricted |
| 203 */ | 203 */ |
| 204 WebInspector.DevicesView.DiscoveryView = class extends WebInspector.VBox { | 204 Devices.DevicesView.DiscoveryView = class extends UI.VBox { |
| 205 constructor() { | 205 constructor() { |
| 206 super(); | 206 super(); |
| 207 this.setMinimumSize(100, 100); | 207 this.setMinimumSize(100, 100); |
| 208 this.element.classList.add('discovery-view'); | 208 this.element.classList.add('discovery-view'); |
| 209 | 209 |
| 210 this.contentElement.createChild('div', 'hbox device-text-row').createChild('
div', 'view-title').textContent = | 210 this.contentElement.createChild('div', 'hbox device-text-row').createChild('
div', 'view-title').textContent = |
| 211 WebInspector.UIString('Settings'); | 211 Common.UIString('Settings'); |
| 212 | 212 |
| 213 var discoverUsbDevicesCheckbox = createCheckboxLabel(WebInspector.UIString('
Discover USB devices')); | 213 var discoverUsbDevicesCheckbox = createCheckboxLabel(Common.UIString('Discov
er USB devices')); |
| 214 discoverUsbDevicesCheckbox.classList.add('usb-checkbox'); | 214 discoverUsbDevicesCheckbox.classList.add('usb-checkbox'); |
| 215 this.element.appendChild(discoverUsbDevicesCheckbox); | 215 this.element.appendChild(discoverUsbDevicesCheckbox); |
| 216 this._discoverUsbDevicesCheckbox = discoverUsbDevicesCheckbox.checkboxElemen
t; | 216 this._discoverUsbDevicesCheckbox = discoverUsbDevicesCheckbox.checkboxElemen
t; |
| 217 this._discoverUsbDevicesCheckbox.addEventListener('click', this._updateDisco
veryConfig.bind(this), false); | 217 this._discoverUsbDevicesCheckbox.addEventListener('click', this._updateDisco
veryConfig.bind(this), false); |
| 218 | 218 |
| 219 var help = this.element.createChild('div', 'discovery-help'); | 219 var help = this.element.createChild('div', 'discovery-help'); |
| 220 help.createChild('span').textContent = WebInspector.UIString('Need help? Rea
d Chrome '); | 220 help.createChild('span').textContent = Common.UIString('Need help? Read Chro
me '); |
| 221 help.appendChild(WebInspector.linkifyURLAsNode( | 221 help.appendChild(UI.linkifyURLAsNode( |
| 222 'https://developers.google.com/chrome-developer-tools/docs/remote-debugg
ing', | 222 'https://developers.google.com/chrome-developer-tools/docs/remote-debugg
ing', |
| 223 WebInspector.UIString('remote debugging documentation.'), undefined, tru
e)); | 223 Common.UIString('remote debugging documentation.'), undefined, true)); |
| 224 | 224 |
| 225 var portForwardingHeader = this.element.createChild('div', 'port-forwarding-
header'); | 225 var portForwardingHeader = this.element.createChild('div', 'port-forwarding-
header'); |
| 226 var portForwardingEnabledCheckbox = createCheckboxLabel(WebInspector.UIStrin
g('Port forwarding')); | 226 var portForwardingEnabledCheckbox = createCheckboxLabel(Common.UIString('Por
t forwarding')); |
| 227 portForwardingEnabledCheckbox.classList.add('port-forwarding-checkbox'); | 227 portForwardingEnabledCheckbox.classList.add('port-forwarding-checkbox'); |
| 228 portForwardingHeader.appendChild(portForwardingEnabledCheckbox); | 228 portForwardingHeader.appendChild(portForwardingEnabledCheckbox); |
| 229 this._portForwardingEnabledCheckbox = portForwardingEnabledCheckbox.checkbox
Element; | 229 this._portForwardingEnabledCheckbox = portForwardingEnabledCheckbox.checkbox
Element; |
| 230 this._portForwardingEnabledCheckbox.addEventListener('click', this._updateDi
scoveryConfig.bind(this), false); | 230 this._portForwardingEnabledCheckbox.addEventListener('click', this._updateDi
scoveryConfig.bind(this), false); |
| 231 | 231 |
| 232 var portForwardingFooter = this.element.createChild('div', 'port-forwarding-
footer'); | 232 var portForwardingFooter = this.element.createChild('div', 'port-forwarding-
footer'); |
| 233 portForwardingFooter.createChild('span').textContent = WebInspector.UIString
( | 233 portForwardingFooter.createChild('span').textContent = Common.UIString( |
| 234 'Define the listening port on your device that maps to a port accessible
from your development machine. '); | 234 'Define the listening port on your device that maps to a port accessible
from your development machine. '); |
| 235 portForwardingFooter.appendChild(WebInspector.linkifyURLAsNode( | 235 portForwardingFooter.appendChild(UI.linkifyURLAsNode( |
| 236 'https://developer.chrome.com/devtools/docs/remote-debugging#port-forwar
ding', | 236 'https://developer.chrome.com/devtools/docs/remote-debugging#port-forwar
ding', |
| 237 WebInspector.UIString('Learn more'), undefined, true)); | 237 Common.UIString('Learn more'), undefined, true)); |
| 238 | 238 |
| 239 this._list = new WebInspector.ListWidget(this); | 239 this._list = new UI.ListWidget(this); |
| 240 this._list.registerRequiredCSS('devices/devicesView.css'); | 240 this._list.registerRequiredCSS('devices/devicesView.css'); |
| 241 this._list.element.classList.add('port-forwarding-list'); | 241 this._list.element.classList.add('port-forwarding-list'); |
| 242 var placeholder = createElementWithClass('div', 'port-forwarding-list-empty'
); | 242 var placeholder = createElementWithClass('div', 'port-forwarding-list-empty'
); |
| 243 placeholder.textContent = WebInspector.UIString('No rules'); | 243 placeholder.textContent = Common.UIString('No rules'); |
| 244 this._list.setEmptyPlaceholder(placeholder); | 244 this._list.setEmptyPlaceholder(placeholder); |
| 245 this._list.show(this.element); | 245 this._list.show(this.element); |
| 246 | 246 |
| 247 this.element.appendChild( | 247 this.element.appendChild( |
| 248 createTextButton(WebInspector.UIString('Add rule'), this._addRuleButtonC
licked.bind(this), 'add-rule-button')); | 248 createTextButton(Common.UIString('Add rule'), this._addRuleButtonClicked
.bind(this), 'add-rule-button')); |
| 249 | 249 |
| 250 /** @type {!Array<!Adb.PortForwardingRule>} */ | 250 /** @type {!Array<!Adb.PortForwardingRule>} */ |
| 251 this._portForwardingConfig = []; | 251 this._portForwardingConfig = []; |
| 252 } | 252 } |
| 253 | 253 |
| 254 _addRuleButtonClicked() { | 254 _addRuleButtonClicked() { |
| 255 this._list.addNewItem(this._portForwardingConfig.length, {port: '', address:
''}); | 255 this._list.addNewItem(this._portForwardingConfig.length, {port: '', address:
''}); |
| 256 } | 256 } |
| 257 | 257 |
| 258 /** | 258 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 276 /** | 276 /** |
| 277 * @override | 277 * @override |
| 278 * @param {*} item | 278 * @param {*} item |
| 279 * @param {boolean} editable | 279 * @param {boolean} editable |
| 280 * @return {!Element} | 280 * @return {!Element} |
| 281 */ | 281 */ |
| 282 renderItem(item, editable) { | 282 renderItem(item, editable) { |
| 283 var rule = /** @type {!Adb.PortForwardingRule} */ (item); | 283 var rule = /** @type {!Adb.PortForwardingRule} */ (item); |
| 284 var element = createElementWithClass('div', 'port-forwarding-list-item'); | 284 var element = createElementWithClass('div', 'port-forwarding-list-item'); |
| 285 var port = element.createChild('div', 'port-forwarding-value port-forwarding
-port'); | 285 var port = element.createChild('div', 'port-forwarding-value port-forwarding
-port'); |
| 286 port.createChild('span', 'port-localhost').textContent = WebInspector.UIStri
ng('localhost:'); | 286 port.createChild('span', 'port-localhost').textContent = Common.UIString('lo
calhost:'); |
| 287 port.createTextChild(rule.port); | 287 port.createTextChild(rule.port); |
| 288 element.createChild('div', 'port-forwarding-separator'); | 288 element.createChild('div', 'port-forwarding-separator'); |
| 289 element.createChild('div', 'port-forwarding-value').textContent = rule.addre
ss; | 289 element.createChild('div', 'port-forwarding-value').textContent = rule.addre
ss; |
| 290 return element; | 290 return element; |
| 291 } | 291 } |
| 292 | 292 |
| 293 /** | 293 /** |
| 294 * @override | 294 * @override |
| 295 * @param {*} item | 295 * @param {*} item |
| 296 * @param {number} index | 296 * @param {number} index |
| 297 */ | 297 */ |
| 298 removeItemRequested(item, index) { | 298 removeItemRequested(item, index) { |
| 299 this._portForwardingConfig.splice(index, 1); | 299 this._portForwardingConfig.splice(index, 1); |
| 300 this._list.removeItem(index); | 300 this._list.removeItem(index); |
| 301 this._updateDiscoveryConfig(); | 301 this._updateDiscoveryConfig(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * @override | 305 * @override |
| 306 * @param {*} item | 306 * @param {*} item |
| 307 * @param {!WebInspector.ListWidget.Editor} editor | 307 * @param {!UI.ListWidget.Editor} editor |
| 308 * @param {boolean} isNew | 308 * @param {boolean} isNew |
| 309 */ | 309 */ |
| 310 commitEdit(item, editor, isNew) { | 310 commitEdit(item, editor, isNew) { |
| 311 var rule = /** @type {!Adb.PortForwardingRule} */ (item); | 311 var rule = /** @type {!Adb.PortForwardingRule} */ (item); |
| 312 rule.port = editor.control('port').value.trim(); | 312 rule.port = editor.control('port').value.trim(); |
| 313 rule.address = editor.control('address').value.trim(); | 313 rule.address = editor.control('address').value.trim(); |
| 314 if (isNew) | 314 if (isNew) |
| 315 this._portForwardingConfig.push(rule); | 315 this._portForwardingConfig.push(rule); |
| 316 this._updateDiscoveryConfig(); | 316 this._updateDiscoveryConfig(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 /** | 319 /** |
| 320 * @override | 320 * @override |
| 321 * @param {*} item | 321 * @param {*} item |
| 322 * @return {!WebInspector.ListWidget.Editor} | 322 * @return {!UI.ListWidget.Editor} |
| 323 */ | 323 */ |
| 324 beginEdit(item) { | 324 beginEdit(item) { |
| 325 var rule = /** @type {!Adb.PortForwardingRule} */ (item); | 325 var rule = /** @type {!Adb.PortForwardingRule} */ (item); |
| 326 var editor = this._createEditor(); | 326 var editor = this._createEditor(); |
| 327 editor.control('port').value = rule.port; | 327 editor.control('port').value = rule.port; |
| 328 editor.control('address').value = rule.address; | 328 editor.control('address').value = rule.address; |
| 329 return editor; | 329 return editor; |
| 330 } | 330 } |
| 331 | 331 |
| 332 /** | 332 /** |
| 333 * @return {!WebInspector.ListWidget.Editor} | 333 * @return {!UI.ListWidget.Editor} |
| 334 */ | 334 */ |
| 335 _createEditor() { | 335 _createEditor() { |
| 336 if (this._editor) | 336 if (this._editor) |
| 337 return this._editor; | 337 return this._editor; |
| 338 | 338 |
| 339 var editor = new WebInspector.ListWidget.Editor(); | 339 var editor = new UI.ListWidget.Editor(); |
| 340 this._editor = editor; | 340 this._editor = editor; |
| 341 var content = editor.contentElement(); | 341 var content = editor.contentElement(); |
| 342 var fields = content.createChild('div', 'port-forwarding-edit-row'); | 342 var fields = content.createChild('div', 'port-forwarding-edit-row'); |
| 343 fields.createChild('div', 'port-forwarding-value port-forwarding-port') | 343 fields.createChild('div', 'port-forwarding-value port-forwarding-port') |
| 344 .appendChild(editor.createInput('port', 'text', 'Device port (3333)', po
rtValidator.bind(this))); | 344 .appendChild(editor.createInput('port', 'text', 'Device port (3333)', po
rtValidator.bind(this))); |
| 345 fields.createChild('div', 'port-forwarding-separator port-forwarding-separat
or-invisible'); | 345 fields.createChild('div', 'port-forwarding-separator port-forwarding-separat
or-invisible'); |
| 346 fields.createChild('div', 'port-forwarding-value') | 346 fields.createChild('div', 'port-forwarding-value') |
| 347 .appendChild(editor.createInput('address', 'text', 'Local address (dev.e
xample.corp:3333)', addressValidator)); | 347 .appendChild(editor.createInput('address', 'text', 'Local address (dev.e
xample.corp:3333)', addressValidator)); |
| 348 return editor; | 348 return editor; |
| 349 | 349 |
| 350 /** | 350 /** |
| 351 * @param {*} item | 351 * @param {*} item |
| 352 * @param {number} index | 352 * @param {number} index |
| 353 * @param {!HTMLInputElement|!HTMLSelectElement} input | 353 * @param {!HTMLInputElement|!HTMLSelectElement} input |
| 354 * @this {WebInspector.DevicesView.DiscoveryView} | 354 * @this {Devices.DevicesView.DiscoveryView} |
| 355 * @return {boolean} | 355 * @return {boolean} |
| 356 */ | 356 */ |
| 357 function portValidator(item, index, input) { | 357 function portValidator(item, index, input) { |
| 358 var value = input.value.trim(); | 358 var value = input.value.trim(); |
| 359 var match = value.match(/^(\d+)$/); | 359 var match = value.match(/^(\d+)$/); |
| 360 if (!match) | 360 if (!match) |
| 361 return false; | 361 return false; |
| 362 var port = parseInt(match[1], 10); | 362 var port = parseInt(match[1], 10); |
| 363 if (port < 1024 || port > 65535) | 363 if (port < 1024 || port > 65535) |
| 364 return false; | 364 return false; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 389 for (var rule of this._portForwardingConfig) | 389 for (var rule of this._portForwardingConfig) |
| 390 configMap[rule.port] = rule.address; | 390 configMap[rule.port] = rule.address; |
| 391 InspectorFrontendHost.setDevicesDiscoveryConfig( | 391 InspectorFrontendHost.setDevicesDiscoveryConfig( |
| 392 this._discoverUsbDevicesCheckbox.checked, this._portForwardingEnabledChe
ckbox.checked, configMap); | 392 this._discoverUsbDevicesCheckbox.checked, this._portForwardingEnabledChe
ckbox.checked, configMap); |
| 393 } | 393 } |
| 394 }; | 394 }; |
| 395 | 395 |
| 396 /** | 396 /** |
| 397 * @unrestricted | 397 * @unrestricted |
| 398 */ | 398 */ |
| 399 WebInspector.DevicesView.DeviceView = class extends WebInspector.VBox { | 399 Devices.DevicesView.DeviceView = class extends UI.VBox { |
| 400 constructor() { | 400 constructor() { |
| 401 super(); | 401 super(); |
| 402 this.setMinimumSize(100, 100); | 402 this.setMinimumSize(100, 100); |
| 403 this.contentElement.classList.add('device-view'); | 403 this.contentElement.classList.add('device-view'); |
| 404 | 404 |
| 405 var topRow = this.contentElement.createChild('div', 'hbox device-text-row'); | 405 var topRow = this.contentElement.createChild('div', 'hbox device-text-row'); |
| 406 this._deviceTitle = topRow.createChild('div', 'view-title'); | 406 this._deviceTitle = topRow.createChild('div', 'view-title'); |
| 407 this._deviceSerial = topRow.createChild('div', 'device-serial'); | 407 this._deviceSerial = topRow.createChild('div', 'device-serial'); |
| 408 this._portStatus = this.contentElement.createChild('div', 'device-port-statu
s hidden'); | 408 this._portStatus = this.contentElement.createChild('div', 'device-port-statu
s hidden'); |
| 409 | 409 |
| 410 this._deviceOffline = this.contentElement.createChild('div'); | 410 this._deviceOffline = this.contentElement.createChild('div'); |
| 411 this._deviceOffline.textContent = | 411 this._deviceOffline.textContent = |
| 412 WebInspector.UIString('Pending authentication: please accept debugging s
ession on the device.'); | 412 Common.UIString('Pending authentication: please accept debugging session
on the device.'); |
| 413 | 413 |
| 414 this._noBrowsers = this.contentElement.createChild('div'); | 414 this._noBrowsers = this.contentElement.createChild('div'); |
| 415 this._noBrowsers.textContent = WebInspector.UIString('No browsers detected.'
); | 415 this._noBrowsers.textContent = Common.UIString('No browsers detected.'); |
| 416 | 416 |
| 417 this._browsers = this.contentElement.createChild('div', 'device-browser-list
vbox'); | 417 this._browsers = this.contentElement.createChild('div', 'device-browser-list
vbox'); |
| 418 | 418 |
| 419 /** @type {!Map<string, !WebInspector.DevicesView.BrowserSection>} */ | 419 /** @type {!Map<string, !Devices.DevicesView.BrowserSection>} */ |
| 420 this._browserById = new Map(); | 420 this._browserById = new Map(); |
| 421 | 421 |
| 422 this._device = null; | 422 this._device = null; |
| 423 } | 423 } |
| 424 | 424 |
| 425 /** | 425 /** |
| 426 * @param {!Adb.Device} device | 426 * @param {!Adb.Device} device |
| 427 */ | 427 */ |
| 428 update(device) { | 428 update(device) { |
| 429 if (!this._device || this._device.adbModel !== device.adbModel) | 429 if (!this._device || this._device.adbModel !== device.adbModel) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 454 this._browserById.set(browser.id, section); | 454 this._browserById.set(browser.id, section); |
| 455 this._browsers.appendChild(section.element); | 455 this._browsers.appendChild(section.element); |
| 456 } | 456 } |
| 457 this._updateBrowserSection(section, browser); | 457 this._updateBrowserSection(section, browser); |
| 458 } | 458 } |
| 459 | 459 |
| 460 this._device = device; | 460 this._device = device; |
| 461 } | 461 } |
| 462 | 462 |
| 463 /** | 463 /** |
| 464 * @return {!WebInspector.DevicesView.BrowserSection} | 464 * @return {!Devices.DevicesView.BrowserSection} |
| 465 */ | 465 */ |
| 466 _createBrowserSection() { | 466 _createBrowserSection() { |
| 467 var element = createElementWithClass('div', 'vbox flex-none'); | 467 var element = createElementWithClass('div', 'vbox flex-none'); |
| 468 var topRow = element.createChild('div', ''); | 468 var topRow = element.createChild('div', ''); |
| 469 var title = topRow.createChild('div', 'device-browser-title'); | 469 var title = topRow.createChild('div', 'device-browser-title'); |
| 470 | 470 |
| 471 var newTabRow = element.createChild('div', 'device-browser-new-tab'); | 471 var newTabRow = element.createChild('div', 'device-browser-new-tab'); |
| 472 newTabRow.createChild('div', '').textContent = WebInspector.UIString('New ta
b:'); | 472 newTabRow.createChild('div', '').textContent = Common.UIString('New tab:'); |
| 473 var newTabInput = newTabRow.createChild('input', ''); | 473 var newTabInput = newTabRow.createChild('input', ''); |
| 474 newTabInput.type = 'text'; | 474 newTabInput.type = 'text'; |
| 475 newTabInput.placeholder = WebInspector.UIString('Enter URL'); | 475 newTabInput.placeholder = Common.UIString('Enter URL'); |
| 476 newTabInput.addEventListener('keydown', newTabKeyDown, false); | 476 newTabInput.addEventListener('keydown', newTabKeyDown, false); |
| 477 var newTabButton = createTextButton(WebInspector.UIString('Open'), openNewTa
b); | 477 var newTabButton = createTextButton(Common.UIString('Open'), openNewTab); |
| 478 newTabRow.appendChild(newTabButton); | 478 newTabRow.appendChild(newTabButton); |
| 479 | 479 |
| 480 var pages = element.createChild('div', 'device-page-list vbox'); | 480 var pages = element.createChild('div', 'device-page-list vbox'); |
| 481 | 481 |
| 482 var viewMore = element.createChild('div', 'device-view-more'); | 482 var viewMore = element.createChild('div', 'device-view-more'); |
| 483 viewMore.addEventListener('click', viewMoreClick, false); | 483 viewMore.addEventListener('click', viewMoreClick, false); |
| 484 updateViewMoreTitle(); | 484 updateViewMoreTitle(); |
| 485 | 485 |
| 486 var section = { | 486 var section = { |
| 487 browser: null, | 487 browser: null, |
| 488 element: element, | 488 element: element, |
| 489 title: title, | 489 title: title, |
| 490 pages: pages, | 490 pages: pages, |
| 491 viewMore: viewMore, | 491 viewMore: viewMore, |
| 492 newTab: newTabRow, | 492 newTab: newTabRow, |
| 493 pageSections: new Map() | 493 pageSections: new Map() |
| 494 }; | 494 }; |
| 495 return section; | 495 return section; |
| 496 | 496 |
| 497 function viewMoreClick() { | 497 function viewMoreClick() { |
| 498 pages.classList.toggle('device-view-more-toggled'); | 498 pages.classList.toggle('device-view-more-toggled'); |
| 499 updateViewMoreTitle(); | 499 updateViewMoreTitle(); |
| 500 } | 500 } |
| 501 | 501 |
| 502 function updateViewMoreTitle() { | 502 function updateViewMoreTitle() { |
| 503 viewMore.textContent = pages.classList.contains('device-view-more-toggled'
) ? | 503 viewMore.textContent = pages.classList.contains('device-view-more-toggled'
) ? |
| 504 WebInspector.UIString('View less tabs\u2026') : | 504 Common.UIString('View less tabs\u2026') : |
| 505 WebInspector.UIString('View more tabs\u2026'); | 505 Common.UIString('View more tabs\u2026'); |
| 506 } | 506 } |
| 507 | 507 |
| 508 /** | 508 /** |
| 509 * @param {!Event} event | 509 * @param {!Event} event |
| 510 */ | 510 */ |
| 511 function newTabKeyDown(event) { | 511 function newTabKeyDown(event) { |
| 512 if (event.key === 'Enter') { | 512 if (event.key === 'Enter') { |
| 513 event.consume(true); | 513 event.consume(true); |
| 514 openNewTab(); | 514 openNewTab(); |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 | 517 |
| 518 function openNewTab() { | 518 function openNewTab() { |
| 519 if (section.browser) { | 519 if (section.browser) { |
| 520 InspectorFrontendHost.openRemotePage(section.browser.id, newTabInput.val
ue.trim() || 'about:blank'); | 520 InspectorFrontendHost.openRemotePage(section.browser.id, newTabInput.val
ue.trim() || 'about:blank'); |
| 521 newTabInput.value = ''; | 521 newTabInput.value = ''; |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 } | 524 } |
| 525 | 525 |
| 526 /** | 526 /** |
| 527 * @param {!WebInspector.DevicesView.BrowserSection} section | 527 * @param {!Devices.DevicesView.BrowserSection} section |
| 528 * @param {!Adb.Browser} browser | 528 * @param {!Adb.Browser} browser |
| 529 */ | 529 */ |
| 530 _updateBrowserSection(section, browser) { | 530 _updateBrowserSection(section, browser) { |
| 531 if (!section.browser || section.browser.adbBrowserName !== browser.adbBrowse
rName || | 531 if (!section.browser || section.browser.adbBrowserName !== browser.adbBrowse
rName || |
| 532 section.browser.adbBrowserVersion !== browser.adbBrowserVersion) { | 532 section.browser.adbBrowserVersion !== browser.adbBrowserVersion) { |
| 533 if (browser.adbBrowserVersion) | 533 if (browser.adbBrowserVersion) |
| 534 section.title.textContent = String.sprintf('%s (%s)', browser.adbBrowser
Name, browser.adbBrowserVersion); | 534 section.title.textContent = String.sprintf('%s (%s)', browser.adbBrowser
Name, browser.adbBrowserVersion); |
| 535 else | 535 else |
| 536 section.title.textContent = browser.adbBrowserName; | 536 section.title.textContent = browser.adbBrowserName; |
| 537 } | 537 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 562 | 562 |
| 563 var kViewMoreCount = 3; | 563 var kViewMoreCount = 3; |
| 564 for (var index = 0, element = section.pages.firstChild; element; element = e
lement.nextSibling, ++index) | 564 for (var index = 0, element = section.pages.firstChild; element; element = e
lement.nextSibling, ++index) |
| 565 element.classList.toggle('device-view-more-page', index >= kViewMoreCount)
; | 565 element.classList.toggle('device-view-more-page', index >= kViewMoreCount)
; |
| 566 section.viewMore.classList.toggle('device-needs-view-more', browser.pages.le
ngth > kViewMoreCount); | 566 section.viewMore.classList.toggle('device-needs-view-more', browser.pages.le
ngth > kViewMoreCount); |
| 567 section.newTab.classList.toggle('hidden', !browser.adbBrowserChromeVersion); | 567 section.newTab.classList.toggle('hidden', !browser.adbBrowserChromeVersion); |
| 568 section.browser = browser; | 568 section.browser = browser; |
| 569 } | 569 } |
| 570 | 570 |
| 571 /** | 571 /** |
| 572 * @return {!WebInspector.DevicesView.PageSection} | 572 * @return {!Devices.DevicesView.PageSection} |
| 573 */ | 573 */ |
| 574 _createPageSection() { | 574 _createPageSection() { |
| 575 var element = createElementWithClass('div', 'vbox'); | 575 var element = createElementWithClass('div', 'vbox'); |
| 576 | 576 |
| 577 var titleRow = element.createChild('div', 'device-page-title-row'); | 577 var titleRow = element.createChild('div', 'device-page-title-row'); |
| 578 var title = titleRow.createChild('div', 'device-page-title'); | 578 var title = titleRow.createChild('div', 'device-page-title'); |
| 579 var inspect = | 579 var inspect = |
| 580 createTextButton(WebInspector.UIString('Inspect'), doAction.bind(null, '
inspect'), 'device-inspect-button'); | 580 createTextButton(Common.UIString('Inspect'), doAction.bind(null, 'inspec
t'), 'device-inspect-button'); |
| 581 titleRow.appendChild(inspect); | 581 titleRow.appendChild(inspect); |
| 582 | 582 |
| 583 var toolbar = new WebInspector.Toolbar(''); | 583 var toolbar = new UI.Toolbar(''); |
| 584 toolbar.appendToolbarItem(new WebInspector.ToolbarMenuButton(appendActions))
; | 584 toolbar.appendToolbarItem(new UI.ToolbarMenuButton(appendActions)); |
| 585 titleRow.appendChild(toolbar.element); | 585 titleRow.appendChild(toolbar.element); |
| 586 | 586 |
| 587 var url = element.createChild('div', 'device-page-url'); | 587 var url = element.createChild('div', 'device-page-url'); |
| 588 var section = {page: null, element: element, title: title, url: url, inspect
: inspect}; | 588 var section = {page: null, element: element, title: title, url: url, inspect
: inspect}; |
| 589 return section; | 589 return section; |
| 590 | 590 |
| 591 /** | 591 /** |
| 592 * @param {!WebInspector.ContextMenu} contextMenu | 592 * @param {!UI.ContextMenu} contextMenu |
| 593 */ | 593 */ |
| 594 function appendActions(contextMenu) { | 594 function appendActions(contextMenu) { |
| 595 contextMenu.appendItem(WebInspector.UIString('Reload'), doAction.bind(null
, 'reload')); | 595 contextMenu.appendItem(Common.UIString('Reload'), doAction.bind(null, 'rel
oad')); |
| 596 contextMenu.appendItem(WebInspector.UIString('Focus'), doAction.bind(null,
'activate')); | 596 contextMenu.appendItem(Common.UIString('Focus'), doAction.bind(null, 'acti
vate')); |
| 597 contextMenu.appendItem(WebInspector.UIString('Close'), doAction.bind(null,
'close')); | 597 contextMenu.appendItem(Common.UIString('Close'), doAction.bind(null, 'clos
e')); |
| 598 } | 598 } |
| 599 | 599 |
| 600 /** | 600 /** |
| 601 * @param {string} action | 601 * @param {string} action |
| 602 */ | 602 */ |
| 603 function doAction(action) { | 603 function doAction(action) { |
| 604 if (section.page) | 604 if (section.page) |
| 605 InspectorFrontendHost.performActionOnRemotePage(section.page.id, action)
; | 605 InspectorFrontendHost.performActionOnRemotePage(section.page.id, action)
; |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 | 608 |
| 609 /** | 609 /** |
| 610 * @param {!WebInspector.DevicesView.PageSection} section | 610 * @param {!Devices.DevicesView.PageSection} section |
| 611 * @param {!Adb.Page} page | 611 * @param {!Adb.Page} page |
| 612 */ | 612 */ |
| 613 _updatePageSection(section, page) { | 613 _updatePageSection(section, page) { |
| 614 if (!section.page || section.page.name !== page.name) { | 614 if (!section.page || section.page.name !== page.name) { |
| 615 section.title.textContent = page.name; | 615 section.title.textContent = page.name; |
| 616 section.title.title = page.name; | 616 section.title.title = page.name; |
| 617 } | 617 } |
| 618 if (!section.page || section.page.url !== page.url) { | 618 if (!section.page || section.page.url !== page.url) { |
| 619 section.url.textContent = ''; | 619 section.url.textContent = ''; |
| 620 section.url.appendChild(WebInspector.linkifyURLAsNode(page.url, undefined,
undefined, true)); | 620 section.url.appendChild(UI.linkifyURLAsNode(page.url, undefined, undefined
, true)); |
| 621 } | 621 } |
| 622 section.inspect.disabled = page.attached; | 622 section.inspect.disabled = page.attached; |
| 623 | 623 |
| 624 section.page = page; | 624 section.page = page; |
| 625 } | 625 } |
| 626 | 626 |
| 627 /** | 627 /** |
| 628 * @param {!Adb.DevicePortForwardingStatus} status | 628 * @param {!Adb.DevicePortForwardingStatus} status |
| 629 */ | 629 */ |
| 630 portForwardingStatusChanged(status) { | 630 portForwardingStatusChanged(status) { |
| 631 var json = JSON.stringify(status); | 631 var json = JSON.stringify(status); |
| 632 if (json === this._cachedPortStatus) | 632 if (json === this._cachedPortStatus) |
| 633 return; | 633 return; |
| 634 this._cachedPortStatus = json; | 634 this._cachedPortStatus = json; |
| 635 | 635 |
| 636 this._portStatus.removeChildren(); | 636 this._portStatus.removeChildren(); |
| 637 this._portStatus.createChild('div', 'device-port-status-text').textContent = | 637 this._portStatus.createChild('div', 'device-port-status-text').textContent = |
| 638 WebInspector.UIString('Port Forwarding:'); | 638 Common.UIString('Port Forwarding:'); |
| 639 var connected = []; | 639 var connected = []; |
| 640 var transient = []; | 640 var transient = []; |
| 641 var error = []; | 641 var error = []; |
| 642 var empty = true; | 642 var empty = true; |
| 643 for (var port in status.ports) { | 643 for (var port in status.ports) { |
| 644 if (!status.ports.hasOwnProperty(port)) | 644 if (!status.ports.hasOwnProperty(port)) |
| 645 continue; | 645 continue; |
| 646 | 646 |
| 647 empty = false; | 647 empty = false; |
| 648 var portStatus = status.ports[port]; | 648 var portStatus = status.ports[port]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 661 transient.push(port); | 661 transient.push(port); |
| 662 } else if (portStatus < 0) { | 662 } else if (portStatus < 0) { |
| 663 portIcon.classList.add('device-view-port-icon-error'); | 663 portIcon.classList.add('device-view-port-icon-error'); |
| 664 error.push(port); | 664 error.push(port); |
| 665 } | 665 } |
| 666 this._portStatus.insertBefore(portIcon, portNumber); | 666 this._portStatus.insertBefore(portIcon, portNumber); |
| 667 } | 667 } |
| 668 | 668 |
| 669 var title = []; | 669 var title = []; |
| 670 if (connected.length) | 670 if (connected.length) |
| 671 title.push(WebInspector.UIString('Connected: %s', connected.join(', '))); | 671 title.push(Common.UIString('Connected: %s', connected.join(', '))); |
| 672 if (transient.length) | 672 if (transient.length) |
| 673 title.push(WebInspector.UIString('Transient: %s', transient.join(', '))); | 673 title.push(Common.UIString('Transient: %s', transient.join(', '))); |
| 674 if (error.length) | 674 if (error.length) |
| 675 title.push(WebInspector.UIString('Error: %s', error.join(', '))); | 675 title.push(Common.UIString('Error: %s', error.join(', '))); |
| 676 this._portStatus.title = title.join('; '); | 676 this._portStatus.title = title.join('; '); |
| 677 this._portStatus.classList.toggle('hidden', empty); | 677 this._portStatus.classList.toggle('hidden', empty); |
| 678 } | 678 } |
| 679 }; | 679 }; |
| 680 | 680 |
| 681 /** @typedef {!{browser: ?Adb.Browser, element: !Element, title: !Element, pages
: !Element, viewMore: !Element, newTab: !Element, pageSections: !Map<string, !We
bInspector.DevicesView.PageSection>}} */ | 681 /** @typedef {!{browser: ?Adb.Browser, element: !Element, title: !Element, pages
: !Element, viewMore: !Element, newTab: !Element, pageSections: !Map<string, !De
vices.DevicesView.PageSection>}} */ |
| 682 WebInspector.DevicesView.BrowserSection; | 682 Devices.DevicesView.BrowserSection; |
| 683 | 683 |
| 684 /** @typedef {!{page: ?Adb.Page, element: !Element, title: !Element, url: !Eleme
nt, inspect: !Element}} */ | 684 /** @typedef {!{page: ?Adb.Page, element: !Element, title: !Element, url: !Eleme
nt, inspect: !Element}} */ |
| 685 WebInspector.DevicesView.PageSection; | 685 Devices.DevicesView.PageSection; |
| OLD | NEW |