| 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 * @implements {WebInspector.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 WebInspector.SecurityPanel = class extends WebInspector.PanelWithSidebar { | 8 Security.SecurityPanel = class extends UI.PanelWithSidebar { |
| 9 constructor() { | 9 constructor() { |
| 10 super('security'); | 10 super('security'); |
| 11 | 11 |
| 12 this._mainView = new WebInspector.SecurityMainView(this); | 12 this._mainView = new Security.SecurityMainView(this); |
| 13 | 13 |
| 14 this._sidebarMainViewElement = new WebInspector.SecurityPanelSidebarTreeElem
ent( | 14 this._sidebarMainViewElement = new Security.SecurityPanelSidebarTreeElement( |
| 15 WebInspector.UIString('Overview'), this._setVisibleView.bind(this, this.
_mainView), | 15 Common.UIString('Overview'), this._setVisibleView.bind(this, this._mainV
iew), |
| 16 'security-main-view-sidebar-tree-item', 'lock-icon'); | 16 'security-main-view-sidebar-tree-item', 'lock-icon'); |
| 17 this._sidebarTree = | 17 this._sidebarTree = |
| 18 new WebInspector.SecurityPanelSidebarTree(this._sidebarMainViewElement,
this.showOrigin.bind(this)); | 18 new Security.SecurityPanelSidebarTree(this._sidebarMainViewElement, this
.showOrigin.bind(this)); |
| 19 this.panelSidebarElement().appendChild(this._sidebarTree.element); | 19 this.panelSidebarElement().appendChild(this._sidebarTree.element); |
| 20 | 20 |
| 21 /** @type {!Map<!Protocol.Network.LoaderId, !WebInspector.NetworkRequest>} *
/ | 21 /** @type {!Map<!Protocol.Network.LoaderId, !SDK.NetworkRequest>} */ |
| 22 this._lastResponseReceivedForLoaderId = new Map(); | 22 this._lastResponseReceivedForLoaderId = new Map(); |
| 23 | 23 |
| 24 /** @type {!Map<!WebInspector.SecurityPanel.Origin, !WebInspector.SecurityPa
nel.OriginState>} */ | 24 /** @type {!Map<!Security.SecurityPanel.Origin, !Security.SecurityPanel.Orig
inState>} */ |
| 25 this._origins = new Map(); | 25 this._origins = new Map(); |
| 26 | 26 |
| 27 /** @type {!Map<!WebInspector.NetworkLogView.MixedContentFilterValues, numbe
r>} */ | 27 /** @type {!Map<!Network.NetworkLogView.MixedContentFilterValues, number>} *
/ |
| 28 this._filterRequestCounts = new Map(); | 28 this._filterRequestCounts = new Map(); |
| 29 | 29 |
| 30 /** @type {!Map<!WebInspector.Target, !Array<!WebInspector.EventTarget.Event
Descriptor>>}*/ | 30 /** @type {!Map<!SDK.Target, !Array<!Common.EventTarget.EventDescriptor>>}*/ |
| 31 this._eventListeners = new Map(); | 31 this._eventListeners = new Map(); |
| 32 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Network); | 32 SDK.targetManager.observeTargets(this, SDK.Target.Capability.Network); |
| 33 } | 33 } |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * @return {!WebInspector.SecurityPanel} | 36 * @return {!Security.SecurityPanel} |
| 37 */ | 37 */ |
| 38 static _instance() { | 38 static _instance() { |
| 39 return /** @type {!WebInspector.SecurityPanel} */ (self.runtime.sharedInstan
ce(WebInspector.SecurityPanel)); | 39 return /** @type {!Security.SecurityPanel} */ (self.runtime.sharedInstance(S
ecurity.SecurityPanel)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @param {string} text | 43 * @param {string} text |
| 44 * @param {!WebInspector.SecurityPanel} panel | 44 * @param {!Security.SecurityPanel} panel |
| 45 * @return {!Element} | 45 * @return {!Element} |
| 46 */ | 46 */ |
| 47 static createCertificateViewerButton(text, panel) { | 47 static createCertificateViewerButton(text, panel) { |
| 48 /** | 48 /** |
| 49 * @param {!Event} e | 49 * @param {!Event} e |
| 50 */ | 50 */ |
| 51 function showCertificateViewer(e) { | 51 function showCertificateViewer(e) { |
| 52 e.consume(); | 52 e.consume(); |
| 53 panel.showCertificateViewer(); | 53 panel.showCertificateViewer(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 return createTextButton(text, showCertificateViewer, 'security-certificate-b
utton'); | 56 return createTextButton(text, showCertificateViewer, 'security-certificate-b
utton'); |
| 57 } | 57 } |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * @param {string} text | 60 * @param {string} text |
| 61 * @param {string} origin | 61 * @param {string} origin |
| 62 * @return {!Element} | 62 * @return {!Element} |
| 63 */ | 63 */ |
| 64 static createCertificateViewerButton2(text, origin) { | 64 static createCertificateViewerButton2(text, origin) { |
| 65 /** | 65 /** |
| 66 * @param {!Event} e | 66 * @param {!Event} e |
| 67 */ | 67 */ |
| 68 function showCertificateViewer(e) { | 68 function showCertificateViewer(e) { |
| 69 function certificateCallback(names) { | 69 function certificateCallback(names) { |
| 70 InspectorFrontendHost.showCertificateViewer(names); | 70 InspectorFrontendHost.showCertificateViewer(names); |
| 71 } | 71 } |
| 72 | 72 |
| 73 e.consume(); | 73 e.consume(); |
| 74 WebInspector.multitargetNetworkManager.getCertificate(origin, certificateC
allback); | 74 SDK.multitargetNetworkManager.getCertificate(origin, certificateCallback); |
| 75 } | 75 } |
| 76 | 76 |
| 77 return createTextButton(text, showCertificateViewer, 'security-certificate-b
utton'); | 77 return createTextButton(text, showCertificateViewer, 'security-certificate-b
utton'); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * @param {!Protocol.Security.SecurityState} securityState | 81 * @param {!Protocol.Security.SecurityState} securityState |
| 82 */ | 82 */ |
| 83 setRanInsecureContentStyle(securityState) { | 83 setRanInsecureContentStyle(securityState) { |
| 84 this._ranInsecureContentStyle = securityState; | 84 this._ranInsecureContentStyle = securityState; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 96 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations | 96 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations |
| 97 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus | 97 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus |
| 98 * @param {boolean} schemeIsCryptographic | 98 * @param {boolean} schemeIsCryptographic |
| 99 */ | 99 */ |
| 100 _updateSecurityState(newSecurityState, explanations, insecureContentStatus, sc
hemeIsCryptographic) { | 100 _updateSecurityState(newSecurityState, explanations, insecureContentStatus, sc
hemeIsCryptographic) { |
| 101 this._sidebarMainViewElement.setSecurityState(newSecurityState); | 101 this._sidebarMainViewElement.setSecurityState(newSecurityState); |
| 102 this._mainView.updateSecurityState(newSecurityState, explanations, insecureC
ontentStatus, schemeIsCryptographic); | 102 this._mainView.updateSecurityState(newSecurityState, explanations, insecureC
ontentStatus, schemeIsCryptographic); |
| 103 } | 103 } |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * @param {!WebInspector.Event} event | 106 * @param {!Common.Event} event |
| 107 */ | 107 */ |
| 108 _onSecurityStateChanged(event) { | 108 _onSecurityStateChanged(event) { |
| 109 var data = /** @type {!WebInspector.PageSecurityState} */ (event.data); | 109 var data = /** @type {!Security.PageSecurityState} */ (event.data); |
| 110 var securityState = /** @type {!Protocol.Security.SecurityState} */ (data.se
curityState); | 110 var securityState = /** @type {!Protocol.Security.SecurityState} */ (data.se
curityState); |
| 111 var explanations = /** @type {!Array<!Protocol.Security.SecurityStateExplana
tion>} */ (data.explanations); | 111 var explanations = /** @type {!Array<!Protocol.Security.SecurityStateExplana
tion>} */ (data.explanations); |
| 112 var insecureContentStatus = /** @type {?Protocol.Security.InsecureContentSta
tus} */ (data.insecureContentStatus); | 112 var insecureContentStatus = /** @type {?Protocol.Security.InsecureContentSta
tus} */ (data.insecureContentStatus); |
| 113 var schemeIsCryptographic = /** @type {boolean} */ (data.schemeIsCryptograph
ic); | 113 var schemeIsCryptographic = /** @type {boolean} */ (data.schemeIsCryptograph
ic); |
| 114 this._updateSecurityState(securityState, explanations, insecureContentStatus
, schemeIsCryptographic); | 114 this._updateSecurityState(securityState, explanations, insecureContentStatus
, schemeIsCryptographic); |
| 115 } | 115 } |
| 116 | 116 |
| 117 selectAndSwitchToMainView() { | 117 selectAndSwitchToMainView() { |
| 118 // The sidebar element will trigger displaying the main view. Rather than ma
king a redundant call to display the main view, we rely on this. | 118 // The sidebar element will trigger displaying the main view. Rather than ma
king a redundant call to display the main view, we rely on this. |
| 119 this._sidebarMainViewElement.select(); | 119 this._sidebarMainViewElement.select(); |
| 120 } | 120 } |
| 121 /** | 121 /** |
| 122 * @param {!WebInspector.SecurityPanel.Origin} origin | 122 * @param {!Security.SecurityPanel.Origin} origin |
| 123 */ | 123 */ |
| 124 showOrigin(origin) { | 124 showOrigin(origin) { |
| 125 var originState = this._origins.get(origin); | 125 var originState = this._origins.get(origin); |
| 126 if (!originState.originView) | 126 if (!originState.originView) |
| 127 originState.originView = new WebInspector.SecurityOriginView(this, origin,
originState); | 127 originState.originView = new Security.SecurityOriginView(this, origin, ori
ginState); |
| 128 | 128 |
| 129 this._setVisibleView(originState.originView); | 129 this._setVisibleView(originState.originView); |
| 130 } | 130 } |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * @override | 133 * @override |
| 134 */ | 134 */ |
| 135 wasShown() { | 135 wasShown() { |
| 136 super.wasShown(); | 136 super.wasShown(); |
| 137 if (!this._visibleView) | 137 if (!this._visibleView) |
| 138 this.selectAndSwitchToMainView(); | 138 this.selectAndSwitchToMainView(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * @override | 142 * @override |
| 143 */ | 143 */ |
| 144 focus() { | 144 focus() { |
| 145 this._sidebarTree.focus(); | 145 this._sidebarTree.focus(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * @param {!WebInspector.VBox} view | 149 * @param {!UI.VBox} view |
| 150 */ | 150 */ |
| 151 _setVisibleView(view) { | 151 _setVisibleView(view) { |
| 152 if (this._visibleView === view) | 152 if (this._visibleView === view) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 if (this._visibleView) | 155 if (this._visibleView) |
| 156 this._visibleView.detach(); | 156 this._visibleView.detach(); |
| 157 | 157 |
| 158 this._visibleView = view; | 158 this._visibleView = view; |
| 159 | 159 |
| 160 if (view) | 160 if (view) |
| 161 this.splitWidget().setMainWidget(view); | 161 this.splitWidget().setMainWidget(view); |
| 162 } | 162 } |
| 163 | 163 |
| 164 /** | 164 /** |
| 165 * @param {!WebInspector.Event} event | 165 * @param {!Common.Event} event |
| 166 */ | 166 */ |
| 167 _onResponseReceived(event) { | 167 _onResponseReceived(event) { |
| 168 var request = /** @type {!WebInspector.NetworkRequest} */ (event.data); | 168 var request = /** @type {!SDK.NetworkRequest} */ (event.data); |
| 169 if (request.resourceType() === WebInspector.resourceTypes.Document) | 169 if (request.resourceType() === Common.resourceTypes.Document) |
| 170 this._lastResponseReceivedForLoaderId.set(request.loaderId, request); | 170 this._lastResponseReceivedForLoaderId.set(request.loaderId, request); |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * @param {!WebInspector.NetworkRequest} request | 174 * @param {!SDK.NetworkRequest} request |
| 175 */ | 175 */ |
| 176 _processRequest(request) { | 176 _processRequest(request) { |
| 177 var origin = WebInspector.ParsedURL.extractOrigin(request.url); | 177 var origin = Common.ParsedURL.extractOrigin(request.url); |
| 178 | 178 |
| 179 if (!origin) { | 179 if (!origin) { |
| 180 // We don't handle resources like data: URIs. Most of them don't affect th
e lock icon. | 180 // We don't handle resources like data: URIs. Most of them don't affect th
e lock icon. |
| 181 return; | 181 return; |
| 182 } | 182 } |
| 183 | 183 |
| 184 var securityState = /** @type {!Protocol.Security.SecurityState} */ (request
.securityState()); | 184 var securityState = /** @type {!Protocol.Security.SecurityState} */ (request
.securityState()); |
| 185 | 185 |
| 186 if (request.mixedContentType === Protocol.Network.RequestMixedContentType.Bl
ockable && this._ranInsecureContentStyle) | 186 if (request.mixedContentType === Protocol.Network.RequestMixedContentType.Bl
ockable && this._ranInsecureContentStyle) |
| 187 securityState = this._ranInsecureContentStyle; | 187 securityState = this._ranInsecureContentStyle; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 211 | 211 |
| 212 this._origins.set(origin, originState); | 212 this._origins.set(origin, originState); |
| 213 | 213 |
| 214 this._sidebarTree.addOrigin(origin, securityState); | 214 this._sidebarTree.addOrigin(origin, securityState); |
| 215 | 215 |
| 216 // Don't construct the origin view yet (let it happen lazily). | 216 // Don't construct the origin view yet (let it happen lazily). |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 /** | 220 /** |
| 221 * @param {!WebInspector.Event} event | 221 * @param {!Common.Event} event |
| 222 */ | 222 */ |
| 223 _onRequestFinished(event) { | 223 _onRequestFinished(event) { |
| 224 var request = /** @type {!WebInspector.NetworkRequest} */ (event.data); | 224 var request = /** @type {!SDK.NetworkRequest} */ (event.data); |
| 225 this._updateFilterRequestCounts(request); | 225 this._updateFilterRequestCounts(request); |
| 226 this._processRequest(request); | 226 this._processRequest(request); |
| 227 } | 227 } |
| 228 | 228 |
| 229 /** | 229 /** |
| 230 * @param {!WebInspector.NetworkRequest} request | 230 * @param {!SDK.NetworkRequest} request |
| 231 */ | 231 */ |
| 232 _updateFilterRequestCounts(request) { | 232 _updateFilterRequestCounts(request) { |
| 233 if (request.mixedContentType === Protocol.Network.RequestMixedContentType.No
ne) | 233 if (request.mixedContentType === Protocol.Network.RequestMixedContentType.No
ne) |
| 234 return; | 234 return; |
| 235 | 235 |
| 236 /** @type {!WebInspector.NetworkLogView.MixedContentFilterValues} */ | 236 /** @type {!Network.NetworkLogView.MixedContentFilterValues} */ |
| 237 var filterKey = WebInspector.NetworkLogView.MixedContentFilterValues.All; | 237 var filterKey = Network.NetworkLogView.MixedContentFilterValues.All; |
| 238 if (request.wasBlocked()) | 238 if (request.wasBlocked()) |
| 239 filterKey = WebInspector.NetworkLogView.MixedContentFilterValues.Blocked; | 239 filterKey = Network.NetworkLogView.MixedContentFilterValues.Blocked; |
| 240 else if (request.mixedContentType === Protocol.Network.RequestMixedContentTy
pe.Blockable) | 240 else if (request.mixedContentType === Protocol.Network.RequestMixedContentTy
pe.Blockable) |
| 241 filterKey = WebInspector.NetworkLogView.MixedContentFilterValues.BlockOver
ridden; | 241 filterKey = Network.NetworkLogView.MixedContentFilterValues.BlockOverridde
n; |
| 242 else if (request.mixedContentType === Protocol.Network.RequestMixedContentTy
pe.OptionallyBlockable) | 242 else if (request.mixedContentType === Protocol.Network.RequestMixedContentTy
pe.OptionallyBlockable) |
| 243 filterKey = WebInspector.NetworkLogView.MixedContentFilterValues.Displayed
; | 243 filterKey = Network.NetworkLogView.MixedContentFilterValues.Displayed; |
| 244 | 244 |
| 245 if (!this._filterRequestCounts.has(filterKey)) | 245 if (!this._filterRequestCounts.has(filterKey)) |
| 246 this._filterRequestCounts.set(filterKey, 1); | 246 this._filterRequestCounts.set(filterKey, 1); |
| 247 else | 247 else |
| 248 this._filterRequestCounts.set(filterKey, this._filterRequestCounts.get(fil
terKey) + 1); | 248 this._filterRequestCounts.set(filterKey, this._filterRequestCounts.get(fil
terKey) + 1); |
| 249 | 249 |
| 250 this._mainView.refreshExplanations(); | 250 this._mainView.refreshExplanations(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 /** | 253 /** |
| 254 * @param {!WebInspector.NetworkLogView.MixedContentFilterValues} filterKey | 254 * @param {!Network.NetworkLogView.MixedContentFilterValues} filterKey |
| 255 * @return {number} | 255 * @return {number} |
| 256 */ | 256 */ |
| 257 filterRequestCount(filterKey) { | 257 filterRequestCount(filterKey) { |
| 258 return this._filterRequestCounts.get(filterKey) || 0; | 258 return this._filterRequestCounts.get(filterKey) || 0; |
| 259 } | 259 } |
| 260 | 260 |
| 261 showCertificateViewer() { | 261 showCertificateViewer() { |
| 262 var securityModel = WebInspector.SecurityModel.fromTarget(this._target); | 262 var securityModel = Security.SecurityModel.fromTarget(this._target); |
| 263 securityModel.showCertificateViewer(); | 263 securityModel.showCertificateViewer(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 /** | 266 /** |
| 267 * @param {!Protocol.Security.SecurityState} stateA | 267 * @param {!Protocol.Security.SecurityState} stateA |
| 268 * @param {!Protocol.Security.SecurityState} stateB | 268 * @param {!Protocol.Security.SecurityState} stateB |
| 269 * @return {!Protocol.Security.SecurityState} | 269 * @return {!Protocol.Security.SecurityState} |
| 270 */ | 270 */ |
| 271 _securityStateMin(stateA, stateB) { | 271 _securityStateMin(stateA, stateB) { |
| 272 return WebInspector.SecurityModel.SecurityStateComparator(stateA, stateB) <
0 ? stateA : stateB; | 272 return Security.SecurityModel.SecurityStateComparator(stateA, stateB) < 0 ?
stateA : stateB; |
| 273 } | 273 } |
| 274 | 274 |
| 275 /** | 275 /** |
| 276 * @override | 276 * @override |
| 277 * @param {!WebInspector.Target} target | 277 * @param {!SDK.Target} target |
| 278 */ | 278 */ |
| 279 targetAdded(target) { | 279 targetAdded(target) { |
| 280 if (this._target) | 280 if (this._target) |
| 281 return; | 281 return; |
| 282 | 282 |
| 283 var listeners = []; | 283 var listeners = []; |
| 284 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target); | 284 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); |
| 285 if (resourceTreeModel) { | 285 if (resourceTreeModel) { |
| 286 listeners = listeners.concat([ | 286 listeners = listeners.concat([ |
| 287 resourceTreeModel.addEventListener( | 287 resourceTreeModel.addEventListener( |
| 288 WebInspector.ResourceTreeModel.Events.MainFrameNavigated, this._onMa
inFrameNavigated, this), | 288 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._onMainFrameNa
vigated, this), |
| 289 resourceTreeModel.addEventListener( | 289 resourceTreeModel.addEventListener( |
| 290 WebInspector.ResourceTreeModel.Events.InterstitialShown, this._onInt
erstitialShown, this), | 290 SDK.ResourceTreeModel.Events.InterstitialShown, this._onInterstitial
Shown, this), |
| 291 resourceTreeModel.addEventListener( | 291 resourceTreeModel.addEventListener( |
| 292 WebInspector.ResourceTreeModel.Events.InterstitialHidden, this._onIn
terstitialHidden, this), | 292 SDK.ResourceTreeModel.Events.InterstitialHidden, this._onInterstitia
lHidden, this), |
| 293 ]); | 293 ]); |
| 294 } | 294 } |
| 295 | 295 |
| 296 var networkManager = WebInspector.NetworkManager.fromTarget(target); | 296 var networkManager = SDK.NetworkManager.fromTarget(target); |
| 297 if (networkManager) { | 297 if (networkManager) { |
| 298 listeners = listeners.concat([ | 298 listeners = listeners.concat([ |
| 299 networkManager.addEventListener( | 299 networkManager.addEventListener( |
| 300 WebInspector.NetworkManager.Events.ResponseReceived, this._onRespons
eReceived, this), | 300 SDK.NetworkManager.Events.ResponseReceived, this._onResponseReceived
, this), |
| 301 networkManager.addEventListener( | 301 networkManager.addEventListener( |
| 302 WebInspector.NetworkManager.Events.RequestFinished, this._onRequestF
inished, this), | 302 SDK.NetworkManager.Events.RequestFinished, this._onRequestFinished,
this), |
| 303 ]); | 303 ]); |
| 304 } | 304 } |
| 305 | 305 |
| 306 var securityModel = WebInspector.SecurityModel.fromTarget(target); | 306 var securityModel = Security.SecurityModel.fromTarget(target); |
| 307 if (securityModel) { | 307 if (securityModel) { |
| 308 listeners = listeners.concat([securityModel.addEventListener( | 308 listeners = listeners.concat([securityModel.addEventListener( |
| 309 WebInspector.SecurityModel.Events.SecurityStateChanged, this._onSecuri
tyStateChanged, this)]); | 309 Security.SecurityModel.Events.SecurityStateChanged, this._onSecuritySt
ateChanged, this)]); |
| 310 } | 310 } |
| 311 | 311 |
| 312 this._target = target; | 312 this._target = target; |
| 313 this._eventListeners.set(target, listeners); | 313 this._eventListeners.set(target, listeners); |
| 314 } | 314 } |
| 315 | 315 |
| 316 /** | 316 /** |
| 317 * @override | 317 * @override |
| 318 * @param {!WebInspector.Target} target | 318 * @param {!SDK.Target} target |
| 319 */ | 319 */ |
| 320 targetRemoved(target) { | 320 targetRemoved(target) { |
| 321 if (this._target !== target) | 321 if (this._target !== target) |
| 322 return; | 322 return; |
| 323 | 323 |
| 324 delete this._target; | 324 delete this._target; |
| 325 | 325 |
| 326 WebInspector.EventTarget.removeEventListeners(this._eventListeners.get(targe
t)); | 326 Common.EventTarget.removeEventListeners(this._eventListeners.get(target)); |
| 327 this._eventListeners.delete(target); | 327 this._eventListeners.delete(target); |
| 328 } | 328 } |
| 329 | 329 |
| 330 /** | 330 /** |
| 331 * @param {!WebInspector.Event} event | 331 * @param {!Common.Event} event |
| 332 */ | 332 */ |
| 333 _onMainFrameNavigated(event) { | 333 _onMainFrameNavigated(event) { |
| 334 var frame = /** type {!Protocol.Page.Frame}*/ (event.data); | 334 var frame = /** type {!Protocol.Page.Frame}*/ (event.data); |
| 335 var request = this._lastResponseReceivedForLoaderId.get(frame.loaderId); | 335 var request = this._lastResponseReceivedForLoaderId.get(frame.loaderId); |
| 336 | 336 |
| 337 this.selectAndSwitchToMainView(); | 337 this.selectAndSwitchToMainView(); |
| 338 this._sidebarTree.clearOrigins(); | 338 this._sidebarTree.clearOrigins(); |
| 339 this._origins.clear(); | 339 this._origins.clear(); |
| 340 this._lastResponseReceivedForLoaderId.clear(); | 340 this._lastResponseReceivedForLoaderId.clear(); |
| 341 this._filterRequestCounts.clear(); | 341 this._filterRequestCounts.clear(); |
| 342 // After clearing the filtered request counts, refresh the | 342 // After clearing the filtered request counts, refresh the |
| 343 // explanations to reflect the new counts. | 343 // explanations to reflect the new counts. |
| 344 this._mainView.refreshExplanations(); | 344 this._mainView.refreshExplanations(); |
| 345 | 345 |
| 346 if (request) { | 346 if (request) { |
| 347 var origin = WebInspector.ParsedURL.extractOrigin(request.url); | 347 var origin = Common.ParsedURL.extractOrigin(request.url); |
| 348 this._sidebarTree.setMainOrigin(origin); | 348 this._sidebarTree.setMainOrigin(origin); |
| 349 this._processRequest(request); | 349 this._processRequest(request); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 _onInterstitialShown() { | 353 _onInterstitialShown() { |
| 354 // The panel might have been displaying the origin view on the | 354 // The panel might have been displaying the origin view on the |
| 355 // previously loaded page. When showing an interstitial, switch | 355 // previously loaded page. When showing an interstitial, switch |
| 356 // back to the Overview view. | 356 // back to the Overview view. |
| 357 this.selectAndSwitchToMainView(); | 357 this.selectAndSwitchToMainView(); |
| 358 this._sidebarTree.toggleOriginsList(true /* hidden */); | 358 this._sidebarTree.toggleOriginsList(true /* hidden */); |
| 359 } | 359 } |
| 360 | 360 |
| 361 _onInterstitialHidden() { | 361 _onInterstitialHidden() { |
| 362 this._sidebarTree.toggleOriginsList(false /* hidden */); | 362 this._sidebarTree.toggleOriginsList(false /* hidden */); |
| 363 } | 363 } |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 /** @typedef {string} */ | 366 /** @typedef {string} */ |
| 367 WebInspector.SecurityPanel.Origin; | 367 Security.SecurityPanel.Origin; |
| 368 | 368 |
| 369 /** | 369 /** |
| 370 * @typedef {Object} | 370 * @typedef {Object} |
| 371 * @property {!Protocol.Security.SecurityState} securityState - Current security
state of the origin. | 371 * @property {!Protocol.Security.SecurityState} securityState - Current security
state of the origin. |
| 372 * @property {?Protocol.Network.SecurityDetails} securityDetails - Security deta
ils of the origin, if available. | 372 * @property {?Protocol.Network.SecurityDetails} securityDetails - Security deta
ils of the origin, if available. |
| 373 * @property {?Promise<>} certificateDetailsPromise - Certificate details of the
origin. | 373 * @property {?Promise<>} certificateDetailsPromise - Certificate details of the
origin. |
| 374 * @property {?WebInspector.SecurityOriginView} originView - Current SecurityOri
ginView corresponding to origin. | 374 * @property {?Security.SecurityOriginView} originView - Current SecurityOriginV
iew corresponding to origin. |
| 375 */ | 375 */ |
| 376 WebInspector.SecurityPanel.OriginState; | 376 Security.SecurityPanel.OriginState; |
| 377 | 377 |
| 378 | 378 |
| 379 /** | 379 /** |
| 380 * @unrestricted | 380 * @unrestricted |
| 381 */ | 381 */ |
| 382 WebInspector.SecurityPanelSidebarTree = class extends TreeOutlineInShadow { | 382 Security.SecurityPanelSidebarTree = class extends TreeOutlineInShadow { |
| 383 /** | 383 /** |
| 384 * @param {!WebInspector.SecurityPanelSidebarTreeElement} mainViewElement | 384 * @param {!Security.SecurityPanelSidebarTreeElement} mainViewElement |
| 385 * @param {function(!WebInspector.SecurityPanel.Origin)} showOriginInPanel | 385 * @param {function(!Security.SecurityPanel.Origin)} showOriginInPanel |
| 386 */ | 386 */ |
| 387 constructor(mainViewElement, showOriginInPanel) { | 387 constructor(mainViewElement, showOriginInPanel) { |
| 388 super(); | 388 super(); |
| 389 this.registerRequiredCSS('security/sidebar.css'); | 389 this.registerRequiredCSS('security/sidebar.css'); |
| 390 this.registerRequiredCSS('security/lockIcon.css'); | 390 this.registerRequiredCSS('security/lockIcon.css'); |
| 391 this.appendChild(mainViewElement); | 391 this.appendChild(mainViewElement); |
| 392 | 392 |
| 393 this._showOriginInPanel = showOriginInPanel; | 393 this._showOriginInPanel = showOriginInPanel; |
| 394 this._mainOrigin = null; | 394 this._mainOrigin = null; |
| 395 | 395 |
| 396 /** @type {!Map<!WebInspector.SecurityPanelSidebarTree.OriginGroupName, !Tre
eElement>} */ | 396 /** @type {!Map<!Security.SecurityPanelSidebarTree.OriginGroupName, !TreeEle
ment>} */ |
| 397 this._originGroups = new Map(); | 397 this._originGroups = new Map(); |
| 398 | 398 |
| 399 for (var key in WebInspector.SecurityPanelSidebarTree.OriginGroupName) { | 399 for (var key in Security.SecurityPanelSidebarTree.OriginGroupName) { |
| 400 var originGroupName = WebInspector.SecurityPanelSidebarTree.OriginGroupNam
e[key]; | 400 var originGroupName = Security.SecurityPanelSidebarTree.OriginGroupName[ke
y]; |
| 401 var originGroup = new TreeElement(originGroupName, true); | 401 var originGroup = new TreeElement(originGroupName, true); |
| 402 originGroup.selectable = false; | 402 originGroup.selectable = false; |
| 403 originGroup.expand(); | 403 originGroup.expand(); |
| 404 originGroup.listItemElement.classList.add('security-sidebar-origins'); | 404 originGroup.listItemElement.classList.add('security-sidebar-origins'); |
| 405 this._originGroups.set(originGroupName, originGroup); | 405 this._originGroups.set(originGroupName, originGroup); |
| 406 this.appendChild(originGroup); | 406 this.appendChild(originGroup); |
| 407 } | 407 } |
| 408 this._clearOriginGroups(); | 408 this._clearOriginGroups(); |
| 409 | 409 |
| 410 // This message will be removed by clearOrigins() during the first new page
load after the panel was opened. | 410 // This message will be removed by clearOrigins() during the first new page
load after the panel was opened. |
| 411 var mainViewReloadMessage = new TreeElement(WebInspector.UIString('Reload to
view details')); | 411 var mainViewReloadMessage = new TreeElement(Common.UIString('Reload to view
details')); |
| 412 mainViewReloadMessage.selectable = false; | 412 mainViewReloadMessage.selectable = false; |
| 413 mainViewReloadMessage.listItemElement.classList.add('security-main-view-relo
ad-message'); | 413 mainViewReloadMessage.listItemElement.classList.add('security-main-view-relo
ad-message'); |
| 414 this._originGroups.get(WebInspector.SecurityPanelSidebarTree.OriginGroupName
.MainOrigin) | 414 this._originGroups.get(Security.SecurityPanelSidebarTree.OriginGroupName.Mai
nOrigin) |
| 415 .appendChild(mainViewReloadMessage); | 415 .appendChild(mainViewReloadMessage); |
| 416 | 416 |
| 417 /** @type {!Map<!WebInspector.SecurityPanel.Origin, !WebInspector.SecurityPa
nelSidebarTreeElement>} */ | 417 /** @type {!Map<!Security.SecurityPanel.Origin, !Security.SecurityPanelSideb
arTreeElement>} */ |
| 418 this._elementsByOrigin = new Map(); | 418 this._elementsByOrigin = new Map(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 /** | 421 /** |
| 422 * @param {boolean} hidden | 422 * @param {boolean} hidden |
| 423 */ | 423 */ |
| 424 toggleOriginsList(hidden) { | 424 toggleOriginsList(hidden) { |
| 425 for (var key in WebInspector.SecurityPanelSidebarTree.OriginGroupName) { | 425 for (var key in Security.SecurityPanelSidebarTree.OriginGroupName) { |
| 426 var originGroupName = WebInspector.SecurityPanelSidebarTree.OriginGroupNam
e[key]; | 426 var originGroupName = Security.SecurityPanelSidebarTree.OriginGroupName[ke
y]; |
| 427 var group = this._originGroups.get(originGroupName); | 427 var group = this._originGroups.get(originGroupName); |
| 428 if (group) | 428 if (group) |
| 429 group.hidden = hidden; | 429 group.hidden = hidden; |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 | 432 |
| 433 /** | 433 /** |
| 434 * @param {!WebInspector.SecurityPanel.Origin} origin | 434 * @param {!Security.SecurityPanel.Origin} origin |
| 435 * @param {!Protocol.Security.SecurityState} securityState | 435 * @param {!Protocol.Security.SecurityState} securityState |
| 436 */ | 436 */ |
| 437 addOrigin(origin, securityState) { | 437 addOrigin(origin, securityState) { |
| 438 var originElement = new WebInspector.SecurityPanelSidebarTreeElement( | 438 var originElement = new Security.SecurityPanelSidebarTreeElement( |
| 439 origin, this._showOriginInPanel.bind(this, origin), 'security-sidebar-tr
ee-item', 'security-property'); | 439 origin, this._showOriginInPanel.bind(this, origin), 'security-sidebar-tr
ee-item', 'security-property'); |
| 440 originElement.listItemElement.title = origin; | 440 originElement.listItemElement.title = origin; |
| 441 this._elementsByOrigin.set(origin, originElement); | 441 this._elementsByOrigin.set(origin, originElement); |
| 442 this.updateOrigin(origin, securityState); | 442 this.updateOrigin(origin, securityState); |
| 443 } | 443 } |
| 444 | 444 |
| 445 /** | 445 /** |
| 446 * @param {!WebInspector.SecurityPanel.Origin} origin | 446 * @param {!Security.SecurityPanel.Origin} origin |
| 447 */ | 447 */ |
| 448 setMainOrigin(origin) { | 448 setMainOrigin(origin) { |
| 449 this._mainOrigin = origin; | 449 this._mainOrigin = origin; |
| 450 } | 450 } |
| 451 | 451 |
| 452 /** | 452 /** |
| 453 * @param {!WebInspector.SecurityPanel.Origin} origin | 453 * @param {!Security.SecurityPanel.Origin} origin |
| 454 * @param {!Protocol.Security.SecurityState} securityState | 454 * @param {!Protocol.Security.SecurityState} securityState |
| 455 */ | 455 */ |
| 456 updateOrigin(origin, securityState) { | 456 updateOrigin(origin, securityState) { |
| 457 var originElement = | 457 var originElement = |
| 458 /** @type {!WebInspector.SecurityPanelSidebarTreeElement} */ (this._elem
entsByOrigin.get(origin)); | 458 /** @type {!Security.SecurityPanelSidebarTreeElement} */ (this._elements
ByOrigin.get(origin)); |
| 459 originElement.setSecurityState(securityState); | 459 originElement.setSecurityState(securityState); |
| 460 | 460 |
| 461 var newParent; | 461 var newParent; |
| 462 if (origin === this._mainOrigin) { | 462 if (origin === this._mainOrigin) { |
| 463 newParent = this._originGroups.get(WebInspector.SecurityPanelSidebarTree.O
riginGroupName.MainOrigin); | 463 newParent = this._originGroups.get(Security.SecurityPanelSidebarTree.Origi
nGroupName.MainOrigin); |
| 464 } else { | 464 } else { |
| 465 switch (securityState) { | 465 switch (securityState) { |
| 466 case Protocol.Security.SecurityState.Secure: | 466 case Protocol.Security.SecurityState.Secure: |
| 467 newParent = this._originGroups.get(WebInspector.SecurityPanelSidebarTr
ee.OriginGroupName.Secure); | 467 newParent = this._originGroups.get(Security.SecurityPanelSidebarTree.O
riginGroupName.Secure); |
| 468 break; | 468 break; |
| 469 case Protocol.Security.SecurityState.Unknown: | 469 case Protocol.Security.SecurityState.Unknown: |
| 470 newParent = this._originGroups.get(WebInspector.SecurityPanelSidebarTr
ee.OriginGroupName.Unknown); | 470 newParent = this._originGroups.get(Security.SecurityPanelSidebarTree.O
riginGroupName.Unknown); |
| 471 break; | 471 break; |
| 472 default: | 472 default: |
| 473 newParent = this._originGroups.get(WebInspector.SecurityPanelSidebarTr
ee.OriginGroupName.NonSecure); | 473 newParent = this._originGroups.get(Security.SecurityPanelSidebarTree.O
riginGroupName.NonSecure); |
| 474 break; | 474 break; |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 var oldParent = originElement.parent; | 478 var oldParent = originElement.parent; |
| 479 if (oldParent !== newParent) { | 479 if (oldParent !== newParent) { |
| 480 if (oldParent) { | 480 if (oldParent) { |
| 481 oldParent.removeChild(originElement); | 481 oldParent.removeChild(originElement); |
| 482 if (oldParent.childCount() === 0) | 482 if (oldParent.childCount() === 0) |
| 483 oldParent.hidden = true; | 483 oldParent.hidden = true; |
| 484 } | 484 } |
| 485 newParent.appendChild(originElement); | 485 newParent.appendChild(originElement); |
| 486 newParent.hidden = false; | 486 newParent.hidden = false; |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 _clearOriginGroups() { | 490 _clearOriginGroups() { |
| 491 for (var originGroup of this._originGroups.values()) { | 491 for (var originGroup of this._originGroups.values()) { |
| 492 originGroup.removeChildren(); | 492 originGroup.removeChildren(); |
| 493 originGroup.hidden = true; | 493 originGroup.hidden = true; |
| 494 } | 494 } |
| 495 this._originGroups.get(WebInspector.SecurityPanelSidebarTree.OriginGroupName
.MainOrigin).hidden = false; | 495 this._originGroups.get(Security.SecurityPanelSidebarTree.OriginGroupName.Mai
nOrigin).hidden = false; |
| 496 } | 496 } |
| 497 | 497 |
| 498 clearOrigins() { | 498 clearOrigins() { |
| 499 this._clearOriginGroups(); | 499 this._clearOriginGroups(); |
| 500 this._elementsByOrigin.clear(); | 500 this._elementsByOrigin.clear(); |
| 501 } | 501 } |
| 502 }; | 502 }; |
| 503 | 503 |
| 504 /** | 504 /** |
| 505 * A mapping from Javascript key IDs to names (sidebar section titles). | 505 * A mapping from Javascript key IDs to names (sidebar section titles). |
| 506 * Note: The names are used as keys into a map, so they must be distinct from ea
ch other. | 506 * Note: The names are used as keys into a map, so they must be distinct from ea
ch other. |
| 507 * @enum {string} | 507 * @enum {string} |
| 508 */ | 508 */ |
| 509 WebInspector.SecurityPanelSidebarTree.OriginGroupName = { | 509 Security.SecurityPanelSidebarTree.OriginGroupName = { |
| 510 MainOrigin: WebInspector.UIString('Main Origin'), | 510 MainOrigin: Common.UIString('Main Origin'), |
| 511 NonSecure: WebInspector.UIString('Non-Secure Origins'), | 511 NonSecure: Common.UIString('Non-Secure Origins'), |
| 512 Secure: WebInspector.UIString('Secure Origins'), | 512 Secure: Common.UIString('Secure Origins'), |
| 513 Unknown: WebInspector.UIString('Unknown / Canceled') | 513 Unknown: Common.UIString('Unknown / Canceled') |
| 514 }; | 514 }; |
| 515 | 515 |
| 516 /** | 516 /** |
| 517 * @unrestricted | 517 * @unrestricted |
| 518 */ | 518 */ |
| 519 WebInspector.SecurityPanelSidebarTreeElement = class extends TreeElement { | 519 Security.SecurityPanelSidebarTreeElement = class extends TreeElement { |
| 520 /** | 520 /** |
| 521 * @param {string} text | 521 * @param {string} text |
| 522 * @param {function()} selectCallback | 522 * @param {function()} selectCallback |
| 523 * @param {string} className | 523 * @param {string} className |
| 524 * @param {string} cssPrefix | 524 * @param {string} cssPrefix |
| 525 */ | 525 */ |
| 526 constructor(text, selectCallback, className, cssPrefix) { | 526 constructor(text, selectCallback, className, cssPrefix) { |
| 527 super('', false); | 527 super('', false); |
| 528 this._selectCallback = selectCallback; | 528 this._selectCallback = selectCallback; |
| 529 this._cssPrefix = cssPrefix; | 529 this._cssPrefix = cssPrefix; |
| 530 this.listItemElement.classList.add(className); | 530 this.listItemElement.classList.add(className); |
| 531 this._iconElement = this.listItemElement.createChild('div', 'icon'); | 531 this._iconElement = this.listItemElement.createChild('div', 'icon'); |
| 532 this._iconElement.classList.add(this._cssPrefix); | 532 this._iconElement.classList.add(this._cssPrefix); |
| 533 this.listItemElement.createChild('span', 'title').textContent = text; | 533 this.listItemElement.createChild('span', 'title').textContent = text; |
| 534 this.setSecurityState(Protocol.Security.SecurityState.Unknown); | 534 this.setSecurityState(Protocol.Security.SecurityState.Unknown); |
| 535 } | 535 } |
| 536 | 536 |
| 537 /** | 537 /** |
| 538 * @param {!WebInspector.SecurityPanelSidebarTreeElement} a | 538 * @param {!Security.SecurityPanelSidebarTreeElement} a |
| 539 * @param {!WebInspector.SecurityPanelSidebarTreeElement} b | 539 * @param {!Security.SecurityPanelSidebarTreeElement} b |
| 540 * @return {number} | 540 * @return {number} |
| 541 */ | 541 */ |
| 542 static SecurityStateComparator(a, b) { | 542 static SecurityStateComparator(a, b) { |
| 543 return WebInspector.SecurityModel.SecurityStateComparator(a.securityState(),
b.securityState()); | 543 return Security.SecurityModel.SecurityStateComparator(a.securityState(), b.s
ecurityState()); |
| 544 } | 544 } |
| 545 | 545 |
| 546 /** | 546 /** |
| 547 * @param {!Protocol.Security.SecurityState} newSecurityState | 547 * @param {!Protocol.Security.SecurityState} newSecurityState |
| 548 */ | 548 */ |
| 549 setSecurityState(newSecurityState) { | 549 setSecurityState(newSecurityState) { |
| 550 if (this._securityState) | 550 if (this._securityState) |
| 551 this._iconElement.classList.remove(this._cssPrefix + '-' + this._securityS
tate); | 551 this._iconElement.classList.remove(this._cssPrefix + '-' + this._securityS
tate); |
| 552 | 552 |
| 553 this._securityState = newSecurityState; | 553 this._securityState = newSecurityState; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 568 onselect() { | 568 onselect() { |
| 569 this._selectCallback(); | 569 this._selectCallback(); |
| 570 return true; | 570 return true; |
| 571 } | 571 } |
| 572 }; | 572 }; |
| 573 | 573 |
| 574 | 574 |
| 575 /** | 575 /** |
| 576 * @unrestricted | 576 * @unrestricted |
| 577 */ | 577 */ |
| 578 WebInspector.SecurityMainView = class extends WebInspector.VBox { | 578 Security.SecurityMainView = class extends UI.VBox { |
| 579 /** | 579 /** |
| 580 * @param {!WebInspector.SecurityPanel} panel | 580 * @param {!Security.SecurityPanel} panel |
| 581 */ | 581 */ |
| 582 constructor(panel) { | 582 constructor(panel) { |
| 583 super(true); | 583 super(true); |
| 584 this.registerRequiredCSS('security/mainView.css'); | 584 this.registerRequiredCSS('security/mainView.css'); |
| 585 this.registerRequiredCSS('security/lockIcon.css'); | 585 this.registerRequiredCSS('security/lockIcon.css'); |
| 586 this.setMinimumSize(200, 100); | 586 this.setMinimumSize(200, 100); |
| 587 | 587 |
| 588 this.contentElement.classList.add('security-main-view'); | 588 this.contentElement.classList.add('security-main-view'); |
| 589 | 589 |
| 590 this._panel = panel; | 590 this._panel = panel; |
| 591 | 591 |
| 592 this._summarySection = this.contentElement.createChild('div', 'security-summ
ary'); | 592 this._summarySection = this.contentElement.createChild('div', 'security-summ
ary'); |
| 593 | 593 |
| 594 // Info explanations should appear after all others. | 594 // Info explanations should appear after all others. |
| 595 this._securityExplanationsMain = this.contentElement.createChild('div', 'sec
urity-explanation-list'); | 595 this._securityExplanationsMain = this.contentElement.createChild('div', 'sec
urity-explanation-list'); |
| 596 this._securityExplanationsExtra = | 596 this._securityExplanationsExtra = |
| 597 this.contentElement.createChild('div', 'security-explanation-list securi
ty-explanations-extra'); | 597 this.contentElement.createChild('div', 'security-explanation-list securi
ty-explanations-extra'); |
| 598 | 598 |
| 599 // Fill the security summary section. | 599 // Fill the security summary section. |
| 600 this._summarySection.createChild('div', 'security-summary-section-title').te
xtContent = | 600 this._summarySection.createChild('div', 'security-summary-section-title').te
xtContent = |
| 601 WebInspector.UIString('Security Overview'); | 601 Common.UIString('Security Overview'); |
| 602 | 602 |
| 603 var lockSpectrum = this._summarySection.createChild('div', 'lock-spectrum'); | 603 var lockSpectrum = this._summarySection.createChild('div', 'lock-spectrum'); |
| 604 lockSpectrum.createChild('div', 'lock-icon lock-icon-secure').title = WebIns
pector.UIString('Secure'); | 604 lockSpectrum.createChild('div', 'lock-icon lock-icon-secure').title = Common
.UIString('Secure'); |
| 605 lockSpectrum.createChild('div', 'lock-icon lock-icon-neutral').title = WebIn
spector.UIString('Not Secure'); | 605 lockSpectrum.createChild('div', 'lock-icon lock-icon-neutral').title = Commo
n.UIString('Not Secure'); |
| 606 lockSpectrum.createChild('div', 'lock-icon lock-icon-insecure').title = | 606 lockSpectrum.createChild('div', 'lock-icon lock-icon-insecure').title = |
| 607 WebInspector.UIString('Not Secure (Broken)'); | 607 Common.UIString('Not Secure (Broken)'); |
| 608 | 608 |
| 609 this._summarySection.createChild('div', 'triangle-pointer-container') | 609 this._summarySection.createChild('div', 'triangle-pointer-container') |
| 610 .createChild('div', 'triangle-pointer-wrapper') | 610 .createChild('div', 'triangle-pointer-wrapper') |
| 611 .createChild('div', 'triangle-pointer'); | 611 .createChild('div', 'triangle-pointer'); |
| 612 | 612 |
| 613 this._summaryText = this._summarySection.createChild('div', 'security-summar
y-text'); | 613 this._summaryText = this._summarySection.createChild('div', 'security-summar
y-text'); |
| 614 } | 614 } |
| 615 | 615 |
| 616 /** | 616 /** |
| 617 * @param {!Element} parent | 617 * @param {!Element} parent |
| 618 * @param {!Protocol.Security.SecurityStateExplanation} explanation | 618 * @param {!Protocol.Security.SecurityStateExplanation} explanation |
| 619 * @return {!Element} | 619 * @return {!Element} |
| 620 */ | 620 */ |
| 621 _addExplanation(parent, explanation) { | 621 _addExplanation(parent, explanation) { |
| 622 var explanationSection = parent.createChild('div', 'security-explanation'); | 622 var explanationSection = parent.createChild('div', 'security-explanation'); |
| 623 explanationSection.classList.add('security-explanation-' + explanation.secur
ityState); | 623 explanationSection.classList.add('security-explanation-' + explanation.secur
ityState); |
| 624 | 624 |
| 625 explanationSection.createChild('div', 'security-property') | 625 explanationSection.createChild('div', 'security-property') |
| 626 .classList.add('security-property-' + explanation.securityState); | 626 .classList.add('security-property-' + explanation.securityState); |
| 627 var text = explanationSection.createChild('div', 'security-explanation-text'
); | 627 var text = explanationSection.createChild('div', 'security-explanation-text'
); |
| 628 text.createChild('div', 'security-explanation-title').textContent = explanat
ion.summary; | 628 text.createChild('div', 'security-explanation-title').textContent = explanat
ion.summary; |
| 629 text.createChild('div').textContent = explanation.description; | 629 text.createChild('div').textContent = explanation.description; |
| 630 | 630 |
| 631 if (explanation.hasCertificate) { | 631 if (explanation.hasCertificate) { |
| 632 text.appendChild(WebInspector.SecurityPanel.createCertificateViewerButton( | 632 text.appendChild(Security.SecurityPanel.createCertificateViewerButton( |
| 633 WebInspector.UIString('View certificate'), this._panel)); | 633 Common.UIString('View certificate'), this._panel)); |
| 634 } | 634 } |
| 635 | 635 |
| 636 return text; | 636 return text; |
| 637 } | 637 } |
| 638 | 638 |
| 639 /** | 639 /** |
| 640 * @param {!Protocol.Security.SecurityState} newSecurityState | 640 * @param {!Protocol.Security.SecurityState} newSecurityState |
| 641 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations | 641 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations |
| 642 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus | 642 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus |
| 643 * @param {boolean} schemeIsCryptographic | 643 * @param {boolean} schemeIsCryptographic |
| 644 */ | 644 */ |
| 645 updateSecurityState(newSecurityState, explanations, insecureContentStatus, sch
emeIsCryptographic) { | 645 updateSecurityState(newSecurityState, explanations, insecureContentStatus, sch
emeIsCryptographic) { |
| 646 // Remove old state. | 646 // Remove old state. |
| 647 // It's safe to call this even when this._securityState is undefined. | 647 // It's safe to call this even when this._securityState is undefined. |
| 648 this._summarySection.classList.remove('security-summary-' + this._securitySt
ate); | 648 this._summarySection.classList.remove('security-summary-' + this._securitySt
ate); |
| 649 | 649 |
| 650 // Add new state. | 650 // Add new state. |
| 651 this._securityState = newSecurityState; | 651 this._securityState = newSecurityState; |
| 652 this._summarySection.classList.add('security-summary-' + this._securityState
); | 652 this._summarySection.classList.add('security-summary-' + this._securityState
); |
| 653 var summaryExplanationStrings = { | 653 var summaryExplanationStrings = { |
| 654 'unknown': WebInspector.UIString('The security of this page is unknown.'), | 654 'unknown': Common.UIString('The security of this page is unknown.'), |
| 655 'insecure': WebInspector.UIString('This page is not secure (broken HTTPS).
'), | 655 'insecure': Common.UIString('This page is not secure (broken HTTPS).'), |
| 656 'neutral': WebInspector.UIString('This page is not secure.'), | 656 'neutral': Common.UIString('This page is not secure.'), |
| 657 'secure': WebInspector.UIString('This page is secure (valid HTTPS).') | 657 'secure': Common.UIString('This page is secure (valid HTTPS).') |
| 658 }; | 658 }; |
| 659 this._summaryText.textContent = summaryExplanationStrings[this._securityStat
e]; | 659 this._summaryText.textContent = summaryExplanationStrings[this._securityStat
e]; |
| 660 | 660 |
| 661 this._explanations = explanations, this._insecureContentStatus = insecureCon
tentStatus; | 661 this._explanations = explanations, this._insecureContentStatus = insecureCon
tentStatus; |
| 662 this._schemeIsCryptographic = schemeIsCryptographic; | 662 this._schemeIsCryptographic = schemeIsCryptographic; |
| 663 | 663 |
| 664 this._panel.setRanInsecureContentStyle(insecureContentStatus.ranInsecureCont
entStyle); | 664 this._panel.setRanInsecureContentStyle(insecureContentStatus.ranInsecureCont
entStyle); |
| 665 this._panel.setDisplayedInsecureContentStyle(insecureContentStatus.displayed
InsecureContentStyle); | 665 this._panel.setDisplayedInsecureContentStyle(insecureContentStatus.displayed
InsecureContentStyle); |
| 666 | 666 |
| 667 this.refreshExplanations(); | 667 this.refreshExplanations(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 681 this._addMixedContentExplanations(); | 681 this._addMixedContentExplanations(); |
| 682 this._addContentWithCertErrorsExplanations(); | 682 this._addContentWithCertErrorsExplanations(); |
| 683 | 683 |
| 684 // If all resources were served securely, add a Secure explanation. | 684 // If all resources were served securely, add a Secure explanation. |
| 685 if (this._schemeIsCryptographic && this._insecureContentStatus && | 685 if (this._schemeIsCryptographic && this._insecureContentStatus && |
| 686 (!this._insecureContentStatus.displayedMixedContent && !this._insecureCo
ntentStatus.ranMixedContent && | 686 (!this._insecureContentStatus.displayedMixedContent && !this._insecureCo
ntentStatus.ranMixedContent && |
| 687 !this._insecureContentStatus.displayedContentWithCertErrors && | 687 !this._insecureContentStatus.displayedContentWithCertErrors && |
| 688 !this._insecureContentStatus.ranContentWithCertErrors)) { | 688 !this._insecureContentStatus.ranContentWithCertErrors)) { |
| 689 this._addExplanation(this._securityExplanationsMain, /** @type {!Protocol.
Security.SecurityStateExplanation} */ ({ | 689 this._addExplanation(this._securityExplanationsMain, /** @type {!Protocol.
Security.SecurityStateExplanation} */ ({ |
| 690 'securityState': Protocol.Security.SecurityState.Se
cure, | 690 'securityState': Protocol.Security.SecurityState.Se
cure, |
| 691 'summary': WebInspector.UIString('Secure Resources'
), | 691 'summary': Common.UIString('Secure Resources'), |
| 692 'description': WebInspector.UIString('All resources
on this page are served securely.') | 692 'description': Common.UIString('All resources on th
is page are served securely.') |
| 693 })); | 693 })); |
| 694 } | 694 } |
| 695 } | 695 } |
| 696 | 696 |
| 697 _addMixedContentExplanations() { | 697 _addMixedContentExplanations() { |
| 698 if (!this._schemeIsCryptographic) | 698 if (!this._schemeIsCryptographic) |
| 699 return; | 699 return; |
| 700 | 700 |
| 701 if (this._insecureContentStatus && | 701 if (this._insecureContentStatus && |
| 702 (this._insecureContentStatus.ranMixedContent || this._insecureContentSta
tus.displayedMixedContent)) { | 702 (this._insecureContentStatus.ranMixedContent || this._insecureContentSta
tus.displayedMixedContent)) { |
| 703 if (this._insecureContentStatus.ranMixedContent) | 703 if (this._insecureContentStatus.ranMixedContent) |
| 704 this._addMixedContentExplanation( | 704 this._addMixedContentExplanation( |
| 705 this._securityExplanationsMain, this._insecureContentStatus.ranInsec
ureContentStyle, | 705 this._securityExplanationsMain, this._insecureContentStatus.ranInsec
ureContentStyle, |
| 706 WebInspector.UIString('Active Mixed Content'), | 706 Common.UIString('Active Mixed Content'), |
| 707 WebInspector.UIString( | 707 Common.UIString( |
| 708 'You have recently allowed non-secure content (such as scripts o
r iframes) to run on this site.'), | 708 'You have recently allowed non-secure content (such as scripts o
r iframes) to run on this site.'), |
| 709 WebInspector.NetworkLogView.MixedContentFilterValues.BlockOverridden
, | 709 Network.NetworkLogView.MixedContentFilterValues.BlockOverridden, |
| 710 showBlockOverriddenMixedContentInNetworkPanel); | 710 showBlockOverriddenMixedContentInNetworkPanel); |
| 711 if (this._insecureContentStatus.displayedMixedContent) | 711 if (this._insecureContentStatus.displayedMixedContent) |
| 712 this._addMixedContentExplanation( | 712 this._addMixedContentExplanation( |
| 713 this._securityExplanationsMain, this._insecureContentStatus.displaye
dInsecureContentStyle, | 713 this._securityExplanationsMain, this._insecureContentStatus.displaye
dInsecureContentStyle, |
| 714 WebInspector.UIString('Mixed Content'), WebInspector.UIString('The s
ite includes HTTP resources.'), | 714 Common.UIString('Mixed Content'), Common.UIString('The site includes
HTTP resources.'), |
| 715 WebInspector.NetworkLogView.MixedContentFilterValues.Displayed, show
DisplayedMixedContentInNetworkPanel); | 715 Network.NetworkLogView.MixedContentFilterValues.Displayed, showDispl
ayedMixedContentInNetworkPanel); |
| 716 } | 716 } |
| 717 | 717 |
| 718 if (this._panel.filterRequestCount(WebInspector.NetworkLogView.MixedContentF
ilterValues.Blocked) > 0) | 718 if (this._panel.filterRequestCount(Network.NetworkLogView.MixedContentFilter
Values.Blocked) > 0) |
| 719 this._addMixedContentExplanation( | 719 this._addMixedContentExplanation( |
| 720 this._securityExplanationsExtra, Protocol.Security.SecurityState.Info, | 720 this._securityExplanationsExtra, Protocol.Security.SecurityState.Info, |
| 721 WebInspector.UIString('Blocked mixed content'), | 721 Common.UIString('Blocked mixed content'), |
| 722 WebInspector.UIString('Your page requested non-secure resources that w
ere blocked.'), | 722 Common.UIString('Your page requested non-secure resources that were bl
ocked.'), |
| 723 WebInspector.NetworkLogView.MixedContentFilterValues.Blocked, showBloc
kedMixedContentInNetworkPanel); | 723 Network.NetworkLogView.MixedContentFilterValues.Blocked, showBlockedMi
xedContentInNetworkPanel); |
| 724 | 724 |
| 725 /** | 725 /** |
| 726 * @param {!Event} e | 726 * @param {!Event} e |
| 727 */ | 727 */ |
| 728 function showDisplayedMixedContentInNetworkPanel(e) { | 728 function showDisplayedMixedContentInNetworkPanel(e) { |
| 729 e.consume(); | 729 e.consume(); |
| 730 WebInspector.NetworkPanel.revealAndFilter([{ | 730 Network.NetworkPanel.revealAndFilter([{ |
| 731 filterType: WebInspector.NetworkLogView.FilterType.MixedContent, | 731 filterType: Network.NetworkLogView.FilterType.MixedContent, |
| 732 filterValue: WebInspector.NetworkLogView.MixedContentFilterValues.Displa
yed | 732 filterValue: Network.NetworkLogView.MixedContentFilterValues.Displayed |
| 733 }]); | 733 }]); |
| 734 } | 734 } |
| 735 | 735 |
| 736 /** | 736 /** |
| 737 * @param {!Event} e | 737 * @param {!Event} e |
| 738 */ | 738 */ |
| 739 function showBlockOverriddenMixedContentInNetworkPanel(e) { | 739 function showBlockOverriddenMixedContentInNetworkPanel(e) { |
| 740 e.consume(); | 740 e.consume(); |
| 741 WebInspector.NetworkPanel.revealAndFilter([{ | 741 Network.NetworkPanel.revealAndFilter([{ |
| 742 filterType: WebInspector.NetworkLogView.FilterType.MixedContent, | 742 filterType: Network.NetworkLogView.FilterType.MixedContent, |
| 743 filterValue: WebInspector.NetworkLogView.MixedContentFilterValues.BlockO
verridden | 743 filterValue: Network.NetworkLogView.MixedContentFilterValues.BlockOverri
dden |
| 744 }]); | 744 }]); |
| 745 } | 745 } |
| 746 | 746 |
| 747 /** | 747 /** |
| 748 * @param {!Event} e | 748 * @param {!Event} e |
| 749 */ | 749 */ |
| 750 function showBlockedMixedContentInNetworkPanel(e) { | 750 function showBlockedMixedContentInNetworkPanel(e) { |
| 751 e.consume(); | 751 e.consume(); |
| 752 WebInspector.NetworkPanel.revealAndFilter([{ | 752 Network.NetworkPanel.revealAndFilter([{ |
| 753 filterType: WebInspector.NetworkLogView.FilterType.MixedContent, | 753 filterType: Network.NetworkLogView.FilterType.MixedContent, |
| 754 filterValue: WebInspector.NetworkLogView.MixedContentFilterValues.Blocke
d | 754 filterValue: Network.NetworkLogView.MixedContentFilterValues.Blocked |
| 755 }]); | 755 }]); |
| 756 } | 756 } |
| 757 } | 757 } |
| 758 | 758 |
| 759 /** | 759 /** |
| 760 * @param {!Element} parent | 760 * @param {!Element} parent |
| 761 * @param {!Protocol.Security.SecurityState} securityState | 761 * @param {!Protocol.Security.SecurityState} securityState |
| 762 * @param {string} summary | 762 * @param {string} summary |
| 763 * @param {string} description | 763 * @param {string} description |
| 764 * @param {!WebInspector.NetworkLogView.MixedContentFilterValues} filterKey | 764 * @param {!Network.NetworkLogView.MixedContentFilterValues} filterKey |
| 765 * @param {!Function} networkFilterFn | 765 * @param {!Function} networkFilterFn |
| 766 */ | 766 */ |
| 767 _addMixedContentExplanation(parent, securityState, summary, description, filte
rKey, networkFilterFn) { | 767 _addMixedContentExplanation(parent, securityState, summary, description, filte
rKey, networkFilterFn) { |
| 768 var mixedContentExplanation = /** @type {!Protocol.Security.SecurityStateExp
lanation} */ ( | 768 var mixedContentExplanation = /** @type {!Protocol.Security.SecurityStateExp
lanation} */ ( |
| 769 {'securityState': securityState, 'summary': summary, 'description': desc
ription}); | 769 {'securityState': securityState, 'summary': summary, 'description': desc
ription}); |
| 770 | 770 |
| 771 var explanation = this._addExplanation(parent, mixedContentExplanation); | 771 var explanation = this._addExplanation(parent, mixedContentExplanation); |
| 772 | 772 |
| 773 var filterRequestCount = this._panel.filterRequestCount(filterKey); | 773 var filterRequestCount = this._panel.filterRequestCount(filterKey); |
| 774 if (!filterRequestCount) { | 774 if (!filterRequestCount) { |
| 775 // Network instrumentation might not have been enabled for the page | 775 // Network instrumentation might not have been enabled for the page |
| 776 // load, so the security panel does not necessarily know a count of | 776 // load, so the security panel does not necessarily know a count of |
| 777 // individual mixed requests at this point. Prompt them to refresh | 777 // individual mixed requests at this point. Prompt them to refresh |
| 778 // instead of pointing them to the Network panel to get prompted | 778 // instead of pointing them to the Network panel to get prompted |
| 779 // to refresh. | 779 // to refresh. |
| 780 var refreshPrompt = explanation.createChild('div', 'security-mixed-content
'); | 780 var refreshPrompt = explanation.createChild('div', 'security-mixed-content
'); |
| 781 refreshPrompt.textContent = WebInspector.UIString('Reload the page to reco
rd requests for HTTP resources.'); | 781 refreshPrompt.textContent = Common.UIString('Reload the page to record req
uests for HTTP resources.'); |
| 782 return; | 782 return; |
| 783 } | 783 } |
| 784 | 784 |
| 785 var requestsAnchor = explanation.createChild('div', 'security-mixed-content
link'); | 785 var requestsAnchor = explanation.createChild('div', 'security-mixed-content
link'); |
| 786 if (filterRequestCount === 1) { | 786 if (filterRequestCount === 1) { |
| 787 requestsAnchor.textContent = WebInspector.UIString('View %d request in Net
work Panel', filterRequestCount); | 787 requestsAnchor.textContent = Common.UIString('View %d request in Network P
anel', filterRequestCount); |
| 788 } else { | 788 } else { |
| 789 requestsAnchor.textContent = WebInspector.UIString('View %d requests in Ne
twork Panel', filterRequestCount); | 789 requestsAnchor.textContent = Common.UIString('View %d requests in Network
Panel', filterRequestCount); |
| 790 } | 790 } |
| 791 requestsAnchor.href = ''; | 791 requestsAnchor.href = ''; |
| 792 requestsAnchor.addEventListener('click', networkFilterFn); | 792 requestsAnchor.addEventListener('click', networkFilterFn); |
| 793 } | 793 } |
| 794 | 794 |
| 795 _addContentWithCertErrorsExplanations() { | 795 _addContentWithCertErrorsExplanations() { |
| 796 if (!this._schemeIsCryptographic) | 796 if (!this._schemeIsCryptographic) |
| 797 return; | 797 return; |
| 798 | 798 |
| 799 if (!this._insecureContentStatus) | 799 if (!this._insecureContentStatus) |
| 800 return; | 800 return; |
| 801 | 801 |
| 802 if (this._insecureContentStatus.ranContentWithCertErrors) { | 802 if (this._insecureContentStatus.ranContentWithCertErrors) { |
| 803 this._addExplanation( | 803 this._addExplanation( |
| 804 this._securityExplanationsMain, /** @type {!Protocol.Security.Security
StateExplanation} */ ({ | 804 this._securityExplanationsMain, /** @type {!Protocol.Security.Security
StateExplanation} */ ({ |
| 805 'securityState': this._insecureContentStatus.ranInsecureContentStyle
, | 805 'securityState': this._insecureContentStatus.ranInsecureContentStyle
, |
| 806 'summary': WebInspector.UIString('Active content with certificate er
rors'), | 806 'summary': Common.UIString('Active content with certificate errors')
, |
| 807 'description': WebInspector.UIString( | 807 'description': Common.UIString( |
| 808 'You have recently allowed content loaded with certificate error
s (such as scripts or iframes) to run on this site.') | 808 'You have recently allowed content loaded with certificate error
s (such as scripts or iframes) to run on this site.') |
| 809 })); | 809 })); |
| 810 } | 810 } |
| 811 | 811 |
| 812 if (this._insecureContentStatus.displayedContentWithCertErrors) { | 812 if (this._insecureContentStatus.displayedContentWithCertErrors) { |
| 813 this._addExplanation(this._securityExplanationsMain, /** @type {!Protocol.
Security.SecurityStateExplanation} */ ({ | 813 this._addExplanation(this._securityExplanationsMain, /** @type {!Protocol.
Security.SecurityStateExplanation} */ ({ |
| 814 'securityState': this._insecureContentStatus.displa
yedInsecureContentStyle, | 814 'securityState': this._insecureContentStatus.displa
yedInsecureContentStyle, |
| 815 'summary': WebInspector.UIString('Content with cert
ificate errors'), | 815 'summary': Common.UIString('Content with certificat
e errors'), |
| 816 'description': WebInspector.UIString( | 816 'description': Common.UIString( |
| 817 'This site includes resources that were loaded
with certificate errors.') | 817 'This site includes resources that were loaded
with certificate errors.') |
| 818 })); | 818 })); |
| 819 } | 819 } |
| 820 } | 820 } |
| 821 }; | 821 }; |
| 822 | 822 |
| 823 /** | 823 /** |
| 824 * @unrestricted | 824 * @unrestricted |
| 825 */ | 825 */ |
| 826 WebInspector.SecurityOriginView = class extends WebInspector.VBox { | 826 Security.SecurityOriginView = class extends UI.VBox { |
| 827 /** | 827 /** |
| 828 * @param {!WebInspector.SecurityPanel} panel | 828 * @param {!Security.SecurityPanel} panel |
| 829 * @param {!WebInspector.SecurityPanel.Origin} origin | 829 * @param {!Security.SecurityPanel.Origin} origin |
| 830 * @param {!WebInspector.SecurityPanel.OriginState} originState | 830 * @param {!Security.SecurityPanel.OriginState} originState |
| 831 */ | 831 */ |
| 832 constructor(panel, origin, originState) { | 832 constructor(panel, origin, originState) { |
| 833 super(); | 833 super(); |
| 834 this._panel = panel; | 834 this._panel = panel; |
| 835 this.setMinimumSize(200, 100); | 835 this.setMinimumSize(200, 100); |
| 836 | 836 |
| 837 this.element.classList.add('security-origin-view'); | 837 this.element.classList.add('security-origin-view'); |
| 838 this.registerRequiredCSS('security/originView.css'); | 838 this.registerRequiredCSS('security/originView.css'); |
| 839 this.registerRequiredCSS('security/lockIcon.css'); | 839 this.registerRequiredCSS('security/lockIcon.css'); |
| 840 | 840 |
| 841 var titleSection = this.element.createChild('div', 'title-section'); | 841 var titleSection = this.element.createChild('div', 'title-section'); |
| 842 var originDisplay = titleSection.createChild('div', 'origin-display'); | 842 var originDisplay = titleSection.createChild('div', 'origin-display'); |
| 843 this._originLockIcon = originDisplay.createChild('span', 'security-property'
); | 843 this._originLockIcon = originDisplay.createChild('span', 'security-property'
); |
| 844 this._originLockIcon.classList.add('security-property-' + originState.securi
tyState); | 844 this._originLockIcon.classList.add('security-property-' + originState.securi
tyState); |
| 845 // TODO(lgarron): Highlight the origin scheme. https://crbug.com/523589 | 845 // TODO(lgarron): Highlight the origin scheme. https://crbug.com/523589 |
| 846 originDisplay.createChild('span', 'origin').textContent = origin; | 846 originDisplay.createChild('span', 'origin').textContent = origin; |
| 847 var originNetworkLink = titleSection.createChild('div', 'link'); | 847 var originNetworkLink = titleSection.createChild('div', 'link'); |
| 848 originNetworkLink.textContent = WebInspector.UIString('View requests in Netw
ork Panel'); | 848 originNetworkLink.textContent = Common.UIString('View requests in Network Pa
nel'); |
| 849 function showOriginRequestsInNetworkPanel() { | 849 function showOriginRequestsInNetworkPanel() { |
| 850 var parsedURL = new WebInspector.ParsedURL(origin); | 850 var parsedURL = new Common.ParsedURL(origin); |
| 851 WebInspector.NetworkPanel.revealAndFilter([ | 851 Network.NetworkPanel.revealAndFilter([ |
| 852 {filterType: WebInspector.NetworkLogView.FilterType.Domain, filterValue:
parsedURL.host}, | 852 {filterType: Network.NetworkLogView.FilterType.Domain, filterValue: pars
edURL.host}, |
| 853 {filterType: WebInspector.NetworkLogView.FilterType.Scheme, filterValue:
parsedURL.scheme} | 853 {filterType: Network.NetworkLogView.FilterType.Scheme, filterValue: pars
edURL.scheme} |
| 854 ]); | 854 ]); |
| 855 } | 855 } |
| 856 originNetworkLink.addEventListener('click', showOriginRequestsInNetworkPanel
, false); | 856 originNetworkLink.addEventListener('click', showOriginRequestsInNetworkPanel
, false); |
| 857 | 857 |
| 858 if (originState.securityDetails) { | 858 if (originState.securityDetails) { |
| 859 var connectionSection = this.element.createChild('div', 'origin-view-secti
on'); | 859 var connectionSection = this.element.createChild('div', 'origin-view-secti
on'); |
| 860 connectionSection.createChild('div', 'origin-view-section-title').textCont
ent = | 860 connectionSection.createChild('div', 'origin-view-section-title').textCont
ent = |
| 861 WebInspector.UIString('Connection'); | 861 Common.UIString('Connection'); |
| 862 | 862 |
| 863 var table = new WebInspector.SecurityDetailsTable(); | 863 var table = new Security.SecurityDetailsTable(); |
| 864 connectionSection.appendChild(table.element()); | 864 connectionSection.appendChild(table.element()); |
| 865 table.addRow('Protocol', originState.securityDetails.protocol); | 865 table.addRow('Protocol', originState.securityDetails.protocol); |
| 866 if (originState.securityDetails.keyExchange) | 866 if (originState.securityDetails.keyExchange) |
| 867 table.addRow('Key Exchange', originState.securityDetails.keyExchange); | 867 table.addRow('Key Exchange', originState.securityDetails.keyExchange); |
| 868 if (originState.securityDetails.keyExchangeGroup) | 868 if (originState.securityDetails.keyExchangeGroup) |
| 869 table.addRow('Key Exchange Group', originState.securityDetails.keyExchan
geGroup); | 869 table.addRow('Key Exchange Group', originState.securityDetails.keyExchan
geGroup); |
| 870 table.addRow( | 870 table.addRow( |
| 871 'Cipher', originState.securityDetails.cipher + | 871 'Cipher', originState.securityDetails.cipher + |
| 872 (originState.securityDetails.mac ? ' with ' + originState.security
Details.mac : '')); | 872 (originState.securityDetails.mac ? ' with ' + originState.security
Details.mac : '')); |
| 873 | 873 |
| 874 // Create the certificate section outside the callback, so that it appears
in the right place. | 874 // Create the certificate section outside the callback, so that it appears
in the right place. |
| 875 var certificateSection = this.element.createChild('div', 'origin-view-sect
ion'); | 875 var certificateSection = this.element.createChild('div', 'origin-view-sect
ion'); |
| 876 certificateSection.createChild('div', 'origin-view-section-title').textCon
tent = | 876 certificateSection.createChild('div', 'origin-view-section-title').textCon
tent = |
| 877 WebInspector.UIString('Certificate'); | 877 Common.UIString('Certificate'); |
| 878 | 878 |
| 879 if (originState.securityDetails.signedCertificateTimestampList.length) { | 879 if (originState.securityDetails.signedCertificateTimestampList.length) { |
| 880 // Create the Certificate Transparency section outside the callback, so
that it appears in the right place. | 880 // Create the Certificate Transparency section outside the callback, so
that it appears in the right place. |
| 881 var sctSection = this.element.createChild('div', 'origin-view-section'); | 881 var sctSection = this.element.createChild('div', 'origin-view-section'); |
| 882 sctSection.createChild('div', 'origin-view-section-title').textContent = | 882 sctSection.createChild('div', 'origin-view-section-title').textContent = |
| 883 WebInspector.UIString('Certificate Transparency'); | 883 Common.UIString('Certificate Transparency'); |
| 884 } | 884 } |
| 885 | 885 |
| 886 var sanDiv = this._createSanDiv(originState.securityDetails.sanList); | 886 var sanDiv = this._createSanDiv(originState.securityDetails.sanList); |
| 887 var validFromString = new Date(1000 * originState.securityDetails.validFro
m).toUTCString(); | 887 var validFromString = new Date(1000 * originState.securityDetails.validFro
m).toUTCString(); |
| 888 var validUntilString = new Date(1000 * originState.securityDetails.validTo
).toUTCString(); | 888 var validUntilString = new Date(1000 * originState.securityDetails.validTo
).toUTCString(); |
| 889 | 889 |
| 890 table = new WebInspector.SecurityDetailsTable(); | 890 table = new Security.SecurityDetailsTable(); |
| 891 certificateSection.appendChild(table.element()); | 891 certificateSection.appendChild(table.element()); |
| 892 table.addRow(WebInspector.UIString('Subject'), originState.securityDetails
.subjectName); | 892 table.addRow(Common.UIString('Subject'), originState.securityDetails.subje
ctName); |
| 893 table.addRow(WebInspector.UIString('SAN'), sanDiv); | 893 table.addRow(Common.UIString('SAN'), sanDiv); |
| 894 table.addRow(WebInspector.UIString('Valid From'), validFromString); | 894 table.addRow(Common.UIString('Valid From'), validFromString); |
| 895 table.addRow(WebInspector.UIString('Valid Until'), validUntilString); | 895 table.addRow(Common.UIString('Valid Until'), validUntilString); |
| 896 table.addRow(WebInspector.UIString('Issuer'), originState.securityDetails.
issuer); | 896 table.addRow(Common.UIString('Issuer'), originState.securityDetails.issuer
); |
| 897 table.addRow( | 897 table.addRow( |
| 898 '', WebInspector.SecurityPanel.createCertificateViewerButton2( | 898 '', Security.SecurityPanel.createCertificateViewerButton2( |
| 899 WebInspector.UIString('Open full certificate details'), origin
)); | 899 Common.UIString('Open full certificate details'), origin)); |
| 900 | 900 |
| 901 if (!originState.securityDetails.signedCertificateTimestampList.length) | 901 if (!originState.securityDetails.signedCertificateTimestampList.length) |
| 902 return; | 902 return; |
| 903 | 903 |
| 904 // Show summary of SCT(s) of Certificate Transparency. | 904 // Show summary of SCT(s) of Certificate Transparency. |
| 905 var sctSummaryTable = new WebInspector.SecurityDetailsTable(); | 905 var sctSummaryTable = new Security.SecurityDetailsTable(); |
| 906 sctSummaryTable.element().classList.add('sct-summary'); | 906 sctSummaryTable.element().classList.add('sct-summary'); |
| 907 sctSection.appendChild(sctSummaryTable.element()); | 907 sctSection.appendChild(sctSummaryTable.element()); |
| 908 for (var i = 0; i < originState.securityDetails.signedCertificateTimestamp
List.length; i++) { | 908 for (var i = 0; i < originState.securityDetails.signedCertificateTimestamp
List.length; i++) { |
| 909 var sct = originState.securityDetails.signedCertificateTimestampList[i]; | 909 var sct = originState.securityDetails.signedCertificateTimestampList[i]; |
| 910 sctSummaryTable.addRow( | 910 sctSummaryTable.addRow( |
| 911 WebInspector.UIString('SCT'), sct.logDescription + ' (' + sct.origin
+ ', ' + sct.status + ')'); | 911 Common.UIString('SCT'), sct.logDescription + ' (' + sct.origin + ',
' + sct.status + ')'); |
| 912 } | 912 } |
| 913 | 913 |
| 914 // Show detailed SCT(s) of Certificate Transparency. | 914 // Show detailed SCT(s) of Certificate Transparency. |
| 915 var sctTableWrapper = sctSection.createChild('div', 'sct-details'); | 915 var sctTableWrapper = sctSection.createChild('div', 'sct-details'); |
| 916 sctTableWrapper.classList.add('hidden'); | 916 sctTableWrapper.classList.add('hidden'); |
| 917 for (var i = 0; i < originState.securityDetails.signedCertificateTimestamp
List.length; i++) { | 917 for (var i = 0; i < originState.securityDetails.signedCertificateTimestamp
List.length; i++) { |
| 918 var sctTable = new WebInspector.SecurityDetailsTable(); | 918 var sctTable = new Security.SecurityDetailsTable(); |
| 919 sctTableWrapper.appendChild(sctTable.element()); | 919 sctTableWrapper.appendChild(sctTable.element()); |
| 920 var sct = originState.securityDetails.signedCertificateTimestampList[i]; | 920 var sct = originState.securityDetails.signedCertificateTimestampList[i]; |
| 921 sctTable.addRow(WebInspector.UIString('Log Name'), sct.logDescription); | 921 sctTable.addRow(Common.UIString('Log Name'), sct.logDescription); |
| 922 sctTable.addRow(WebInspector.UIString('Log ID'), sct.logId.replace(/(.{2
})/g, '$1 ')); | 922 sctTable.addRow(Common.UIString('Log ID'), sct.logId.replace(/(.{2})/g,
'$1 ')); |
| 923 sctTable.addRow(WebInspector.UIString('Validation Status'), sct.status); | 923 sctTable.addRow(Common.UIString('Validation Status'), sct.status); |
| 924 sctTable.addRow(WebInspector.UIString('Source'), sct.origin); | 924 sctTable.addRow(Common.UIString('Source'), sct.origin); |
| 925 sctTable.addRow(WebInspector.UIString('Issued At'), new Date(sct.timesta
mp).toUTCString()); | 925 sctTable.addRow(Common.UIString('Issued At'), new Date(sct.timestamp).to
UTCString()); |
| 926 sctTable.addRow(WebInspector.UIString('Hash Algorithm'), sct.hashAlgorit
hm); | 926 sctTable.addRow(Common.UIString('Hash Algorithm'), sct.hashAlgorithm); |
| 927 sctTable.addRow(WebInspector.UIString('Signature Algorithm'), sct.signat
ureAlgorithm); | 927 sctTable.addRow(Common.UIString('Signature Algorithm'), sct.signatureAlg
orithm); |
| 928 sctTable.addRow(WebInspector.UIString('Signature Data'), sct.signatureDa
ta.replace(/(.{2})/g, '$1 ')); | 928 sctTable.addRow(Common.UIString('Signature Data'), sct.signatureData.rep
lace(/(.{2})/g, '$1 ')); |
| 929 } | 929 } |
| 930 | 930 |
| 931 // Add link to toggle between displaying of the summary of the SCT(s) and
the detailed SCT(s). | 931 // Add link to toggle between displaying of the summary of the SCT(s) and
the detailed SCT(s). |
| 932 var toggleSctsDetailsLink = sctSection.createChild('div', 'link'); | 932 var toggleSctsDetailsLink = sctSection.createChild('div', 'link'); |
| 933 toggleSctsDetailsLink.classList.add('sct-toggle'); | 933 toggleSctsDetailsLink.classList.add('sct-toggle'); |
| 934 toggleSctsDetailsLink.textContent = WebInspector.UIString('Show full detai
ls'); | 934 toggleSctsDetailsLink.textContent = Common.UIString('Show full details'); |
| 935 function toggleSctDetailsDisplay() { | 935 function toggleSctDetailsDisplay() { |
| 936 var isDetailsShown = !sctTableWrapper.classList.contains('hidden'); | 936 var isDetailsShown = !sctTableWrapper.classList.contains('hidden'); |
| 937 if (isDetailsShown) | 937 if (isDetailsShown) |
| 938 toggleSctsDetailsLink.textContent = WebInspector.UIString('Show full d
etails'); | 938 toggleSctsDetailsLink.textContent = Common.UIString('Show full details
'); |
| 939 else | 939 else |
| 940 toggleSctsDetailsLink.textContent = WebInspector.UIString('Hide full d
etails'); | 940 toggleSctsDetailsLink.textContent = Common.UIString('Hide full details
'); |
| 941 sctSummaryTable.element().classList.toggle('hidden'); | 941 sctSummaryTable.element().classList.toggle('hidden'); |
| 942 sctTableWrapper.classList.toggle('hidden'); | 942 sctTableWrapper.classList.toggle('hidden'); |
| 943 } | 943 } |
| 944 toggleSctsDetailsLink.addEventListener('click', toggleSctDetailsDisplay, f
alse); | 944 toggleSctsDetailsLink.addEventListener('click', toggleSctDetailsDisplay, f
alse); |
| 945 | 945 |
| 946 var noteSection = this.element.createChild('div', 'origin-view-section'); | 946 var noteSection = this.element.createChild('div', 'origin-view-section'); |
| 947 // TODO(lgarron): Fix the issue and then remove this section. See comment
in SecurityPanel._processRequest(). | 947 // TODO(lgarron): Fix the issue and then remove this section. See comment
in SecurityPanel._processRequest(). |
| 948 noteSection.createChild('div').textContent = | 948 noteSection.createChild('div').textContent = |
| 949 WebInspector.UIString('The security details above are from the first i
nspected response.'); | 949 Common.UIString('The security details above are from the first inspect
ed response.'); |
| 950 } else if (originState.securityState !== Protocol.Security.SecurityState.Unk
nown) { | 950 } else if (originState.securityState !== Protocol.Security.SecurityState.Unk
nown) { |
| 951 var notSecureSection = this.element.createChild('div', 'origin-view-sectio
n'); | 951 var notSecureSection = this.element.createChild('div', 'origin-view-sectio
n'); |
| 952 notSecureSection.createChild('div', 'origin-view-section-title').textConte
nt = | 952 notSecureSection.createChild('div', 'origin-view-section-title').textConte
nt = |
| 953 WebInspector.UIString('Not Secure'); | 953 Common.UIString('Not Secure'); |
| 954 notSecureSection.createChild('div').textContent = | 954 notSecureSection.createChild('div').textContent = |
| 955 WebInspector.UIString('Your connection to this origin is not secure.')
; | 955 Common.UIString('Your connection to this origin is not secure.'); |
| 956 } else { | 956 } else { |
| 957 var noInfoSection = this.element.createChild('div', 'origin-view-section')
; | 957 var noInfoSection = this.element.createChild('div', 'origin-view-section')
; |
| 958 noInfoSection.createChild('div', 'origin-view-section-title').textContent
= | 958 noInfoSection.createChild('div', 'origin-view-section-title').textContent
= |
| 959 WebInspector.UIString('No Security Information'); | 959 Common.UIString('No Security Information'); |
| 960 noInfoSection.createChild('div').textContent = | 960 noInfoSection.createChild('div').textContent = |
| 961 WebInspector.UIString('No security details are available for this orig
in.'); | 961 Common.UIString('No security details are available for this origin.'); |
| 962 } | 962 } |
| 963 } | 963 } |
| 964 | 964 |
| 965 /** | 965 /** |
| 966 * @param {!Array<string>} sanList | 966 * @param {!Array<string>} sanList |
| 967 * *return {!Element} | 967 * *return {!Element} |
| 968 */ | 968 */ |
| 969 _createSanDiv(sanList) { | 969 _createSanDiv(sanList) { |
| 970 var sanDiv = createElement('div'); | 970 var sanDiv = createElement('div'); |
| 971 if (sanList.length === 0) { | 971 if (sanList.length === 0) { |
| 972 sanDiv.textContent = WebInspector.UIString('(N/A)'); | 972 sanDiv.textContent = Common.UIString('(N/A)'); |
| 973 sanDiv.classList.add('empty-san'); | 973 sanDiv.classList.add('empty-san'); |
| 974 } else { | 974 } else { |
| 975 var truncatedNumToShow = 2; | 975 var truncatedNumToShow = 2; |
| 976 var listIsTruncated = sanList.length > truncatedNumToShow + 1; | 976 var listIsTruncated = sanList.length > truncatedNumToShow + 1; |
| 977 for (var i = 0; i < sanList.length; i++) { | 977 for (var i = 0; i < sanList.length; i++) { |
| 978 var span = sanDiv.createChild('span', 'san-entry'); | 978 var span = sanDiv.createChild('span', 'san-entry'); |
| 979 span.textContent = sanList[i]; | 979 span.textContent = sanList[i]; |
| 980 if (listIsTruncated && i >= truncatedNumToShow) | 980 if (listIsTruncated && i >= truncatedNumToShow) |
| 981 span.classList.add('truncated-entry'); | 981 span.classList.add('truncated-entry'); |
| 982 } | 982 } |
| 983 if (listIsTruncated) { | 983 if (listIsTruncated) { |
| 984 var truncatedSANToggle = sanDiv.createChild('div', 'link'); | 984 var truncatedSANToggle = sanDiv.createChild('div', 'link'); |
| 985 truncatedSANToggle.href = ''; | 985 truncatedSANToggle.href = ''; |
| 986 | 986 |
| 987 function toggleSANTruncation() { | 987 function toggleSANTruncation() { |
| 988 if (sanDiv.classList.contains('truncated-san')) { | 988 if (sanDiv.classList.contains('truncated-san')) { |
| 989 sanDiv.classList.remove('truncated-san'); | 989 sanDiv.classList.remove('truncated-san'); |
| 990 truncatedSANToggle.textContent = WebInspector.UIString('Show less'); | 990 truncatedSANToggle.textContent = Common.UIString('Show less'); |
| 991 } else { | 991 } else { |
| 992 sanDiv.classList.add('truncated-san'); | 992 sanDiv.classList.add('truncated-san'); |
| 993 truncatedSANToggle.textContent = WebInspector.UIString('Show more (%
d total)', sanList.length); | 993 truncatedSANToggle.textContent = Common.UIString('Show more (%d tota
l)', sanList.length); |
| 994 } | 994 } |
| 995 } | 995 } |
| 996 truncatedSANToggle.addEventListener('click', toggleSANTruncation, false)
; | 996 truncatedSANToggle.addEventListener('click', toggleSANTruncation, false)
; |
| 997 toggleSANTruncation(); | 997 toggleSANTruncation(); |
| 998 } | 998 } |
| 999 } | 999 } |
| 1000 return sanDiv; | 1000 return sanDiv; |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 /** | 1003 /** |
| 1004 * @param {!Protocol.Security.SecurityState} newSecurityState | 1004 * @param {!Protocol.Security.SecurityState} newSecurityState |
| 1005 */ | 1005 */ |
| 1006 setSecurityState(newSecurityState) { | 1006 setSecurityState(newSecurityState) { |
| 1007 for (var className of Array.prototype.slice.call(this._originLockIcon.classL
ist)) { | 1007 for (var className of Array.prototype.slice.call(this._originLockIcon.classL
ist)) { |
| 1008 if (className.startsWith('security-property-')) | 1008 if (className.startsWith('security-property-')) |
| 1009 this._originLockIcon.classList.remove(className); | 1009 this._originLockIcon.classList.remove(className); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 this._originLockIcon.classList.add('security-property-' + newSecurityState); | 1012 this._originLockIcon.classList.add('security-property-' + newSecurityState); |
| 1013 } | 1013 } |
| 1014 }; | 1014 }; |
| 1015 | 1015 |
| 1016 /** | 1016 /** |
| 1017 * @unrestricted | 1017 * @unrestricted |
| 1018 */ | 1018 */ |
| 1019 WebInspector.SecurityDetailsTable = class { | 1019 Security.SecurityDetailsTable = class { |
| 1020 constructor() { | 1020 constructor() { |
| 1021 this._element = createElement('table'); | 1021 this._element = createElement('table'); |
| 1022 this._element.classList.add('details-table'); | 1022 this._element.classList.add('details-table'); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 /** | 1025 /** |
| 1026 * @return: {!Element} | 1026 * @return: {!Element} |
| 1027 */ | 1027 */ |
| 1028 element() { | 1028 element() { |
| 1029 return this._element; | 1029 return this._element; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 /** | 1032 /** |
| 1033 * @param {string} key | 1033 * @param {string} key |
| 1034 * @param {string|!Node} value | 1034 * @param {string|!Node} value |
| 1035 */ | 1035 */ |
| 1036 addRow(key, value) { | 1036 addRow(key, value) { |
| 1037 var row = this._element.createChild('div', 'details-table-row'); | 1037 var row = this._element.createChild('div', 'details-table-row'); |
| 1038 row.createChild('div').textContent = key; | 1038 row.createChild('div').textContent = key; |
| 1039 | 1039 |
| 1040 var valueDiv = row.createChild('div'); | 1040 var valueDiv = row.createChild('div'); |
| 1041 if (typeof value === 'string') { | 1041 if (typeof value === 'string') { |
| 1042 valueDiv.textContent = value; | 1042 valueDiv.textContent = value; |
| 1043 } else { | 1043 } else { |
| 1044 valueDiv.appendChild(value); | 1044 valueDiv.appendChild(value); |
| 1045 } | 1045 } |
| 1046 } | 1046 } |
| 1047 }; | 1047 }; |
| OLD | NEW |