Bug 1888259 - Show a notification when a Content Analysis request is denied for lack of an agent connection r=dlp-reviewers,fluent-reviewers,handyman
Note that this also covers the case when the connection initially succeeds but then the agent goes away - we hope to handle this better in bug 1888293. This also shows a message if the signature verification fails. Differential Revision: https://phabricator.services.mozilla.com/D206024
This commit is contained in:
@@ -243,7 +243,7 @@ export const ContentAnalysis = {
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
async observe(aSubj, aTopic) {
|
||||
async observe(aSubj, aTopic, _aData) {
|
||||
switch (aTopic) {
|
||||
case "quit-application-requested": {
|
||||
let pendingRequests =
|
||||
@@ -345,7 +345,7 @@ export const ContentAnalysis = {
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "dlp-response":
|
||||
case "dlp-response": {
|
||||
const request = aSubj.QueryInterface(Ci.nsIContentAnalysisResponse);
|
||||
// Cancels timer or slow message UI,
|
||||
// if present, and possibly presents the CA verdict.
|
||||
@@ -379,12 +379,14 @@ export const ContentAnalysis = {
|
||||
windowAndResourceNameOrOperationType.resourceNameOrOperationType,
|
||||
windowAndResourceNameOrOperationType.browsingContext,
|
||||
request.requestToken,
|
||||
responseResult
|
||||
responseResult,
|
||||
request.cancelError
|
||||
);
|
||||
this._showAnotherPendingDialog(
|
||||
windowAndResourceNameOrOperationType.browsingContext
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -662,7 +664,8 @@ export const ContentAnalysis = {
|
||||
aResourceNameOrOperationType,
|
||||
aBrowsingContext,
|
||||
aRequestToken,
|
||||
aCAResult
|
||||
aCAResult,
|
||||
aRequestCancelError
|
||||
) {
|
||||
let message = null;
|
||||
let timeoutMs = 0;
|
||||
@@ -683,7 +686,7 @@ export const ContentAnalysis = {
|
||||
);
|
||||
timeoutMs = this._RESULT_NOTIFICATION_FAST_TIMEOUT_MS;
|
||||
break;
|
||||
case Ci.nsIContentAnalysisResponse.eWarn:
|
||||
case Ci.nsIContentAnalysisResponse.eWarn: {
|
||||
const result = await Services.prompt.asyncConfirmEx(
|
||||
aBrowsingContext,
|
||||
Ci.nsIPromptService.MODAL_TYPE_TAB,
|
||||
@@ -711,6 +714,7 @@ export const ContentAnalysis = {
|
||||
const allow = result.get("buttonNumClicked") === 0;
|
||||
lazy.gContentAnalysis.respondToWarnDialog(aRequestToken, allow);
|
||||
return null;
|
||||
}
|
||||
case Ci.nsIContentAnalysisResponse.eBlock:
|
||||
if (!lazy.showBlockedResult) {
|
||||
// Don't show anything
|
||||
@@ -724,13 +728,51 @@ export const ContentAnalysis = {
|
||||
timeoutMs = this._RESULT_NOTIFICATION_TIMEOUT_MS;
|
||||
break;
|
||||
case Ci.nsIContentAnalysisResponse.eUnspecified:
|
||||
message = await this.l10n.formatValue("contentanalysis-error-message", {
|
||||
content: this._getResourceNameFromNameOrOperationType(
|
||||
aResourceNameOrOperationType
|
||||
),
|
||||
});
|
||||
message = await this.l10n.formatValue(
|
||||
"contentanalysis-unspecified-error-message",
|
||||
{
|
||||
agent: lazy.agentName,
|
||||
content: this._getResourceNameFromNameOrOperationType(
|
||||
aResourceNameOrOperationType
|
||||
),
|
||||
}
|
||||
);
|
||||
timeoutMs = this._RESULT_NOTIFICATION_TIMEOUT_MS;
|
||||
break;
|
||||
case Ci.nsIContentAnalysisResponse.eCanceled:
|
||||
{
|
||||
let messageId;
|
||||
switch (aRequestCancelError) {
|
||||
case Ci.nsIContentAnalysisResponse.eUserInitiated:
|
||||
console.error(
|
||||
"Got unexpected cancel response with eUserInitiated"
|
||||
);
|
||||
return null;
|
||||
case Ci.nsIContentAnalysisResponse.eNoAgent:
|
||||
messageId = "contentanalysis-no-agent-connected-message";
|
||||
break;
|
||||
case Ci.nsIContentAnalysisResponse.eInvalidAgentSignature:
|
||||
messageId = "contentanalysis-invalid-agent-signature-message";
|
||||
break;
|
||||
case Ci.nsIContentAnalysisResponse.eErrorOther:
|
||||
messageId = "contentanalysis-unspecified-error-message";
|
||||
break;
|
||||
default:
|
||||
console.error(
|
||||
"Unexpected CA cancelError value: " + aRequestCancelError
|
||||
);
|
||||
messageId = "contentanalysis-unspecified-error-message";
|
||||
break;
|
||||
}
|
||||
message = await this.l10n.formatValue(messageId, {
|
||||
agent: lazy.agentName,
|
||||
content: this._getResourceNameFromNameOrOperationType(
|
||||
aResourceNameOrOperationType
|
||||
),
|
||||
});
|
||||
timeoutMs = this._RESULT_NOTIFICATION_TIMEOUT_MS;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unexpected CA result value: " + aCAResult);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user