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

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 final 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
« no previous file with comments | « Source/devtools/front_end/security/SecurityModel.js ('k') | Source/devtools/front_end/security/module.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9e4b5dbdf04ef5668e6d0f033cc5e3d5e288c3d2
--- /dev/null
+++ b/Source/devtools/front_end/security/SecurityPanel.js
@@ -0,0 +1,105 @@
+// 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");
+
+ // Create security state section.
+ var securityStateSection = this.element.createChild("div");
+ this._lockIcon = securityStateSection.createChild("div", "lock-icon");
+ this._securityStateText = securityStateSection.createChild("div", "security-state");
+
+ WebInspector.targetManager.observeTargets(this);
+}
+
+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);
+ },
+
+ /**
+ * @override
+ * @param {!WebInspector.Target} target
+ */
+ targetAdded: function(target)
+ {
+ if (!this._target) {
+ this._target = target;
+ this._securityModel = WebInspector.SecurityModel.fromTarget(target);
+ this._securityModel.addEventListener(WebInspector.SecurityModel.EventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
+ this._updateSecurityState(this._securityModel.securityState());
+ }
+ },
+
+ /**
+ * @override
+ * @param {!WebInspector.Target} target
+ */
+ targetRemoved: function(target)
+ {
+ if (target === this._target) {
+ this._securityModel.removeEventListener(WebInspector.SecurityModel.EventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
+ delete this._securityModel;
+ delete this._target;
+ this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} */ ("unknown"));
+ }
+ },
+
+ __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();
+ }
+}
« no previous file with comments | « Source/devtools/front_end/security/SecurityModel.js ('k') | Source/devtools/front_end/security/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698