mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 05:35:05 +08:00
Move and rename files. NOAUTOREVERT=true NOPRESUBMIT=true NOTREECHECKS=true Bug: 768828 TBR=darin@chromium.org NOTRY=true Change-Id: I66d3b155808bc5bdbf237b80208e1e552bcf7f28 Reviewed-on: https://chromium-review.googlesource.com/1001153 Reviewed-by: Blink Reformat <blink-reformat@chromium.org> Commit-Queue: Blink Reformat <blink-reformat@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#549061} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0aee4434a4dba42a42abaea9bfbc0cd196a63bc1
123 lines
3.9 KiB
JavaScript
123 lines
3.9 KiB
JavaScript
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
/**
|
|
* @unrestricted
|
|
*/
|
|
Security.SecurityModel = class extends SDK.SDKModel {
|
|
/**
|
|
* @param {!SDK.Target} target
|
|
*/
|
|
constructor(target) {
|
|
super(target);
|
|
this._dispatcher = new Security.SecurityDispatcher(this);
|
|
this._securityAgent = target.securityAgent();
|
|
target.registerSecurityDispatcher(this._dispatcher);
|
|
this._securityAgent.enable();
|
|
}
|
|
|
|
/**
|
|
* @return {!SDK.ResourceTreeModel}
|
|
*/
|
|
resourceTreeModel() {
|
|
return /** @type {!SDK.ResourceTreeModel} */ (this.target().model(SDK.ResourceTreeModel));
|
|
}
|
|
|
|
/**
|
|
* @return {!SDK.NetworkManager}
|
|
*/
|
|
networkManager() {
|
|
return /** @type {!SDK.NetworkManager} */ (this.target().model(SDK.NetworkManager));
|
|
}
|
|
|
|
/**
|
|
* @param {!Protocol.Security.SecurityState} a
|
|
* @param {!Protocol.Security.SecurityState} b
|
|
* @return {number}
|
|
*/
|
|
static SecurityStateComparator(a, b) {
|
|
let securityStateMap;
|
|
if (Security.SecurityModel._symbolicToNumericSecurityState) {
|
|
securityStateMap = Security.SecurityModel._symbolicToNumericSecurityState;
|
|
} else {
|
|
securityStateMap = new Map();
|
|
const ordering = [
|
|
Protocol.Security.SecurityState.Info, Protocol.Security.SecurityState.Insecure,
|
|
Protocol.Security.SecurityState.Neutral, Protocol.Security.SecurityState.Secure,
|
|
// Unknown is max so that failed/cancelled requests don't overwrite the origin security state for successful requests,
|
|
// and so that failed/cancelled requests appear at the bottom of the origins list.
|
|
Protocol.Security.SecurityState.Unknown
|
|
];
|
|
for (let i = 0; i < ordering.length; i++)
|
|
securityStateMap.set(ordering[i], i + 1);
|
|
Security.SecurityModel._symbolicToNumericSecurityState = securityStateMap;
|
|
}
|
|
const aScore = securityStateMap.get(a) || 0;
|
|
const bScore = securityStateMap.get(b) || 0;
|
|
|
|
return aScore - bScore;
|
|
}
|
|
};
|
|
|
|
SDK.SDKModel.register(Security.SecurityModel, SDK.Target.Capability.Security, false);
|
|
|
|
/** @enum {symbol} */
|
|
Security.SecurityModel.Events = {
|
|
SecurityStateChanged: Symbol('SecurityStateChanged')
|
|
};
|
|
|
|
|
|
/**
|
|
* @unrestricted
|
|
*/
|
|
Security.PageSecurityState = class {
|
|
/**
|
|
* @param {!Protocol.Security.SecurityState} securityState
|
|
* @param {boolean} schemeIsCryptographic
|
|
* @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations
|
|
* @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus
|
|
* @param {?string} summary
|
|
*/
|
|
constructor(securityState, schemeIsCryptographic, explanations, insecureContentStatus, summary) {
|
|
this.securityState = securityState;
|
|
this.schemeIsCryptographic = schemeIsCryptographic;
|
|
this.explanations = explanations;
|
|
this.insecureContentStatus = insecureContentStatus;
|
|
this.summary = summary;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @implements {Protocol.SecurityDispatcher}
|
|
* @unrestricted
|
|
*/
|
|
Security.SecurityDispatcher = class {
|
|
constructor(model) {
|
|
this._model = model;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {!Protocol.Security.SecurityState} securityState
|
|
* @param {boolean} schemeIsCryptographic
|
|
* @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations
|
|
* @param {!Protocol.Security.InsecureContentStatus} insecureContentStatus
|
|
* @param {?string=} summary
|
|
*/
|
|
securityStateChanged(securityState, schemeIsCryptographic, explanations, insecureContentStatus, summary) {
|
|
const pageSecurityState = new Security.PageSecurityState(
|
|
securityState, schemeIsCryptographic, explanations, insecureContentStatus, summary || null);
|
|
this._model.dispatchEventToListeners(Security.SecurityModel.Events.SecurityStateChanged, pageSecurityState);
|
|
}
|
|
|
|
|
|
/**
|
|
* @override
|
|
* @param {number} eventId
|
|
* @param {string} errorType
|
|
* @param {string} requestURL
|
|
*/
|
|
certificateError(eventId, errorType, requestURL) {
|
|
}
|
|
};
|