| 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) { |
| 68 this._securityModel.removeEventListener(WebInspector.SecurityModel.E
ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); |
| 69 delete this._securityModel; |
| 70 delete this._target; |
| 71 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} *
/ ("unknown")); |
| 72 } |
| 73 }, |
| 74 |
| 75 __proto__: WebInspector.Panel.prototype |
| 76 } |
| 77 |
| 78 /** |
| 79 * @return {!WebInspector.SecurityPanel} |
| 80 */ |
| 81 WebInspector.SecurityPanel._instance = function() |
| 82 { |
| 83 if (!WebInspector.SecurityPanel._instanceObject) |
| 84 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa
nel(); |
| 85 return WebInspector.SecurityPanel._instanceObject; |
| 86 } |
| 87 |
| 88 /** |
| 89 * @constructor |
| 90 * @implements {WebInspector.PanelFactory} |
| 91 */ |
| 92 WebInspector.SecurityPanelFactory = function() |
| 93 { |
| 94 } |
| 95 |
| 96 WebInspector.SecurityPanelFactory.prototype = { |
| 97 /** |
| 98 * @override |
| 99 * @return {!WebInspector.Panel} |
| 100 */ |
| 101 createPanel: function() |
| 102 { |
| 103 return WebInspector.SecurityPanel._instance(); |
| 104 } |
| 105 } |
| OLD | NEW |