Commit Graph

78 Commits

Author SHA1 Message Date
Greg Stoll
b48f6f4035 Bug 1972786 - show various DLP agent errors for download operations a=diannaS
Show these errors in the download panel, etc.

Original Revision: https://phabricator.services.mozilla.com/D254295

Differential Revision: https://phabricator.services.mozilla.com/D258587
2025-07-24 20:20:47 +00:00
Greg Stoll
972e0fdf7c Bug 1972773 - avoid showing "confirm quit" dialog in Content Analysis if we have already cancelled quit a=diannaS
I think there may be some other corner cases (if the user decides to confirm
the quit with a download running we still still show a dialog here), but
that is harder to fix and this is a start.

Original Revision: https://phabricator.services.mozilla.com/D254291

Differential Revision: https://phabricator.services.mozilla.com/D258213
2025-07-23 17:33:29 +00:00
Greg Stoll
1b51797326 Bug 1965504 part 4 - don't show the normal Content Analysis dialogs for downloads a=diannaS
One annoying part to this is that for "Save As" downloads on a PDF (for
example), we don't get a valid browsing context. For downloads, the only
thing we need a browsing context for us to get a window so we can show
the "DLP busy" notification, so just use the window that we were
initialized with. In practice I can't tell any difference.

Original Revision: https://phabricator.services.mozilla.com/D251880

Differential Revision: https://phabricator.services.mozilla.com/D258204
2025-07-23 17:33:04 +00:00
Greg Stoll
7ec9c6d8f4 Bug 1965504 part 1 - add Download operation type and rename fileNameForDisplay a=diannaS
We only ever used operationDisplayString to represent a filename,
so go ahead and formalize that.

Original Revision: https://phabricator.services.mozilla.com/D251877

Differential Revision: https://phabricator.services.mozilla.com/D258201
2025-07-23 17:32:55 +00:00
Greg Stoll
036a0bca8e Bug 1955250 - make Content Analysis able to display tab-modal dialogs in sidebar r=dlp-reviewers,desktop-theme-reviewers,reusable-components-reviewers,sidebar-reviewers,mstriemer,emz,handyman,nika,jsudiaman,emilio
Content Analysis needs to be able to show a tab-modal dialog in the
sidebar, in case users paste text into a GenAI chatbot, etc. The dialogs
need to be tab-modal because the "DLP busy" dialog needs to be closable
by the JS code when the operation is done.

This change detects whether a dialog is trying to be displayed from a
browser inside the sidebar and shows it correctly.

Note that this does not change how extensions behave; if they try to
display a tab-modal dialog it will end up being window-modal (see
discussion in bug 1680066 and bug 1513656). I had a patch to fix this
but ran into some window leaks during tests that I was unable to address.

Differential Revision: https://phabricator.services.mozilla.com/D242957
2025-05-17 15:32:35 +00:00
Greg Stoll
c2396a2055 Bug 1965230 - add test for DLP block dialog r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D248486
2025-05-15 20:56:27 +00:00
Greg Stoll
358bbfae32 Bug 1964606 - make cancelling Content Analysis request from the busy dialog work r=dlp-reviewers,haik
The fix to bug 1963360 broke cancelling in the dialog. This is a small
fix but I also added a few tests around the busy/cancel dialog, which
will hopefully prevent these kinds of regressions in the future.

Differential Revision: https://phabricator.services.mozilla.com/D248103
2025-05-08 05:54:48 +00:00
Greg Stoll
6ebdc2c56d Bug 1963360, 1963525 - don't cancel associated Content Analysis user actions when operation finishes r=dlp-reviewers,handyman
When we close the DLP busy dialog programmatically, we shouldn't cancel
associated user actions. This can cause a problem if we're analyzing files
in batch mode (since once one operation finishes, it will cancel the other
selected files). It can also cause problems with WARN responses, since it
will cancel the operation before the user can select ALLOW or BLOCK.

I have on my list to add tests for the WARN dialog, which I'll hopefully
get around to soon and I think would have caught this.

Differential Revision: https://phabricator.services.mozilla.com/D247320
2025-05-01 03:50:47 +00:00
David P
2ff239406e Bug 1959897: Cancel all parts of a folder check when the user presses cancel r=dlp-reviewers,gstoll
Since the cancel dialog is only associated with one user action ID, and a
folder check now uses different user action IDs for each file, user-cancel
needs to cancel all of the associated user action IDs.  (Other cancel
reasons will not want that behavior.)

This patch adds a set of these compound actions to the service.  Each entry
is the complete set of user action IDs that constitute the compound action.
The set is held until the compound action issues a response.

Differential Revision: https://phabricator.services.mozilla.com/D246160
2025-04-24 18:35:50 +00:00
Narcis Beleuzu
2c62587ed4 Backed out 3 changesets (bug 1959897, bug 1961681) for bc failure on browser_content_analysis_quit_confirmation_dialog.js . CLOSED TREE
Backed out changeset 467eb65531bb (bug 1961681)
Backed out changeset 8c31a7235349 (bug 1961681)
Backed out changeset 850588e929b6 (bug 1959897)
2025-04-24 01:58:57 +03:00
David P
d32b0a6902 Bug 1959897: Cancel all parts of a folder check when the user presses cancel r=dlp-reviewers,gstoll
Since the cancel dialog is only associated with one user action ID, and a
folder check now uses different user action IDs for each file, user-cancel
needs to cancel all of the associated user action IDs.  (Other cancel
reasons will not want that behavior.)

This patch adds a set of these compound actions to the service.  Each entry
is the complete set of user action IDs that constitute the compound action.
The set is held until the compound action issues a response.

Differential Revision: https://phabricator.services.mozilla.com/D246160
2025-04-23 20:49:08 +00:00
Greg Stoll
1252c63fc5 Bug 1960387 - add tests for Content Analysis confirm quit dialog r=dlp-reviewers,handyman
This required a few changes to ContentAnalysis.sys.mjs to:
- allow using an overridden nsIContentAnalysis and calling initialize()
  again so it will reevaluate whether content analysis is active and set
  up the needed observers to show dialogs.
- clean up some logic about setting up and tearing down observers

This should let us test more dialogs in the future - I'm starting with
the quit confirm dialog because it's been a problem before.

Differential Revision: https://phabricator.services.mozilla.com/D245572
2025-04-23 13:39:49 +00:00
Greg Stoll
55cbe61557 Bug 1960715 - add type-checking to Content Analysis JS files r=zombie,dlp-reviewers,handyman
This will enable VS Code to do type-checking on these files. Most of
the problems it found were fairly trivial (or wrong type declarations),
but the extra call to _removeSlowCAMessage() seems like a real problem
(will flag in the review)

Differential Revision: https://phabricator.services.mozilla.com/D245625
2025-04-15 19:50:09 +00:00
Greg Stoll
26789907b9 Bug 1959966 - cancel WARN Content Analysis dialogs in an earlier event when quitting to avoid a shutdownhang r=dlp-reviewers,handyman
Per the comment, the quit-application event can be delayed if the user
quits via keyboard or the hamburger menu (as opposed to simply closing
the last window). I didn't dig too deep into this but this seems like
the kind of thing we can do in quit-application-granted anyway.

Differential Revision: https://phabricator.services.mozilla.com/D245594
2025-04-15 16:49:52 +00:00
Greg Stoll
3ce64c5a23 Bug 1959966 - cancel WARN Content Analysis dialogs when quitting to avoid a shutdownhang r=dlp-reviewers,handyman
Explicitly cancel pending WARNs when we quit so that the dialogs go away
and nothing gets stuck. I feel like this used to work by coincidence,
but now we do it explicitly.

Differential Revision: https://phabricator.services.mozilla.com/D245291
2025-04-11 19:55:59 +00:00
Greg Stoll
7e9943b81c Bug 1959810 - add JSDoc types and turn on JSDoc rule for ContentAnalysis.sys.mjs r=dlp-reviewers,frontend-codestyle-reviewers,handyman
There is one functional change where having types helped me notice that
we never use a property of an object we return.

Differential Revision: https://phabricator.services.mozilla.com/D245143
2025-04-11 12:30:00 +00:00
Greg Stoll
0f76fa2f28 Bug 1959115 - monitor pastes into GenAI custom prompt for Content Analysis r=dlp-reviewers,firefox-ai-ml-reviewers,handyman,Mardak
We handle this similarly to pasting into a prompt() dialog, so I
refactored that logic into a new ContentAnalysisUtils and call it from
both places.

Also drive-by cleanup of BUG_COMPONENT for a few Content Analysis
moz.build's

Differential Revision: https://phabricator.services.mozilla.com/D244818
2025-04-10 20:48:22 +00:00
Cristian Tuns
0346c15046 Backed out changeset 8517aa5a4d0d (bug 1959115) for causing bc failures in /browser_clipboard_paste_prompt_content_analysis.js CLOSED TREE 2025-04-10 11:46:56 -04:00
Greg Stoll
09c5ab87cb Bug 1959115 - monitor pastes into GenAI custom prompt for Content Analysis r=dlp-reviewers,firefox-ai-ml-reviewers,handyman,Mardak
We handle this similarly to pasting into a prompt() dialog, so I
refactored that logic into a new ContentAnalysisUtils and call it from
both places.

Also drive-by cleanup of BUG_COMPONENT for a few Content Analysis
moz.build's

Differential Revision: https://phabricator.services.mozilla.com/D244818
2025-04-10 14:42:19 +00:00
Greg Stoll
e179f747af Bug 1957902 - fix the Content Analysis quit confirmation dialog r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D244186
2025-04-02 20:02:39 +00:00
David P
77e415486e Bug 1957039: Show CA response dialog even if the user action was canceled r=dlp-reviewers,gstoll
The busy dialog had already been removed, so this was throwing an exception
as busyDialogInfo was null.

Differential Revision: https://phabricator.services.mozilla.com/D243563
2025-03-28 22:15:54 +00:00
David P
4aa7ab2db2 Bug 1952508: Part 3 - Show number of items in file content analysis busy dialog r=dlp-reviewers,fluent-reviewers,bolsson,gstoll
Differential Revision: https://phabricator.services.mozilla.com/D242224
2025-03-26 01:07:18 +00:00
David P
6e1e12d214 Bug 1952508: Part 2 - Never show more than one busy dialog per tab r=dlp-reviewers,gstoll
This prevents CA from showing many busy dialogs, each of which required a
layout reflow.  This does not prevent CA from showing many other dialogs
(e.g. block and warn dialogs).

Differential Revision: https://phabricator.services.mozilla.com/D242223
2025-03-26 01:07:18 +00:00
Sandor Molnar
ae46e424dd Backed out 5 changesets (bug 1952508) for causing build bustages. CLOSED TREE
Backed out changeset 828a657b93e4 (bug 1952508)
Backed out changeset 47c1df1f21b8 (bug 1952508)
Backed out changeset 878a81c456a4 (bug 1952508)
Backed out changeset 31521327899b (bug 1952508)
Backed out changeset f976f3915b88 (bug 1952508)
2025-03-25 23:30:56 +02:00
David P
6f9ad4538e Bug 1952508: Part 3 - Show number of items in file content analysis busy dialog r=dlp-reviewers,fluent-reviewers,bolsson,gstoll
Differential Revision: https://phabricator.services.mozilla.com/D242224
2025-03-25 18:25:20 +00:00
David P
762e06f051 Bug 1952508: Part 2 - Never show more than one busy dialog per tab r=dlp-reviewers,gstoll
This prevents CA from showing many busy dialogs, each of which required a
layout reflow.  This does not prevent CA from showing many other dialogs
(e.g. block and warn dialogs).

Differential Revision: https://phabricator.services.mozilla.com/D242223
2025-03-25 18:25:20 +00:00
Greg Stoll
187eb94796 Bug 1951414 - fix confirmation dialog when quitting while Content Analysis requests are active r=dlp-reviewers,handyman
I broke this in bug 1928064 when I refactored a bunch of the JS code.

Differential Revision: https://phabricator.services.mozilla.com/D240189
2025-03-03 17:43:46 +00:00
David P
ff715e46d1 Bug 1950501: Ignore browser.contentanalysis.show_blocked_dialog for non-agent messages r=dlp-reviewers,gstoll
Messages not from an agent can't have been shown by an agent, so ignore the pref for them.

Differential Revision: https://phabricator.services.mozilla.com/D239825
2025-02-27 00:31:50 +00:00
Greg Stoll
54ae391135 Bug 1950615 - show "unable to connect" Content Analysis dialog in all cases r=dlp-reviewers,handyman
I verified that this fixes the problem in this bug and does not regress
bug 1928064.

The problem was that if only one request was being made with the same
user action ID, the otherEntries would always be empty, and so we would
not show the dialog. Now we handle multiple requests by removing their
info from requestTokenToRequestInfo, and thus when we get the
"dlp-request-made" notification we will exit early and not show a dialog.

Differential Revision: https://phabricator.services.mozilla.com/D239755
2025-02-26 18:57:29 +00:00
Greg Stoll
be00c74732 Bug 1948884 - make Content Analysis icon show up with vertical tabs r=desktop-theme-reviewers,sfoster
Differential Revision: https://phabricator.services.mozilla.com/D238669
2025-02-25 20:21:52 +00:00
Greg Stoll
8d790dc2c5 Bug 1928064 part 3 - don't show multiple error dialogs for the same userActionId r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D239398
2025-02-25 01:33:01 +00:00
Greg Stoll
97c001a20c Bug 1928064 part 2 - simplify MapByTopBrowsingContext to RequestInfos r=dlp-reviewers,handyman
We are no longer using the grouping by BrowsingContext functionality,
so rename and greatly simplify this class. (not strictly needed for this
change, but simpler is better!)

Differential Revision: https://phabricator.services.mozilla.com/D239397
2025-02-25 01:33:00 +00:00
David P
b9cdd727a8 Bug 1894538: Part 2 - Cancel content analysis requests on timeout r=dlp-reviewers,fluent-reviewers,flod,gstoll
Differential Revision: https://phabricator.services.mozilla.com/D237661
2025-02-18 20:02:43 +00:00
David P
469f02dde1 Bug 1936020: Part 7 - Refactor ContentAnalysis C++ and IDL classes r=dlp-reviewers,gstoll
The changes include:
1. Making various IDL classes builtin.
2. Making nsIContentAnalysisResponse subclass nsIContentAnalysisResult.
3. Making requestToken and userAction fields internal to CA service.
4. Added sourceWindowGlobal (the source of the data to scan) to request and
   use it for content-source-is-same-tab determinations.
5. Made nsIContentAnalysisCallback expect a Result, not a Response.
6. Added cancelRequestsByUserAction and renamed cancelContentAnalysisRequest to cancelRequestsByRequestToken (deprecated).
7. Added ability for CancelAllRequests to forbid future requests (not needed but for peace of mind).
8. Added MakeResponseForTest since response is not builtin.
9. Made ContentAnalysis SupportsWeakPtr so that it can be weakly held by the MultipartRequestCallback,
   which can't just re-get the service since it doesn't want the mock one.
10. Move SafeContentAnalysisResultCallback functionality to ContentAnalysisCallback.
11. Make various routines use userActionId instead of requestToken.
12. Add MultipartRequestCallback to count that we get the right number of responses.
13. Remove unneeded thread sync behavior.  The only part that was kind-of
    neeed was to abort behavior on a background thread if the request were
    canceled first -- this is a race that we don't need to win so we now just
    ignore it and ignore the result (TODO: I'm not positive I send cancel to
    the agent in this case).
14. Send cancel to the agent (in all other cancel cases).
15. Simplify the request map, which is now the user action map mUserActionMap.
16. Makes the MultipartRequestCallback the nexus for filtering requests --
    this way filters are applied uniformly instead of sometimes-at-some-point-
    for-some-use-cases.
17. Adds showBlockedRequestDialog for showing a block dialog when requests
    are rejected before they are expanded into their final form.
18. Adds SafeGetStaticErrorName for logging nsresults.

Differential Revision: https://phabricator.services.mozilla.com/D236630
2025-02-13 19:19:17 +00:00
David P
2af003235e Bug 1936020: Part 4 - Fix contentanalysis.sys.mjs typo r=dlp-reviewers,gstoll
Rename "request" variable that is a response to "response".

Differential Revision: https://phabricator.services.mozilla.com/D236627
2025-02-13 19:19:16 +00:00
Greg Stoll
30b5ca4b60 Bug 1926362 - make cancelling a DLP request actually cancel with the DLP agent r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D231145
2024-12-06 14:41:37 +00:00
David P
acd7b80652 Bug 1929636: Improve content analysis paste-blocked and warn dialogs when agent is not connected r=dlp-reviewers,gstoll
When the DLP agent can't be reached, we enact default DLP behavior based on the
browser.contentanalysis.default_result pref.  That still shows result dialogs
for pastes, and when default-warn is enabled, and the messages used for those
when the agent *is* connected would confuse the user here.  This changes those
messages.

Differential Revision: https://phabricator.services.mozilla.com/D228233
2024-11-07 17:46:02 +00:00
Greg Stoll
c9025fc7e5 Bug 1915351 part 6 - make Content Analysis JS display multiple dialogs seamlessly r=dlp-reviewers,handyman
This uses the already-existing ability of the TabDialogManager to show
a dialog immediately after the previous one closes. So this code doesn't
need to keep track of what dialog to show next - it just displays them
all (and closes them appropriately), and the TabDialogManager will show
them one at a time.

Differential Revision: https://phabricator.services.mozilla.com/D223415
2024-10-28 22:37:58 +00:00
Alexandru Marc
0633abca1a Backed out 10 changesets (bug 1879401, bug 1915351) for causing multiple regressions. CLOSED TREE
Backed out changeset 574d567bbbf1 (bug 1915351)
Backed out changeset 4fcb7eea243f (bug 1915351)
Backed out changeset aa0e2ce8cf21 (bug 1915351)
Backed out changeset 1cf3847d73a7 (bug 1915351)
Backed out changeset fba6942240ea (bug 1915351)
Backed out changeset c5279472391f (bug 1915351)
Backed out changeset a20adf8d4516 (bug 1915351)
Backed out changeset 2b900eb520ce (bug 1915351)
Backed out changeset a8b2b1f62ae6 (bug 1915351)
Backed out changeset 989b843531f8 (bug 1879401)
2024-10-25 16:43:29 +03:00
Greg Stoll
e66bb15ca2 Bug 1915351 part 6 - make Content Analysis JS display multiple dialogs seamlessly r=dlp-reviewers,handyman
This uses the already-existing ability of the TabDialogManager to show
a dialog immediately after the previous one closes. So this code doesn't
need to keep track of what dialog to show next - it just displays them
all (and closes them appropriately), and the TabDialogManager will show
them one at a time.

Differential Revision: https://phabricator.services.mozilla.com/D223415
2024-10-24 02:15:14 +00:00
Greg Stoll
575789c7d8 Bug 1921079 - make DLP agent name bold in panel r=dlp-reviewers,fluent-reviewers,handyman
I tried this for the hover text as well but unsurprisingly bold text
isn't styled any differently there.

Differential Revision: https://phabricator.services.mozilla.com/D225856
2024-10-18 19:30:29 +00:00
Greg Stoll
8761987491 Bug 1912384 part 2 - don't show dialog for cached DLP results r=dlp-reviewers,handyman
For BLOCKED text, if we do two requests in quick succession, we will now
return a cached result for the second request. This patch avoids showing
the BLOCK dialog more than once. (also works for WARN)

Differential Revision: https://phabricator.services.mozilla.com/D219496
2024-08-22 13:15:36 +00:00
Gijs Kruitbosch
a6f6ff1c9a Bug 1896783 - start using the category manager for browser delayed startup, r=mossop,webcompat-reviewers,twisniewski
Differential Revision: https://phabricator.services.mozilla.com/D210433
2024-08-14 13:10:41 +00:00
Greg Stoll
6e33f54294 Bug 1902969 - cancel DLP request when warn dialog is moved to new window r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D213998
2024-06-28 19:01:05 +00:00
Greg Stoll
5d5b96fb12 Bug 1900798 - go back to async "DLP blocked" dialog for print preview r=dlp-reviewers,handyman
A new attempt to fix these problems - always use asynchronous dialogs, but in the print preview case show the "DLP blocked" dialog on the original browsingContext that displayed the print preview dialog (since the dialog itself is about to close)

Differential Revision: https://phabricator.services.mozilla.com/D212815
2024-06-12 19:39:15 +00:00
Greg Stoll
1981579755 Bug 1899703, 1899971 - don't shutdownhang when quitting while DLP request is active r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D212474
2024-06-05 14:05:56 +00:00
Greg Stoll
0ed79d0d07 Bug 1899714 - make DLP block dialog show up again for print preview window r=dlp-reviewers,handyman
I verified that quitting while the synchronous version of the dialog is active doesn't hang, so we're not re-regressing bug 1898718.

Differential Revision: https://phabricator.services.mozilla.com/D212189
2024-06-04 23:03:52 +00:00
Greg Stoll
6bdae479cd Bug 1898718 - show DLP response dialog asynchronously so it doesn't block shutdown r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D211870
2024-05-29 18:11:37 +00:00
Greg Stoll
4bcafcb40b Bug 1893536 - Use more natural wording for Content Analysis error messages r=dlp-reviewers,fluent-reviewers,bolsson,handyman
Differential Revision: https://phabricator.services.mozilla.com/D208678
2024-04-27 10:44:51 +00:00
Greg Stoll
230709d6c4 Bug 1893497 - Remove unneeded await on l10n.setAttributes in ContentAnalysis.sys.mjs r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D208658
2024-04-25 22:53:26 +00:00