| 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.Panel} | 7 * @extends {WebInspector.Panel} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.SecurityPanel = function() { | 10 WebInspector.SecurityPanel = function() { |
| 11 WebInspector.Panel.call(this, "security"); | 11 WebInspector.Panel.call(this, "security"); |
| 12 this.registerRequiredCSS("security/securityPanel.css"); | 12 this.registerRequiredCSS("security/securityPanel.css"); |
| 13 | 13 |
| 14 // Create security state section. | 14 // Create security state section. |
| 15 var securityStateSection = this.element.createChild("div"); | 15 var securityStateSection = this.element.createChild("div"); |
| 16 this._lockIcon = securityStateSection.createChild("div", "lock-icon"); | 16 this._lockIcon = securityStateSection.createChild("div", "lock-icon"); |
| 17 this._securityStateText = securityStateSection.createChild("div", "security-
state"); | 17 this._securityStateText = securityStateSection.createChild("div", "security-
state"); |
| 18 securityStateSection.createChild("hr"); |
| 19 this._securityExplanations = securityStateSection.createChild("div", "securi
ty-explanations"); |
| 18 | 20 |
| 19 WebInspector.targetManager.observeTargets(this); | 21 WebInspector.targetManager.observeTargets(this); |
| 20 } | 22 } |
| 21 | 23 |
| 22 WebInspector.SecurityPanel.prototype = { | 24 WebInspector.SecurityPanel.prototype = { |
| 23 /** | 25 /** |
| 26 * @param {!SecurityAgent.SecurityStateExplanation} explanation |
| 27 */ |
| 28 _addExplanation: function(explanation) { |
| 29 var explanationDiv = this._securityExplanations.createChild("div", "secu
rity-explanation"); |
| 30 |
| 31 var explanationLockIcon = explanationDiv.createChild("div", "lock-icon")
; |
| 32 explanationLockIcon.classList.add("lock-icon-" + explanation.securitySta
te); |
| 33 explanationDiv.createChild("div", "explanation-title").textContent = exp
lanation.summary; |
| 34 explanationDiv.createChild("div", "explanation-text").textContent = expl
anation.description; |
| 35 }, |
| 36 |
| 37 /** |
| 24 * @param {!SecurityAgent.SecurityState} newSecurityState | 38 * @param {!SecurityAgent.SecurityState} newSecurityState |
| 39 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations |
| 25 */ | 40 */ |
| 26 _updateSecurityState: function(newSecurityState) | 41 _updateSecurityState: function(newSecurityState, explanations) |
| 27 { | 42 { |
| 28 // Remove old state. | 43 // Remove old state. |
| 29 // It's safe to call this even when this._securityState is undefined. | 44 // It's safe to call this even when this._securityState is undefined. |
| 30 this._lockIcon.classList.remove("lock-icon-" + this._securityState); | 45 this._lockIcon.classList.remove("lock-icon-" + this._securityState); |
| 31 | 46 |
| 32 // Add new state. | 47 // Add new state. |
| 33 this._securityState = newSecurityState; | 48 this._securityState = newSecurityState; |
| 34 this._lockIcon.classList.add("lock-icon-" + this._securityState); | 49 this._lockIcon.classList.add("lock-icon-" + this._securityState); |
| 35 this._securityStateText.textContent = this._securityState; | 50 this._securityStateText.textContent = WebInspector.UIString("Page securi
ty state: %s", this._securityState); |
| 51 |
| 52 this._securityExplanations.removeChildren(); |
| 53 for (var explanation of explanations) |
| 54 this._addExplanation(explanation); |
| 36 }, | 55 }, |
| 37 | 56 |
| 38 /** | 57 /** |
| 39 * @param {!WebInspector.Event} event | 58 * @param {!WebInspector.Event} event |
| 40 */ | 59 */ |
| 41 _onSecurityStateChanged: function(event) | 60 _onSecurityStateChanged: function(event) |
| 42 { | 61 { |
| 43 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d
ata); | 62 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d
ata.securityState); |
| 44 this._updateSecurityState(securityState); | 63 var explanations = /** @type {!Array<!SecurityAgent.SecurityStateExplana
tion>} */ (event.data.explanations); |
| 64 this._updateSecurityState(securityState, explanations); |
| 45 }, | 65 }, |
| 46 | 66 |
| 47 /** | 67 /** |
| 48 * @override | 68 * @override |
| 49 * @param {!WebInspector.Target} target | 69 * @param {!WebInspector.Target} target |
| 50 */ | 70 */ |
| 51 targetAdded: function(target) | 71 targetAdded: function(target) |
| 52 { | 72 { |
| 53 if (!this._target) { | 73 if (!this._target) { |
| 54 this._target = target; | 74 this._target = target; |
| 55 this._securityModel = WebInspector.SecurityModel.fromTarget(target); | 75 this._securityModel = WebInspector.SecurityModel.fromTarget(target); |
| 56 this._securityModel.addEventListener(WebInspector.SecurityModel.Even
tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | 76 this._securityModel.addEventListener(WebInspector.SecurityModel.Even
tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); |
| 57 this._updateSecurityState(this._securityModel.securityState()); | 77 this._updateSecurityState(this._securityModel.securityState(), []); |
| 58 } | 78 } |
| 59 }, | 79 }, |
| 60 | 80 |
| 61 /** | 81 /** |
| 62 * @override | 82 * @override |
| 63 * @param {!WebInspector.Target} target | 83 * @param {!WebInspector.Target} target |
| 64 */ | 84 */ |
| 65 targetRemoved: function(target) | 85 targetRemoved: function(target) |
| 66 { | 86 { |
| 67 if (target === this._target) { | 87 if (target === this._target) { |
| 68 this._securityModel.removeEventListener(WebInspector.SecurityModel.E
ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | 88 this._securityModel.removeEventListener(WebInspector.SecurityModel.E
ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); |
| 69 delete this._securityModel; | 89 delete this._securityModel; |
| 70 delete this._target; | 90 delete this._target; |
| 71 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} *
/ ("unknown")); | 91 this._updateSecurityState(SecurityAgent.SecurityState.Unknown, []); |
| 72 } | 92 } |
| 73 }, | 93 }, |
| 74 | 94 |
| 75 __proto__: WebInspector.Panel.prototype | 95 __proto__: WebInspector.Panel.prototype |
| 76 } | 96 } |
| 77 | 97 |
| 78 /** | 98 /** |
| 79 * @return {!WebInspector.SecurityPanel} | 99 * @return {!WebInspector.SecurityPanel} |
| 80 */ | 100 */ |
| 81 WebInspector.SecurityPanel._instance = function() | 101 WebInspector.SecurityPanel._instance = function() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 WebInspector.SecurityPanelFactory.prototype = { | 116 WebInspector.SecurityPanelFactory.prototype = { |
| 97 /** | 117 /** |
| 98 * @override | 118 * @override |
| 99 * @return {!WebInspector.Panel} | 119 * @return {!WebInspector.Panel} |
| 100 */ | 120 */ |
| 101 createPanel: function() | 121 createPanel: function() |
| 102 { | 122 { |
| 103 return WebInspector.SecurityPanel._instance(); | 123 return WebInspector.SecurityPanel._instance(); |
| 104 } | 124 } |
| 105 } | 125 } |
| OLD | NEW |