Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js b/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js |
| index 049bcf840e6db2aae7c1b70ba7b8fcee43ef1b7e..c3bd0e9c8a35c79427a53c9daa51d582c8fb974c 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js |
| @@ -19,6 +19,16 @@ WebInspector.ServiceWorkersView = function() |
| /** @type {!Map<!WebInspector.ServiceWorkerRegistration, !WebInspector.ServiceWorkersView.Section>} */ |
| this._sections = new Map(); |
| + this._toolbar.appendToolbarItem(WebInspector.NetworkConditionsSelector.createOfflineToolbarCheckbox()); |
| + var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString("Update on reload"), WebInspector.UIString("Force update Service Worker on page reload"), WebInspector.settings.createSetting("serviceWorkerUpdateOnReload", false)); |
| + this._toolbar.appendToolbarItem(forceUpdate); |
| + var fallbackToNetwork = new WebInspector.ToolbarCheckbox(WebInspector.UIString("Bypass for network"), WebInspector.UIString("Bypass Service Worker and load resources from the network"), WebInspector.settings.createSetting("bypassServiceWorker", false)); |
|
dgozman
2016/10/14 18:33:34
Should we remove networkManager.bypassServiceWorke
pfeldman
2016/10/14 20:03:22
Done.
|
| + this._toolbar.appendToolbarItem(fallbackToNetwork); |
| + this._toolbar.appendSpacer(); |
| + this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UIString("Show all"), WebInspector.UIString("Show all Service Workers regardless of the origin")); |
| + this._showAllCheckbox.inputElement.addEventListener("change", this._updateSectionVisibility.bind(this), false); |
| + this._toolbar.appendToolbarItem(this._showAllCheckbox); |
| + |
| WebInspector.targetManager.observeTargets(this); |
| } |
| @@ -29,25 +39,11 @@ WebInspector.ServiceWorkersView.prototype = { |
| */ |
| targetAdded: function(target) |
| { |
| - var securityOriginManager = WebInspector.SecurityOriginManager.fromTarget(target); |
| - if (this._manager || !target.serviceWorkerManager || !securityOriginManager) |
| + if (this._manager || !target.serviceWorkerManager) |
| return; |
| this._manager = target.serviceWorkerManager; |
| this._subTargetsManager = target.subTargetsManager; |
| - this._securityOriginManager = securityOriginManager; |
| - |
| - this._toolbar.appendToolbarItem(WebInspector.NetworkConditionsSelector.createOfflineToolbarCheckbox()); |
| - var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString("Update on reload"), WebInspector.UIString("Force update Service Worker on page reload"), this._manager.forceUpdateOnReloadSetting()); |
| - this._toolbar.appendToolbarItem(forceUpdate); |
| - var networkManager = target && WebInspector.NetworkManager.fromTarget(target); |
| - if (networkManager) { |
| - var fallbackToNetwork = new WebInspector.ToolbarCheckbox(WebInspector.UIString("Bypass for network"), WebInspector.UIString("Bypass Service Worker and load resources from the network"), networkManager.bypassServiceWorkerSetting()); |
| - this._toolbar.appendToolbarItem(fallbackToNetwork); |
| - this._toolbar.appendSpacer(); |
| - } |
| - this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UIString("Show all"), WebInspector.UIString("Show all Service Workers regardless of the origin")); |
| - this._showAllCheckbox.inputElement.addEventListener("change", this._updateSectionVisibility.bind(this), false); |
| - this._toolbar.appendToolbarItem(this._showAllCheckbox); |
| + this._securityOriginManager = WebInspector.SecurityOriginManager.fromTarget(target); |
| for (var registration of this._manager.registrations().values()) |
| this._updateRegistration(registration); |
| @@ -55,8 +51,8 @@ WebInspector.ServiceWorkersView.prototype = { |
| this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.RegistrationUpdated, this._registrationUpdated, this); |
| this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.RegistrationDeleted, this._registrationDeleted, this); |
| this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events.RegistrationErrorAdded, this._registrationErrorAdded, this); |
| - securityOriginManager.addEventListener(WebInspector.SecurityOriginManager.Events.SecurityOriginAdded, this._updateSectionVisibility, this); |
| - securityOriginManager.addEventListener(WebInspector.SecurityOriginManager.Events.SecurityOriginRemoved, this._updateSectionVisibility, this); |
| + this._securityOriginManager.addEventListener(WebInspector.SecurityOriginManager.Events.SecurityOriginAdded, this._updateSectionVisibility, this); |
| + this._securityOriginManager.addEventListener(WebInspector.SecurityOriginManager.Events.SecurityOriginRemoved, this._updateSectionVisibility, this); |
| }, |
| /** |
| @@ -65,9 +61,17 @@ WebInspector.ServiceWorkersView.prototype = { |
| */ |
| targetRemoved: function(target) |
| { |
| - if (this._manager !== target.serviceWorkerManager) |
| + if (!this._manager && this._manager !== target.serviceWorkerManager) |
|
dgozman
2016/10/14 18:33:34
&& -> ||
pfeldman
2016/10/14 20:03:22
Oops :(
|
| return; |
| + |
| + this._manager.removeEventListener(WebInspector.ServiceWorkerManager.Events.RegistrationUpdated, this._registrationUpdated, this); |
|
dgozman
2016/10/14 18:33:34
Use WebInspector.EventTarget.removeEventListeners.
pfeldman
2016/10/14 20:03:22
Done.
|
| + this._manager.removeEventListener(WebInspector.ServiceWorkerManager.Events.RegistrationDeleted, this._registrationDeleted, this); |
| + this._manager.removeEventListener(WebInspector.ServiceWorkerManager.Events.RegistrationErrorAdded, this._registrationErrorAdded, this); |
| + this._securityOriginManager.removeEventListener(WebInspector.SecurityOriginManager.Events.SecurityOriginAdded, this._updateSectionVisibility, this); |
| + this._securityOriginManager.removeEventListener(WebInspector.SecurityOriginManager.Events.SecurityOriginRemoved, this._updateSectionVisibility, this); |
| + |
| this._manager = null; |
| + this._subTargetsManager = null; |
| this._securityOriginManager = null; |
| }, |