Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 { | |
| 11 WebInspector.PanelWithSidebar.call(this, "security"); | 12 WebInspector.PanelWithSidebar.call(this, "security"); |
| 12 this.registerRequiredCSS("security/securityPanel.css"); | 13 this.registerRequiredCSS("security/securityPanel.css"); |
| 13 this.registerRequiredCSS("security/lockIcon.css"); | 14 this.registerRequiredCSS("security/lockIcon.css"); |
| 14 | 15 |
| 15 var sidebarTree = new TreeOutlineInShadow(); | 16 var sidebarTree = new TreeOutlineInShadow(); |
| 16 sidebarTree.element.classList.add("sidebar-tree"); | 17 sidebarTree.element.classList.add("sidebar-tree"); |
| 17 this.panelSidebarElement().appendChild(sidebarTree.element); | 18 this.panelSidebarElement().appendChild(sidebarTree.element); |
| 19 sidebarTree.registerRequiredCSS("security/sidebar.css"); | |
| 18 sidebarTree.registerRequiredCSS("security/lockIcon.css"); | 20 sidebarTree.registerRequiredCSS("security/lockIcon.css"); |
| 19 this.setDefaultFocusedElement(sidebarTree.element); | 21 this.setDefaultFocusedElement(sidebarTree.element); |
| 20 | 22 |
| 21 this._sidebarMainViewElement = new WebInspector.SecurityMainViewSidebarTreeE lement(this); | 23 this._sidebarMainViewElement = new WebInspector.SecurityMainViewSidebarTreeE lement(this); |
| 22 sidebarTree.appendChild(this._sidebarMainViewElement); | 24 sidebarTree.appendChild(this._sidebarMainViewElement); |
| 23 | 25 |
| 26 // TODO(lgarron): Add a section for the main origin. (https://crbug.com/5235 86) | |
| 27 this._sidebarOriginSection = new WebInspector.SidebarSectionTreeElement(WebI nspector.UIString("Origins")); | |
| 28 this._sidebarOriginSection.listItemElement.classList.add("security-sidebar-o rigins"); | |
| 29 sidebarTree.appendChild(this._sidebarOriginSection); | |
| 30 | |
| 24 this._mainView = new WebInspector.SecurityMainView(); | 31 this._mainView = new WebInspector.SecurityMainView(); |
| 25 this.showMainView(); | |
| 26 | 32 |
| 27 /** @type {!Map<string, !{securityState: !SecurityAgent.SecurityState, secur ityDetails: ?NetworkAgent.SecurityDetails}>} */ | 33 /** @type {!Map<string, !{securityState: !SecurityAgent.SecurityState, secur ityDetails: ?NetworkAgent.SecurityDetails}>} */ |
|
dgozman
2015/08/25 20:21:51
You store the originView here. Update JSDoc.
lgarron
2015/08/25 21:03:07
Good point. I've created a separate WebInspector.S
| |
| 28 this._origins = new Map(); | 34 this._origins = new Map(); |
| 29 WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.E ventTypes.InspectedURLChanged, this._clear, this); | 35 // TODO(lgarron): add event listeners to call _clear() once we figure out ho w to clear the panel properly (https://crbug.com/522762). |
| 30 WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.E ventTypes.WillReloadPage, this._clear, this); | |
| 31 WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.E ventTypes.MainFrameNavigated, this._clear, this); | |
| 32 | 36 |
| 33 WebInspector.targetManager.observeTargets(this); | 37 WebInspector.targetManager.observeTargets(this); |
| 34 } | 38 } |
| 35 | 39 |
| 40 /** @typedef {string} */ | |
| 41 WebInspector.SecurityPanel.Origin; | |
| 42 | |
| 36 WebInspector.SecurityPanel.prototype = { | 43 WebInspector.SecurityPanel.prototype = { |
| 37 | 44 |
| 38 /** | 45 /** |
| 39 * @param {!SecurityAgent.SecurityState} newSecurityState | 46 * @param {!SecurityAgent.SecurityState} newSecurityState |
| 40 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations | 47 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations |
| 41 */ | 48 */ |
| 42 _updateSecurityState: function(newSecurityState, explanations) | 49 _updateSecurityState: function(newSecurityState, explanations) |
| 43 { | 50 { |
| 44 this._sidebarMainViewElement.setSecurityState(newSecurityState); | 51 this._sidebarMainViewElement.setSecurityState(newSecurityState); |
| 45 this._mainView.updateSecurityState(newSecurityState, explanations); | 52 this._mainView.updateSecurityState(newSecurityState, explanations); |
| 46 }, | 53 }, |
| 47 | 54 |
| 48 /** | 55 /** |
| 49 * @param {!WebInspector.Event} event | 56 * @param {!WebInspector.Event} event |
| 50 */ | 57 */ |
| 51 _onSecurityStateChanged: function(event) | 58 _onSecurityStateChanged: function(event) |
| 52 { | 59 { |
| 53 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata.securityState); | 60 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata.securityState); |
| 54 var explanations = /** @type {!Array<!SecurityAgent.SecurityStateExplana tion>} */ (event.data.explanations); | 61 var explanations = /** @type {!Array<!SecurityAgent.SecurityStateExplana tion>} */ (event.data.explanations); |
| 55 this._updateSecurityState(securityState, explanations); | 62 this._updateSecurityState(securityState, explanations); |
| 56 }, | 63 }, |
| 57 | 64 |
| 58 showMainView: function() | 65 showMainView: function() |
| 59 { | 66 { |
| 60 this._setVisibleView(this._mainView); | 67 this._setVisibleView(this._mainView); |
| 61 }, | 68 }, |
| 62 | 69 |
| 63 /** | 70 /** |
| 71 * @param {!WebInspector.SecurityPanel.Origin} origin | |
| 72 */ | |
| 73 showOrigin: function(origin) | |
| 74 { | |
| 75 var originData = this._origins.get(origin); | |
| 76 if (!originData.originView) | |
| 77 originData.originView = new WebInspector.SecurityOriginView(this, or igin, originData.securityState, originData.securityDetails); | |
| 78 | |
| 79 this._setVisibleView(originData.originView); | |
| 80 }, | |
| 81 | |
| 82 wasShown: function() | |
| 83 { | |
| 84 WebInspector.Panel.prototype.wasShown.call(this); | |
| 85 if (!this._visibleView) | |
| 86 this._sidebarMainViewElement.select(); | |
| 87 }, | |
| 88 | |
| 89 /** | |
| 64 * @param {!WebInspector.VBox} view | 90 * @param {!WebInspector.VBox} view |
| 65 */ | 91 */ |
| 66 _setVisibleView: function(view) | 92 _setVisibleView: function(view) |
| 67 { | 93 { |
| 68 if (this._visibleView === view) | 94 if (this._visibleView === view) |
| 69 return; | 95 return; |
| 70 | 96 |
| 71 if (this._visibleView) | 97 if (this._visibleView) |
| 72 this._visibleView.detach(); | 98 this._visibleView.detach(); |
| 73 | 99 |
| 74 this._visibleView = view; | 100 this._visibleView = view; |
| 75 | 101 |
| 76 if (view) | 102 if (view) |
| 77 this.splitWidget().setMainWidget(view); | 103 this.splitWidget().setMainWidget(view); |
| 78 }, | 104 }, |
| 79 | 105 |
| 80 /** | 106 /** |
| 81 * @param {!WebInspector.Event} event | 107 * @param {!WebInspector.Event} event |
| 82 */ | 108 */ |
| 83 _onResponseReceivedSecurityDetails: function(event) | 109 _onResponseReceivedSecurityDetails: function(event) |
| 84 { | 110 { |
| 85 var data = event.data; | 111 var data = event.data; |
| 86 var origin = /** @type {string} */ (data.origin); | 112 var origin = /** @type {string} */ (data.origin); |
| 87 var securityState = /** @type {!SecurityAgent.SecurityState} */ (data.se curityState); | 113 var securityState = /** @type {!SecurityAgent.SecurityState} */ (data.se curityState); |
| 88 | 114 |
| 89 if (this._origins.has(origin)) { | 115 if (this._origins.has(origin)) { |
| 90 var originData = this._origins.get(origin); | 116 var originData = this._origins.get(origin); |
| 91 originData.securityState = this._securityStateMin(originData.securit yState, securityState); | 117 var oldSecurityState = originData.securityState; |
| 118 originData.securityState = this._securityStateMin(oldSecurityState, securityState); | |
| 119 if (oldSecurityState != originData.securityState) { | |
| 120 originData.sidebarElement.setSecurityState(securityState); | |
| 121 if (originData.originView) | |
| 122 originData.originView.setSecurityState(securityState); | |
| 123 } | |
| 92 } else { | 124 } else { |
| 93 // TODO(lgarron): Store a (deduplicated) list of different security details we have seen. | 125 // TODO(lgarron): Store a (deduplicated) list of different security details we have seen. https://crbug.com/503170 |
| 94 var originData = {}; | 126 var originData = {}; |
| 95 originData.securityState = securityState; | 127 originData.securityState = securityState; |
| 96 if (data.securityDetails) | 128 if (data.securityDetails) |
| 97 originData.securityDetails = data.securityDetails; | 129 originData.securityDetails = data.securityDetails; |
| 98 | 130 |
| 99 this._origins.set(origin, originData); | 131 this._origins.set(origin, originData); |
| 132 | |
| 133 originData.sidebarElement = new WebInspector.SecurityOriginViewSideb arTreeElement(this, origin); | |
| 134 this._sidebarOriginSection.appendChild(originData.sidebarElement); | |
| 135 originData.sidebarElement.setSecurityState(securityState); | |
| 136 | |
| 137 // Don't construct the origin view yet (let it happen lazily). | |
| 100 } | 138 } |
| 101 }, | 139 }, |
| 102 | 140 |
| 103 /** | 141 /** |
| 104 * @param {!SecurityAgent.SecurityState} stateA | 142 * @param {!SecurityAgent.SecurityState} stateA |
| 105 * @param {!SecurityAgent.SecurityState} stateB | 143 * @param {!SecurityAgent.SecurityState} stateB |
| 106 * @return {!SecurityAgent.SecurityState} | 144 * @return {!SecurityAgent.SecurityState} |
| 107 */ | 145 */ |
| 108 _securityStateMin: function(stateA, stateB) | 146 _securityStateMin: function(stateA, stateB) |
| 109 { | 147 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 this._networkManager.removeEventListener(WebInspector.NetworkManager .EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDet ails, this); | 179 this._networkManager.removeEventListener(WebInspector.NetworkManager .EventTypes.ResponseReceivedSecurityDetails, this._onResponseReceivedSecurityDet ails, this); |
| 142 delete this._networkManager; | 180 delete this._networkManager; |
| 143 delete this._target; | 181 delete this._target; |
| 144 this._clear(); | 182 this._clear(); |
| 145 } | 183 } |
| 146 }, | 184 }, |
| 147 | 185 |
| 148 _clear: function() | 186 _clear: function() |
| 149 { | 187 { |
| 150 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []); | 188 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []); |
| 189 this._sidebarMainViewElement.select(); | |
| 190 this._sidebarOriginSection.removeChildren(); | |
| 151 this._origins.clear(); | 191 this._origins.clear(); |
| 152 }, | 192 }, |
| 153 | 193 |
| 154 __proto__: WebInspector.PanelWithSidebar.prototype | 194 __proto__: WebInspector.PanelWithSidebar.prototype |
| 155 } | 195 } |
| 156 | 196 |
| 157 /** | 197 /** |
| 158 * @return {!WebInspector.SecurityPanel} | 198 * @return {!WebInspector.SecurityPanel} |
| 159 */ | 199 */ |
| 160 WebInspector.SecurityPanel._instance = function() | 200 WebInspector.SecurityPanel._instance = function() |
| 161 { | 201 { |
| 162 if (!WebInspector.SecurityPanel._instanceObject) | 202 if (!WebInspector.SecurityPanel._instanceObject) |
| 163 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa nel(); | 203 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa nel(); |
| 164 return WebInspector.SecurityPanel._instanceObject; | 204 return WebInspector.SecurityPanel._instanceObject; |
| 165 } | 205 } |
| 166 | 206 |
| 167 /** | 207 /** |
| 168 * @constructor | 208 * @constructor |
| 169 * @extends {WebInspector.SidebarTreeElement} | 209 * @extends {WebInspector.SidebarTreeElement} |
| 170 * @param {!WebInspector.SecurityPanel} panel | 210 * @param {!WebInspector.SecurityPanel} panel |
| 171 */ | 211 */ |
| 172 WebInspector.SecurityMainViewSidebarTreeElement = function(panel) | 212 WebInspector.SecurityMainViewSidebarTreeElement = function(panel) |
| 173 { | 213 { |
| 174 this._panel = panel; | 214 this._panel = panel; |
| 175 this.small = true; | 215 WebInspector.SidebarTreeElement.call(this, "security-main-view-sidebar-tree- item", WebInspector.UIString("Overview")); |
| 176 WebInspector.SidebarTreeElement.call(this, "security-sidebar-tree-item", Web Inspector.UIString("Overview")); | |
| 177 this.iconElement.classList.add("lock-icon"); | 216 this.iconElement.classList.add("lock-icon"); |
| 178 } | 217 } |
| 179 | 218 |
| 180 WebInspector.SecurityMainViewSidebarTreeElement.prototype = { | 219 WebInspector.SecurityMainViewSidebarTreeElement.prototype = { |
| 181 onattach: function() | 220 onattach: function() |
| 182 { | 221 { |
| 183 WebInspector.SidebarTreeElement.prototype.onattach.call(this); | 222 WebInspector.SidebarTreeElement.prototype.onattach.call(this); |
| 184 }, | 223 }, |
| 185 | 224 |
| 186 /** | 225 /** |
| 187 * @param {!SecurityAgent.SecurityState} newSecurityState | 226 * @param {!SecurityAgent.SecurityState} newSecurityState |
| 188 */ | 227 */ |
| 189 setSecurityState: function(newSecurityState) | 228 setSecurityState: function(newSecurityState) |
| 190 { | 229 { |
| 191 for (var className of this.iconElement.classList) | 230 for (var className of Array.prototype.slice.call(this.iconElement.classL ist)) { |
| 192 if (className.indexOf("lock-icon-") === 0) | 231 if (className.startsWith("lock-icon-")) |
| 193 this.iconElement.classList.remove(className); | 232 this.iconElement.classList.remove(className); |
| 233 } | |
| 194 | 234 |
| 195 this.iconElement.classList.add("lock-icon-" + newSecurityState); | 235 this.iconElement.classList.add("lock-icon-" + newSecurityState); |
| 196 }, | 236 }, |
| 197 | 237 |
| 198 /** | 238 /** |
| 199 * @override | 239 * @override |
| 200 * @return {boolean} | 240 * @return {boolean} |
| 201 */ | 241 */ |
| 202 onselect: function() | 242 onselect: function() |
| 203 { | 243 { |
| 204 this._panel.showMainView(); | 244 this._panel.showMainView(); |
| 205 return true; | 245 return true; |
| 206 }, | 246 }, |
| 207 | 247 |
| 208 __proto__: WebInspector.SidebarTreeElement.prototype | 248 __proto__: WebInspector.SidebarTreeElement.prototype |
| 209 } | 249 } |
| 210 | 250 |
| 211 /** | 251 /** |
| 212 * @constructor | 252 * @constructor |
| 253 * @extends {WebInspector.SidebarTreeElement} | |
| 254 * @param {!WebInspector.SecurityPanel} panel | |
| 255 * @param {!WebInspector.SecurityPanel.Origin} origin | |
| 256 */ | |
| 257 WebInspector.SecurityOriginViewSidebarTreeElement = function(panel, origin) | |
| 258 { | |
| 259 this._panel = panel; | |
| 260 this._origin = origin; | |
| 261 this.small = true; | |
| 262 WebInspector.SidebarTreeElement.call(this, "security-sidebar-tree-item", ori gin); | |
| 263 this.iconElement.classList.add("security-property"); | |
| 264 } | |
| 265 | |
| 266 WebInspector.SecurityOriginViewSidebarTreeElement.prototype = { | |
| 267 /** | |
| 268 * @override | |
| 269 * @return {boolean} | |
| 270 */ | |
| 271 onselect: function() | |
| 272 { | |
| 273 this._panel.showOrigin(this._origin); | |
| 274 return true; | |
| 275 }, | |
| 276 | |
| 277 /** | |
| 278 * @param {!SecurityAgent.SecurityState} newSecurityState | |
| 279 */ | |
| 280 setSecurityState: function(newSecurityState) | |
| 281 { | |
| 282 for (var className of Array.prototype.slice.call(this.iconElement.classL ist)) { | |
| 283 if (className.startsWith("security-property-")) | |
| 284 this.iconElement.classList.remove(className); | |
| 285 } | |
| 286 | |
| 287 this.iconElement.classList.add("security-property-" + newSecurityState); | |
| 288 }, | |
| 289 | |
| 290 __proto__: WebInspector.SidebarTreeElement.prototype | |
| 291 } | |
| 292 | |
| 293 /** | |
| 294 * @constructor | |
| 213 * @implements {WebInspector.PanelFactory} | 295 * @implements {WebInspector.PanelFactory} |
| 214 */ | 296 */ |
| 215 WebInspector.SecurityPanelFactory = function() | 297 WebInspector.SecurityPanelFactory = function() |
| 216 { | 298 { |
| 217 } | 299 } |
| 218 | 300 |
| 219 WebInspector.SecurityPanelFactory.prototype = { | 301 WebInspector.SecurityPanelFactory.prototype = { |
| 220 /** | 302 /** |
| 221 * @override | 303 * @override |
| 222 * @return {!WebInspector.Panel} | 304 * @return {!WebInspector.Panel} |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 250 WebInspector.SecurityMainView.prototype = { | 332 WebInspector.SecurityMainView.prototype = { |
| 251 /** | 333 /** |
| 252 * @param {!SecurityAgent.SecurityStateExplanation} explanation | 334 * @param {!SecurityAgent.SecurityStateExplanation} explanation |
| 253 */ | 335 */ |
| 254 _addExplanation: function(explanation) | 336 _addExplanation: function(explanation) |
| 255 { | 337 { |
| 256 var explanationDiv = this._securityExplanations.createChild("div", "secu rity-explanation"); | 338 var explanationDiv = this._securityExplanations.createChild("div", "secu rity-explanation"); |
| 257 | 339 |
| 258 var explanationLockIcon = explanationDiv.createChild("div", "lock-icon") ; | 340 var explanationLockIcon = explanationDiv.createChild("div", "lock-icon") ; |
| 259 explanationLockIcon.classList.add("lock-icon-" + explanation.securitySta te); | 341 explanationLockIcon.classList.add("lock-icon-" + explanation.securitySta te); |
| 260 explanationDiv.createChild("div", "explanation-title").textContent = exp lanation.summary; | 342 explanationDiv.createChild("div", "explanation-title").textContent = Web Inspector.UIString(explanation.summary); |
| 261 explanationDiv.createChild("div", "explanation-text").textContent = expl anation.description; | 343 explanationDiv.createChild("div", "explanation-text").textContent = WebI nspector.UIString(explanation.description); |
| 262 }, | 344 }, |
| 263 | 345 |
| 264 /** | 346 /** |
| 265 * @param {!SecurityAgent.SecurityState} newSecurityState | 347 * @param {!SecurityAgent.SecurityState} newSecurityState |
| 266 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations | 348 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations |
| 267 */ | 349 */ |
| 268 updateSecurityState: function(newSecurityState, explanations) | 350 updateSecurityState: function(newSecurityState, explanations) |
| 269 { | 351 { |
| 270 // Remove old state. | 352 // Remove old state. |
| 271 // It's safe to call this even when this._securityState is undefined. | 353 // It's safe to call this even when this._securityState is undefined. |
| 272 this._lockIcon.classList.remove("lock-icon-" + this._securityState); | 354 this._lockIcon.classList.remove("lock-icon-" + this._securityState); |
| 273 | 355 |
| 274 // Add new state. | 356 // Add new state. |
| 275 this._securityState = newSecurityState; | 357 this._securityState = newSecurityState; |
| 276 this._lockIcon.classList.add("lock-icon-" + this._securityState); | 358 this._lockIcon.classList.add("lock-icon-" + this._securityState); |
| 277 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState); | 359 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState); |
| 278 | 360 |
| 279 this._securityExplanations.removeChildren(); | 361 this._securityExplanations.removeChildren(); |
| 280 for (var explanation of explanations) | 362 for (var explanation of explanations) |
| 281 this._addExplanation(explanation); | 363 this._addExplanation(explanation); |
| 282 }, | 364 }, |
| 283 | 365 |
| 284 __proto__: WebInspector.VBox.prototype | 366 __proto__: WebInspector.VBox.prototype |
| 285 } | 367 } |
| 368 | |
| 369 /** | |
| 370 * @constructor | |
| 371 * @extends {WebInspector.VBox} | |
| 372 * @param {!WebInspector.SecurityPanel} panel | |
| 373 * @param {!WebInspector.SecurityPanel.Origin} origin | |
| 374 * @param {!SecurityAgent.SecurityState} securityState | |
| 375 * @param {?NetworkAgent.SecurityDetails} securityDetails | |
| 376 */ | |
| 377 WebInspector.SecurityOriginView = function(panel, origin, securityState, securit yDetails) | |
| 378 { | |
| 379 this._panel = panel; | |
| 380 WebInspector.VBox.call(this); | |
| 381 this.setMinimumSize(200, 100); | |
| 382 | |
| 383 this.element.classList.add("security-origin-view"); | |
| 384 this.registerRequiredCSS("security/originView.css"); | |
| 385 this.registerRequiredCSS("security/lockIcon.css"); | |
| 386 | |
| 387 var titleSection = this.element.createChild("div", "origin-view-section titl e-section"); | |
| 388 titleSection.createChild("div", "origin-view-title").textContent = WebInspec tor.UIString("Origin"); | |
| 389 var originDisplay = titleSection.createChild("div", "origin-display"); | |
| 390 this._originLockIcon = originDisplay.createChild("span", "security-property" ); | |
| 391 this._originLockIcon.classList.add("security-property-" + securityState); | |
| 392 // TODO(lgarron): Highlight the origin scheme. https://crbug.com/523589 | |
| 393 originDisplay.createChild("span", "origin").textContent = origin; | |
| 394 | |
| 395 if (securityDetails && securityDetails.certificateDetails) { | |
| 396 var connectionSection = this.element.createChild("div", "origin-view-sec tion"); | |
| 397 connectionSection.createChild("div", "origin-view-section-title").textCo ntent = WebInspector.UIString("Connection"); | |
| 398 | |
| 399 var table = new WebInspector.SecurityDetailsTable(); | |
| 400 connectionSection.appendChild(table.element()); | |
| 401 table.addRow("Protocol", securityDetails.protocol); | |
| 402 table.addRow("Key Exchange", securityDetails.keyExchange); | |
| 403 table.addRow("Cipher Suite", securityDetails.cipher + (securityDetails.m ac ? " with " + securityDetails.mac : "")); | |
| 404 } | |
| 405 | |
| 406 if (securityDetails) { | |
| 407 var certificateSection = this.element.createChild("div", "origin-view-se ction"); | |
| 408 certificateSection.createChild("div", "origin-view-section-title").textC ontent = WebInspector.UIString("Certificate"); | |
| 409 | |
| 410 var sanDiv = this._createSanDiv(securityDetails); | |
| 411 var validFromString = new Date(1000 * securityDetails.certificateDetails .validFrom).toUTCString(); | |
| 412 var validUntilString = new Date(1000 * securityDetails.certificateDetail s.validTo).toUTCString(); | |
| 413 | |
| 414 var table = new WebInspector.SecurityDetailsTable(); | |
| 415 certificateSection.appendChild(table.element()); | |
| 416 table.addRow("Subject", securityDetails.certificateDetails.subject.name) ; | |
| 417 table.addRow("SAN", sanDiv); | |
| 418 table.addRow("Valid From", validFromString); | |
| 419 table.addRow("Valid Until", validUntilString); | |
| 420 table.addRow("Issuer", securityDetails.certificateDetails.issuer); | |
| 421 // TODO(lgarron): Make SCT status available in certificate details and s how it here. | |
| 422 | |
| 423 // TODO(lgarron): Implement a link to get certificateDetails. https://cr bug.com/506468 | |
| 424 | |
| 425 var noteSection = this.element.createChild("div", "origin-view-section") ; | |
| 426 noteSection.createChild("div", "origin-view-section-title").textContent = WebInspector.UIString("Development Note"); | |
| 427 // TODO(lgarron): Fix the issue and then remove this section. See commen t in _onResponseReceivedSecurityDetails | |
| 428 noteSection.createChild("div").textContent = WebInspector.UIString("At t he moment, this view only shows security details from the first connection made to %s", origin); | |
| 429 } | |
| 430 | |
| 431 if (!securityDetails) { | |
| 432 var notSecureSection = this.element.createChild("div", "origin-view-sect ion"); | |
| 433 notSecureSection.createChild("div", "origin-view-section-title").textCon tent = WebInspector.UIString("Not Secure"); | |
| 434 notSecureSection.createChild("div").textContent = WebInspector.UIString( "Your connection to this origin is not secure."); | |
| 435 } | |
| 436 } | |
| 437 | |
| 438 WebInspector.SecurityOriginView.prototype = { | |
| 439 | |
| 440 /** | |
| 441 * @param {!NetworkAgent.SecurityDetails} securityDetails | |
| 442 * *return {!Element} | |
| 443 */ | |
| 444 _createSanDiv: function(securityDetails) | |
| 445 { | |
| 446 // TODO(lgarron): Truncate the display of SAN entries and add a button t o toggle the full list. https://crbug.com/523591 | |
| 447 var sanDiv = createElement("div"); | |
| 448 var sanList = securityDetails.certificateDetails.subject.sanDnsNames.con cat(securityDetails.certificateDetails.subject.sanIpAddresses); | |
| 449 if (sanList.length === 0) { | |
| 450 sanDiv.textContent = WebInspector.UIString("(N/A)"); | |
| 451 } else { | |
| 452 for (var sanEntry of sanList) { | |
| 453 var span = sanDiv.createChild("span", "san-entry"); | |
| 454 span.textContent = WebInspector.UIString(sanEntry); | |
| 455 } | |
| 456 } | |
| 457 return sanDiv; | |
| 458 }, | |
| 459 | |
| 460 /** | |
| 461 * @param {!SecurityAgent.SecurityState} newSecurityState | |
| 462 */ | |
| 463 setSecurityState: function(newSecurityState) | |
| 464 { | |
| 465 for (var className of Array.prototype.slice.call(this._originLockIcon.cl assList)) { | |
| 466 if (className.startsWith("security-property-")) | |
| 467 this._originLockIcon.classList.remove(className); | |
| 468 } | |
| 469 | |
| 470 this._originLockIcon.classList.add("security-property-" + newSecuritySta te); | |
| 471 }, | |
| 472 | |
| 473 __proto__: WebInspector.VBox.prototype | |
| 474 } | |
| 475 | |
| 476 /** | |
| 477 * @constructor | |
| 478 */ | |
| 479 WebInspector.SecurityDetailsTable = function() { | |
|
dgozman
2015/08/25 20:21:51
nit: { on next line
lgarron
2015/08/25 21:03:07
Done.
| |
| 480 this._element = createElement("table"); | |
| 481 this._element.classList.add("details-table"); | |
| 482 } | |
| 483 | |
| 484 WebInspector.SecurityDetailsTable.prototype = { | |
| 485 | |
| 486 /** | |
| 487 * @return: {!Element} | |
| 488 */ | |
| 489 element: function() { | |
|
dgozman
2015/08/25 20:21:51
nit: { on next line
lgarron
2015/08/25 21:03:07
Done.
| |
| 490 return this._element; | |
| 491 }, | |
| 492 | |
| 493 /** | |
| 494 * @param {string} key | |
| 495 * @param {string|!HTMLDivElement} value | |
| 496 */ | |
| 497 addRow: function(key, value) | |
| 498 { | |
| 499 var row = this._element.createChild("div", "details-table-row"); | |
| 500 row.createChild("div").textContent = WebInspector.UIString(key); | |
| 501 | |
| 502 var valueDiv = row.createChild("div"); | |
| 503 if (value instanceof HTMLDivElement) { | |
| 504 valueDiv.appendChild(value); | |
| 505 } else { | |
| 506 valueDiv.textContent = value; | |
| 507 } | |
| 508 }, | |
|
dgozman
2015/08/25 20:21:51
nit: extra comma
lgarron
2015/08/25 21:03:07
Done.
| |
| 509 } | |
| 510 | |
| OLD | NEW |