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

Side by Side Diff: Source/devtools/front_end/security/SecurityPanel.js

Issue 1179353002: Surface lock icon explanations in the DevTools Security panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use SecurityAgent.SecurityStateExplanation instead of creating a WebInspector.SecurityModel.Securit… 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.Panel} 7 * @extends {WebInspector.Panel}
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.SecurityPanel = function() { 10 WebInspector.SecurityPanel = function() {
11 WebInspector.Panel.call(this, "security"); 11 WebInspector.Panel.call(this, "security");
12 this.registerRequiredCSS("security/securityPanel.css"); 12 this.registerRequiredCSS("security/securityPanel.css");
13 13
14 // Create security state section. 14 // Create security state section.
15 var securityStateSection = this.element.createChild("div"); 15 var securityStateSection = this.element.createChild("div");
16 this._lockIcon = securityStateSection.createChild("div", "lock-icon"); 16 this._lockIcon = securityStateSection.createChild("div", "lock-icon");
17 this._securityStateText = securityStateSection.createChild("div", "security- state"); 17 this._securityStateText = securityStateSection.createChild("div", "security- state");
18 securityStateSection.createChild("hr");
19 this._securityExplanations = securityStateSection.createChild("div", "securi ty-explanations");
18 20
19 WebInspector.targetManager.observeTargets(this); 21 WebInspector.targetManager.observeTargets(this);
20 } 22 }
21 23
22 WebInspector.SecurityPanel.prototype = { 24 WebInspector.SecurityPanel.prototype = {
25
26
dgozman 2015/06/19 11:33:36 nit: extra blank lines.
lgarron 2015/06/19 17:35:41 Removed.
27 /**
28 * @param {!SecurityAgent.SecurityStateExplanation} explanation
29 */
30 _addExplanation: function(explanation) {
31 var explanationDiv = this._securityExplanations.createChild("div", "secu rity-explanation");
32
33 var explanationLockIcon = explanationDiv.createChild("div", "lock-icon") ;
34 explanationLockIcon.classList.add("lock-icon-" + explanation.securitySta te);
35 explanationDiv.createChild("div", "explanation-title").textContent = exp lanation.summary;
36 explanationDiv.createChild("div", "explanation-text").textContent = expl anation.description;
37 },
38
23 /** 39 /**
24 * @param {!SecurityAgent.SecurityState} newSecurityState 40 * @param {!SecurityAgent.SecurityState} newSecurityState
41 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations
25 */ 42 */
26 _updateSecurityState: function(newSecurityState) 43 _updateSecurityState: function(newSecurityState, explanations)
27 { 44 {
28 // Remove old state. 45 // Remove old state.
29 // It's safe to call this even when this._securityState is undefined. 46 // It's safe to call this even when this._securityState is undefined.
30 this._lockIcon.classList.remove("lock-icon-" + this._securityState); 47 this._lockIcon.classList.remove("lock-icon-" + this._securityState);
31 48
32 // Add new state. 49 // Add new state.
33 this._securityState = newSecurityState; 50 this._securityState = newSecurityState;
34 this._lockIcon.classList.add("lock-icon-" + this._securityState); 51 this._lockIcon.classList.add("lock-icon-" + this._securityState);
35 this._securityStateText.textContent = this._securityState; 52 this._securityStateText.textContent = WebInspector.UIString("Page securi ty state: %s", this._securityState);
53
54 this._securityExplanations.removeChildren();
55 for (var explanation of explanations) {
dgozman 2015/06/19 11:33:36 nit: no {} for one-line blocks.
lgarron 2015/06/19 17:35:41 Done. (Even if I like my unconditional for-braces
56 this._addExplanation(explanation);
57 }
36 }, 58 },
37 59
38 /** 60 /**
39 * @param {!WebInspector.Event} event 61 * @param {!WebInspector.Event} event
40 */ 62 */
41 _onSecurityStateChanged: function(event) 63 _onSecurityStateChanged: function(event)
42 { 64 {
43 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata); 65 var securityState = /** @type {!SecurityAgent.SecurityState} */ (event.d ata.securityState);
44 this._updateSecurityState(securityState); 66 var explanations = /** @type {!Array<!SecurityAgent.SecurityStateExplana tion>} */ (event.data.explanations);
67 this._updateSecurityState(securityState, explanations);
45 }, 68 },
46 69
47 /** 70 /**
48 * @override 71 * @override
49 * @param {!WebInspector.Target} target 72 * @param {!WebInspector.Target} target
50 */ 73 */
51 targetAdded: function(target) 74 targetAdded: function(target)
52 { 75 {
53 if (!this._target) { 76 if (!this._target) {
54 this._target = target; 77 this._target = target;
55 this._securityModel = WebInspector.SecurityModel.fromTarget(target); 78 this._securityModel = WebInspector.SecurityModel.fromTarget(target);
56 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this); 79 this._securityModel.addEventListener(WebInspector.SecurityModel.Even tTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
57 this._updateSecurityState(this._securityModel.securityState()); 80 this._updateSecurityState(this._securityModel.securityState(), []);
58 } 81 }
59 }, 82 },
60 83
61 /** 84 /**
62 * @override 85 * @override
63 * @param {!WebInspector.Target} target 86 * @param {!WebInspector.Target} target
64 */ 87 */
65 targetRemoved: function(target) 88 targetRemoved: function(target)
66 { 89 {
67 if (target === this._target) { 90 if (target === this._target) {
68 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this); 91 this._securityModel.removeEventListener(WebInspector.SecurityModel.E ventTypes.SecurityStateChanged, this._onSecurityStateChanged, this);
69 delete this._securityModel; 92 delete this._securityModel;
70 delete this._target; 93 delete this._target;
71 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} * / ("unknown")); 94 this._updateSecurityState(/** @type {!SecurityAgent.SecurityState} * / ("unknown"), []);
72 } 95 }
73 }, 96 },
74 97
75 __proto__: WebInspector.Panel.prototype 98 __proto__: WebInspector.Panel.prototype
76 } 99 }
77 100
78 /** 101 /**
79 * @return {!WebInspector.SecurityPanel} 102 * @return {!WebInspector.SecurityPanel}
80 */ 103 */
81 WebInspector.SecurityPanel._instance = function() 104 WebInspector.SecurityPanel._instance = function()
(...skipping 14 matching lines...) Expand all
96 WebInspector.SecurityPanelFactory.prototype = { 119 WebInspector.SecurityPanelFactory.prototype = {
97 /** 120 /**
98 * @override 121 * @override
99 * @return {!WebInspector.Panel} 122 * @return {!WebInspector.Panel}
100 */ 123 */
101 createPanel: function() 124 createPanel: function()
102 { 125 {
103 return WebInspector.SecurityPanel._instance(); 126 return WebInspector.SecurityPanel._instance();
104 } 127 }
105 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698