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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/security/SecurityModel.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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
5 /** 4 /**
6 * @constructor 5 * @unrestricted
7 * @extends {WebInspector.SDKModel}
8 * @param {!WebInspector.Target} target
9 */ 6 */
10 WebInspector.SecurityModel = function(target) 7 WebInspector.SecurityModel = class extends WebInspector.SDKModel {
11 { 8 /**
12 WebInspector.SDKModel.call(this, WebInspector.SecurityModel, target); 9 * @param {!WebInspector.Target} target
10 */
11 constructor(target) {
12 super(WebInspector.SecurityModel, target);
13 this._dispatcher = new WebInspector.SecurityDispatcher(this); 13 this._dispatcher = new WebInspector.SecurityDispatcher(this);
14 this._securityAgent = target.securityAgent(); 14 this._securityAgent = target.securityAgent();
15 target.registerSecurityDispatcher(this._dispatcher); 15 target.registerSecurityDispatcher(this._dispatcher);
16 this._securityAgent.enable(); 16 this._securityAgent.enable();
17 }; 17 }
18 18
19 /** @enum {symbol} */ 19 /**
20 WebInspector.SecurityModel.Events = { 20 * @param {!WebInspector.Target} target
21 SecurityStateChanged: Symbol("SecurityStateChanged") 21 * @return {?WebInspector.SecurityModel}
22 }; 22 */
23 23 static fromTarget(target) {
24 WebInspector.SecurityModel.prototype = {
25 __proto__: WebInspector.SDKModel.prototype,
26
27 showCertificateViewer: function()
28 {
29 this._securityAgent.showCertificateViewer();
30 }
31 };
32
33 /**
34 * @param {!WebInspector.Target} target
35 * @return {?WebInspector.SecurityModel}
36 */
37 WebInspector.SecurityModel.fromTarget = function(target)
38 {
39 var model = /** @type {?WebInspector.SecurityModel} */ (target.model(WebInsp ector.SecurityModel)); 24 var model = /** @type {?WebInspector.SecurityModel} */ (target.model(WebInsp ector.SecurityModel));
40 if (!model) 25 if (!model)
41 model = new WebInspector.SecurityModel(target); 26 model = new WebInspector.SecurityModel(target);
42 return model; 27 return model;
43 }; 28 }
44 29
45 /** 30 /**
46 * @param {!SecurityAgent.SecurityState} a 31 * @param {!SecurityAgent.SecurityState} a
47 * @param {!SecurityAgent.SecurityState} b 32 * @param {!SecurityAgent.SecurityState} b
48 * @return {number} 33 * @return {number}
49 */ 34 */
50 WebInspector.SecurityModel.SecurityStateComparator = function(a, b) 35 static SecurityStateComparator(a, b) {
51 {
52 var securityStateMap; 36 var securityStateMap;
53 if (WebInspector.SecurityModel._symbolicToNumericSecurityState) { 37 if (WebInspector.SecurityModel._symbolicToNumericSecurityState) {
54 securityStateMap = WebInspector.SecurityModel._symbolicToNumericSecurity State; 38 securityStateMap = WebInspector.SecurityModel._symbolicToNumericSecuritySt ate;
55 } else { 39 } else {
56 securityStateMap = new Map(); 40 securityStateMap = new Map();
57 var ordering = [ 41 var ordering = [
58 SecurityAgent.SecurityState.Info, 42 SecurityAgent.SecurityState.Info, SecurityAgent.SecurityState.Insecure, SecurityAgent.SecurityState.Neutral,
59 SecurityAgent.SecurityState.Insecure, 43 SecurityAgent.SecurityState.Warning, SecurityAgent.SecurityState.Secure,
60 SecurityAgent.SecurityState.Neutral, 44 // Unknown is max so that failed/cancelled requests don't overwrite the origin security state for successful requests,
61 SecurityAgent.SecurityState.Warning, 45 // and so that failed/cancelled requests appear at the bottom of the ori gins list.
62 SecurityAgent.SecurityState.Secure, 46 SecurityAgent.SecurityState.Unknown
63 // Unknown is max so that failed/cancelled requests don't overwrite the origin security state for successful requests, 47 ];
64 // and so that failed/cancelled requests appear at the bottom of the origins list. 48 for (var i = 0; i < ordering.length; i++)
65 SecurityAgent.SecurityState.Unknown 49 securityStateMap.set(ordering[i], i + 1);
66 ]; 50 WebInspector.SecurityModel._symbolicToNumericSecurityState = securityState Map;
67 for (var i = 0; i < ordering.length; i++)
68 securityStateMap.set(ordering[i], i + 1);
69 WebInspector.SecurityModel._symbolicToNumericSecurityState = securitySta teMap;
70 } 51 }
71 var aScore = securityStateMap.get(a) || 0; 52 var aScore = securityStateMap.get(a) || 0;
72 var bScore = securityStateMap.get(b) || 0; 53 var bScore = securityStateMap.get(b) || 0;
73 54
74 return aScore - bScore; 55 return aScore - bScore;
56 }
57
58 showCertificateViewer() {
59 this._securityAgent.showCertificateViewer();
60 }
75 }; 61 };
76 62
63 /** @enum {symbol} */
64 WebInspector.SecurityModel.Events = {
65 SecurityStateChanged: Symbol('SecurityStateChanged')
66 };
67
68
77 /** 69 /**
78 * @constructor 70 * @unrestricted
79 * @param {!SecurityAgent.SecurityState} securityState
80 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations
81 * @param {?SecurityAgent.InsecureContentStatus} insecureContentStatus
82 * @param {boolean} schemeIsCryptographic
83 */ 71 */
84 WebInspector.PageSecurityState = function(securityState, explanations, insecureC ontentStatus, schemeIsCryptographic) { 72 WebInspector.PageSecurityState = class {
73 /**
74 * @param {!SecurityAgent.SecurityState} securityState
75 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations
76 * @param {?SecurityAgent.InsecureContentStatus} insecureContentStatus
77 * @param {boolean} schemeIsCryptographic
78 */
79 constructor(securityState, explanations, insecureContentStatus, schemeIsCrypto graphic) {
85 this.securityState = securityState; 80 this.securityState = securityState;
86 this.explanations = explanations; 81 this.explanations = explanations;
87 this.insecureContentStatus = insecureContentStatus; 82 this.insecureContentStatus = insecureContentStatus;
88 this.schemeIsCryptographic = schemeIsCryptographic; 83 this.schemeIsCryptographic = schemeIsCryptographic;
84 }
89 }; 85 };
90 86
91 /** 87 /**
92 * @constructor
93 * @implements {SecurityAgent.Dispatcher} 88 * @implements {SecurityAgent.Dispatcher}
89 * @unrestricted
94 */ 90 */
95 WebInspector.SecurityDispatcher = function(model) 91 WebInspector.SecurityDispatcher = class {
96 { 92 constructor(model) {
97 this._model = model; 93 this._model = model;
94 }
95
96 /**
97 * @override
98 * @param {!SecurityAgent.SecurityState} securityState
99 * @param {!Array<!SecurityAgent.SecurityStateExplanation>=} explanations
100 * @param {!SecurityAgent.InsecureContentStatus=} insecureContentStatus
101 * @param {boolean=} schemeIsCryptographic
102 */
103 securityStateChanged(securityState, explanations, insecureContentStatus, schem eIsCryptographic) {
104 var pageSecurityState = new WebInspector.PageSecurityState(
105 securityState, explanations || [], insecureContentStatus || null, scheme IsCryptographic || false);
106 this._model.dispatchEventToListeners(WebInspector.SecurityModel.Events.Secur ityStateChanged, pageSecurityState);
107 }
98 }; 108 };
99
100 WebInspector.SecurityDispatcher.prototype = {
101 /**
102 * @override
103 * @param {!SecurityAgent.SecurityState} securityState
104 * @param {!Array<!SecurityAgent.SecurityStateExplanation>=} explanations
105 * @param {!SecurityAgent.InsecureContentStatus=} insecureContentStatus
106 * @param {boolean=} schemeIsCryptographic
107 */
108 securityStateChanged: function(securityState, explanations, insecureContentS tatus, schemeIsCryptographic)
109 {
110 var pageSecurityState = new WebInspector.PageSecurityState(securityState , explanations || [], insecureContentStatus || null, schemeIsCryptographic || fa lse);
111 this._model.dispatchEventToListeners(WebInspector.SecurityModel.Events.S ecurityStateChanged, pageSecurityState);
112 }
113 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698