| 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 15 matching lines...) Expand all Loading... |
| 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 var securityOriginManager = WebInspector.SecurityOriginManager.fromTarge
t(target); | 32 var securityOriginManager = WebInspector.SecurityOriginManager.fromTarge
t(target); |
| 33 if (this._manager || !target.serviceWorkerManager || !securityOriginMana
ger) | 33 if (this._manager || !target.serviceWorkerManager || !securityOriginMana
ger) |
| 34 return; | 34 return; |
| 35 this._manager = target.serviceWorkerManager; | 35 this._manager = target.serviceWorkerManager; |
| 36 this._subTargetsManager = target.subTargetsManager; |
| 36 this._securityOriginManager = securityOriginManager; | 37 this._securityOriginManager = securityOriginManager; |
| 37 | 38 |
| 38 this._toolbar.appendToolbarItem(WebInspector.NetworkConditionsSelector.c
reateOfflineToolbarCheckbox()); | 39 this._toolbar.appendToolbarItem(WebInspector.NetworkConditionsSelector.c
reateOfflineToolbarCheckbox()); |
| 39 var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString
("Update on reload"), WebInspector.UIString("Force update Service Worker on page
reload"), this._manager.forceUpdateOnReloadSetting()); | 40 var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString
("Update on reload"), WebInspector.UIString("Force update Service Worker on page
reload"), this._manager.forceUpdateOnReloadSetting()); |
| 40 this._toolbar.appendToolbarItem(forceUpdate); | 41 this._toolbar.appendToolbarItem(forceUpdate); |
| 41 var networkManager = target && WebInspector.NetworkManager.fromTarget(ta
rget); | 42 var networkManager = target && WebInspector.NetworkManager.fromTarget(ta
rget); |
| 42 if (networkManager) { | 43 if (networkManager) { |
| 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(
)); | 44 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(
)); |
| 44 this._toolbar.appendToolbarItem(fallbackToNetwork); | 45 this._toolbar.appendToolbarItem(fallbackToNetwork); |
| 45 this._toolbar.appendSpacer(); | 46 this._toolbar.appendSpacer(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 section._addError(error); | 102 section._addError(error); |
| 102 }, | 103 }, |
| 103 | 104 |
| 104 /** | 105 /** |
| 105 * @param {!WebInspector.ServiceWorkerRegistration} registration | 106 * @param {!WebInspector.ServiceWorkerRegistration} registration |
| 106 */ | 107 */ |
| 107 _updateRegistration: function(registration) | 108 _updateRegistration: function(registration) |
| 108 { | 109 { |
| 109 var section = this._sections.get(registration); | 110 var section = this._sections.get(registration); |
| 110 if (!section) { | 111 if (!section) { |
| 111 section = new WebInspector.ServiceWorkersView.Section(this._manager,
this._reportView.appendSection(""), registration); | 112 section = new WebInspector.ServiceWorkersView.Section(this._manager,
this._subTargetsManager, this._reportView.appendSection(""), registration); |
| 112 this._sections.set(registration, section); | 113 this._sections.set(registration, section); |
| 113 } | 114 } |
| 114 this._updateSectionVisibility(); | 115 this._updateSectionVisibility(); |
| 115 section._scheduleUpdate(); | 116 section._scheduleUpdate(); |
| 116 }, | 117 }, |
| 117 | 118 |
| 118 /** | 119 /** |
| 119 * @param {!WebInspector.Event} event | 120 * @param {!WebInspector.Event} event |
| 120 */ | 121 */ |
| 121 _registrationDeleted: function(event) | 122 _registrationDeleted: function(event) |
| 122 { | 123 { |
| 123 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} *
/ (event.data); | 124 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} *
/ (event.data); |
| 124 var section = this._sections.get(registration); | 125 var section = this._sections.get(registration); |
| 125 if (section) | 126 if (section) |
| 126 section._section.remove(); | 127 section._section.remove(); |
| 127 this._sections.delete(registration); | 128 this._sections.delete(registration); |
| 128 }, | 129 }, |
| 129 | 130 |
| 130 __proto__: WebInspector.VBox.prototype | 131 __proto__: WebInspector.VBox.prototype |
| 131 } | 132 } |
| 132 | 133 |
| 133 /** | 134 /** |
| 134 * @constructor | 135 * @constructor |
| 135 * @param {!WebInspector.ServiceWorkerManager} manager | 136 * @param {!WebInspector.ServiceWorkerManager} manager |
| 137 * @param {!WebInspector.SubTargetsManager} subTargetsManager |
| 136 * @param {!WebInspector.ReportView.Section} section | 138 * @param {!WebInspector.ReportView.Section} section |
| 137 * @param {!WebInspector.ServiceWorkerRegistration} registration | 139 * @param {!WebInspector.ServiceWorkerRegistration} registration |
| 138 */ | 140 */ |
| 139 WebInspector.ServiceWorkersView.Section = function(manager, section, registratio
n) | 141 WebInspector.ServiceWorkersView.Section = function(manager, subTargetsManager, s
ection, registration) |
| 140 { | 142 { |
| 141 this._manager = manager; | 143 this._manager = manager; |
| 144 this._subTargetsManager = subTargetsManager; |
| 142 this._section = section; | 145 this._section = section; |
| 143 this._registration = registration; | 146 this._registration = registration; |
| 144 | 147 |
| 145 this._toolbar = section.createToolbar(); | 148 this._toolbar = section.createToolbar(); |
| 146 this._toolbar.renderAsLinks(); | 149 this._toolbar.renderAsLinks(); |
| 147 this._updateButton = new WebInspector.ToolbarButton(WebInspector.UIString("U
pdate"), undefined, WebInspector.UIString("Update")); | 150 this._updateButton = new WebInspector.ToolbarButton(WebInspector.UIString("U
pdate"), undefined, WebInspector.UIString("Update")); |
| 148 this._updateButton.addEventListener("click", this._updateButtonClicked.bind(
this)); | 151 this._updateButton.addEventListener("click", this._updateButtonClicked.bind(
this)); |
| 149 this._toolbar.appendToolbarItem(this._updateButton); | 152 this._toolbar.appendToolbarItem(this._updateButton); |
| 150 this._pushButton = new WebInspector.ToolbarButton(WebInspector.UIString("Emu
late push event"), undefined, WebInspector.UIString("Push")); | 153 this._pushButton = new WebInspector.ToolbarButton(WebInspector.UIString("Emu
late push event"), undefined, WebInspector.UIString("Push")); |
| 151 this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this
)); | 154 this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this
)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 createLink(activeEntry, WebInspector.UIString("start"), this._st
artButtonClicked.bind(this)); | 230 createLink(activeEntry, WebInspector.UIString("start"), this._st
artButtonClicked.bind(this)); |
| 228 } | 231 } |
| 229 | 232 |
| 230 var clientsList = this._wrapWidget(this._section.appendField(WebInsp
ector.UIString("Clients"))); | 233 var clientsList = this._wrapWidget(this._section.appendField(WebInsp
ector.UIString("Clients"))); |
| 231 clientsList.removeChildren(); | 234 clientsList.removeChildren(); |
| 232 this._section.setFieldVisible(WebInspector.UIString("Clients"), acti
ve.controlledClients.length); | 235 this._section.setFieldVisible(WebInspector.UIString("Clients"), acti
ve.controlledClients.length); |
| 233 for (var client of active.controlledClients) { | 236 for (var client of active.controlledClients) { |
| 234 var clientLabelText = clientsList.createChild("div", "service-wo
rker-client"); | 237 var clientLabelText = clientsList.createChild("div", "service-wo
rker-client"); |
| 235 if (this._clientInfoCache.has(client)) | 238 if (this._clientInfoCache.has(client)) |
| 236 this._updateClientInfo(clientLabelText, /** @type {!WebInspe
ctor.TargetInfo} */(this._clientInfoCache.get(client))); | 239 this._updateClientInfo(clientLabelText, /** @type {!WebInspe
ctor.TargetInfo} */(this._clientInfoCache.get(client))); |
| 237 this._manager.getTargetInfo(client, this._onClientInfo.bind(this
, clientLabelText)); | 240 this._subTargetsManager.getTargetInfo(client, this._onClientInfo
.bind(this, clientLabelText)); |
| 238 } | 241 } |
| 239 } | 242 } |
| 240 | 243 |
| 241 if (waiting) { | 244 if (waiting) { |
| 242 var waitingEntry = versionsStack.createChild("div", "service-worker-
version"); | 245 var waitingEntry = versionsStack.createChild("div", "service-worker-
version"); |
| 243 waitingEntry.createChild("div", "service-worker-waiting-circle"); | 246 waitingEntry.createChild("div", "service-worker-waiting-circle"); |
| 244 waitingEntry.createChild("span").textContent = WebInspector.UIString
("#%s waiting to activate", waiting.id); | 247 waitingEntry.createChild("span").textContent = WebInspector.UIString
("#%s waiting to activate", waiting.id); |
| 245 createLink(waitingEntry, WebInspector.UIString("skipWaiting"), this.
_skipButtonClicked.bind(this)); | 248 createLink(waitingEntry, WebInspector.UIString("skipWaiting"), this.
_skipButtonClicked.bind(this)); |
| 246 waitingEntry.createChild("div", "service-worker-subtitle").textConte
nt = new Date(waiting.scriptResponseTime * 1000).toLocaleString(); | 249 waitingEntry.createChild("div", "service-worker-subtitle").textConte
nt = new Date(waiting.scriptResponseTime * 1000).toLocaleString(); |
| 247 if (!this._manager.targetForVersionId(waiting.id) && (waiting.isRunn
ing() || waiting.isStarting())) | 250 if (!this._manager.targetForVersionId(waiting.id) && (waiting.isRunn
ing() || waiting.isStarting())) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 this._clientInfoCache.set(targetInfo.id, targetInfo); | 330 this._clientInfoCache.set(targetInfo.id, targetInfo); |
| 328 this._updateClientInfo(element, targetInfo); | 331 this._updateClientInfo(element, targetInfo); |
| 329 }, | 332 }, |
| 330 | 333 |
| 331 /** | 334 /** |
| 332 * @param {!Element} element | 335 * @param {!Element} element |
| 333 * @param {!WebInspector.TargetInfo} targetInfo | 336 * @param {!WebInspector.TargetInfo} targetInfo |
| 334 */ | 337 */ |
| 335 _updateClientInfo: function(element, targetInfo) | 338 _updateClientInfo: function(element, targetInfo) |
| 336 { | 339 { |
| 337 if (!(targetInfo.isWebContents() || targetInfo.isFrame())) { | 340 if (targetInfo.type !== TargetAgent.TargetType.Page && targetInfo.type !
== TargetAgent.TargetType.Frame) { |
| 338 element.createTextChild(WebInspector.UIString("Worker: %s", targetIn
fo.url)); | 341 element.createTextChild(WebInspector.UIString("Worker: %s", targetIn
fo.url)); |
| 339 return; | 342 return; |
| 340 } | 343 } |
| 341 element.removeChildren(); | 344 element.removeChildren(); |
| 342 element.createTextChild(targetInfo.url); | 345 element.createTextChild(targetInfo.url); |
| 343 var focusLabel = element.createChild("label", "link"); | 346 var focusLabel = element.createChild("label", "link"); |
| 344 focusLabel.createTextChild("focus"); | 347 focusLabel.createTextChild("focus"); |
| 345 focusLabel.addEventListener("click", this._activateTarget.bind(this, tar
getInfo.id), true); | 348 focusLabel.addEventListener("click", this._activateTarget.bind(this, tar
getInfo.id), true); |
| 346 }, | 349 }, |
| 347 | 350 |
| 348 /** | 351 /** |
| 349 * @param {string} targetId | 352 * @param {string} targetId |
| 350 */ | 353 */ |
| 351 _activateTarget: function(targetId) | 354 _activateTarget: function(targetId) |
| 352 { | 355 { |
| 353 this._manager.activateTarget(targetId); | 356 this._subTargetsManager.activateTarget(targetId); |
| 354 }, | 357 }, |
| 355 | 358 |
| 356 _startButtonClicked: function() | 359 _startButtonClicked: function() |
| 357 { | 360 { |
| 358 this._manager.startWorker(this._registration.scopeURL); | 361 this._manager.startWorker(this._registration.scopeURL); |
| 359 }, | 362 }, |
| 360 | 363 |
| 361 _skipButtonClicked: function() | 364 _skipButtonClicked: function() |
| 362 { | 365 { |
| 363 this._manager.skipWaiting(this._registration.scopeURL); | 366 this._manager.skipWaiting(this._registration.scopeURL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 return contentElement; | 411 return contentElement; |
| 409 }, | 412 }, |
| 410 | 413 |
| 411 _dispose: function() | 414 _dispose: function() |
| 412 { | 415 { |
| 413 this._linkifier.dispose(); | 416 this._linkifier.dispose(); |
| 414 if (this._pendingUpdate) | 417 if (this._pendingUpdate) |
| 415 clearTimeout(this._pendingUpdate); | 418 clearTimeout(this._pendingUpdate); |
| 416 } | 419 } |
| 417 } | 420 } |
| OLD | NEW |