| 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 * @implements {SDK.SDKModelObserver<!SDK.ServiceWorkerManager>} | 5 * @implements {SDK.SDKModelObserver<!SDK.ServiceWorkerManager>} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Resources.ServiceWorkersView = class extends UI.VBox { | 8 Resources.ServiceWorkersView = class extends UI.VBox { |
| 9 constructor() { | 9 constructor() { |
| 10 super(true); | 10 super(true); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 280 |
| 281 var clientsList = this._wrapWidget(this._section.appendField(Common.UIStri
ng('Clients'))); | 281 var clientsList = this._wrapWidget(this._section.appendField(Common.UIStri
ng('Clients'))); |
| 282 clientsList.removeChildren(); | 282 clientsList.removeChildren(); |
| 283 this._section.setFieldVisible(Common.UIString('Clients'), active.controlle
dClients.length); | 283 this._section.setFieldVisible(Common.UIString('Clients'), active.controlle
dClients.length); |
| 284 for (var client of active.controlledClients) { | 284 for (var client of active.controlledClients) { |
| 285 var clientLabelText = clientsList.createChild('div', 'service-worker-cli
ent'); | 285 var clientLabelText = clientsList.createChild('div', 'service-worker-cli
ent'); |
| 286 if (this._clientInfoCache.has(client)) { | 286 if (this._clientInfoCache.has(client)) { |
| 287 this._updateClientInfo( | 287 this._updateClientInfo( |
| 288 clientLabelText, /** @type {!Protocol.Target.TargetInfo} */ (this.
_clientInfoCache.get(client))); | 288 clientLabelText, /** @type {!Protocol.Target.TargetInfo} */ (this.
_clientInfoCache.get(client))); |
| 289 } | 289 } |
| 290 this._manager.target().targetAgent().getTargetInfo(client, this._onClien
tInfo.bind(this, clientLabelText)); | 290 this._manager.controlledClientInfo(client).then(this._onClientInfo.bind(
this, clientLabelText)); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 if (waiting) { | 294 if (waiting) { |
| 295 var waitingEntry = versionsStack.createChild('div', 'service-worker-versio
n'); | 295 var waitingEntry = versionsStack.createChild('div', 'service-worker-versio
n'); |
| 296 waitingEntry.createChild('div', 'service-worker-waiting-circle'); | 296 waitingEntry.createChild('div', 'service-worker-waiting-circle'); |
| 297 waitingEntry.createChild('span').textContent = Common.UIString('#%s waitin
g to activate', waiting.id); | 297 waitingEntry.createChild('span').textContent = Common.UIString('#%s waitin
g to activate', waiting.id); |
| 298 createLink(waitingEntry, Common.UIString('skipWaiting'), this._skipButtonC
licked.bind(this)); | 298 createLink(waitingEntry, Common.UIString('skipWaiting'), this._skipButtonC
licked.bind(this)); |
| 299 waitingEntry.createChild('div', 'service-worker-subtitle').textContent = | 299 waitingEntry.createChild('div', 'service-worker-subtitle').textContent = |
| 300 Common.UIString('Received %s', new Date(waiting.scriptResponseTime * 1
000).toLocaleString()); | 300 Common.UIString('Received %s', new Date(waiting.scriptResponseTime * 1
000).toLocaleString()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 * @param {!Common.Event} event | 375 * @param {!Common.Event} event |
| 376 */ | 376 */ |
| 377 _syncButtonClicked(event) { | 377 _syncButtonClicked(event) { |
| 378 var tag = 'test-tag-from-devtools'; | 378 var tag = 'test-tag-from-devtools'; |
| 379 var lastChance = true; | 379 var lastChance = true; |
| 380 this._manager.dispatchSyncEvent(this._registration.id, tag, lastChance); | 380 this._manager.dispatchSyncEvent(this._registration.id, tag, lastChance); |
| 381 } | 381 } |
| 382 | 382 |
| 383 /** | 383 /** |
| 384 * @param {!Element} element | 384 * @param {!Element} element |
| 385 * @param {?Protocol.Error} error | |
| 386 * @param {?Protocol.Target.TargetInfo} targetInfo | 385 * @param {?Protocol.Target.TargetInfo} targetInfo |
| 387 */ | 386 */ |
| 388 _onClientInfo(element, error, targetInfo) { | 387 _onClientInfo(element, targetInfo) { |
| 389 if (error || !targetInfo) | 388 if (!targetInfo) |
| 390 return; | 389 return; |
| 391 this._clientInfoCache.set(targetInfo.targetId, targetInfo); | 390 this._clientInfoCache.set(targetInfo.targetId, targetInfo); |
| 392 this._updateClientInfo(element, targetInfo); | 391 this._updateClientInfo(element, targetInfo); |
| 393 } | 392 } |
| 394 | 393 |
| 395 /** | 394 /** |
| 396 * @param {!Element} element | 395 * @param {!Element} element |
| 397 * @param {!Protocol.Target.TargetInfo} targetInfo | 396 * @param {!Protocol.Target.TargetInfo} targetInfo |
| 398 */ | 397 */ |
| 399 _updateClientInfo(element, targetInfo) { | 398 _updateClientInfo(element, targetInfo) { |
| 400 if (targetInfo.type !== 'page' && targetInfo.type === 'iframe') { | 399 if (targetInfo.type !== 'page' && targetInfo.type === 'iframe') { |
| 401 element.createTextChild(Common.UIString('Worker: %s', targetInfo.url)); | 400 element.createTextChild(Common.UIString('Worker: %s', targetInfo.url)); |
| 402 return; | 401 return; |
| 403 } | 402 } |
| 404 element.removeChildren(); | 403 element.removeChildren(); |
| 405 element.createTextChild(targetInfo.url); | 404 element.createTextChild(targetInfo.url); |
| 406 var focusLabel = element.createChild('label', 'link'); | 405 var focusLabel = element.createChild('label', 'link'); |
| 407 focusLabel.createTextChild('focus'); | 406 focusLabel.createTextChild('focus'); |
| 408 focusLabel.addEventListener('click', this._activateTarget.bind(this, targetI
nfo.targetId), true); | 407 focusLabel.addEventListener('click', () => this._manager.activateControlledC
lient(targetInfo.targetId), true); |
| 409 } | |
| 410 | |
| 411 /** | |
| 412 * @param {string} targetId | |
| 413 */ | |
| 414 _activateTarget(targetId) { | |
| 415 this._manager.target().targetAgent().activateTarget(targetId); | |
| 416 } | 408 } |
| 417 | 409 |
| 418 _startButtonClicked() { | 410 _startButtonClicked() { |
| 419 this._manager.startWorker(this._registration.scopeURL); | 411 this._manager.startWorker(this._registration.scopeURL); |
| 420 } | 412 } |
| 421 | 413 |
| 422 _skipButtonClicked() { | 414 _skipButtonClicked() { |
| 423 this._manager.skipWaiting(this._registration.scopeURL); | 415 this._manager.skipWaiting(this._registration.scopeURL); |
| 424 } | 416 } |
| 425 | 417 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 456 * @return {!Element} | 448 * @return {!Element} |
| 457 */ | 449 */ |
| 458 _wrapWidget(container) { | 450 _wrapWidget(container) { |
| 459 var shadowRoot = UI.createShadowRootWithCoreStyles(container); | 451 var shadowRoot = UI.createShadowRootWithCoreStyles(container); |
| 460 UI.appendStyle(shadowRoot, 'resources/serviceWorkersView.css'); | 452 UI.appendStyle(shadowRoot, 'resources/serviceWorkersView.css'); |
| 461 var contentElement = createElement('div'); | 453 var contentElement = createElement('div'); |
| 462 shadowRoot.appendChild(contentElement); | 454 shadowRoot.appendChild(contentElement); |
| 463 return contentElement; | 455 return contentElement; |
| 464 } | 456 } |
| 465 }; | 457 }; |
| OLD | NEW |