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

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: Refactor the ResponseReceivedSecurityDetails dispatch method and handle it directly in the Security panel. 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
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..afcc54fe1f25012669b8680dedbba79b6cfe11c3 100644
--- a/Source/devtools/front_end/security/SecurityPanel.js
+++ b/Source/devtools/front_end/security/SecurityPanel.js
@@ -24,6 +24,10 @@ WebInspector.SecurityPanel = function() {
this._mainView = new WebInspector.SecurityMainView();
this.showMainView();
+ this._origins = {};
dgozman 2015/08/19 01:51:35 Use Map.
lgarron 2015/08/19 02:24:24 Oooh, shiny. My first time using Map in Javascript
+ WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.WillReloadPage, this._onWillReloadPage, this);
+ WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.Load, this._onLoadEventFired, this);
+
WebInspector.targetManager.observeTargets(this);
}
@@ -72,6 +76,37 @@ WebInspector.SecurityPanel.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _onResponseReceivedSecurityDetails: function(event)
+ {
+ var data = event.data;
+ var origin = data.origin;
+ var securityState = data.securityState;
+
+ if (origin in this._origins) {
+ this._origins[origin].securityState = this._securityStateMin(this._origins[origin].securityState, securityState);
+ } else {
+ // TODO(lgarron): Store a list of deduplicated different security details we have seen.
+ this._origins[origin] = {
+ securityState: securityState,
+ securityDetails: data.securityDetails
+ }
+ }
+ },
+
+ /**
+ * @param {!SecurityAgent.SecurityState} stateA
+ * @param {!SecurityAgent.SecurityState} stateB
+ * @return {!SecurityAgent.SecurityState}
+ */
+ _securityStateMin: function(stateA, stateB)
+ {
+ var ordering = ["unknown", "insecure", "http", "warning", "secure"];
+ return (ordering.indexOf(stateA) < ordering.indexOf(stateB)) ? stateA : stateB;
+ },
+
+ /**
* @override
* @param {!WebInspector.Target} target
*/
@@ -82,6 +117,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 = {};
+ this._networkManager = target.networkManager;
+ this._networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDetails, this);
}
},
@@ -94,11 +133,22 @@ 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._origins = {};
this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []);
}
},
+ _onWillReloadPage: function() {
dgozman 2015/08/19 01:51:35 { on new line everywhere.
lgarron 2015/08/19 02:24:24 I try to avoid it, but I still do this out of habi
+ this._origins = {};
+ },
+
+ _onLoadEventFired: function() {
dgozman 2015/08/19 01:51:35 You can call this |clear| and merge with previous
lgarron 2015/08/19 02:24:24 Done. Always happy to keep things DRY. :-)
+ this._origins = {};
+ },
+
__proto__: WebInspector.PanelWithSidebar.prototype
}

Powered by Google App Engine
This is Rietveld 408576698