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

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

Issue 2122353002: [DevTools] Make resource tree model optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UI String("Show all"), WebInspector.UIString("Show all Service Workers regardless o f the origin")); 46 this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UI String("Show all"), WebInspector.UIString("Show all Service Workers regardless o f the origin"));
47 this._showAllCheckbox.inputElement.addEventListener("change", this._upda teSectionVisibility.bind(this), false); 47 this._showAllCheckbox.inputElement.addEventListener("change", this._upda teSectionVisibility.bind(this), false);
48 this._toolbar.appendToolbarItem(this._showAllCheckbox); 48 this._toolbar.appendToolbarItem(this._showAllCheckbox);
49 49
50 for (var registration of this._manager.registrations().values()) 50 for (var registration of this._manager.registrations().values())
51 this._updateRegistration(registration); 51 this._updateRegistration(registration);
52 52
53 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationUpdated, this._registrationUpdated, this); 53 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationUpdated, this._registrationUpdated, this);
54 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationDeleted, this._registrationDeleted, this); 54 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationDeleted, this._registrationDeleted, this);
55 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationErrorAdded, this._registrationErrorAdded, this); 55 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationErrorAdded, this._registrationErrorAdded, this);
56 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginAdded, this._updateSectionVisibility, this); 56 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(this._ target);
dgozman 2016/07/14 16:29:28 ditto
eostroukhov-old 2016/07/20 23:46:15 Done.
57 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginRemoved, this._updateSectionVisibility, this); 57 if (resourceTreeModel) {
58 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Ev entTypes.SecurityOriginAdded, this._updateSectionVisibility, this);
59 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Ev entTypes.SecurityOriginRemoved, this._updateSectionVisibility, this);
60 }
58 }, 61 },
59 62
60 /** 63 /**
61 * @override 64 * @override
62 * @param {!WebInspector.Target} target 65 * @param {!WebInspector.Target} target
63 */ 66 */
64 targetRemoved: function(target) 67 targetRemoved: function(target)
65 { 68 {
66 if (target !== this._target) 69 if (target !== this._target)
67 return; 70 return;
68 delete this._target; 71 delete this._target;
69 }, 72 },
70 73
71 _updateSectionVisibility: function() 74 _updateSectionVisibility: function()
72 { 75 {
73 var securityOrigins = new Set(this._target.resourceTreeModel.securityOri gins()); 76 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(this._ target);
77 var securityOrigins = new Set(resourceTreeModel ? resourceTreeModel.secu rityOrigins() : []);
74 for (var section of this._sections.values()) { 78 for (var section of this._sections.values()) {
75 var visible = this._showAllCheckbox.checked() || securityOrigins.has (section._registration.securityOrigin); 79 var visible = this._showAllCheckbox.checked() || securityOrigins.has (section._registration.securityOrigin);
76 section._section.element.classList.toggle("hidden", !visible); 80 section._section.element.classList.toggle("hidden", !visible);
77 } 81 }
78 }, 82 },
79 83
80 /** 84 /**
81 * @param {!WebInspector.Event} event 85 * @param {!WebInspector.Event} event
82 */ 86 */
83 _registrationUpdated: function(event) 87 _registrationUpdated: function(event)
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 return contentElement; 410 return contentElement;
407 }, 411 },
408 412
409 _dispose: function() 413 _dispose: function()
410 { 414 {
411 this._linkifier.dispose(); 415 this._linkifier.dispose();
412 if (this._pendingUpdate) 416 if (this._pendingUpdate)
413 clearTimeout(this._pendingUpdate); 417 clearTimeout(this._pendingUpdate);
414 } 418 }
415 } 419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698