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

Unified Diff: Source/devtools/front_end/security/SecurityPanel.js

Issue 1284413004: Keep track of per-origin security details in the Security panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix nits and align with WebInspector.TargetManager.prototype to listen for navigations. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/sdk/NetworkManager.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/security/SecurityPanel.js
diff --git a/Source/devtools/front_end/security/SecurityPanel.js b/Source/devtools/front_end/security/SecurityPanel.js
index 721e9dcda969a1e6450e11ee929d42328151be5a..85747c5796db01db75b537b39b79a85ac47ce17f 100644
--- a/Source/devtools/front_end/security/SecurityPanel.js
+++ b/Source/devtools/front_end/security/SecurityPanel.js
@@ -24,6 +24,12 @@ WebInspector.SecurityPanel = function() {
this._mainView = new WebInspector.SecurityMainView();
this.showMainView();
+ /** @type {!Map<string, !Object>} */
dgozman 2015/08/19 22:51:49 You can even create typedef for this object to che
lgarron 2015/08/19 22:56:26 Is there a way to do this in one definition, or do
+ this._origins = new Map();
+ WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._clear, this);
+ WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillReloadPage, this._clear, this);
+ WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._clear, this);
+
WebInspector.targetManager.observeTargets(this);
}
@@ -72,6 +78,40 @@ WebInspector.SecurityPanel.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _onResponseReceivedSecurityDetails: function(event)
+ {
+ var data = event.data;
+ var origin = /** @type {string} */ (data.origin);
+ var securityState = /** @type {!SecurityAgent.SecurityState} */ (data.securityState);
+
+ if (this._origins.has(origin)) {
+ var originData = this._origins.get(origin);
+ originData.securityState = this._securityStateMin(originData.securityState, securityState);
+ } else {
+ // TODO(lgarron): Store a (deduplicated) list of different security details we have seen.
+ var originData = {};
+ this._origins.set(origin, originData);
+
+ originData.securityState = securityState;
+ if (data.securityDetails)
+ originData.securityDetails = data.securityDetails;
+ }
+ },
+
+ /**
+ * @param {!SecurityAgent.SecurityState} stateA
+ * @param {!SecurityAgent.SecurityState} stateB
+ * @return {!SecurityAgent.SecurityState}
+ */
+ _securityStateMin: function(stateA, stateB)
+ {
+ var ordering = ["unknown", "insecure", "neutral", "warning", "secure"];
+ return (ordering.indexOf(stateA) < ordering.indexOf(stateB)) ? stateA : stateB;
+ },
+
+ /**
* @override
* @param {!WebInspector.Target} target
*/
@@ -82,6 +122,10 @@ WebInspector.SecurityPanel.prototype = {
this._securityModel = WebInspector.SecurityModel.fromTarget(target);
this._securityModel.addEventListener(WebInspector.SecurityModel.EventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
this._updateSecurityState(this._securityModel.securityState(), []);
+
+ this._origins.clear();
+ this._networkManager = target.networkManager;
+ this._networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDetails, this);
}
},
@@ -94,11 +138,19 @@ WebInspector.SecurityPanel.prototype = {
if (target === this._target) {
this._securityModel.removeEventListener(WebInspector.SecurityModel.EventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
delete this._securityModel;
+ this._networkManager.removeEventListener(WebInspector.NetworkManager.EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDetails, this);
+ delete this._networkManager;
delete this._target;
- this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []);
+ this._clear();
}
},
+ _clear: function()
+ {
+ this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []);
+ this._origins.clear();
+ },
+
__proto__: WebInspector.PanelWithSidebar.prototype
}
« no previous file with comments | « Source/devtools/front_end/sdk/NetworkManager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698