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

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

Issue 1215493002: Add a sidebar to the DevTools Security panel. (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
« no previous file with comments | « no previous file | Source/devtools/front_end/security/securityPanel.css » ('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
index 4348fbb2829ff54684b0a6a2c918a31c25c88aa9..439e4037e6b792b2633dec85f6684ef97d4511ab 100644
--- a/Source/devtools/front_end/security/SecurityPanel.js
+++ b/Source/devtools/front_end/security/SecurityPanel.js
@@ -4,35 +4,28 @@
/**
* @constructor
- * @extends {WebInspector.Panel}
+ * @extends {WebInspector.PanelWithSidebar}
* @implements {WebInspector.TargetManager.Observer}
*/
WebInspector.SecurityPanel = function() {
- WebInspector.Panel.call(this, "security");
+ WebInspector.PanelWithSidebar.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");
- securityStateSection.createChild("hr");
- this._securityExplanations = securityStateSection.createChild("div", "security-explanations");
+ var sidebarTree = new TreeOutlineInShadow();
+ sidebarTree.element.classList.add("sidebar-tree");
+ this.panelSidebarElement().appendChild(sidebarTree.element);
+ this.setDefaultFocusedElement(sidebarTree.element);
+
+ this._sidebarMainViewElement = new WebInspector.SecurityMainViewSidebarTreeElement(this);
+ sidebarTree.appendChild(this._sidebarMainViewElement);
+
+ this._mainView = new WebInspector.SecurityMainView();
+ this.showMainView();
WebInspector.targetManager.observeTargets(this);
}
WebInspector.SecurityPanel.prototype = {
- /**
- * @param {!SecurityAgent.SecurityStateExplanation} explanation
- */
- _addExplanation: function(explanation) {
- var explanationDiv = this._securityExplanations.createChild("div", "security-explanation");
-
- var explanationLockIcon = explanationDiv.createChild("div", "lock-icon");
- explanationLockIcon.classList.add("lock-icon-" + explanation.securityState);
- explanationDiv.createChild("div", "explanation-title").textContent = explanation.summary;
- explanationDiv.createChild("div", "explanation-text").textContent = explanation.description;
- },
/**
* @param {!SecurityAgent.SecurityState} newSecurityState
@@ -40,18 +33,8 @@ WebInspector.SecurityPanel.prototype = {
*/
_updateSecurityState: function(newSecurityState, explanations)
{
- // 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 = WebInspector.UIString("Page security state: %s", this._securityState);
-
- this._securityExplanations.removeChildren();
- for (var explanation of explanations)
- this._addExplanation(explanation);
+ this._sidebarMainViewElement.setSecurityState(newSecurityState);
+ this._mainView.updateSecurityState(newSecurityState, explanations);
},
/**
@@ -64,6 +47,36 @@ WebInspector.SecurityPanel.prototype = {
this._updateSecurityState(securityState, explanations);
},
+ showMainView: function()
+ {
+ this.setVisibleView(this._mainView);
+ },
+
+ /**
+ * @return {!WebInspector.VBox}
+ */
+ getVisibleView: function()
dgozman 2015/06/28 16:22:34 This is not used. Remove.
+ {
+ return this._visibleView;
+ },
+
+ /**
+ * @param {!WebInspector.VBox} view
+ */
+ setVisibleView: function(view)
dgozman 2015/06/28 16:22:34 Make it private.
+ {
+ if (this._visibleView === view)
+ return;
+
+ if (this._visibleView)
+ this._visibleView.detach();
+
+ this._visibleView = view;
+
+ if (view)
+ this.splitWidget().setMainWidget(view);
+ },
+
/**
* @override
* @param {!WebInspector.Target} target
@@ -92,7 +105,7 @@ WebInspector.SecurityPanel.prototype = {
}
},
- __proto__: WebInspector.Panel.prototype
+ __proto__: WebInspector.PanelWithSidebar.prototype
}
/**
@@ -107,6 +120,50 @@ WebInspector.SecurityPanel._instance = function()
/**
* @constructor
+ * @extends {WebInspector.SidebarTreeElement}
+ * @param {!WebInspector.SecurityPanel} panel
+ */
+WebInspector.SecurityMainViewSidebarTreeElement = function(panel)
+{
+ this._panel = panel;
+ this.small = true;
+ WebInspector.SidebarTreeElement.call(this, "security-sidebar-tree-item", WebInspector.UIString("Overview"));
+ this.iconElement.classList.add("lock-icon");
dgozman 2015/06/28 16:22:34 For this to work, split off lockIcon.css and regis
+}
+
+WebInspector.SecurityMainViewSidebarTreeElement.prototype = {
+ onattach: function()
+ {
+ WebInspector.SidebarTreeElement.prototype.onattach.call(this);
+ },
+
+ /**
+ * @param {!SecurityAgent.SecurityState} newSecurityState
+ */
+ setSecurityState: function(newSecurityState)
+ {
+ for (var className of this.iconElement.classList)
+ if (className.indexOf("lock-icon-") === 0)
+ this.iconElement.classList.remove(className);
+
+ this.iconElement.classList.add("lock-icon-" + newSecurityState);
+ },
+
+ /**
+ * @override
+ * @return {boolean}
+ */
+ onselect: function()
+ {
+ this._panel.showMainView();
+ return true;
+ },
+
+ __proto__: WebInspector.SidebarTreeElement.prototype
+}
+
+/**
+ * @constructor
* @implements {WebInspector.PanelFactory}
*/
WebInspector.SecurityPanelFactory = function()
@@ -122,4 +179,61 @@ WebInspector.SecurityPanelFactory.prototype = {
{
return WebInspector.SecurityPanel._instance();
}
-}
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.VBox}
+ */
+WebInspector.SecurityMainView = function()
+{
+ WebInspector.VBox.call(this);
+ this.setMinimumSize(100, 100);
+
+ this.element.classList.add("security-main-view");
+
+ // Create security state section.
+ var securityStateSection = this.element.createChild("div");
+ this._lockIcon = securityStateSection.createChild("div", "lock-icon");
+ this._securityStateText = securityStateSection.createChild("div", "security-state");
+ securityStateSection.createChild("hr");
+ this._securityExplanations = securityStateSection.createChild("div", "security-explanations");
+
+}
+
+WebInspector.SecurityMainView.prototype = {
+ /**
+ * @param {!SecurityAgent.SecurityStateExplanation} explanation
+ */
+ _addExplanation: function(explanation)
+ {
+ var explanationDiv = this._securityExplanations.createChild("div", "security-explanation");
+
+ var explanationLockIcon = explanationDiv.createChild("div", "lock-icon");
+ explanationLockIcon.classList.add("lock-icon-" + explanation.securityState);
+ explanationDiv.createChild("div", "explanation-title").textContent = explanation.summary;
+ explanationDiv.createChild("div", "explanation-text").textContent = explanation.description;
+ },
+
+ /**
+ * @param {!SecurityAgent.SecurityState} newSecurityState
+ * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations
+ */
+ updateSecurityState: function(newSecurityState, explanations)
+ {
+ // 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 = WebInspector.UIString("Page security state: %s", this._securityState);
+
+ this._securityExplanations.removeChildren();
+ for (var explanation of explanations)
+ this._addExplanation(explanation);
+ },
+
+ __proto__: WebInspector.VBox.prototype
+}
« no previous file with comments | « no previous file | Source/devtools/front_end/security/securityPanel.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698