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

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: Address dgozman's comments. 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..f37579ed71d8073ccf0b9e6faf4312101a955128
--- /dev/null
+++ b/Source/devtools/front_end/security/SecurityPanel.js
@@ -0,0 +1,90 @@
+// 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}
+ * @implements {WebInspector.TargetManager.Observer}
+ */
+WebInspector.SecurityPanel = function() {
+ WebInspector.Panel.call(this, "security");
+ this.registerRequiredCSS("security/securityPanel.css");
+
+ WebInspector.targetManager.addModelListener(WebInspector.SecurityManager, WebInspector.SecurityManager.EventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
+
+ this.element.appendChild(this._createSecurityStateSection());
+}
+
+WebInspector.SecurityPanel.prototype = {
+ _updateSecurityState: function (newSecurityState)
+ {
+ // Remove old state.
+ // It's safe to call this even when this.securityState is undefined.
+ this.lockIcon.classList.remove(this.securityState);
+
+ // Add new state.
+ this.securityState = newSecurityState;
+ this.lockIcon.classList.add(this.securityState);
+ this.securityStateText.textContent = this.securityState;
+ },
+
+ _onSecurityStateChanged: function (event)
+ {
+ this._updateSecurityState(event.data);
+ },
+
+ _createSecurityStateSection: function()
+ {
+ var securityStateSection = createElement("div");
+
+ this.lockIcon = createElementWithClass("div", "lock-icon");
+ securityStateSection.appendChild(this.lockIcon);
+
+ this.securityStateText = createElementWithClass("div", "security-state");
+ securityStateSection.appendChild(this.securityStateText);
+
+ this._updateSecurityState("unknown");
+
+ return securityStateSection;
+ },
+
+ /**
+ * @override
+ * @param {!WebInspector.Target} target
+ */
+ targetAdded: function(target)
+ {
+ },
+
+ __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