OLD | NEW |
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.SDKModel} | 7 * @extends {WebInspector.SDKModel} |
8 * @param {!WebInspector.Target} target | 8 * @param {!WebInspector.Target} target |
9 */ | 9 */ |
10 WebInspector.SecurityModel = function(target) | 10 WebInspector.SecurityModel = function(target) |
11 { | 11 { |
12 WebInspector.SDKModel.call(this, WebInspector.SecurityModel, target); | 12 WebInspector.SDKModel.call(this, 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 /** @enum {symbol} */ |
20 WebInspector.SecurityModel.Events = { | 20 WebInspector.SecurityModel.Events = { |
21 SecurityStateChanged: Symbol("SecurityStateChanged") | 21 SecurityStateChanged: Symbol("SecurityStateChanged") |
22 } | 22 }; |
23 | 23 |
24 WebInspector.SecurityModel.prototype = { | 24 WebInspector.SecurityModel.prototype = { |
25 __proto__: WebInspector.SDKModel.prototype, | 25 __proto__: WebInspector.SDKModel.prototype, |
26 | 26 |
27 showCertificateViewer: function() | 27 showCertificateViewer: function() |
28 { | 28 { |
29 this._securityAgent.showCertificateViewer(); | 29 this._securityAgent.showCertificateViewer(); |
30 } | 30 } |
31 } | 31 }; |
32 | 32 |
33 /** | 33 /** |
34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
35 * @return {?WebInspector.SecurityModel} | 35 * @return {?WebInspector.SecurityModel} |
36 */ | 36 */ |
37 WebInspector.SecurityModel.fromTarget = function(target) | 37 WebInspector.SecurityModel.fromTarget = function(target) |
38 { | 38 { |
39 var model = /** @type {?WebInspector.SecurityModel} */ (target.model(WebInsp
ector.SecurityModel)); | 39 var model = /** @type {?WebInspector.SecurityModel} */ (target.model(WebInsp
ector.SecurityModel)); |
40 if (!model) | 40 if (!model) |
41 model = new WebInspector.SecurityModel(target); | 41 model = new WebInspector.SecurityModel(target); |
42 return model; | 42 return model; |
43 } | 43 }; |
44 | 44 |
45 /** | 45 /** |
46 * @param {!SecurityAgent.SecurityState} a | 46 * @param {!SecurityAgent.SecurityState} a |
47 * @param {!SecurityAgent.SecurityState} b | 47 * @param {!SecurityAgent.SecurityState} b |
48 * @return {number} | 48 * @return {number} |
49 */ | 49 */ |
50 WebInspector.SecurityModel.SecurityStateComparator = function(a, b) | 50 WebInspector.SecurityModel.SecurityStateComparator = function(a, b) |
51 { | 51 { |
52 var securityStateMap; | 52 var securityStateMap; |
53 if (WebInspector.SecurityModel._symbolicToNumericSecurityState) { | 53 if (WebInspector.SecurityModel._symbolicToNumericSecurityState) { |
(...skipping 11 matching lines...) Expand all Loading... |
65 SecurityAgent.SecurityState.Unknown | 65 SecurityAgent.SecurityState.Unknown |
66 ]; | 66 ]; |
67 for (var i = 0; i < ordering.length; i++) | 67 for (var i = 0; i < ordering.length; i++) |
68 securityStateMap.set(ordering[i], i + 1); | 68 securityStateMap.set(ordering[i], i + 1); |
69 WebInspector.SecurityModel._symbolicToNumericSecurityState = securitySta
teMap; | 69 WebInspector.SecurityModel._symbolicToNumericSecurityState = securitySta
teMap; |
70 } | 70 } |
71 var aScore = securityStateMap.get(a) || 0; | 71 var aScore = securityStateMap.get(a) || 0; |
72 var bScore = securityStateMap.get(b) || 0; | 72 var bScore = securityStateMap.get(b) || 0; |
73 | 73 |
74 return aScore - bScore; | 74 return aScore - bScore; |
75 } | 75 }; |
76 | 76 |
77 /** | 77 /** |
78 * @constructor | 78 * @constructor |
79 * @param {!SecurityAgent.SecurityState} securityState | 79 * @param {!SecurityAgent.SecurityState} securityState |
80 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations | 80 * @param {!Array<!SecurityAgent.SecurityStateExplanation>} explanations |
81 * @param {?SecurityAgent.InsecureContentStatus} insecureContentStatus | 81 * @param {?SecurityAgent.InsecureContentStatus} insecureContentStatus |
82 * @param {boolean} schemeIsCryptographic | 82 * @param {boolean} schemeIsCryptographic |
83 */ | 83 */ |
84 WebInspector.PageSecurityState = function(securityState, explanations, insecureC
ontentStatus, schemeIsCryptographic) { | 84 WebInspector.PageSecurityState = function(securityState, explanations, insecureC
ontentStatus, schemeIsCryptographic) { |
85 this.securityState = securityState; | 85 this.securityState = securityState; |
86 this.explanations = explanations; | 86 this.explanations = explanations; |
87 this.insecureContentStatus = insecureContentStatus; | 87 this.insecureContentStatus = insecureContentStatus; |
88 this.schemeIsCryptographic = schemeIsCryptographic; | 88 this.schemeIsCryptographic = schemeIsCryptographic; |
89 } | 89 }; |
90 | 90 |
91 /** | 91 /** |
92 * @constructor | 92 * @constructor |
93 * @implements {SecurityAgent.Dispatcher} | 93 * @implements {SecurityAgent.Dispatcher} |
94 */ | 94 */ |
95 WebInspector.SecurityDispatcher = function(model) | 95 WebInspector.SecurityDispatcher = function(model) |
96 { | 96 { |
97 this._model = model; | 97 this._model = model; |
98 } | 98 }; |
99 | 99 |
100 WebInspector.SecurityDispatcher.prototype = { | 100 WebInspector.SecurityDispatcher.prototype = { |
101 /** | 101 /** |
102 * @override | 102 * @override |
103 * @param {!SecurityAgent.SecurityState} securityState | 103 * @param {!SecurityAgent.SecurityState} securityState |
104 * @param {!Array<!SecurityAgent.SecurityStateExplanation>=} explanations | 104 * @param {!Array<!SecurityAgent.SecurityStateExplanation>=} explanations |
105 * @param {!SecurityAgent.InsecureContentStatus=} insecureContentStatus | 105 * @param {!SecurityAgent.InsecureContentStatus=} insecureContentStatus |
106 * @param {boolean=} schemeIsCryptographic | 106 * @param {boolean=} schemeIsCryptographic |
107 */ | 107 */ |
108 securityStateChanged: function(securityState, explanations, insecureContentS
tatus, schemeIsCryptographic) | 108 securityStateChanged: function(securityState, explanations, insecureContentS
tatus, schemeIsCryptographic) |
109 { | 109 { |
110 var pageSecurityState = new WebInspector.PageSecurityState(securityState
, explanations || [], insecureContentStatus || null, schemeIsCryptographic || fa
lse); | 110 var pageSecurityState = new WebInspector.PageSecurityState(securityState
, explanations || [], insecureContentStatus || null, schemeIsCryptographic || fa
lse); |
111 this._model.dispatchEventToListeners(WebInspector.SecurityModel.Events.S
ecurityStateChanged, pageSecurityState); | 111 this._model.dispatchEventToListeners(WebInspector.SecurityModel.Events.S
ecurityStateChanged, pageSecurityState); |
112 } | 112 } |
113 } | 113 }; |
OLD | NEW |