Skip to content

Commit 81781df

Browse files
committed
Bug 1811076: Part 6 - Show a cancelable "slow agent" dialog on slow content analysis r=nika,Gijs,rkraesig,fluent-reviewers,bolsson
This adds a modal dialog to some content analysis use cases that blocks input while CA is running. The dialog can be canceled, which cancels the CA (if possible) and the operation that required it. Differential Revision: https://phabricator.services.mozilla.com/D189578
1 parent 259f5e9 commit 81781df

File tree

12 files changed

+397
-111
lines changed

12 files changed

+397
-111
lines changed

browser/components/contentanalysis/content/ContentAnalysis.sys.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
1616

1717
const lazy = {};
1818

19+
XPCOMUtils.defineLazyServiceGetter(
20+
lazy,
21+
"gContentAnalysis",
22+
"@mozilla.org/contentanalysis;1",
23+
Ci.nsIContentAnalysis
24+
);
25+
1926
ChromeUtils.defineESModuleGetters(lazy, {
2027
clearTimeout: "resource://gre/modules/Timer.sys.mjs",
2128
setTimeout: "resource://gre/modules/Timer.sys.mjs",
@@ -387,7 +394,10 @@ export const ContentAnalysis = {
387394
},
388395

389396
_shouldShowBlockingNotification(aOperation) {
390-
return false;
397+
return !(
398+
aOperation == Ci.nsIContentAnalysisRequest.FILE_DOWNLOADED ||
399+
aOperation == Ci.nsIContentAnalysisRequest.PRINT
400+
);
391401
},
392402

393403
// This function also transforms the nameOrL10NId so we won't have to
@@ -486,7 +496,8 @@ export const ContentAnalysis = {
486496
content: this._getResourceNameFromNameOrL10NId(aResourceNameOrL10NId),
487497
}),
488498
Ci.nsIPromptService.BUTTON_POS_0 *
489-
Ci.nsIPromptService.BUTTON_TITLE_CANCEL,
499+
Ci.nsIPromptService.BUTTON_TITLE_CANCEL +
500+
Ci.nsIPromptService.SHOW_SPINNER,
490501
null,
491502
null,
492503
null,
@@ -504,6 +515,7 @@ export const ContentAnalysis = {
504515
// This is also be called if the tab/window is closed while a request is in progress,
505516
// in which case we need to cancel the request.
506517
if (this.requestTokenToRequestInfo.delete(aRequestToken)) {
518+
lazy.gContentAnalysis.cancelContentAnalysisRequest(aRequestToken);
507519
let dlpBusyView =
508520
this.dlpBusyViewsByTopBrowsingContext.getEntry(aBrowsingContext);
509521
if (dlpBusyView) {

netwerk/base/nsIPrompt.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ interface nsIPrompt : nsISupports
5656
/* used for security dialogs, buttons are initially disabled */
5757
const unsigned long BUTTON_DELAY_ENABLE = 1 << 26;
5858

59+
const unsigned long SHOW_SPINNER = 1 << 27;
60+
5961
const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
6062
(BUTTON_TITLE_CANCEL * BUTTON_POS_1);
6163
const unsigned long STD_YES_NO_BUTTONS = (BUTTON_TITLE_YES * BUTTON_POS_0) +

0 commit comments

Comments
 (0)