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() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 * @property {?NetworkAgent.CertificateDetails} securityDetails.certificateDetai
ls - Certificate details of the origin (attached to security details), if availa
ble. | 50 * @property {?NetworkAgent.CertificateDetails} securityDetails.certificateDetai
ls - Certificate details of the origin (attached to security details), if availa
ble. |
51 * @property {?WebInspector.SecurityOriginView} originView - Current SecurityOri
ginView corresponding to origin. | 51 * @property {?WebInspector.SecurityOriginView} originView - Current SecurityOri
ginView corresponding to origin. |
52 */ | 52 */ |
53 WebInspector.SecurityPanel.OriginState; | 53 WebInspector.SecurityPanel.OriginState; |
54 | 54 |
55 WebInspector.SecurityPanel.prototype = { | 55 WebInspector.SecurityPanel.prototype = { |
56 | 56 |
57 /** | 57 /** |
58 * @param {!SecurityAgent.SecurityState} newSecurityState | 58 * @param {!SecurityAgent.SecurityState} newSecurityState |
59 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations | 59 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations |
| 60 * @param {?SecurityAgent.MixedContentStatus} mixedContentStatus |
| 61 * @param {boolean} schemeIsCryptographic |
60 */ | 62 */ |
61 _updateSecurityState: function(newSecurityState, explanations) | 63 _updateSecurityState: function(newSecurityState, explanations, mixedContentS
tatus, schemeIsCryptographic) |
62 { | 64 { |
63 this._sidebarMainViewElement.setSecurityState(newSecurityState); | 65 this._sidebarMainViewElement.setSecurityState(newSecurityState); |
64 this._mainView.updateSecurityState(newSecurityState, explanations); | 66 this._mainView.updateSecurityState(newSecurityState, explanations, mixed
ContentStatus, schemeIsCryptographic); |
65 }, | 67 }, |
66 | 68 |
67 /** | 69 /** |
68 * @param {!WebInspector.Event} event | 70 * @param {!WebInspector.Event} event |
69 */ | 71 */ |
70 _onSecurityStateChanged: function(event) | 72 _onSecurityStateChanged: function(event) |
71 { | 73 { |
72 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d
ata.securityState); | 74 var data = /** @type {!WebInspector.PageSecurityState} */ (event.data); |
73 var explanations = /** @type {!Array<!SecurityAgent.SecurityStateExplana
tion>} */ (event.data.explanations); | 75 var securityState = /** @type {!SecurityAgent.SecurityState} */ (data.se
curityState); |
74 this._updateSecurityState(securityState, explanations); | 76 var explanations = /** @type {!Array<!SecurityAgent.SecurityStateExplana
tion>} */ (data.explanations); |
| 77 var mixedContentStatus = /** @type {?SecurityAgent.MixedContentStatus} *
/ (data.mixedContentStatus); |
| 78 var schemeIsCryptographic = /** @type {boolean} */ (data.schemeIsCryptog
raphic); |
| 79 this._updateSecurityState(securityState, explanations, mixedContentStatu
s, schemeIsCryptographic); |
75 }, | 80 }, |
76 | 81 |
77 showMainView: function() | 82 showMainView: function() |
78 { | 83 { |
79 this._setVisibleView(this._mainView); | 84 this._setVisibleView(this._mainView); |
80 }, | 85 }, |
81 | 86 |
82 /** | 87 /** |
83 * @param {!WebInspector.SecurityPanel.Origin} origin | 88 * @param {!WebInspector.SecurityPanel.Origin} origin |
84 */ | 89 */ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 /** | 178 /** |
174 * @override | 179 * @override |
175 * @param {!WebInspector.Target} target | 180 * @param {!WebInspector.Target} target |
176 */ | 181 */ |
177 targetRemoved: function(target) | 182 targetRemoved: function(target) |
178 { | 183 { |
179 }, | 184 }, |
180 | 185 |
181 _clear: function() | 186 _clear: function() |
182 { | 187 { |
183 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []); | 188 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, [], null,
false); |
184 this._sidebarMainViewElement.select(); | 189 this._sidebarMainViewElement.select(); |
185 this._sidebarOriginSection.removeChildren(); | 190 this._sidebarOriginSection.removeChildren(); |
186 this._origins.clear(); | 191 this._origins.clear(); |
187 }, | 192 }, |
188 | 193 |
189 __proto__: WebInspector.PanelWithSidebar.prototype | 194 __proto__: WebInspector.PanelWithSidebar.prototype |
190 } | 195 } |
191 | 196 |
192 /** | 197 /** |
193 * @return {!WebInspector.SecurityPanel} | 198 * @return {!WebInspector.SecurityPanel} |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 text.createChild("div", "security-summary-section-title").textContent = WebI
nspector.UIString("Security Overview"); | 330 text.createChild("div", "security-summary-section-title").textContent = WebI
nspector.UIString("Security Overview"); |
326 this._summaryExplanation = text.createChild("div", "security-explanation"); | 331 this._summaryExplanation = text.createChild("div", "security-explanation"); |
327 | 332 |
328 this._securityExplanations = this.element.createChild("div", "security-expla
nation-list"); | 333 this._securityExplanations = this.element.createChild("div", "security-expla
nation-list"); |
329 | 334 |
330 } | 335 } |
331 | 336 |
332 WebInspector.SecurityMainView.prototype = { | 337 WebInspector.SecurityMainView.prototype = { |
333 /** | 338 /** |
334 * @param {!SecurityAgent.SecurityStateExplanation} explanation | 339 * @param {!SecurityAgent.SecurityStateExplanation} explanation |
| 340 * @return {!Element} |
335 */ | 341 */ |
336 _addExplanation: function(explanation) | 342 _addExplanation: function(explanation) |
337 { | 343 { |
338 var explanationSection = this._securityExplanations.createChild("div", "
security-section"); | 344 var explanationSection = this._securityExplanations.createChild("div", "
security-section"); |
339 explanationSection.classList.add("security-explanation"); | 345 explanationSection.classList.add("security-explanation"); |
340 | 346 |
341 explanationSection.createChild("div", "lock-icon").classList.add("lock-i
con-" + explanation.securityState); | 347 explanationSection.createChild("div", "lock-icon").classList.add("lock-i
con-" + explanation.securityState); |
342 var text = explanationSection.createChild("div", "security-section-text"
); | 348 var text = explanationSection.createChild("div", "security-section-text"
); |
343 text.createChild("div", "security-section-title").textContent = explanat
ion.summary; | 349 text.createChild("div", "security-section-title").textContent = explanat
ion.summary; |
344 text.createChild("div", "security-explanation").textContent = explanatio
n.description; | 350 text.createChild("div", "security-explanation").textContent = explanatio
n.description; |
345 if ("certificateId" in explanation) { | 351 if ("certificateId" in explanation) { |
346 var certificateAnchor = text.createChild("div", "security-certificat
e-id link"); | 352 var certificateAnchor = text.createChild("div", "security-certificat
e-id link"); |
347 certificateAnchor.textContent = WebInspector.UIString("View certific
ate"); | 353 certificateAnchor.textContent = WebInspector.UIString("View certific
ate"); |
348 certificateAnchor.href = ""; | 354 certificateAnchor.href = ""; |
349 certificateAnchor.addEventListener("click", showCertificateViewer, f
alse); | 355 certificateAnchor.addEventListener("click", showCertificateViewer, f
alse); |
350 } | 356 } |
| 357 |
| 358 return text; |
| 359 |
351 /** | 360 /** |
352 * @param {!Event} e | 361 * @param {!Event} e |
353 */ | 362 */ |
354 function showCertificateViewer(e) | 363 function showCertificateViewer(e) |
355 { | 364 { |
356 e.consume(); | 365 e.consume(); |
357 WebInspector.targetManager.mainTarget().networkManager.showCertifica
teViewer(/** @type {number} */ (explanation.certificateId)); | 366 WebInspector.targetManager.mainTarget().networkManager.showCertifica
teViewer(/** @type {number} */ (explanation.certificateId)); |
358 } | 367 } |
359 }, | 368 }, |
360 | 369 |
361 /** | 370 /** |
362 * @param {!SecurityAgent.SecurityState} newSecurityState | 371 * @param {!SecurityAgent.SecurityState} newSecurityState |
363 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations | 372 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations |
| 373 * @param {?SecurityAgent.MixedContentStatus} mixedContentStatus |
| 374 * @param {boolean} schemeIsCryptographic |
364 */ | 375 */ |
365 updateSecurityState: function(newSecurityState, explanations) | 376 updateSecurityState: function(newSecurityState, explanations, mixedContentSt
atus, schemeIsCryptographic) |
366 { | 377 { |
367 // Remove old state. | 378 // Remove old state. |
368 // It's safe to call this even when this._securityState is undefined. | 379 // It's safe to call this even when this._securityState is undefined. |
369 this._summarylockIcon.classList.remove("lock-icon-" + this._securityStat
e); | 380 this._summarylockIcon.classList.remove("lock-icon-" + this._securityStat
e); |
370 this._summaryExplanation.classList.remove("security-state-" + this._secu
rityState); | 381 this._summaryExplanation.classList.remove("security-state-" + this._secu
rityState); |
371 | 382 |
372 // Add new state. | 383 // Add new state. |
373 this._securityState = newSecurityState; | 384 this._securityState = newSecurityState; |
374 this._summarylockIcon.classList.add("lock-icon-" + this._securityState); | 385 this._summarylockIcon.classList.add("lock-icon-" + this._securityState); |
375 this._summaryExplanation.classList.add("security-state-" + this._securit
yState); | 386 this._summaryExplanation.classList.add("security-state-" + this._securit
yState); |
376 var summaryExplanationStrings = { | 387 var summaryExplanationStrings = { |
377 "unknown": WebInspector.UIString("This security of this page is unk
nown."), | 388 "unknown": WebInspector.UIString("This security of this page is unk
nown."), |
378 "insecure": WebInspector.UIString("This page is insecure (broken HTT
PS)."), | 389 "insecure": WebInspector.UIString("This page is insecure (broken HTT
PS)."), |
379 "neutral": WebInspector.UIString("This page is not secure."), | 390 "neutral": WebInspector.UIString("This page is not secure."), |
380 "secure": WebInspector.UIString("This page is secure (valid HTTPS)
.") | 391 "secure": WebInspector.UIString("This page is secure (valid HTTPS)
.") |
381 } | 392 } |
382 this._summaryExplanation.textContent = summaryExplanationStrings[this._s
ecurityState]; | 393 this._summaryExplanation.textContent = summaryExplanationStrings[this._s
ecurityState]; |
383 | 394 |
384 this._securityExplanations.removeChildren(); | 395 this._securityExplanations.removeChildren(); |
385 for (var explanation of explanations) | 396 for (var explanation of explanations) |
386 this._addExplanation(explanation); | 397 this._addExplanation(explanation); |
| 398 |
| 399 if (schemeIsCryptographic && mixedContentStatus && (mixedContentStatus.r
anInsecureContent || mixedContentStatus.displayedInsecureContent)) { |
| 400 /** @type {!SecurityAgent.SecurityStateExplanation} */ |
| 401 var mixedContentExplanation; |
| 402 if (mixedContentStatus.ranInsecureContent) { |
| 403 mixedContentExplanation = /** @type {!SecurityAgent.SecurityStat
eExplanation} */ ({ |
| 404 "securityState": mixedContentStatus.ranInsecureContentStyle, |
| 405 "summary": WebInspector.UIString("Active Mixed Content"), |
| 406 "description": WebInspector.UIString("You have recently allo
wed insecure content (such as scripts or iframes) to run on this site.") |
| 407 }); |
| 408 } else if (mixedContentStatus.displayedInsecureContent) { |
| 409 mixedContentExplanation = /** @type {!SecurityAgent.SecurityStat
eExplanation} */ ({ |
| 410 "securityState": mixedContentStatus.displayedInsecureContent
Style, |
| 411 "summary": WebInspector.UIString("Mixed Content"), |
| 412 "description": WebInspector.UIString("The site includes HTTP
resources.") |
| 413 }); |
| 414 } |
| 415 |
| 416 var requestsAnchor = this._addExplanation(mixedContentExplanation).c
reateChild("div", "security-mixed-content link"); |
| 417 requestsAnchor.textContent = WebInspector.UIString("View requests in
Network Panel"); |
| 418 requestsAnchor.href = ""; |
| 419 requestsAnchor.addEventListener("click", mixedContentStatus.ranInsec
ureContent ? showBlockOverriddenMixedContentInNetworkPanel : showDisplayedMixedC
ontentInNetworkPanel, false); |
| 420 } |
| 421 |
| 422 /** |
| 423 * @param {!Event} e |
| 424 */ |
| 425 function showDisplayedMixedContentInNetworkPanel(e) |
| 426 { |
| 427 e.consume(); |
| 428 WebInspector.NetworkPanel.revealAndFilter(WebInspector.NetworkLogVie
w.FilterType.MixedContent, "displayed"); |
| 429 } |
| 430 |
| 431 /** |
| 432 * @param {!Event} e |
| 433 */ |
| 434 function showBlockOverriddenMixedContentInNetworkPanel(e) |
| 435 { |
| 436 e.consume(); |
| 437 WebInspector.NetworkPanel.revealAndFilter(WebInspector.NetworkLogVie
w.FilterType.MixedContent, "block-overridden"); |
| 438 } |
387 }, | 439 }, |
388 | 440 |
389 __proto__: WebInspector.VBox.prototype | 441 __proto__: WebInspector.VBox.prototype |
390 } | 442 } |
391 | 443 |
392 /** | 444 /** |
393 * @constructor | 445 * @constructor |
394 * @extends {WebInspector.VBox} | 446 * @extends {WebInspector.VBox} |
395 * @param {!WebInspector.SecurityPanel} panel | 447 * @param {!WebInspector.SecurityPanel} panel |
396 * @param {!WebInspector.SecurityPanel.Origin} origin | 448 * @param {!WebInspector.SecurityPanel.Origin} origin |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 599 |
548 var valueDiv = row.createChild("div"); | 600 var valueDiv = row.createChild("div"); |
549 if (value instanceof HTMLDivElement) { | 601 if (value instanceof HTMLDivElement) { |
550 valueDiv.appendChild(value); | 602 valueDiv.appendChild(value); |
551 } else { | 603 } else { |
552 valueDiv.textContent = value; | 604 valueDiv.textContent = value; |
553 } | 605 } |
554 } | 606 } |
555 } | 607 } |
556 | 608 |
OLD | NEW |