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

Side by Side 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 unified diff | Download patch
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 WebInspector.PanelWithSidebar.call(this, "security"); 11 WebInspector.PanelWithSidebar.call(this, "security");
12 this.registerRequiredCSS("security/securityPanel.css"); 12 this.registerRequiredCSS("security/securityPanel.css");
13 this.registerRequiredCSS("security/lockIcon.css"); 13 this.registerRequiredCSS("security/lockIcon.css");
14 14
15 var sidebarTree = new TreeOutlineInShadow(); 15 var sidebarTree = new TreeOutlineInShadow();
16 sidebarTree.element.classList.add("sidebar-tree"); 16 sidebarTree.element.classList.add("sidebar-tree");
17 this.panelSidebarElement().appendChild(sidebarTree.element); 17 this.panelSidebarElement().appendChild(sidebarTree.element);
18 sidebarTree.registerRequiredCSS("security/lockIcon.css"); 18 sidebarTree.registerRequiredCSS("security/lockIcon.css");
19 this.setDefaultFocusedElement(sidebarTree.element); 19 this.setDefaultFocusedElement(sidebarTree.element);
20 20
21 this._sidebarMainViewElement = new WebInspector.SecurityMainViewSidebarTreeE lement(this); 21 this._sidebarMainViewElement = new WebInspector.SecurityMainViewSidebarTreeE lement(this);
22 sidebarTree.appendChild(this._sidebarMainViewElement); 22 sidebarTree.appendChild(this._sidebarMainViewElement);
23 23
24 this._mainView = new WebInspector.SecurityMainView(); 24 this._mainView = new WebInspector.SecurityMainView();
25 this.showMainView(); 25 this.showMainView();
26 26
27 this._origins = new Map();
dgozman 2015/08/19 20:22:30 Please annotate with type.
lgarron 2015/08/19 22:51:33 Done.
28 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.WillReloadPage, this._clear, this);
29 WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.E ventTypes.MainFrameNavigated, this._clear, this);
30
27 WebInspector.targetManager.observeTargets(this); 31 WebInspector.targetManager.observeTargets(this);
28 } 32 }
29 33
30 WebInspector.SecurityPanel.prototype = { 34 WebInspector.SecurityPanel.prototype = {
31 35
32 /** 36 /**
33 * @param {!SecurityAgent.SecurityState} newSecurityState 37 * @param {!SecurityAgent.SecurityState} newSecurityState
34 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations 38 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations
35 */ 39 */
36 _updateSecurityState: function(newSecurityState, explanations) 40 _updateSecurityState: function(newSecurityState, explanations)
(...skipping 28 matching lines...) Expand all
65 if (this._visibleView) 69 if (this._visibleView)
66 this._visibleView.detach(); 70 this._visibleView.detach();
67 71
68 this._visibleView = view; 72 this._visibleView = view;
69 73
70 if (view) 74 if (view)
71 this.splitWidget().setMainWidget(view); 75 this.splitWidget().setMainWidget(view);
72 }, 76 },
73 77
74 /** 78 /**
79 * @param {!WebInspector.Event} event
80 */
81 _onResponseReceivedSecurityDetails: function(event)
82 {
83 var data = event.data;
84 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.
85 var securityState = data.securityState;
86
87 if (this._origins.has(origin)) {
88 var originData = this._origins.get(origin);
89 originData.securityState = this._securityStateMin(originData.securit yState, securityState);
90 } else {
91 // TODO(lgarron): Store a (deduplicated) list of different security details we have seen.
92 var originData = {};
93 this._origins.set(origin, originData);
94
95 originData.securityState = securityState;
96 if (data.securityDetails) {
dgozman 2015/08/19 20:22:30 nit: no {} for one-liners
lgarron 2015/08/19 22:51:33 Done.
97 originData.securityDetails = data.securityDetails;
98 }
99 }
100 },
101
102 /**
103 * @param {!SecurityAgent.SecurityState} stateA
104 * @param {!SecurityAgent.SecurityState} stateB
105 * @return {!SecurityAgent.SecurityState}
106 */
107 _securityStateMin: function(stateA, stateB)
108 {
109 var ordering = ["unknown", "insecure", "http", "warning", "secure"];
110 return (ordering.indexOf(stateA) < ordering.indexOf(stateB)) ? stateA : stateB;
111 },
112
113 /**
75 * @override 114 * @override
76 * @param {!WebInspector.Target} target 115 * @param {!WebInspector.Target} target
77 */ 116 */
78 targetAdded: function(target) 117 targetAdded: function(target)
79 { 118 {
80 if (!this._target) { 119 if (!this._target) {
81 this._target = target; 120 this._target = target;
82 this._securityModel = WebInspector.SecurityModel.fromTarget(target); 121 this._securityModel = WebInspector.SecurityModel.fromTarget(target);
83 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); 122 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
84 this._updateSecurityState(this._securityModel.securityState(), []); 123 this._updateSecurityState(this._securityModel.securityState(), []);
124
125 this._origins.clear();
126 this._networkManager = target.networkManager;
127 this._networkManager.addEventListener(WebInspector.NetworkManager.Ev entTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDetail s, this);
85 } 128 }
86 }, 129 },
87 130
88 /** 131 /**
89 * @override 132 * @override
90 * @param {!WebInspector.Target} target 133 * @param {!WebInspector.Target} target
91 */ 134 */
92 targetRemoved: function(target) 135 targetRemoved: function(target)
93 { 136 {
94 if (target === this._target) { 137 if (target === this._target) {
95 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); 138 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
96 delete this._securityModel; 139 delete this._securityModel;
140 this._networkManager.removeEventListener(WebInspector.NetworkManager .EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDet ails, this);
141 delete this._networkManager;
97 delete this._target; 142 delete this._target;
98 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []); 143 this._clear();
99 } 144 }
100 }, 145 },
101 146
147 _clear: function()
148 {
149 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []);
150 this._origins.clear();
151 },
152
102 __proto__: WebInspector.PanelWithSidebar.prototype 153 __proto__: WebInspector.PanelWithSidebar.prototype
103 } 154 }
104 155
105 /** 156 /**
106 * @return {!WebInspector.SecurityPanel} 157 * @return {!WebInspector.SecurityPanel}
107 */ 158 */
108 WebInspector.SecurityPanel._instance = function() 159 WebInspector.SecurityPanel._instance = function()
109 { 160 {
110 if (!WebInspector.SecurityPanel._instanceObject) 161 if (!WebInspector.SecurityPanel._instanceObject)
111 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa nel(); 162 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa nel();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 this._lockIcon.classList.add("lock-icon-" + this._securityState); 275 this._lockIcon.classList.add("lock-icon-" + this._securityState);
225 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState); 276 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState);
226 277
227 this._securityExplanations.removeChildren(); 278 this._securityExplanations.removeChildren();
228 for (var explanation of explanations) 279 for (var explanation of explanations)
229 this._addExplanation(explanation); 280 this._addExplanation(explanation);
230 }, 281 },
231 282
232 __proto__: WebInspector.VBox.prototype 283 __proto__: WebInspector.VBox.prototype
233 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698