Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: Source/devtools/front_end/resources/ServiceWorkersView.js

Issue 1100403004: Add skipWaiting checkbox to ServiceWorkersView in DevTools [2/2 blink] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use annotated named function Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/resources/serviceWorkersView.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 /** 231 /**
232 * @param {!WebInspector.ServiceWorkerRegistration} registration 232 * @param {!WebInspector.ServiceWorkerRegistration} registration
233 */ 233 */
234 _updateRegistration: function(registration) 234 _updateRegistration: function(registration)
235 { 235 {
236 var swRegistrationElement = this._registrationElements.get(registration. id); 236 var swRegistrationElement = this._registrationElements.get(registration. id);
237 if (swRegistrationElement) { 237 if (swRegistrationElement) {
238 swRegistrationElement._updateRegistration(registration); 238 swRegistrationElement._updateRegistration(registration);
239 return; 239 return;
240 } 240 }
241 swRegistrationElement = new WebInspector.SWRegistrationElement(this._man ager, registration); 241 swRegistrationElement = new WebInspector.SWRegistrationElement(this._man ager, this, registration);
242 this._registrationElements.set(registration.id, swRegistrationElement); 242 this._registrationElements.set(registration.id, swRegistrationElement);
243 this._childrenListNode.appendChild(swRegistrationElement._element); 243 this._childrenListNode.appendChild(swRegistrationElement._element);
244 }, 244 },
245 245
246 /** 246 /**
247 * @param {string} registrationId 247 * @param {string} registrationId
248 */ 248 */
249 _deleteRegistration: function(registrationId) 249 _deleteRegistration: function(registrationId)
250 { 250 {
251 var swRegistrationElement = this._registrationElements.get(registrationI d); 251 var swRegistrationElement = this._registrationElements.get(registrationI d);
252 if (!swRegistrationElement) 252 if (!swRegistrationElement)
253 return; 253 return;
254 this._registrationElements.delete(registrationId); 254 this._registrationElements.delete(registrationId);
255 this._childrenListNode.removeChild(swRegistrationElement._element); 255 this._childrenListNode.removeChild(swRegistrationElement._element);
256 } 256 },
257
258 /**
259 * @return {boolean}
260 */
261 _visible: function()
262 {
263 return !!this._element.parentElement;
264 },
257 } 265 }
258 266
259 /** 267 /**
260 * @constructor 268 * @constructor
261 * @param {!WebInspector.ServiceWorkerManager} manager 269 * @param {!WebInspector.ServiceWorkerManager} manager
270 * @param {!WebInspector.ServiceWorkerOriginElement} originElement
262 * @param {!WebInspector.ServiceWorkerRegistration} registration 271 * @param {!WebInspector.ServiceWorkerRegistration} registration
263 */ 272 */
264 WebInspector.SWRegistrationElement = function(manager, registration) 273 WebInspector.SWRegistrationElement = function(manager, originElement, registrati on)
265 { 274 {
266 this._manager = manager; 275 this._manager = manager;
276 this._originElement = originElement;
267 this._registration = registration; 277 this._registration = registration;
268 this._element = createElementWithClass("div", "service-workers-registration" ); 278 this._element = createElementWithClass("div", "service-workers-registration" );
269 var headerNode = this._element.createChild("li").createChild("div", "service -workers-registration-header"); 279 var headerNode = this._element.createChild("li").createChild("div", "service -workers-registration-header");
270 this._titleNode = headerNode.createChild("div", "service-workers-registratio n-title"); 280 this._titleNode = headerNode.createChild("div", "service-workers-registratio n-title");
271 this._deleteButton = headerNode.createChild("button", "service-workers-butto n service-workers-delete-button"); 281 this._deleteButton = headerNode.createChild("button", "service-workers-butto n service-workers-delete-button");
272 this._deleteButton.addEventListener("click", this._deleteButtonClicked.bind( this), false); 282 this._deleteButton.addEventListener("click", this._deleteButtonClicked.bind( this), false);
273 this._deleteButton.title = WebInspector.UIString("Delete"); 283 this._deleteButton.title = WebInspector.UIString("Delete");
274 this._updateButton = headerNode.createChild("button", "service-workers-butto n service-workers-update-button"); 284 this._updateButton = headerNode.createChild("button", "service-workers-butto n service-workers-update-button");
275 this._updateButton.addEventListener("click", this._updateButtonClicked.bind( this), false); 285 this._updateButton.addEventListener("click", this._updateButtonClicked.bind( this), false);
276 this._updateButton.title = WebInspector.UIString("Update"); 286 this._updateButton.title = WebInspector.UIString("Update");
277 this._updateButton.disabled = true 287 this._updateButton.disabled = true
278 this._pushButton = headerNode.createChild("button", "service-workers-button service-workers-push-button"); 288 this._pushButton = headerNode.createChild("button", "service-workers-button service-workers-push-button");
279 this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this ), false); 289 this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this ), false);
280 this._pushButton.title = WebInspector.UIString("Emulate push event"); 290 this._pushButton.title = WebInspector.UIString("Emulate push event");
281 this._pushButton.disabled = true 291 this._pushButton.disabled = true
282 this._childrenListNode = this._element.createChild("ol"); 292 this._childrenListNode = this._element.createChild("ol");
293
294 this._skipWaitingCheckboxLabel = createCheckboxLabel(WebInspector.UIString(" Skip waiting"));
295 this._skipWaitingCheckboxLabel.title = WebInspector.UIString("Simulate skipW aiting()");
296 this._skipWaitingCheckboxLabel.classList.add("service-workers-skip-waiting-c heckbox-label");
297 this._skipWaitingCheckbox = this._skipWaitingCheckboxLabel.checkboxElement;
298 this._skipWaitingCheckbox.checked = true;
299 this._skipWaitingCheckbox.classList.add("service-workers-skip-waiting-checkb ox");
300 this._skipWaitingCheckbox.addEventListener("change", this._skipWaitingCheckb oxChanged.bind(this), false);
301
283 this._updateRegistration(registration); 302 this._updateRegistration(registration);
284 } 303 }
285 304
286 WebInspector.SWRegistrationElement.prototype = { 305 WebInspector.SWRegistrationElement.prototype = {
287 /** 306 /**
288 * @param {!WebInspector.ServiceWorkerRegistration} registration 307 * @param {!WebInspector.ServiceWorkerRegistration} registration
289 */ 308 */
290 _updateRegistration: function(registration) 309 _updateRegistration: function(registration)
291 { 310 {
292 this._registration = registration; 311 this._registration = registration;
293 this._titleNode.textContent = WebInspector.UIString(registration.isDelet ed ? "Scope: %s - deleted" : "Scope: %s", registration.scopeURL.asParsedURL().pa th); 312 this._titleNode.textContent = WebInspector.UIString(registration.isDelet ed ? "Scope: %s - deleted" : "Scope: %s", registration.scopeURL.asParsedURL().pa th);
294 this._updateButton.disabled = !!registration.isDeleted; 313 this._updateButton.disabled = !!registration.isDeleted;
295 this._deleteButton.disabled = !!registration.isDeleted; 314 this._deleteButton.disabled = !!registration.isDeleted;
315 this._skipWaitingCheckboxLabel.remove();
296 this._updateVersionList(); 316 this._updateVersionList();
317
318 if (this._visible() && this._skipWaitingCheckbox.checked) {
319 this._registration.versions.valuesArray().map(callSkipWaitingForInst alledVersions.bind(this));
320 }
321
322 /**
323 * @this {WebInspector.SWRegistrationElement}
324 * @param {!WebInspector.ServiceWorkerVersion} version
325 */
326 function callSkipWaitingForInstalledVersions(version)
327 {
328 if (version.isInstalled())
329 this._manager.skipWaiting(version.id);
330 }
297 }, 331 },
298 332
299 _updateVersionList: function() 333 _updateVersionList: function()
300 { 334 {
301 var fragment = createDocumentFragment(); 335 var fragment = createDocumentFragment();
302 var tableElement = createElementWithClass("div", "service-workers-versio ns-table"); 336 var tableElement = createElementWithClass("div", "service-workers-versio ns-table");
303 var versions = this._registration.versions.valuesArray(); 337 var versions = this._registration.versions.valuesArray();
304 versions = versions.filter(function(version) { 338 versions = versions.filter(function(version) {
305 return !version.isStoppedAndRedundant() || version.errorMessages.len gth; 339 return !version.isStoppedAndRedundant() || version.errorMessages.len gth;
306 }); 340 });
(...skipping 22 matching lines...) Expand all
329 }, 363 },
330 364
331 /** 365 /**
332 * @param {!Array.<!WebInspector.ServiceWorkerVersion>} versions 366 * @param {!Array.<!WebInspector.ServiceWorkerVersion>} versions
333 * @param {string} modeClass 367 * @param {string} modeClass
334 * @param {string} modeTitle 368 * @param {string} modeTitle
335 */ 369 */
336 _createVersionModeRow: function(versions, modeClass, modeTitle) 370 _createVersionModeRow: function(versions, modeClass, modeTitle)
337 { 371 {
338 var modeRowElement = createElementWithClass("div", "service-workers-vers ion-mode-row service-workers-version-mode-row-" + modeClass); 372 var modeRowElement = createElementWithClass("div", "service-workers-vers ion-mode-row service-workers-version-mode-row-" + modeClass);
339 modeRowElement.createChild("div", "service-workers-version-mode").create Child("div", "service-workers-version-mode-text").createTextChild(modeTitle); 373 var modeTitleDiv = modeRowElement.createChild("div", "service-workers-ve rsion-mode");
374 modeTitleDiv.createChild("div", "service-workers-version-mode-text").cre ateTextChild(modeTitle);
375 if (modeClass == "waiting") {
376 modeTitleDiv.appendChild(this._skipWaitingCheckboxLabel);
377 }
340 var versionsElement = modeRowElement.createChild("div", "service-workers -versions"); 378 var versionsElement = modeRowElement.createChild("div", "service-workers -versions");
341 for (var version of versions) { 379 for (var version of versions) {
342 var stateRowElement = versionsElement.createChild("div", "service-wo rkers-version-row"); 380 var stateRowElement = versionsElement.createChild("div", "service-wo rkers-version-row");
343 var statusDiv = stateRowElement.createChild("div", "service-workers- version-status"); 381 var statusDiv = stateRowElement.createChild("div", "service-workers- version-status");
344 var icon = statusDiv.createChild("div", "service-workers-version-sta tus-icon service-workers-color-" + (version.id % 10)); 382 var icon = statusDiv.createChild("div", "service-workers-version-sta tus-icon service-workers-color-" + (version.id % 10));
345 icon.title = WebInspector.UIString("ID: %s", version.id); 383 icon.title = WebInspector.UIString("ID: %s", version.id);
346 statusDiv.createChild("div", "service-workers-version-status-text"). createTextChild(version.status); 384 statusDiv.createChild("div", "service-workers-version-status-text"). createTextChild(version.status);
347 var runningStatusDiv = stateRowElement.createChild("div", "service-w orkers-version-running-status"); 385 var runningStatusDiv = stateRowElement.createChild("div", "service-w orkers-version-running-status");
348 if (version.isRunning() || version.isStarting()) { 386 if (version.isRunning() || version.isStarting()) {
349 var stopButton = runningStatusDiv.createChild("button", "service -workers-button service-workers-stop-button service-workers-version-running-stat us-button"); 387 var stopButton = runningStatusDiv.createChild("button", "service -workers-button service-workers-stop-button service-workers-version-running-stat us-button");
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 this._manager.stopWorker(versionId); 479 this._manager.stopWorker(versionId);
442 }, 480 },
443 481
444 /** 482 /**
445 * @param {string} versionId 483 * @param {string} versionId
446 * @param {!Event} event 484 * @param {!Event} event
447 */ 485 */
448 _inspectButtonClicked: function(versionId, event) 486 _inspectButtonClicked: function(versionId, event)
449 { 487 {
450 this._manager.inspectWorker(versionId); 488 this._manager.inspectWorker(versionId);
451 } 489 },
490
491 _skipWaitingCheckboxChanged: function()
492 {
493 if (!this._skipWaitingCheckbox.checked)
494 return;
495 this._registration.versions.valuesArray().map(callSkipWaitingForInstalle dVersions.bind(this));
496
497 /**
498 * @this {WebInspector.SWRegistrationElement}
499 * @param {!WebInspector.ServiceWorkerVersion} version
500 */
501 function callSkipWaitingForInstalledVersions(version)
502 {
503 if (version.isInstalled())
504 this._manager.skipWaiting(version.id);
505 }
506 },
507
508 /**
509 * @return {boolean}
510 */
511 _visible: function()
512 {
513 return this._originElement._visible();
514 },
452 } 515 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/resources/serviceWorkersView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698