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 */ | |
| 9 WebInspector.SecurityPanel = function() { | |
| 10 WebInspector.Panel.call(this, "security"); | |
| 11 this.registerRequiredCSS("security/securityPanel.css"); | |
| 12 | |
| 13 this._securityModel = WebInspector.SecurityModel.fromTarget(WebInspector.tar getManager.mainTarget()); | |
| 14 this._securityModel.addEventListener(WebInspector.SecurityModel.EventTypes.S ecurityStateChanged, this._onSecurityStateChanged, this); | |
| 15 | |
| 16 // Create security state section | |
|
dgozman
2015/06/16 13:42:58
nit: full stop please.
lgarron
2015/06/16 19:25:43
Done.
| |
| 17 var securityStateSection = createElement("div"); | |
|
dgozman
2015/06/16 13:42:58
... = this.element.createChild("div");
lgarron
2015/06/16 19:25:43
Done, but won't that mutate the DOM multiple times
dgozman
2015/06/16 19:43:36
It will. However, if you don't force layout, it sh
| |
| 18 this._lockIcon = securityStateSection.createChild("div", "lock-icon"); | |
| 19 this._securityStateText = securityStateSection.createChild("div", "security- state"); | |
| 20 this._updateSecurityState(this._securityModel.securityState()); | |
| 21 this.element.appendChild(securityStateSection); | |
| 22 } | |
| 23 | |
| 24 WebInspector.SecurityPanel.prototype = { | |
| 25 /** | |
| 26 * @param {!SecurityAgent.SecurityState} newSecurityState | |
| 27 */ | |
| 28 _updateSecurityState: function(newSecurityState) | |
| 29 { | |
| 30 // Remove old state. | |
| 31 // It's safe to call this even when this._securityState is undefined. | |
| 32 this._lockIcon.classList.remove("lock-icon-" + this._securityState); | |
| 33 | |
| 34 // Add new state. | |
| 35 this._securityState = newSecurityState; | |
| 36 this._lockIcon.classList.add("lock-icon-" + this._securityState); | |
| 37 this._securityStateText.textContent = this._securityState; | |
| 38 }, | |
| 39 | |
| 40 /** | |
| 41 * @param {!WebInspector.Event} event | |
| 42 */ | |
| 43 _onSecurityStateChanged: function(event) | |
| 44 { | |
| 45 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata); | |
| 46 this._updateSecurityState(securityState); | |
| 47 }, | |
| 48 | |
| 49 __proto__: WebInspector.Panel.prototype | |
| 50 } | |
| 51 | |
| 52 /** | |
| 53 * @return {!WebInspector.SecurityPanel} | |
| 54 */ | |
| 55 WebInspector.SecurityPanel._instance = function() | |
| 56 { | |
| 57 if (!WebInspector.SecurityPanel._instanceObject) | |
| 58 WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPa nel(); | |
| 59 return WebInspector.SecurityPanel._instanceObject; | |
| 60 } | |
| 61 | |
| 62 /** | |
| 63 * @constructor | |
| 64 * @implements {WebInspector.PanelFactory} | |
| 65 */ | |
| 66 WebInspector.SecurityPanelFactory = function() | |
| 67 { | |
| 68 } | |
| 69 | |
| 70 WebInspector.SecurityPanelFactory.prototype = { | |
| 71 /** | |
| 72 * @override | |
| 73 * @return {!WebInspector.Panel} | |
| 74 */ | |
| 75 createPanel: function() | |
| 76 { | |
| 77 return WebInspector.SecurityPanel._instance(); | |
| 78 } | |
| 79 } | |
| OLD | NEW |