Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2160)

Unified Diff: Source/devtools/front_end/security/SecurityPanel.js

Issue 1159163005: Add a minimal Security panel to DevTools (behind a hidden experiment). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move sdk/SecurityManager.js to security/SecurityModel.js. forrealz. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/security/SecurityPanel.js
diff --git a/Source/devtools/front_end/security/SecurityPanel.js b/Source/devtools/front_end/security/SecurityPanel.js
new file mode 100644
index 0000000000000000000000000000000000000000..6826ce9c4768a3f30b0ad3ea0e55645d92a538eb
--- /dev/null
+++ b/Source/devtools/front_end/security/SecurityPanel.js
@@ -0,0 +1,79 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @constructor
+ * @extends {WebInspector.Panel}
+ */
+WebInspector.SecurityPanel = function() {
+ WebInspector.Panel.call(this, "security");
+ this.registerRequiredCSS("security/securityPanel.css");
+
+ this._securityModel = WebInspector.SecurityModel.fromTarget(WebInspector.targetManager.mainTarget());
+ this._securityModel.addEventListener(WebInspector.SecurityModel.EventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
+
+ // Create security state section
dgozman 2015/06/16 13:42:58 nit: full stop please.
lgarron 2015/06/16 19:25:43 Done.
+ 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
+ this._lockIcon = securityStateSection.createChild("div", "lock-icon");
+ this._securityStateText = securityStateSection.createChild("div", "security-state");
+ this._updateSecurityState(this._securityModel.securityState());
+ this.element.appendChild(securityStateSection);
+}
+
+WebInspector.SecurityPanel.prototype = {
+ /**
+ * @param {!SecurityAgent.SecurityState} newSecurityState
+ */
+ _updateSecurityState: function(newSecurityState)
+ {
+ // Remove old state.
+ // It's safe to call this even when this._securityState is undefined.
+ this._lockIcon.classList.remove("lock-icon-" + this._securityState);
+
+ // Add new state.
+ this._securityState = newSecurityState;
+ this._lockIcon.classList.add("lock-icon-" + this._securityState);
+ this._securityStateText.textContent = this._securityState;
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _onSecurityStateChanged: function(event)
+ {
+ var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.data);
+ this._updateSecurityState(securityState);
+ },
+
+ __proto__: WebInspector.Panel.prototype
+}
+
+/**
+ * @return {!WebInspector.SecurityPanel}
+ */
+WebInspector.SecurityPanel._instance = function()
+{
+ if (!WebInspector.SecurityPanel._instanceObject)
+ WebInspector.SecurityPanel._instanceObject = new WebInspector.SecurityPanel();
+ return WebInspector.SecurityPanel._instanceObject;
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.PanelFactory}
+ */
+WebInspector.SecurityPanelFactory = function()
+{
+}
+
+WebInspector.SecurityPanelFactory.prototype = {
+ /**
+ * @override
+ * @return {!WebInspector.Panel}
+ */
+ createPanel: function()
+ {
+ return WebInspector.SecurityPanel._instance();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698