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"); | |
|
dgozman
2015/06/18 10:50:49
This is ok for now, but as you add more content we
lgarron
2015/06/18 18:16:18
Acknowledged.
(I tried a few ideas like div border
| |
| 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 _addExplanation: function(explanation) { | |
|
dgozman
2015/06/18 10:50:49
JSDoc please.
lgarron
2015/06/18 18:16:18
Done.
| |
| 27 var explanationDiv = this._securityExplanations.createChild("div", "secu rity-explanation"); | |
| 28 | |
| 29 var explanationLockIcon = explanationDiv.createChild("div", "lock-icon") ; | |
| 30 explanationLockIcon.classList.add("lock-icon-" + explanation.securitySta te); | |
| 31 explanationDiv.createChild("div", "explanation-title").textContent = exp lanation.summary; | |
| 32 explanationDiv.createChild("div", "explanation-text").textContent = expl anation.description; | |
| 33 }, | |
| 34 | |
| 23 /** | 35 /** |
| 24 * @param {!SecurityAgent.SecurityState} newSecurityState | 36 * @param {!SecurityAgent.SecurityState} newSecurityState |
| 37 * @param {!Array<!WebInspector.SecurityModel.SecurityStateExplanation>} exp lanations | |
| 25 */ | 38 */ |
| 26 _updateSecurityState: function(newSecurityState) | 39 _updateSecurityState: function(newSecurityState, explanations) |
| 27 { | 40 { |
| 28 // Remove old state. | 41 // Remove old state. |
| 29 // It's safe to call this even when this._securityState is undefined. | 42 // It's safe to call this even when this._securityState is undefined. |
| 30 this._lockIcon.classList.remove("lock-icon-" + this._securityState); | 43 this._lockIcon.classList.remove("lock-icon-" + this._securityState); |
| 31 | 44 |
| 32 // Add new state. | 45 // Add new state. |
| 33 this._securityState = newSecurityState; | 46 this._securityState = newSecurityState; |
| 34 this._lockIcon.classList.add("lock-icon-" + this._securityState); | 47 this._lockIcon.classList.add("lock-icon-" + this._securityState); |
| 35 this._securityStateText.textContent = this._securityState; | 48 this._securityStateText.textContent = "Page security state: " + this._se curityState; |
|
dgozman
2015/06/18 10:50:49
Wrap all user-visible text in WebInspector.UIStrin
lgarron
2015/06/18 18:16:18
Done.
(We have our own [vs]printf? Awesome! 😎)
| |
| 49 | |
| 50 this._securityExplanations.removeChildren(); | |
| 51 explanations.map(this._addExplanation.bind(this)); | |
|
dgozman
2015/06/18 10:50:49
We usually use for..of for this.
lgarron
2015/06/18 18:16:18
Done.
(I did not know that for...of was introduced
| |
| 36 }, | 52 }, |
| 37 | 53 |
| 38 /** | 54 /** |
| 39 * @param {!WebInspector.Event} event | 55 * @param {!WebInspector.Event} event |
| 40 */ | 56 */ |
| 41 _onSecurityStateChanged: function(event) | 57 _onSecurityStateChanged: function(event) |
| 42 { | 58 { |
| 43 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata); | 59 var eventData = /** @type {!WebInspector.SecurityDispatcher.SecurityStat eChangedEvent} */ (event.data); |
| 44 this._updateSecurityState(securityState); | 60 this._updateSecurityState(eventData.securityState, eventData.explanation s); |
| 45 }, | 61 }, |
| 46 | 62 |
| 47 /** | 63 /** |
| 48 * @override | 64 * @override |
| 49 * @param {!WebInspector.Target} target | 65 * @param {!WebInspector.Target} target |
| 50 */ | 66 */ |
| 51 targetAdded: function(target) | 67 targetAdded: function(target) |
| 52 { | 68 { |
| 53 if (!this._target) { | 69 if (!this._target) { |
| 54 this._target = target; | 70 this._target = target; |
| 55 this._securityModel = WebInspector.SecurityModel.fromTarget(target); | 71 this._securityModel = WebInspector.SecurityModel.fromTarget(target); |
| 56 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | 72 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); |
| 57 this._updateSecurityState(this._securityModel.securityState()); | 73 this._updateSecurityState(this._securityModel.securityState(), []); |
| 58 } | 74 } |
| 59 }, | 75 }, |
| 60 | 76 |
| 61 /** | 77 /** |
| 62 * @override | 78 * @override |
| 63 * @param {!WebInspector.Target} target | 79 * @param {!WebInspector.Target} target |
| 64 */ | 80 */ |
| 65 targetRemoved: function(target) | 81 targetRemoved: function(target) |
| 66 { | 82 { |
| 67 if (target === this._target) { | 83 if (target === this._target) { |
| 68 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | 84 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); |
| 69 delete this._securityModel; | 85 delete this._securityModel; |
| 70 delete this._target; | 86 delete this._target; |
| 71 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} * / ("unknown")); | 87 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} * / ("unknown"), []); |
| 72 } | 88 } |
| 73 }, | 89 }, |
| 74 | 90 |
| 75 __proto__: WebInspector.Panel.prototype | 91 __proto__: WebInspector.Panel.prototype |
| 76 } | 92 } |
| 77 | 93 |
| 78 /** | 94 /** |
| 79 * @return {!WebInspector.SecurityPanel} | 95 * @return {!WebInspector.SecurityPanel} |
| 80 */ | 96 */ |
| 81 WebInspector.SecurityPanel._instance = function() | 97 WebInspector.SecurityPanel._instance = function() |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 96 WebInspector.SecurityPanelFactory.prototype = { | 112 WebInspector.SecurityPanelFactory.prototype = { |
| 97 /** | 113 /** |
| 98 * @override | 114 * @override |
| 99 * @return {!WebInspector.Panel} | 115 * @return {!WebInspector.Panel} |
| 100 */ | 116 */ |
| 101 createPanel: function() | 117 createPanel: function() |
| 102 { | 118 { |
| 103 return WebInspector.SecurityPanel._instance(); | 119 return WebInspector.SecurityPanel._instance(); |
| 104 } | 120 } |
| 105 } | 121 } |
| OLD | NEW |