Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @constructor | |
| 7 * @extends {WebInspector.Panel} | |
| 8 * @implements {WebInspector.TargetManager.Observer} | |
| 9 */ | |
| 10 WebInspector.SecurityPanel = function() { | |
| 11 WebInspector.Panel.call(this, "security"); | |
| 12 this.registerRequiredCSS("security/securityPanel.css"); | |
| 13 | |
| 14 // Create security state section. | |
| 15 var securityStateSection = this.element.createChild("div"); | |
| 16 this._lockIcon = securityStateSection.createChild("div", "lock-icon"); | |
| 17 this._securityStateText = securityStateSection.createChild("div", "security- state"); | |
| 18 | |
| 19 WebInspector.targetManager.observeTargets(this); | |
| 20 } | |
| 21 | |
| 22 WebInspector.SecurityPanel.prototype = { | |
| 23 /** | |
| 24 * @param {!SecurityAgent.SecurityState} newSecurityState | |
| 25 */ | |
| 26 _updateSecurityState: function(newSecurityState) | |
| 27 { | |
| 28 // Remove old state. | |
| 29 // It's safe to call this even when this._securityState is undefined. | |
| 30 this._lockIcon.classList.remove("lock-icon-" + this._securityState); | |
| 31 | |
| 32 // Add new state. | |
| 33 this._securityState = newSecurityState; | |
| 34 this._lockIcon.classList.add("lock-icon-" + this._securityState); | |
| 35 this._securityStateText.textContent = this._securityState; | |
| 36 }, | |
| 37 | |
| 38 /** | |
| 39 * @param {!WebInspector.Event} event | |
| 40 */ | |
| 41 _onSecurityStateChanged: function(event) | |
| 42 { | |
| 43 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata); | |
| 44 this._updateSecurityState(securityState); | |
| 45 }, | |
| 46 | |
| 47 /** | |
| 48 * @override | |
| 49 * @param {!WebInspector.Target} target | |
| 50 */ | |
| 51 targetAdded: function(target) | |
| 52 { | |
| 53 if (!this._target) { | |
| 54 this._target = target; | |
| 55 this._securityModel = WebInspector.SecurityModel.fromTarget(target); | |
| 56 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | |
| 57 this._updateSecurityState(this._securityModel.securityState()); | |
| 58 } | |
| 59 }, | |
| 60 | |
| 61 /** | |
| 62 * @override | |
| 63 * @param {!WebInspector.Target} target | |
| 64 */ | |
| 65 targetRemoved: function(target) | |
| 66 { | |
| 67 if (target == this._target) { | |
|
dgozman
2015/06/16 19:43:36
===
lgarron
2015/06/16 20:17:47
:-D
| |
| 68 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); | |
| 69 delete this._securityModel; | |
| 70 delete this._target; | |
|
dgozman
2015/06/16 19:43:36
Clear security state indication in UI as well.
lgarron
2015/06/16 20:17:47
Done.
| |
| 71 } | |
| 72 }, | |
| 73 | |
| 74 __proto__: WebInspector.Panel.prototype | |
| 75 } | |
| 76 | |
| 77 /** | |
| 78 * @return {!WebInspector.SecurityPanel} | |
| 79 */ | |
| 80 WebInspector.SecurityPanel._instance = function() | |
| 81 { | |
| 82 if (!WebInspector.SecurityPanel._instanceObject) | |
| 83 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa nel(); | |
| 84 return WebInspector.SecurityPanel._instanceObject; | |
| 85 } | |
| 86 | |
| 87 /** | |
| 88 * @constructor | |
| 89 * @implements {WebInspector.PanelFactory} | |
| 90 */ | |
| 91 WebInspector.SecurityPanelFactory = function() | |
| 92 { | |
| 93 } | |
| 94 | |
| 95 WebInspector.SecurityPanelFactory.prototype = { | |
| 96 /** | |
| 97 * @override | |
| 98 * @return {!WebInspector.Panel} | |
| 99 */ | |
| 100 createPanel: function() | |
| 101 { | |
| 102 return WebInspector.SecurityPanel._instance(); | |
| 103 } | |
| 104 } | |
| OLD | NEW |