Chromium Code Reviews| 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() |
| 11 { | 11 { |
| 12 WebInspector.VBox.call(this, true); | 12 WebInspector.VBox.call(this, true); |
| 13 this.registerRequiredCSS("resources/serviceWorkersView.css"); | 13 this.registerRequiredCSS("resources/serviceWorkersView.css"); |
| 14 this.contentElement.classList.add("service-workers-view"); | 14 this.contentElement.classList.add("service-workers-view"); |
| 15 | 15 |
| 16 /** @type {!Set.<string>} */ | 16 /** @type {!Set.<string>} */ |
| 17 this._securityOriginHosts = new Set(); | 17 this._securityOriginHosts = new Set(); |
| 18 /** @type {!Map.<string, !WebInspector.ServiceWorkerOriginWidget>} */ | 18 /** @type {!Map.<string, !WebInspector.ServiceWorkerOriginWidget>} */ |
| 19 this._originHostToOriginWidgetMap = new Map(); | 19 this._originHostToOriginWidgetMap = new Map(); |
| 20 /** @type {!Map.<string, !WebInspector.ServiceWorkerOriginWidget>} */ | 20 /** @type {!Map.<string, !WebInspector.ServiceWorkerOriginWidget>} */ |
| 21 this._registrationIdToOriginWidgetMap = new Map(); | 21 this._registrationIdToOriginWidgetMap = new Map(); |
| 22 | 22 |
| 23 var settingsDiv = createElementWithClass("div", "service-workers-settings"); | 23 this._toolbar = new WebInspector.Toolbar("", this.contentElement); |
| 24 var debugOnStartCheckboxLabel = createCheckboxLabel(WebInspector.UIString("O pen DevTools window and pause JavaScript execution on Service Worker startup for debugging.")); | |
|
horo
2016/03/30 05:17:35
Why do you remove this debugOnStartCheckbox?
pfeldman
2016/03/30 17:11:44
It does not currently work in combination with the
horo
2016/03/31 02:39:45
OK. Sounds reasonable.
Please write about this in
| |
| 25 this._debugOnStartCheckbox = debugOnStartCheckboxLabel.checkboxElement; | |
| 26 this._debugOnStartCheckbox.addEventListener("change", this._debugOnStartChec kboxChanged.bind(this), false) | |
| 27 this._debugOnStartCheckbox.disabled = true | |
| 28 settingsDiv.appendChild(debugOnStartCheckboxLabel); | |
| 29 this.contentElement.appendChild(settingsDiv); | |
| 30 | 24 |
| 31 this._root = this.contentElement.createChild("div"); | 25 this._root = this.contentElement.createChild("div"); |
| 32 this._root.classList.add("service-workers-root"); | 26 this._root.classList.add("service-workers-root"); |
| 33 | 27 |
| 34 WebInspector.targetManager.observeTargets(this); | 28 WebInspector.targetManager.observeTargets(this); |
| 35 } | 29 } |
| 36 | 30 |
| 37 WebInspector.ServiceWorkersView.prototype = { | 31 WebInspector.ServiceWorkersView.prototype = { |
| 38 /** | 32 /** |
| 39 * @override | 33 * @override |
| 40 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
| 41 */ | 35 */ |
| 42 targetAdded: function(target) | 36 targetAdded: function(target) |
| 43 { | 37 { |
| 44 if (this._target) | 38 if (this._target) |
| 45 return; | 39 return; |
| 46 this._target = target; | 40 this._target = target; |
| 47 this._manager = this._target.serviceWorkerManager; | 41 this._manager = this._target.serviceWorkerManager; |
| 48 | 42 |
| 49 this._debugOnStartCheckbox.disabled = false; | 43 var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString ("Update on reload"), WebInspector.UIString("Update Service Worker on page reloa d"), this._manager.forceUpdateOnReloadSetting()); |
| 50 this._debugOnStartCheckbox.checked = this._manager.debugOnStart(); | 44 this._toolbar.appendToolbarItem(forceUpdate); |
| 45 | |
| 51 for (var registration of this._manager.registrations().values()) | 46 for (var registration of this._manager.registrations().values()) |
| 52 this._updateRegistration(registration); | 47 this._updateRegistration(registration); |
| 53 | 48 |
| 54 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationUpdated, this._registrationUpdated, this); | 49 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationUpdated, this._registrationUpdated, this); |
| 55 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationDeleted, this._registrationDeleted, this); | 50 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationDeleted, this._registrationDeleted, this); |
| 56 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. DebugOnStartUpdated, this._debugOnStartUpdated, this); | |
| 57 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this); | 51 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this); |
| 58 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this); | 52 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this); |
| 59 var securityOrigins = this._target.resourceTreeModel.securityOrigins(); | 53 var securityOrigins = this._target.resourceTreeModel.securityOrigins(); |
| 60 for (var i = 0; i < securityOrigins.length; ++i) | 54 for (var i = 0; i < securityOrigins.length; ++i) |
| 61 this._addOrigin(securityOrigins[i]); | 55 this._addOrigin(securityOrigins[i]); |
| 62 }, | 56 }, |
| 63 | 57 |
| 64 /** | 58 /** |
| 65 * @override | 59 * @override |
| 66 * @param {!WebInspector.Target} target | 60 * @param {!WebInspector.Target} target |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 if (originWidget._hasRegistration()) | 110 if (originWidget._hasRegistration()) |
| 117 return; | 111 return; |
| 118 if (this._securityOriginHosts.has(originWidget._originHost)) | 112 if (this._securityOriginHosts.has(originWidget._originHost)) |
| 119 originWidget.detach(); | 113 originWidget.detach(); |
| 120 this._originHostToOriginWidgetMap.delete(originWidget._originHost); | 114 this._originHostToOriginWidgetMap.delete(originWidget._originHost); |
| 121 }, | 115 }, |
| 122 | 116 |
| 123 /** | 117 /** |
| 124 * @param {!WebInspector.Event} event | 118 * @param {!WebInspector.Event} event |
| 125 */ | 119 */ |
| 126 _debugOnStartUpdated: function(event) | |
| 127 { | |
| 128 var debugOnStart = /** @type {boolean} */ (event.data); | |
| 129 this._debugOnStartCheckbox.checked = debugOnStart; | |
| 130 }, | |
| 131 | |
| 132 /** | |
| 133 * @param {!WebInspector.Event} event | |
| 134 */ | |
| 135 _securityOriginAdded: function(event) | 120 _securityOriginAdded: function(event) |
| 136 { | 121 { |
| 137 this._addOrigin(/** @type {string} */ (event.data)); | 122 this._addOrigin(/** @type {string} */ (event.data)); |
| 138 }, | 123 }, |
| 139 | 124 |
| 140 /** | 125 /** |
| 141 * @param {string} securityOrigin | 126 * @param {string} securityOrigin |
| 142 */ | 127 */ |
| 143 _addOrigin: function(securityOrigin) | 128 _addOrigin: function(securityOrigin) |
| 144 { | 129 { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 167 var originHost = parsedURL.host; | 152 var originHost = parsedURL.host; |
| 168 if (!this._securityOriginHosts.has(originHost)) | 153 if (!this._securityOriginHosts.has(originHost)) |
| 169 return; | 154 return; |
| 170 this._securityOriginHosts.delete(originHost); | 155 this._securityOriginHosts.delete(originHost); |
| 171 var originWidget = this._originHostToOriginWidgetMap.get(originHost); | 156 var originWidget = this._originHostToOriginWidgetMap.get(originHost); |
| 172 if (!originWidget) | 157 if (!originWidget) |
| 173 return; | 158 return; |
| 174 originWidget.detach(); | 159 originWidget.detach(); |
| 175 }, | 160 }, |
| 176 | 161 |
| 177 _debugOnStartCheckboxChanged: function() | |
| 178 { | |
| 179 if (!this._manager) | |
| 180 return; | |
| 181 this._manager.setDebugOnStart(this._debugOnStartCheckbox.checked); | |
|
dgozman
2016/03/30 21:09:54
Remove it from manager, protocol and backend.
pfeldman
2016/03/31 05:02:31
Done.
| |
| 182 this._debugOnStartCheckbox.checked = this._manager.debugOnStart(); | |
| 183 }, | |
| 184 | |
| 185 __proto__: WebInspector.VBox.prototype | 162 __proto__: WebInspector.VBox.prototype |
| 186 } | 163 } |
| 187 | 164 |
| 188 /** | 165 /** |
| 189 * @constructor | 166 * @constructor |
| 190 * @extends {WebInspector.VBox} | 167 * @extends {WebInspector.VBox} |
| 191 * @param {!WebInspector.ServiceWorkerManager} manager | 168 * @param {!WebInspector.ServiceWorkerManager} manager |
| 192 * @param {string} originHost | 169 * @param {string} originHost |
| 193 */ | 170 */ |
| 194 WebInspector.ServiceWorkerOriginWidget = function(manager, originHost) | 171 WebInspector.ServiceWorkerOriginWidget = function(manager, originHost) |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 * @param {string} versionId | 543 * @param {string} versionId |
| 567 * @param {!Event} event | 544 * @param {!Event} event |
| 568 */ | 545 */ |
| 569 _inspectButtonClicked: function(versionId, event) | 546 _inspectButtonClicked: function(versionId, event) |
| 570 { | 547 { |
| 571 this._manager.inspectWorker(versionId); | 548 this._manager.inspectWorker(versionId); |
| 572 }, | 549 }, |
| 573 | 550 |
| 574 __proto__: WebInspector.VBox.prototype | 551 __proto__: WebInspector.VBox.prototype |
| 575 } | 552 } |
| OLD | NEW |