| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.SecurityModel = class extends WebInspector.SDKModel { | 7 Security.SecurityModel = class extends SDK.SDKModel { |
| 8 /** | 8 /** |
| 9 * @param {!WebInspector.Target} target | 9 * @param {!SDK.Target} target |
| 10 */ | 10 */ |
| 11 constructor(target) { | 11 constructor(target) { |
| 12 super(WebInspector.SecurityModel, target); | 12 super(Security.SecurityModel, target); |
| 13 this._dispatcher = new WebInspector.SecurityDispatcher(this); | 13 this._dispatcher = new Security.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 /** | 19 /** |
| 20 * @param {!WebInspector.Target} target | 20 * @param {!SDK.Target} target |
| 21 * @return {?WebInspector.SecurityModel} | 21 * @return {?Security.SecurityModel} |
| 22 */ | 22 */ |
| 23 static fromTarget(target) { | 23 static fromTarget(target) { |
| 24 var model = /** @type {?WebInspector.SecurityModel} */ (target.model(WebInsp
ector.SecurityModel)); | 24 var model = /** @type {?Security.SecurityModel} */ (target.model(Security.Se
curityModel)); |
| 25 if (!model) | 25 if (!model) |
| 26 model = new WebInspector.SecurityModel(target); | 26 model = new Security.SecurityModel(target); |
| 27 return model; | 27 return model; |
| 28 } | 28 } |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * @param {!Protocol.Security.SecurityState} a | 31 * @param {!Protocol.Security.SecurityState} a |
| 32 * @param {!Protocol.Security.SecurityState} b | 32 * @param {!Protocol.Security.SecurityState} b |
| 33 * @return {number} | 33 * @return {number} |
| 34 */ | 34 */ |
| 35 static SecurityStateComparator(a, b) { | 35 static SecurityStateComparator(a, b) { |
| 36 var securityStateMap; | 36 var securityStateMap; |
| 37 if (WebInspector.SecurityModel._symbolicToNumericSecurityState) { | 37 if (Security.SecurityModel._symbolicToNumericSecurityState) { |
| 38 securityStateMap = WebInspector.SecurityModel._symbolicToNumericSecuritySt
ate; | 38 securityStateMap = Security.SecurityModel._symbolicToNumericSecurityState; |
| 39 } else { | 39 } else { |
| 40 securityStateMap = new Map(); | 40 securityStateMap = new Map(); |
| 41 var ordering = [ | 41 var ordering = [ |
| 42 Protocol.Security.SecurityState.Info, Protocol.Security.SecurityState.In
secure, Protocol.Security.SecurityState.Neutral, | 42 Protocol.Security.SecurityState.Info, Protocol.Security.SecurityState.In
secure, Protocol.Security.SecurityState.Neutral, |
| 43 Protocol.Security.SecurityState.Warning, Protocol.Security.SecurityState
.Secure, | 43 Protocol.Security.SecurityState.Warning, Protocol.Security.SecurityState
.Secure, |
| 44 // Unknown is max so that failed/cancelled requests don't overwrite the
origin security state for successful requests, | 44 // Unknown is max so that failed/cancelled requests don't overwrite the
origin security state for successful requests, |
| 45 // and so that failed/cancelled requests appear at the bottom of the ori
gins list. | 45 // and so that failed/cancelled requests appear at the bottom of the ori
gins list. |
| 46 Protocol.Security.SecurityState.Unknown | 46 Protocol.Security.SecurityState.Unknown |
| 47 ]; | 47 ]; |
| 48 for (var i = 0; i < ordering.length; i++) | 48 for (var i = 0; i < ordering.length; i++) |
| 49 securityStateMap.set(ordering[i], i + 1); | 49 securityStateMap.set(ordering[i], i + 1); |
| 50 WebInspector.SecurityModel._symbolicToNumericSecurityState = securityState
Map; | 50 Security.SecurityModel._symbolicToNumericSecurityState = securityStateMap; |
| 51 } | 51 } |
| 52 var aScore = securityStateMap.get(a) || 0; | 52 var aScore = securityStateMap.get(a) || 0; |
| 53 var bScore = securityStateMap.get(b) || 0; | 53 var bScore = securityStateMap.get(b) || 0; |
| 54 | 54 |
| 55 return aScore - bScore; | 55 return aScore - bScore; |
| 56 } | 56 } |
| 57 | 57 |
| 58 showCertificateViewer() { | 58 showCertificateViewer() { |
| 59 this._securityAgent.showCertificateViewer(); | 59 this._securityAgent.showCertificateViewer(); |
| 60 } | 60 } |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 /** @enum {symbol} */ | 63 /** @enum {symbol} */ |
| 64 WebInspector.SecurityModel.Events = { | 64 Security.SecurityModel.Events = { |
| 65 SecurityStateChanged: Symbol('SecurityStateChanged') | 65 SecurityStateChanged: Symbol('SecurityStateChanged') |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * @unrestricted | 70 * @unrestricted |
| 71 */ | 71 */ |
| 72 WebInspector.PageSecurityState = class { | 72 Security.PageSecurityState = class { |
| 73 /** | 73 /** |
| 74 * @param {!Protocol.Security.SecurityState} securityState | 74 * @param {!Protocol.Security.SecurityState} securityState |
| 75 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations | 75 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations |
| 76 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus | 76 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus |
| 77 * @param {boolean} schemeIsCryptographic | 77 * @param {boolean} schemeIsCryptographic |
| 78 */ | 78 */ |
| 79 constructor(securityState, explanations, insecureContentStatus, schemeIsCrypto
graphic) { | 79 constructor(securityState, explanations, insecureContentStatus, schemeIsCrypto
graphic) { |
| 80 this.securityState = securityState; | 80 this.securityState = securityState; |
| 81 this.explanations = explanations; | 81 this.explanations = explanations; |
| 82 this.insecureContentStatus = insecureContentStatus; | 82 this.insecureContentStatus = insecureContentStatus; |
| 83 this.schemeIsCryptographic = schemeIsCryptographic; | 83 this.schemeIsCryptographic = schemeIsCryptographic; |
| 84 } | 84 } |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * @implements {Protocol.SecurityDispatcher} | 88 * @implements {Protocol.SecurityDispatcher} |
| 89 * @unrestricted | 89 * @unrestricted |
| 90 */ | 90 */ |
| 91 WebInspector.SecurityDispatcher = class { | 91 Security.SecurityDispatcher = class { |
| 92 constructor(model) { | 92 constructor(model) { |
| 93 this._model = model; | 93 this._model = model; |
| 94 } | 94 } |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * @override | 97 * @override |
| 98 * @param {!Protocol.Security.SecurityState} securityState | 98 * @param {!Protocol.Security.SecurityState} securityState |
| 99 * @param {!Array<!Protocol.Security.SecurityStateExplanation>=} explanations | 99 * @param {!Array<!Protocol.Security.SecurityStateExplanation>=} explanations |
| 100 * @param {!Protocol.Security.InsecureContentStatus=} insecureContentStatus | 100 * @param {!Protocol.Security.InsecureContentStatus=} insecureContentStatus |
| 101 * @param {boolean=} schemeIsCryptographic | 101 * @param {boolean=} schemeIsCryptographic |
| 102 */ | 102 */ |
| 103 securityStateChanged(securityState, explanations, insecureContentStatus, schem
eIsCryptographic) { | 103 securityStateChanged(securityState, explanations, insecureContentStatus, schem
eIsCryptographic) { |
| 104 var pageSecurityState = new WebInspector.PageSecurityState( | 104 var pageSecurityState = new Security.PageSecurityState( |
| 105 securityState, explanations || [], insecureContentStatus || null, scheme
IsCryptographic || false); | 105 securityState, explanations || [], insecureContentStatus || null, scheme
IsCryptographic || false); |
| 106 this._model.dispatchEventToListeners(WebInspector.SecurityModel.Events.Secur
ityStateChanged, pageSecurityState); | 106 this._model.dispatchEventToListeners(Security.SecurityModel.Events.SecurityS
tateChanged, pageSecurityState); |
| 107 } | 107 } |
| 108 }; | 108 }; |
| OLD | NEW |