| 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 11 matching lines...) Expand all Loading... |
| 22 WebInspector.targetManager.observeTargets(this); | 22 WebInspector.targetManager.observeTargets(this); |
| 23 } | 23 } |
| 24 | 24 |
| 25 WebInspector.ServiceWorkersView.prototype = { | 25 WebInspector.ServiceWorkersView.prototype = { |
| 26 /** | 26 /** |
| 27 * @override | 27 * @override |
| 28 * @param {!WebInspector.Target} target | 28 * @param {!WebInspector.Target} target |
| 29 */ | 29 */ |
| 30 targetAdded: function(target) | 30 targetAdded: function(target) |
| 31 { | 31 { |
| 32 if (this._target || !target.serviceWorkerManager) | 32 var securityOriginManager = WebInspector.SecurityOriginManager.fromTarge
t(target); |
| 33 if (this._manager || !target.serviceWorkerManager || !securityOriginMana
ger) |
| 33 return; | 34 return; |
| 34 this._target = target; | 35 this._manager = target.serviceWorkerManager; |
| 35 this._manager = this._target.serviceWorkerManager; | 36 this._securityOriginManager = securityOriginManager; |
| 36 | 37 |
| 37 this._toolbar.appendToolbarItem(WebInspector.NetworkConditionsSelector.c
reateOfflineToolbarCheckbox()); | 38 this._toolbar.appendToolbarItem(WebInspector.NetworkConditionsSelector.c
reateOfflineToolbarCheckbox()); |
| 38 var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString
("Update on reload"), WebInspector.UIString("Force update Service Worker on page
reload"), this._manager.forceUpdateOnReloadSetting()); | 39 var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString
("Update on reload"), WebInspector.UIString("Force update Service Worker on page
reload"), this._manager.forceUpdateOnReloadSetting()); |
| 39 this._toolbar.appendToolbarItem(forceUpdate); | 40 this._toolbar.appendToolbarItem(forceUpdate); |
| 40 var networkManager = this._target && WebInspector.NetworkManager.fromTar
get(this._target); | 41 var networkManager = target && WebInspector.NetworkManager.fromTarget(ta
rget); |
| 41 if (networkManager) { | 42 if (networkManager) { |
| 42 var fallbackToNetwork = new WebInspector.ToolbarCheckbox(WebInspecto
r.UIString("Bypass for network"), WebInspector.UIString("Bypass Service Worker a
nd load resources from the network"), networkManager.bypassServiceWorkerSetting(
)); | 43 var fallbackToNetwork = new WebInspector.ToolbarCheckbox(WebInspecto
r.UIString("Bypass for network"), WebInspector.UIString("Bypass Service Worker a
nd load resources from the network"), networkManager.bypassServiceWorkerSetting(
)); |
| 43 this._toolbar.appendToolbarItem(fallbackToNetwork); | 44 this._toolbar.appendToolbarItem(fallbackToNetwork); |
| 44 this._toolbar.appendSpacer(); | 45 this._toolbar.appendSpacer(); |
| 45 } | 46 } |
| 46 this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UI
String("Show all"), WebInspector.UIString("Show all Service Workers regardless o
f the origin")); | 47 this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UI
String("Show all"), WebInspector.UIString("Show all Service Workers regardless o
f the origin")); |
| 47 this._showAllCheckbox.inputElement.addEventListener("change", this._upda
teSectionVisibility.bind(this), false); | 48 this._showAllCheckbox.inputElement.addEventListener("change", this._upda
teSectionVisibility.bind(this), false); |
| 48 this._toolbar.appendToolbarItem(this._showAllCheckbox); | 49 this._toolbar.appendToolbarItem(this._showAllCheckbox); |
| 49 | 50 |
| 50 for (var registration of this._manager.registrations().values()) | 51 for (var registration of this._manager.registrations().values()) |
| 51 this._updateRegistration(registration); | 52 this._updateRegistration(registration); |
| 52 | 53 |
| 53 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.
RegistrationUpdated, this._registrationUpdated, this); | 54 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.
RegistrationUpdated, this._registrationUpdated, this); |
| 54 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.
RegistrationDeleted, this._registrationDeleted, this); | 55 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.
RegistrationDeleted, this._registrationDeleted, this); |
| 55 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.
RegistrationErrorAdded, this._registrationErrorAdded, this); | 56 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.
RegistrationErrorAdded, this._registrationErrorAdded, this); |
| 56 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre
eModel.EventTypes.SecurityOriginAdded, this._updateSectionVisibility, this); | 57 securityOriginManager.addEventListener(WebInspector.SecurityOriginManage
r.EventTypes.SecurityOriginAdded, this._updateSectionVisibility, this); |
| 57 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre
eModel.EventTypes.SecurityOriginRemoved, this._updateSectionVisibility, this); | 58 securityOriginManager.addEventListener(WebInspector.SecurityOriginManage
r.EventTypes.SecurityOriginRemoved, this._updateSectionVisibility, this); |
| 58 }, | 59 }, |
| 59 | 60 |
| 60 /** | 61 /** |
| 61 * @override | 62 * @override |
| 62 * @param {!WebInspector.Target} target | 63 * @param {!WebInspector.Target} target |
| 63 */ | 64 */ |
| 64 targetRemoved: function(target) | 65 targetRemoved: function(target) |
| 65 { | 66 { |
| 66 if (target !== this._target) | 67 if (this._manager !== target.serviceWorkerManager) |
| 67 return; | 68 return; |
| 68 delete this._target; | 69 this._manager = null; |
| 70 this._securityOriginManager = null; |
| 69 }, | 71 }, |
| 70 | 72 |
| 71 _updateSectionVisibility: function() | 73 _updateSectionVisibility: function() |
| 72 { | 74 { |
| 73 var securityOrigins = new Set(this._target.resourceTreeModel.securityOri
gins()); | 75 var securityOrigins = new Set(this._securityOriginManager.securityOrigin
s()); |
| 74 for (var section of this._sections.values()) { | 76 for (var section of this._sections.values()) { |
| 75 var visible = this._showAllCheckbox.checked() || securityOrigins.has
(section._registration.securityOrigin); | 77 var visible = this._showAllCheckbox.checked() || securityOrigins.has
(section._registration.securityOrigin); |
| 76 section._section.element.classList.toggle("hidden", !visible); | 78 section._section.element.classList.toggle("hidden", !visible); |
| 77 } | 79 } |
| 78 }, | 80 }, |
| 79 | 81 |
| 80 /** | 82 /** |
| 81 * @param {!WebInspector.Event} event | 83 * @param {!WebInspector.Event} event |
| 82 */ | 84 */ |
| 83 _registrationUpdated: function(event) | 85 _registrationUpdated: function(event) |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 return contentElement; | 408 return contentElement; |
| 407 }, | 409 }, |
| 408 | 410 |
| 409 _dispose: function() | 411 _dispose: function() |
| 410 { | 412 { |
| 411 this._linkifier.dispose(); | 413 this._linkifier.dispose(); |
| 412 if (this._pendingUpdate) | 414 if (this._pendingUpdate) |
| 413 clearTimeout(this._pendingUpdate); | 415 clearTimeout(this._pendingUpdate); |
| 414 } | 416 } |
| 415 } | 417 } |
| OLD | NEW |