| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.ServiceWorkersView = function() | 10 WebInspector.ServiceWorkersView = function() |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 */ | 307 */ |
| 308 _updateRegistration: function(registration) | 308 _updateRegistration: function(registration) |
| 309 { | 309 { |
| 310 this._registration = registration; | 310 this._registration = registration; |
| 311 this._updateButton.setEnabled(!registration.isDeleted); | 311 this._updateButton.setEnabled(!registration.isDeleted); |
| 312 this._deleteButton.setEnabled(!registration.isDeleted); | 312 this._deleteButton.setEnabled(!registration.isDeleted); |
| 313 | 313 |
| 314 /** @type {!Map<string, !WebInspector.SWVersionWidget>} */ | 314 /** @type {!Map<string, !WebInspector.SWVersionWidget>} */ |
| 315 var versionWidgets = new Map(); | 315 var versionWidgets = new Map(); |
| 316 | 316 |
| 317 // Remove all the redundant workers that are older than the |
| 318 // active version. |
| 319 var versions = registration.versions.valuesArray(); |
| 320 var activeVersion = versions.find(version => version.mode() === WebInspe
ctor.ServiceWorkerVersion.Modes.Active); |
| 321 if (activeVersion) { |
| 322 versions = versions.filter(version => { |
| 323 if (version.mode() == WebInspector.ServiceWorkerVersion.Modes.Re
dundant) |
| 324 return version.scriptLastModified > activeVersion.scriptLast
Modified; |
| 325 return true; |
| 326 }); |
| 327 } |
| 328 |
| 329 var firstMode; |
| 317 var modesWithVersions = new Set(); | 330 var modesWithVersions = new Set(); |
| 318 var firstMode; | 331 for (var version of versions) { |
| 319 for (var version of registration.versions.valuesArray()) { | |
| 320 if (version.isStoppedAndRedundant() && !version.errorMessages.length
) | 332 if (version.isStoppedAndRedundant() && !version.errorMessages.length
) |
| 321 continue; | 333 continue; |
| 322 var mode = version.mode(); | 334 var mode = version.mode(); |
| 323 if (!firstMode) | 335 if (!firstMode) |
| 324 firstMode = mode; | 336 firstMode = mode; |
| 325 modesWithVersions.add(mode); | 337 modesWithVersions.add(mode); |
| 326 var view = this._tabbedPane.tabView(mode); | 338 var view = this._tabbedPane.tabView(mode); |
| 327 var versionWidget = this._versionWidgets.get(version.id); | 339 var versionWidget = this._versionWidgets.get(version.id); |
| 328 if (versionWidget) | 340 if (versionWidget) |
| 329 versionWidget._updateVersion(version); | 341 versionWidget._updateVersion(version); |
| 330 else | 342 else |
| 331 versionWidget = new WebInspector.SWVersionWidget(this._manager,
this._registration.scopeURL, version); | 343 versionWidget = new WebInspector.SWVersionWidget(this._manager,
this._registration.scopeURL, version); |
| 332 versionWidget.show(view.element); | 344 versionWidget.show(view.element, view.element.firstElementChild); |
| 333 versionWidgets.set(version.id, versionWidget); | 345 versionWidgets.set(version.id, versionWidget); |
| 334 } | 346 } |
| 335 for (var id of this._versionWidgets.keys()) { | 347 for (var id of this._versionWidgets.keys()) { |
| 336 if (!versionWidgets.has(id)) | 348 if (!versionWidgets.has(id)) |
| 337 this._versionWidgets.get(id).detach(); | 349 this._versionWidgets.get(id).detach(); |
| 338 } | 350 } |
| 339 this._versionWidgets = versionWidgets; | 351 this._versionWidgets = versionWidgets; |
| 340 | 352 |
| 341 for (var id of this._tabbedPane.tabIds()) | 353 for (var id of this._tabbedPane.tabIds()) |
| 342 this._tabbedPane.setTabEnabled(id, modesWithVersions.has(id)); | 354 this._tabbedPane.setTabEnabled(id, modesWithVersions.has(id)); |
| 343 | 355 |
| 344 this._pushButton.setEnabled(modesWithVersions.has(WebInspector.ServiceWo
rkerVersion.Modes.Active) && !this._registration.isDeleted); | 356 this._pushButton.setEnabled(modesWithVersions.has(WebInspector.ServiceWo
rkerVersion.Modes.Active) && !this._registration.isDeleted); |
| 345 | 357 |
| 346 if (modesWithVersions.has(this._lastManuallySelectedTab)) { | 358 if (modesWithVersions.has(this._lastManuallySelectedTab)) { |
| 347 this._tabbedPane.selectTab(this._lastManuallySelectedTab); | 359 this._tabbedPane.selectTab(this._lastManuallySelectedTab); |
| 348 return; | 360 return; |
| 349 } | 361 } |
| 350 if (modesWithVersions.has(WebInspector.ServiceWorkerVersion.Modes.Active
)) { | 362 if (activeVersion) { |
| 351 this._tabbedPane.selectTab(WebInspector.ServiceWorkerVersion.Modes.A
ctive); | 363 this._tabbedPane.selectTab(WebInspector.ServiceWorkerVersion.Modes.A
ctive); |
| 352 return; | 364 return; |
| 353 } | 365 } |
| 354 if (firstMode) | 366 if (firstMode) |
| 355 this._tabbedPane.selectTab(firstMode); | 367 this._tabbedPane.selectTab(firstMode); |
| 356 }, | 368 }, |
| 357 | 369 |
| 358 /** | 370 /** |
| 359 * @param {!WebInspector.Event} event | 371 * @param {!WebInspector.Event} event |
| 360 */ | 372 */ |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 * @param {string} versionId | 585 * @param {string} versionId |
| 574 * @param {!Event} event | 586 * @param {!Event} event |
| 575 */ | 587 */ |
| 576 _inspectButtonClicked: function(versionId, event) | 588 _inspectButtonClicked: function(versionId, event) |
| 577 { | 589 { |
| 578 this._manager.inspectWorker(versionId); | 590 this._manager.inspectWorker(versionId); |
| 579 }, | 591 }, |
| 580 | 592 |
| 581 __proto__: WebInspector.VBox.prototype | 593 __proto__: WebInspector.VBox.prototype |
| 582 } | 594 } |
| OLD | NEW |