Skip to content

Commit

Permalink
Bug 1811076: Part 6 - Show a cancelable "slow agent" dialog on slow c…
Browse files Browse the repository at this point in the history
…ontent 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

UltraBlame original commit: 7ca7d7ab66453b81c86545a277ab0fdde9f19171
  • Loading branch information
marco-c committed Dec 12, 2023
1 parent 6f2492c commit d756740
Show file tree
Hide file tree
Showing 12 changed files with 396 additions and 110 deletions.
16 changes: 14 additions & 2 deletions browser/components/contentanalysis/content/ContentAnalysis.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const lazy = {};

XPCOMUtils.defineLazyServiceGetter(
lazy,
"gContentAnalysis",
"@mozilla.org/contentanalysis;1",
Ci.nsIContentAnalysis
);

ChromeUtils.defineESModuleGetters(lazy, {
clearTimeout: "resource://gre/modules/Timer.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs",
Expand Down Expand Up @@ -387,7 +394,10 @@ export const ContentAnalysis = {
},

_shouldShowBlockingNotification(aOperation) {
return false;
return !(
aOperation == Ci.nsIContentAnalysisRequest.FILE_DOWNLOADED ||
aOperation == Ci.nsIContentAnalysisRequest.PRINT
);
},

// This function also transforms the nameOrL10NId so we won't have to
Expand Down Expand Up @@ -486,7 +496,8 @@ export const ContentAnalysis = {
content: this._getResourceNameFromNameOrL10NId(aResourceNameOrL10NId),
}),
Ci.nsIPromptService.BUTTON_POS_0 *
Ci.nsIPromptService.BUTTON_TITLE_CANCEL,
Ci.nsIPromptService.BUTTON_TITLE_CANCEL +
Ci.nsIPromptService.SHOW_SPINNER,
null,
null,
null,
Expand All @@ -504,6 +515,7 @@ export const ContentAnalysis = {
// This is also be called if the tab/window is closed while a request is in progress,
// in which case we need to cancel the request.
if (this.requestTokenToRequestInfo.delete(aRequestToken)) {
lazy.gContentAnalysis.cancelContentAnalysisRequest(aRequestToken);
let dlpBusyView =
this.dlpBusyViewsByTopBrowsingContext.getEntry(aBrowsingContext);
if (dlpBusyView) {
Expand Down
2 changes: 2 additions & 0 deletions netwerk/base/nsIPrompt.idl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ interface nsIPrompt : nsISupports

const unsigned long BUTTON_DELAY_ENABLE = 1 << 26;

const unsigned long SHOW_SPINNER = 1 << 27;

const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
(BUTTON_TITLE_CANCEL * BUTTON_POS_1);
const unsigned long STD_YES_NO_BUTTONS = (BUTTON_TITLE_YES * BUTTON_POS_0) +
Expand Down
Loading

0 comments on commit d756740

Please sign in to comment.