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

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: 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 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 = {};
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
28 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.WillReloadPage, this._onWillReloadPage, this);
29 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.Load, this._onLoadEventFired, 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;
85 var securityState = data.securityState;
86
87 if (origin in this._origins) {
88 this._origins[origin].securityState = this._securityStateMin(this._o rigins[origin].securityState, securityState);
89 } else {
90 // TODO(lgarron): Store a list of deduplicated different security de tails we have seen.
91 this._origins[origin] = {
92 securityState: securityState,
93 securityDetails: data.securityDetails
94 }
95 }
96 },
97
98 /**
99 * @param {!SecurityAgent.SecurityState} stateA
100 * @param {!SecurityAgent.SecurityState} stateB
101 * @return {!SecurityAgent.SecurityState}
102 */
103 _securityStateMin: function(stateA, stateB)
104 {
105 var ordering = ["unknown", "insecure", "http", "warning", "secure"];
106 return (ordering.indexOf(stateA) < ordering.indexOf(stateB)) ? stateA : stateB;
107 },
108
109 /**
75 * @override 110 * @override
76 * @param {!WebInspector.Target} target 111 * @param {!WebInspector.Target} target
77 */ 112 */
78 targetAdded: function(target) 113 targetAdded: function(target)
79 { 114 {
80 if (!this._target) { 115 if (!this._target) {
81 this._target = target; 116 this._target = target;
82 this._securityModel = WebInspector.SecurityModel.fromTarget(target); 117 this._securityModel = WebInspector.SecurityModel.fromTarget(target);
83 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); 118 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
84 this._updateSecurityState(this._securityModel.securityState(), []); 119 this._updateSecurityState(this._securityModel.securityState(), []);
120
121 this._origins = {};
122 this._networkManager = target.networkManager;
123 this._networkManager.addEventListener(WebInspector.NetworkManager.Ev entTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDetail s, this);
85 } 124 }
86 }, 125 },
87 126
88 /** 127 /**
89 * @override 128 * @override
90 * @param {!WebInspector.Target} target 129 * @param {!WebInspector.Target} target
91 */ 130 */
92 targetRemoved: function(target) 131 targetRemoved: function(target)
93 { 132 {
94 if (target === this._target) { 133 if (target === this._target) {
95 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); 134 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
96 delete this._securityModel; 135 delete this._securityModel;
136 this._networkManager.removeEventListener(WebInspector.NetworkManager .EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDet ails, this);
137 delete this._networkManager;
97 delete this._target; 138 delete this._target;
139 this._origins = {};
98 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []); 140 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []);
99 } 141 }
100 }, 142 },
101 143
144 _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
145 this._origins = {};
146 },
147
148 _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. :-)
149 this._origins = {};
150 },
151
102 __proto__: WebInspector.PanelWithSidebar.prototype 152 __proto__: WebInspector.PanelWithSidebar.prototype
103 } 153 }
104 154
105 /** 155 /**
106 * @return {!WebInspector.SecurityPanel} 156 * @return {!WebInspector.SecurityPanel}
107 */ 157 */
108 WebInspector.SecurityPanel._instance = function() 158 WebInspector.SecurityPanel._instance = function()
109 { 159 {
110 if (!WebInspector.SecurityPanel._instanceObject) 160 if (!WebInspector.SecurityPanel._instanceObject)
111 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa nel(); 161 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); 274 this._lockIcon.classList.add("lock-icon-" + this._securityState);
225 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState); 275 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState);
226 276
227 this._securityExplanations.removeChildren(); 277 this._securityExplanations.removeChildren();
228 for (var explanation of explanations) 278 for (var explanation of explanations)
229 this._addExplanation(explanation); 279 this._addExplanation(explanation);
230 }, 280 },
231 281
232 __proto__: WebInspector.VBox.prototype 282 __proto__: WebInspector.VBox.prototype
233 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698