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

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: Incorporate dgozman@'s suggestions and use MainFrameNavigated instead of LoadEventFired. 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..686c962a04196fa6728233fa148d32c176984776 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 = new Map();
dgozman 2015/08/19 20:22:30 Please annotate with type.
lgarron 2015/08/19 22:51:33 Done.
+ WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.WillReloadPage, this._clear, this);
+ WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._clear, this);
+
WebInspector.targetManager.observeTargets(this);
}
@@ -72,6 +76,41 @@ WebInspector.SecurityPanel.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _onResponseReceivedSecurityDetails: function(event)
+ {
+ var data = event.data;
+ var origin = data.origin;
dgozman 2015/08/19 20:22:30 This (and securityState) will need a cast.
lgarron 2015/08/19 22:51:33 Done.
+ var 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) {
dgozman 2015/08/19 20:22:30 nit: no {} for one-liners
lgarron 2015/08/19 22:51:33 Done.
+ originData.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 +121,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 +137,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
}

Powered by Google App Engine
This is Rietveld 408576698