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

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

Issue 1938183003: Security panel: add listeners only to the added target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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()
11 { 11 {
12 WebInspector.PanelWithSidebar.call(this, "security"); 12 WebInspector.PanelWithSidebar.call(this, "security");
13 13
14 this._mainView = new WebInspector.SecurityMainView(this); 14 this._mainView = new WebInspector.SecurityMainView(this);
15 15
16 this._sidebarMainViewElement = new WebInspector.SecurityPanelSidebarTreeElem ent(WebInspector.UIString("Overview"), this._setVisibleView.bind(this, this._mai nView), "security-main-view-sidebar-tree-item", "lock-icon"); 16 this._sidebarMainViewElement = new WebInspector.SecurityPanelSidebarTreeElem ent(WebInspector.UIString("Overview"), this._setVisibleView.bind(this, this._mai nView), "security-main-view-sidebar-tree-item", "lock-icon");
17 this._sidebarTree = new WebInspector.SecurityPanelSidebarTree(this._sidebarM ainViewElement, this.showOrigin.bind(this)); 17 this._sidebarTree = new WebInspector.SecurityPanelSidebarTree(this._sidebarM ainViewElement, this.showOrigin.bind(this));
18 this.panelSidebarElement().appendChild(this._sidebarTree.element); 18 this.panelSidebarElement().appendChild(this._sidebarTree.element);
19 this.setDefaultFocusedElement(this._sidebarTree.element); 19 this.setDefaultFocusedElement(this._sidebarTree.element);
20 20
21 /** @type {!Map<!NetworkAgent.LoaderId, !WebInspector.NetworkRequest>} */ 21 /** @type {!Map<!NetworkAgent.LoaderId, !WebInspector.NetworkRequest>} */
22 this._lastResponseReceivedForLoaderId = new Map(); 22 this._lastResponseReceivedForLoaderId = new Map();
23 23
24 /** @type {!Map<!WebInspector.SecurityPanel.Origin, !WebInspector.SecurityPa nel.OriginState>} */ 24 /** @type {!Map<!WebInspector.SecurityPanel.Origin, !WebInspector.SecurityPa nel.OriginState>} */
25 this._origins = new Map(); 25 this._origins = new Map();
26 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._onMainFrameN avigated, this);
27 26
28 /** @type {!Map<!WebInspector.NetworkLogView.MixedContentFilterValues, numbe r>} */ 27 /** @type {!Map<!WebInspector.NetworkLogView.MixedContentFilterValues, numbe r>} */
29 this._filterRequestCounts = new Map(); 28 this._filterRequestCounts = new Map();
30 29
31 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e); 30 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e);
32
33 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.ResponseReceived, this._onResponseReceived, this);
34 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.RequestFinished, this._onRequestFinished, th is);
35 WebInspector.targetManager.addModelListener(WebInspector.SecurityModel, WebI nspector.SecurityModel.EventTypes.SecurityStateChanged, this._onSecurityStateCha nged, this);
36 } 31 }
37 32
38 /** @typedef {string} */ 33 /** @typedef {string} */
39 WebInspector.SecurityPanel.Origin; 34 WebInspector.SecurityPanel.Origin;
40 35
41 /** 36 /**
42 * @typedef {Object} 37 * @typedef {Object}
43 * @property {!SecurityAgent.SecurityState} securityState - Current security sta te of the origin. 38 * @property {!SecurityAgent.SecurityState} securityState - Current security sta te of the origin.
44 * @property {?NetworkAgent.SecurityDetails} securityDetails - Security details of the origin, if available. 39 * @property {?NetworkAgent.SecurityDetails} securityDetails - Security details of the origin, if available.
45 * @property {?Promise<!NetworkAgent.CertificateDetails>} certificateDetailsProm ise - Certificate details of the origin. Only available if securityDetails are a vailable. 40 * @property {?Promise<!NetworkAgent.CertificateDetails>} certificateDetailsProm ise - Certificate details of the origin. Only available if securityDetails are a vailable.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 { 236 {
242 return WebInspector.SecurityModel.SecurityStateComparator(stateA, stateB ) < 0 ? stateA : stateB; 237 return WebInspector.SecurityModel.SecurityStateComparator(stateA, stateB ) < 0 ? stateA : stateB;
243 }, 238 },
244 239
245 /** 240 /**
246 * @override 241 * @override
247 * @param {!WebInspector.Target} target 242 * @param {!WebInspector.Target} target
248 */ 243 */
249 targetAdded: function(target) 244 targetAdded: function(target)
250 { 245 {
251 WebInspector.SecurityModel.fromTarget(target); 246 if (this._target)
247 return;
248
249 this._target = target;
250
251 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel .EventTypes.MainFrameNavigated, this._onMainFrameNavigated, this);
252 target.networkManager.addEventListener(WebInspector.NetworkManager.Event Types.ResponseReceived, this._onResponseReceived, this);
253 target.networkManager.addEventListener(WebInspector.NetworkManager.Event Types.RequestFinished, this._onRequestFinished, this);
254
255 var securityModel = WebInspector.SecurityModel.fromTarget(target);
256 securityModel.addEventListener(WebInspector.SecurityModel.EventTypes.Sec urityStateChanged, this._onSecurityStateChanged, this);
252 }, 257 },
253 258
254 /** 259 /**
255 * @override 260 * @override
256 * @param {!WebInspector.Target} target 261 * @param {!WebInspector.Target} target
257 */ 262 */
258 targetRemoved: function(target) 263 targetRemoved: function(target)
259 { 264 {
260 }, 265 },
261 266
262 _clearOrigins: function() 267 _clearOrigins: function()
263 { 268 {
264 this.selectAndSwitchToMainView(); 269 this.selectAndSwitchToMainView();
265 this._sidebarTree.clearOrigins(); 270 this._sidebarTree.clearOrigins();
266 this._origins.clear(); 271 this._origins.clear();
267 this._lastResponseReceivedForLoaderId.clear(); 272 this._lastResponseReceivedForLoaderId.clear();
268 this._filterRequestCounts.clear(); 273 this._filterRequestCounts.clear();
269 }, 274 },
270 275
271 /** 276 /**
272 * @param {!WebInspector.Event} event 277 * @param {!WebInspector.Event} event
273 */ 278 */
274 _onMainFrameNavigated: function(event) { 279 _onMainFrameNavigated: function(event) {
275 280
276 var frame = /** type {!PageAgent.Frame}*/ (event.data); 281 var frame = /** type {!PageAgent.Frame}*/ (event.data);
277 var request = this._lastResponseReceivedForLoaderId.get(frame.loaderId); 282 var request = this._lastResponseReceivedForLoaderId.get(frame.loaderId);
278 this._clearOrigins(); 283 this._clearOrigins();
279 284
280 var origin = WebInspector.ParsedURL.splitURLIntoPathComponents(request.u rl)[0];
281 this._sidebarTree.setMainOrigin(origin);
282 285
283 if (request) 286 if (request) {
287 var origin = WebInspector.ParsedURL.splitURLIntoPathComponents(reque st.url)[0];
288 this._sidebarTree.setMainOrigin(origin);
284 this._processRequest(request); 289 this._processRequest(request);
290 }
285 }, 291 },
286 292
287 __proto__: WebInspector.PanelWithSidebar.prototype 293 __proto__: WebInspector.PanelWithSidebar.prototype
288 } 294 }
289 295
290 /** 296 /**
291 * @return {!WebInspector.SecurityPanel} 297 * @return {!WebInspector.SecurityPanel}
292 */ 298 */
293 WebInspector.SecurityPanel._instance = function() 299 WebInspector.SecurityPanel._instance = function()
294 { 300 {
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 row.createChild("div").textContent = key; 937 row.createChild("div").textContent = key;
932 938
933 var valueDiv = row.createChild("div"); 939 var valueDiv = row.createChild("div");
934 if (typeof value === "string") { 940 if (typeof value === "string") {
935 valueDiv.textContent = value; 941 valueDiv.textContent = value;
936 } else { 942 } else {
937 valueDiv.appendChild(value); 943 valueDiv.appendChild(value);
938 } 944 }
939 } 945 }
940 } 946 }
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