Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.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 = { |
| 25 | |
| 26 | |
|
dgozman
2015/06/19 11:33:36
nit: extra blank lines.
lgarron
2015/06/19 17:35:41
Removed.
| |
| 27 /** | |
| 28 * @param {!SecurityAgent.SecurityStateExplanation} explanation | |
| 29 */ | |
| 30 _addExplanation: function(explanation) { | |
| 31 var explanationDiv = this._securityExplanations.createChild("div", "secu rity-explanation"); | |
| 32 | |
| 33 var explanationLockIcon = explanationDiv.createChild("div", "lock-icon") ; | |
| 34 explanationLockIcon.classList.add("lock-icon-" + explanation.securitySta te); | |
| 35 explanationDiv.createChild("div", "explanation-title").textContent = exp lanation.summary; | |
| 36 explanationDiv.createChild("div", "explanation-text").textContent = expl anation.description; | |
| 37 }, | |
| 38 | |
| 23 /** | 39 /** |
| 24 * @param {!SecurityAgent.SecurityState} newSecurityState | 40 * @param {!SecurityAgent.SecurityState} newSecurityState |
| 41 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations | |
| 25 */ | 42 */ |
| 26 _updateSecurityState: function(newSecurityState) | 43 _updateSecurityState: function(newSecurityState, explanations) |
| 27 { | 44 { |
| 28 // Remove old state. | 45 // Remove old state. |
| 29 // It's safe to call this even when this._securityState is undefined. | 46 // It's safe to call this even when this._securityState is undefined. |
| 30 this._lockIcon.classList.remove("lock-icon-" + this._securityState); | 47 this._lockIcon.classList.remove("lock-icon-" + this._securityState); |
| 31 | 48 |
| 32 // Add new state. | 49 // Add new state. |
| 33 this._securityState = newSecurityState; | 50 this._securityState = newSecurityState; |
| 34 this._lockIcon.classList.add("lock-icon-" + this._securityState); | 51 this._lockIcon.classList.add("lock-icon-" + this._securityState); |
| 35 this._securityStateText.textContent = this._securityState; | 52 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState); |
| 53 | |
| 54 this._securityExplanations.removeChildren(); | |
| 55 for (var explanation of explanations) { | |
|
dgozman
2015/06/19 11:33:36
nit: no {} for one-line blocks.
lgarron
2015/06/19 17:35:41
Done.
(Even if I like my unconditional for-braces
| |
| 56 this._addExplanation(explanation); | |
| 57 } | |
| 36 }, | 58 }, |
| 37 | 59 |
| 38 /** | 60 /** |
| 39 * @param {!WebInspector.Event} event | 61 * @param {!WebInspector.Event} event |
| 40 */ | 62 */ |
| 41 _onSecurityStateChanged: function(event) | 63 _onSecurityStateChanged: function(event) |
| 42 { | 64 { |
| 43 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata); | 65 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata.securityState); |
| 44 this._updateSecurityState(securityState); | 66 var explanations = /** @type {!Array<!SecurityAgent.SecurityStateExplana tion>} */ (event.data.explanations); |
| 67 this._updateSecurityState(securityState, explanations); | |
| 45 }, | 68 }, |
| 46 | 69 |
| 47 /** | 70 /** |
| 48 * @override | 71 * @override |
| 49 * @param {!WebInspector.Target} target | 72 * @param {!WebInspector.Target} target |
| 50 */ | 73 */ |
| 51 targetAdded: function(target) | 74 targetAdded: function(target) |
| 52 { | 75 { |
| 53 if (!this._target) { | 76 if (!this._target) { |
| 54 this._target = target; | 77 this._target = target; |
| 55 this._securityModel = WebInspector.SecurityModel.fromTarget(target); | 78 this._securityModel = WebInspector.SecurityModel.fromTarget(target); |
| 56 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | 79 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); |
| 57 this._updateSecurityState(this._securityModel.securityState()); | 80 this._updateSecurityState(this._securityModel.securityState(), []); |
| 58 } | 81 } |
| 59 }, | 82 }, |
| 60 | 83 |
| 61 /** | 84 /** |
| 62 * @override | 85 * @override |
| 63 * @param {!WebInspector.Target} target | 86 * @param {!WebInspector.Target} target |
| 64 */ | 87 */ |
| 65 targetRemoved: function(target) | 88 targetRemoved: function(target) |
| 66 { | 89 { |
| 67 if (target === this._target) { | 90 if (target === this._target) { |
| 68 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | 91 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); |
| 69 delete this._securityModel; | 92 delete this._securityModel; |
| 70 delete this._target; | 93 delete this._target; |
| 71 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} * / ("unknown")); | 94 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} * / ("unknown"), []); |
| 72 } | 95 } |
| 73 }, | 96 }, |
| 74 | 97 |
| 75 __proto__: WebInspector.Panel.prototype | 98 __proto__: WebInspector.Panel.prototype |
| 76 } | 99 } |
| 77 | 100 |
| 78 /** | 101 /** |
| 79 * @return {!WebInspector.SecurityPanel} | 102 * @return {!WebInspector.SecurityPanel} |
| 80 */ | 103 */ |
| 81 WebInspector.SecurityPanel._instance = function() | 104 WebInspector.SecurityPanel._instance = function() |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 96 WebInspector.SecurityPanelFactory.prototype = { | 119 WebInspector.SecurityPanelFactory.prototype = { |
| 97 /** | 120 /** |
| 98 * @override | 121 * @override |
| 99 * @return {!WebInspector.Panel} | 122 * @return {!WebInspector.Panel} |
| 100 */ | 123 */ |
| 101 createPanel: function() | 124 createPanel: function() |
| 102 { | 125 { |
| 103 return WebInspector.SecurityPanel._instance(); | 126 return WebInspector.SecurityPanel._instance(); |
| 104 } | 127 } |
| 105 } | 128 } |
| OLD | NEW |