Commit Graph

92 Commits

Author SHA1 Message Date
Edgar Chen
ff98dc4662 Bug 1895691 - Reuse the log module defined in nsBaseClipboard for clipboard logging; r=stransky
Same as other platforms.

Differential Revision: https://phabricator.services.mozilla.com/D209795
2024-05-10 08:20:59 +00:00
Cristian Tuns
9fc48cae40 Backed out 2 changesets (bug 1895691) for causing build bustages in nsClipboard.cpp CLOSED TREE
Backed out changeset df63f327ed12 (bug 1895691)
Backed out changeset 6472c0eeb086 (bug 1895691)
2024-05-09 17:31:18 -04:00
Edgar Chen
54f5b09c81 Bug 1895691 - Reuse the log module defined in nsBaseClipboard for clipboard logging; r=stransky
Same as other platforms.

Differential Revision: https://phabricator.services.mozilla.com/D209795
2024-05-09 21:11:20 +00:00
Greg Stoll
4e868d690a Bug 1888713 - move Content Analysis clipboard code into the Content Analysis code r=dlp-reviewers,handyman
Got [[ https://treeherder.mozilla.org/jobs?repo=try&revision=e6b8fb3ed7af5b1bd665e376a5917d196327b2d2 | good try builds here ]].

Differential Revision: https://phabricator.services.mozilla.com/D207784
2024-04-22 18:29:52 +00:00
Edgar Chen
546880ae4d Bug 1867636 - Rename nsITransferable::requestingPrincipal; r=nika
Differential Revision: https://phabricator.services.mozilla.com/D207272
2024-04-18 10:06:07 +00:00
Greg Stoll
3625ba8618 Bug 1869868 part 2 - do not consult DLP when copy/pasting items in the same tab r=edgar,dlp-reviewers,credential-management-reviewers,handyman,sgalich
Differential Revision: https://phabricator.services.mozilla.com/D205744
2024-04-15 12:10:46 +00:00
Greg Stoll
e83346061a Bug 1869868 part 1 - some refactoring in preparation for future changes, no functionality changes r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D205743
2024-04-15 12:10:46 +00:00
Greg Stoll
3b30cfb6a3 Bug 1888498 - don't pass an empty string to Content Analysis r=dlp-reviewers,handyman
Differential Revision: https://phabricator.services.mozilla.com/D206053
2024-04-01 18:54:33 +00:00
Edgar Chen
6a0a9db644 Bug 1884020 - Make reading from clipboard cache returns same flavor order as reading from system clipboard; r=spohl
This basically makes the macOS behave the same as other platform (currently only
macOS would read data from clipboard cache). And also this would ensure behavior
doesn't change if one day we would like to enable reading-from-clipboard-cache
on other platforms as well.

Differential Revision: https://phabricator.services.mozilla.com/D203893
2024-03-14 08:25:02 +00:00
Edgar Chen
6c793941cd Bug 1858627 - Add nsIClipboard API to return nsIAsyncSetClipboardData synchrously; r=ipc-reviewers,nika
This is a sync version of `nsIClipboard.asyncGetData`, which can be used for
synchronous clipboard APIs, e.g. DataTransfer, to support the clipboard seqence
number concept, see bug 1879401.

Differential Revision: https://phabricator.services.mozilla.com/D201364
2024-03-13 20:44:06 +00:00
Cristian Tuns
4e35ce0b65 Backed out 4 changesets (bug 1858627) for causing build bustages with "-p style --lib" CLOSED TREE
Backed out changeset 7f3f50c77406 (bug 1858627)
Backed out changeset 96327aab8126 (bug 1858627)
Backed out changeset 0655d0feb163 (bug 1858627)
Backed out changeset d3a1b3ac7611 (bug 1858627)
2024-03-13 05:23:51 -04:00
Edgar Chen
2451222410 Bug 1858627 - Add nsIClipboard API to return nsIAsyncSetClipboardData synchrously; r=ipc-reviewers,nika
This is a sync version of `nsIClipboard.asyncGetData`, which can be used for
synchronous clipboard APIs, e.g. DataTransfer, to support the clipboard seqence
number concept, see bug 1879401.

Depends on D201657

Differential Revision: https://phabricator.services.mozilla.com/D201364
2024-03-13 01:07:17 +00:00
Norisz Fay
6b73c14ada Backed out 4 changesets (bug 1858627) for causing build bustage CLOSED TREE
Backed out changeset eaf5e6b7ddd4 (bug 1858627)
Backed out changeset 9efc1874ac78 (bug 1858627)
Backed out changeset 8f4ca2ab875b (bug 1858627)
Backed out changeset 02f94f12c3ef (bug 1858627)
2024-03-13 01:47:31 +02:00
Edgar Chen
258b00c550 Bug 1858627 - Add nsIClipboard API to return nsIAsyncSetClipboardData synchrously; r=ipc-reviewers,nika
This is a sync version of `nsIClipboard.asyncGetData`, which can be used for
synchronous clipboard APIs, e.g. DataTransfer, to support the clipboard seqence
number concept, see bug 1879401.

Depends on D201657

Differential Revision: https://phabricator.services.mozilla.com/D201364
2024-03-12 21:51:53 +00:00
Natalia Csoregi
c447e5b344 Backed out 4 changesets (bug 1858627) for causing clipboard/paste failures. CLOSED TREE
Backed out changeset ad694926aa45 (bug 1858627)
Backed out changeset aca702ea720f (bug 1858627)
Backed out changeset 1d5175296606 (bug 1858627)
Backed out changeset 05b957fe3079 (bug 1858627)
2024-03-06 11:52:20 +02:00
Edgar Chen
ccd554877a Bug 1858627 - Add nsIClipboard API to return nsIAsyncSetClipboardData synchrously; r=ipc-reviewers,nika
This is a sync version of `nsIClipboard.asyncGetData`, which can be used for
synchronous clipboard APIs, e.g. DataTransfer, to support the clipboard seqence
number concept, see bug 1879401.

Depends on D201657

Differential Revision: https://phabricator.services.mozilla.com/D201364
2024-03-06 00:30:58 +00:00
Greg Stoll
3c0283579d Bug 1879182 - add a pref to make Content Analysis allow by default r=handyman
This will make DLP requests return Allow if the agent is not present or returns an error.

Differential Revision: https://phabricator.services.mozilla.com/D201277
2024-02-14 16:10:53 +00:00
Greg Stoll
b2839267e7 Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers
When content analysis is on, pastes will be checked by the CA
agent while tab input is blocked. The synchronous nsIClipboard.getData()
method must block until the analysis result is received, so this
requires doing a SpinEventLoopUntil.

Differential Revision: https://phabricator.services.mozilla.com/D196997
2024-02-13 11:26:48 +00:00
Cristian Tuns
35a4843e35 Backed out changeset 9dfe3fe4ccc5 (bug 1871135) for causing mochitest failures in nsClipboardProxy.cpp CLOSED TREE 2024-02-12 12:04:41 -05:00
Greg Stoll
215d43e99f Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers
When content analysis is on, pastes will be checked by the CA
agent while tab input is blocked. The synchronous nsIClipboard.getData()
method must block until the analysis result is received, so this
requires doing a SpinEventLoopUntil.

Differential Revision: https://phabricator.services.mozilla.com/D196997
2024-02-12 16:05:06 +00:00
Cristian Tuns
907b8f6b06 Backed out changeset 3caca1d10dcc (bug 1871135) for causing build bustages in nsBaseClipboard.cpp CLOSED TREE 2024-02-12 09:59:09 -05:00
Greg Stoll
1d234e67c7 Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers
When content analysis is on, pastes will be checked by the CA
agent while tab input is blocked. The synchronous nsIClipboard.getData()
method must block until the analysis result is received, so this
requires doing a SpinEventLoopUntil.

Differential Revision: https://phabricator.services.mozilla.com/D196997
2024-02-12 00:49:39 +00:00
Edgar Chen
0319a4477e Bug 1863843 - nsBaseClipboard::GetData should handle unsupported clipboard type; r=stransky
By design, nsBaseClipboard should always pass valid clipboard type to native
implementation of each platform,

Differential Revision: https://phabricator.services.mozilla.com/D196833
2023-12-19 13:09:15 +00:00
Edgar Chen
4920a38082 Bug 1777448 - Part 2: Suppress the paste context menu when the clipboard data originates from a same-origin page; r=nika
And don't allow new request being associated with existing pending request if
the requests are from different origin.

This patch also set proper principal to nsItransferable for clipboard write in
various cases,
- Copy image via context menu.
- Copy current selection via keyboard shortcut or context menu.
- Data is provided by script when copy operation is triggered via keyboard
  shortcut or context menu.
- Clipboard data is put via async clipboard.

Depends on D190761

Differential Revision: https://phabricator.services.mozilla.com/D190796
2023-12-08 07:08:42 +00:00
Edgar Chen
88ac2e701c Bug 1777448 - Part 1: Don't not show paste contextmenu for background tab; r=nika,hsivonen
Displaying the paste context menu for background tabs can be surprising and
confusing for users, so we reject the request and don't allow it being associated
with existing pending request.

Depends on D190405

Differential Revision: https://phabricator.services.mozilla.com/D190761
2023-12-08 07:08:42 +00:00
Cristian Tuns
983b4d3824 Backed out 2 changesets (bug 1777448) for causing bc failures in /browser_navigator_clipboard_contextmenu_suppression.js CLOSED TREE
Backed out changeset 6dee3dce64ad (bug 1777448)
Backed out changeset 32841cae9b3b (bug 1777448)
2023-12-06 19:55:14 -05:00
Edgar Chen
154d82633b Bug 1777448 - Part 2: Suppress the paste context menu when the clipboard data originates from a same-origin page; r=nika
And don't allow new request being associated with existing pending request if
the requests are from different origin.

This patch also set proper principal to nsItransferable for clipboard write in
various cases,
- Copy image via context menu.
- Copy current selection via keyboard shortcut or context menu.
- Data is provided by script when copy operation is triggered via keyboard
  shortcut or context menu.
- Clipboard data is put via async clipboard.

Depends on D190761

Differential Revision: https://phabricator.services.mozilla.com/D190796
2023-12-06 20:29:00 +00:00
Edgar Chen
f4c4baa9b6 Bug 1777448 - Part 1: Don't not show paste contextmenu for background tab; r=nika,hsivonen
Displaying the paste context menu for background tabs can be surprising and
confusing for users, so we reject the request and don't allow it being associated
with existing pending request.

Depends on D190405

Differential Revision: https://phabricator.services.mozilla.com/D190761
2023-12-06 20:29:00 +00:00
Edgar Chen
2aae48d684 Bug 1866994 - Handle clipboard contextmenu in parent process; r=geckoview-reviewers,extension-reviewers,webidl,win-reviewers,saschanaz,robwu,nika,Gijs,m_kato,emilio
This patch makes the clipboard context menu trigger from the parent process rather
than the content process. A new method, `confirmUserPaste`, is added on `nsIPromptService`
to trigger frontend UI.

The behavior of handling multiple requests should remain unchanged, new tests are
added to ensure that.

Differential Revision: https://phabricator.services.mozilla.com/D190405
2023-11-28 15:38:01 +00:00
Edgar Chen
a3fe0c33fa Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-14 09:21:24 +00:00
Noemi Erli
125514869a Backed out changeset b0ff38a7d9fb (bug 1852947) for causing aInstanceSize related assertion failures 2023-11-11 03:25:58 +02:00
Edgar Chen
4faccbe94d Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-10 15:04:26 +00:00
Noemi Erli
21b5a66c6c Backed out changeset 7355802744d1 (bug 1852947) for causing failures in test_clipboard_asyncGetData.html CLOSED TREE 2023-11-09 12:32:56 +02:00
Edgar Chen
48567b2dc7 Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-09 07:47:00 +00:00
Norisz Fay
4dd26c382d Backed out changeset c8561b4726a2 (bug 1852947) for causing bustage on nsClipboardProxy.cpp CLOSED TREE 2023-11-08 23:44:50 +02:00
Edgar Chen
588feb86b5 Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-08 20:11:08 +00:00
Edgar Chen
fd5f5f4361 Bug 1862956 - Use FlavorsTransferableCanExport to get the available flavor list from cached transferable; r=nika,spohl
Differential Revision: https://phabricator.services.mozilla.com/D192678
2023-11-03 16:50:11 +00:00
Edgar Chen
5f2be2ef2d Bug 1861927 - Part 1: Rename nsIAsyncSetClipboardDataCallback to nsIAsyncClipboardRequestCallback; r=nika
It is going to be reused for clipboard read, so make the name more generic.

Differential Revision: https://phabricator.services.mozilla.com/D188526
2023-10-30 09:46:19 +00:00
Edgar Chen
5659e52b94 Bug 1856052 - Remove unused parameter from SetNativeClipboardData; r=geckoview-reviewers,win-reviewers,spohl,mhowell,m_kato
After bug 1851817, all platforms uses nsBaseClipboard as base class and clipboard
owner is handled there, so nsIClipboardOwner parameter is unused.

Differential Revision: https://phabricator.services.mozilla.com/D190236
2023-10-17 13:15:31 +00:00
Edgar Chen
0a1a6032c2 Bug 1851817 - Part 5: Merge ClipboardSetDataHelper into nsBaseClipboard; r=spohl
Now all platform uses nsBaseClipboard, so we could just merge ClipboardSetDataHelper
into nsBaseClipboard.

Depends on D188252

Differential Revision: https://phabricator.services.mozilla.com/D188253
2023-10-04 20:47:40 +00:00
Edgar Chen
d315704e5f Bug 1851817 - Part 4: Make GTK nsClipboard use nsBaseClipboard; r=stransky
Depends on D188251

Differential Revision: https://phabricator.services.mozilla.com/D188252
2023-10-04 20:47:40 +00:00
Edgar Chen
600fbb1e12 Bug 1851817 - Part 2: Add AsyncGetNativeClipboardData; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `GetNativeClipboardData` instead.

Depends on D188249

Differential Revision: https://phabricator.services.mozilla.com/D188250
2023-10-04 20:47:39 +00:00
Edgar Chen
dad14ba129 Bug 1851817 - Part 1: Add AsyncHasNativeClipboardDataMatchingFlavors; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `HasNativeClipboardDataMatchingFlavors`
instead.

Differential Revision: https://phabricator.services.mozilla.com/D188249
2023-10-04 20:47:39 +00:00
Sandor Molnar
32b7bf39b9 Backed out 5 changesets (bug 1851817) for causing wpt failures on clipboard-apis/async-promise-write-blobs-read-blobs.https.html CLOSED TREE
Backed out changeset 72e7e4417cc9 (bug 1851817)
Backed out changeset 7c035f460830 (bug 1851817)
Backed out changeset 0ea5e417de98 (bug 1851817)
Backed out changeset b46e4efa80ae (bug 1851817)
Backed out changeset f3c15030aa8a (bug 1851817)
2023-10-04 05:22:17 +03:00
Edgar Chen
a95ec3637d Bug 1851817 - Part 5: Merge ClipboardSetDataHelper into nsBaseClipboard; r=spohl
Now all platform uses nsBaseClipboard, so we could just merge ClipboardSetDataHelper
into nsBaseClipboard.

Depends on D188252

Differential Revision: https://phabricator.services.mozilla.com/D188253
2023-10-03 22:49:11 +00:00
Edgar Chen
e2b3a3872a Bug 1851817 - Part 4: Make GTK nsClipboard use nsBaseClipboard; r=stransky
Depends on D188251

Differential Revision: https://phabricator.services.mozilla.com/D188252
2023-10-03 22:49:10 +00:00
Edgar Chen
353776f39b Bug 1851817 - Part 2: Add AsyncGetNativeClipboardData; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `GetNativeClipboardData` instead.

Depends on D188249

Differential Revision: https://phabricator.services.mozilla.com/D188250
2023-10-03 22:49:09 +00:00
Edgar Chen
cc3b129995 Bug 1851817 - Part 1: Add AsyncHasNativeClipboardDataMatchingFlavors; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `HasNativeClipboardDataMatchingFlavors`
instead.

Differential Revision: https://phabricator.services.mozilla.com/D188249
2023-10-03 22:49:09 +00:00
Edgar Chen
99e703cad0 Bug 1854934 - Part 3: Rename CLIPBOARD_LOG* to MOZ_CLIPBOARD_LOG*; r=rkraesig,win-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D189157
2023-09-26 15:29:13 +00:00
Edgar Chen
5efaf23765 Bug 1854934 - Part 2: Dump more information for debugging; r=win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D189146
2023-09-26 15:29:12 +00:00