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

Side by Side Diff: Source/devtools/front_end/security/SecurityPanel.js

Issue 1311013007: Add model listeners in the Security panel constructor (instead of in targetAdded). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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.PanelWithSidebar} 7 * @extends {WebInspector.PanelWithSidebar}
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.SecurityPanel = function() 10 WebInspector.SecurityPanel = function()
(...skipping 16 matching lines...) Expand all
27 this._sidebarOriginSection = new WebInspector.SidebarSectionTreeElement(WebI nspector.UIString("Origins")); 27 this._sidebarOriginSection = new WebInspector.SidebarSectionTreeElement(WebI nspector.UIString("Origins"));
28 this._sidebarOriginSection.listItemElement.classList.add("security-sidebar-o rigins"); 28 this._sidebarOriginSection.listItemElement.classList.add("security-sidebar-o rigins");
29 sidebarTree.appendChild(this._sidebarOriginSection); 29 sidebarTree.appendChild(this._sidebarOriginSection);
30 30
31 this._mainView = new WebInspector.SecurityMainView(); 31 this._mainView = new WebInspector.SecurityMainView();
32 32
33 /** @type {!Map<!WebInspector.SecurityPanel.Origin, !WebInspector.SecurityPa nel.OriginState>} */ 33 /** @type {!Map<!WebInspector.SecurityPanel.Origin, !WebInspector.SecurityPa nel.OriginState>} */
34 this._origins = new Map(); 34 this._origins = new Map();
35 // TODO(lgarron): add event listeners to call _clear() once we figure out ho w to clear the panel properly (https://crbug.com/522762). 35 // TODO(lgarron): add event listeners to call _clear() once we figure out ho w to clear the panel properly (https://crbug.com/522762).
36 36
37 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.ResponseReceivedSecurityDetails, this._onRes ponseReceivedSecurityDetails, this);
38 WebInspector.targetManager.addModelListener(WebInspector.SecurityModel, WebI nspector.SecurityModel.EventTypes.SecurityStateChanged, this._onSecurityStateCha nged, this);
39
37 WebInspector.targetManager.observeTargets(this); 40 WebInspector.targetManager.observeTargets(this);
38 } 41 }
39 42
40 /** @typedef {string} */ 43 /** @typedef {string} */
41 WebInspector.SecurityPanel.Origin; 44 WebInspector.SecurityPanel.Origin;
42 45
43 /** 46 /**
44 * @typedef {Object} 47 * @typedef {Object}
45 * @property {!SecurityAgent.SecurityState} securityState - Current security sta te of the origin. 48 * @property {!SecurityAgent.SecurityState} securityState - Current security sta te of the origin.
46 * @property {?NetworkAgent.SecurityDetails} securityDetails - Security details of the origin, if available. 49 * @property {?NetworkAgent.SecurityDetails} securityDetails - Security details of the origin, if available.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 var ordering = ["unknown", "insecure", "neutral", "warning", "secure"]; 160 var ordering = ["unknown", "insecure", "neutral", "warning", "secure"];
158 return (ordering.indexOf(stateA) < ordering.indexOf(stateB)) ? stateA : stateB; 161 return (ordering.indexOf(stateA) < ordering.indexOf(stateB)) ? stateA : stateB;
159 }, 162 },
160 163
161 /** 164 /**
162 * @override 165 * @override
163 * @param {!WebInspector.Target} target 166 * @param {!WebInspector.Target} target
164 */ 167 */
165 targetAdded: function(target) 168 targetAdded: function(target)
166 { 169 {
167 if (!this._target) { 170 WebInspector.SecurityModel.fromTarget(target);
168 this._target = target;
169 this._securityModel = WebInspector.SecurityModel.fromTarget(target);
170 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
171 this._updateSecurityState(this._securityModel.securityState(), []);
172
173 this._origins.clear();
174 this._networkManager = target.networkManager;
175 this._networkManager.addEventListener(WebInspector.NetworkManager.Ev entTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDetail s, this);
176 }
177 }, 171 },
178 172
179 /** 173 /**
180 * @override 174 * @override
181 * @param {!WebInspector.Target} target 175 * @param {!WebInspector.Target} target
182 */ 176 */
183 targetRemoved: function(target) 177 targetRemoved: function(target)
184 { 178 {
185 if (target === this._target) {
186 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
187 delete this._securityModel;
188 this._networkManager.removeEventListener(WebInspector.NetworkManager .EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDet ails, this);
189 delete this._networkManager;
190 delete this._target;
191 this._clear();
192 }
193 }, 179 },
194 180
195 _clear: function() 181 _clear: function()
196 { 182 {
197 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []); 183 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []);
198 this._sidebarMainViewElement.select(); 184 this._sidebarMainViewElement.select();
199 this._sidebarOriginSection.removeChildren(); 185 this._sidebarOriginSection.removeChildren();
200 this._origins.clear(); 186 this._origins.clear();
201 }, 187 },
202 188
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 512
527 var valueDiv = row.createChild("div"); 513 var valueDiv = row.createChild("div");
528 if (value instanceof HTMLDivElement) { 514 if (value instanceof HTMLDivElement) {
529 valueDiv.appendChild(value); 515 valueDiv.appendChild(value);
530 } else { 516 } else {
531 valueDiv.textContent = value; 517 valueDiv.textContent = value;
532 } 518 }
533 } 519 }
534 } 520 }
535 521
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698