Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_HOST_IMPL_H_ |
| 6 | #define CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_HOST_IMPL_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <memory> |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 10 | #include <optional> |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 11 | #include <string> |
| 12 | #include <vector> |
| 13 | |
Avi Drissman | adac2199 | 2023-01-11 23:46:39 | [diff] [blame] | 14 | #include "base/functional/callback_forward.h" |
Daniel Cheng | d4c3eab | 2021-08-31 18:39:01 | [diff] [blame] | 15 | #include "base/gtest_prod_util.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 16 | #include "base/memory/weak_ptr.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 17 | #include "base/time/time.h" |
| 18 | #include "build/build_config.h" |
| 19 | #include "content/browser/renderer_host/render_frame_host_impl.h" |
| 20 | #include "content/common/content_export.h" |
Dominique Fauteux-Chapleau | 88798b9 | 2024-03-14 20:22:10 | [diff] [blame^] | 21 | #include "content/public/browser/clipboard_types.h" |
Daniel Cheng | 9fb887ff | 2021-10-01 20:27:38 | [diff] [blame] | 22 | #include "content/public/browser/document_service.h" |
Austin Sullivan | fc87089 | 2021-04-29 18:40:11 | [diff] [blame] | 23 | #include "mojo/public/cpp/base/big_buffer.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 24 | #include "mojo/public/cpp/bindings/receiver.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 25 | #include "third_party/blink/public/mojom/clipboard/clipboard.mojom.h" |
| 26 | #include "ui/base/clipboard/clipboard.h" |
| 27 | |
| 28 | class GURL; |
| 29 | |
| 30 | namespace ui { |
| 31 | class ScopedClipboardWriter; |
| 32 | } // namespace ui |
| 33 | |
| 34 | namespace content { |
| 35 | |
| 36 | class ClipboardHostImplTest; |
| 37 | |
Dominique Fauteux-Chapleau | c174eaa | 2024-02-12 19:29:24 | [diff] [blame] | 38 | // Returns a representation of the last source ClipboardEndpoint. This will |
| 39 | // either match the last clipboard write if `seqno` matches the last browser tab |
| 40 | // write, or an endpoint built from `Clipboard::GetSource()` called with |
| 41 | // `clipboard_buffer` otherwise. |
| 42 | // |
| 43 | // //content maintains additional metadata on top of what the //ui layer already |
| 44 | // tracks about clipboard data's source, e.g. the WebContents that provided the |
| 45 | // data. This function allows retrieving both the //ui metadata and the |
| 46 | // //content metadata in a single call. |
| 47 | // |
| 48 | // To avoid returning stale //content metadata if the writer has changed, the |
| 49 | // sequence number is used to validate if the writer has changed or not since |
| 50 | // the //content metadata was last updated. |
| 51 | CONTENT_EXPORT ClipboardEndpoint |
| 52 | GetSourceClipboardEndpoint(ui::ClipboardSequenceNumberToken seqno, |
| 53 | ui::ClipboardBuffer clipboard_buffer); |
| 54 | |
Alexander Timin | e3383d0 | 2021-06-24 19:57:59 | [diff] [blame] | 55 | class CONTENT_EXPORT ClipboardHostImpl |
Daniel Cheng | 9fb887ff | 2021-10-01 20:27:38 | [diff] [blame] | 56 | : public DocumentService<blink::mojom::ClipboardHost> { |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 57 | public: |
| 58 | ~ClipboardHostImpl() override; |
| 59 | |
| 60 | static void Create( |
| 61 | RenderFrameHost* render_frame_host, |
| 62 | mojo::PendingReceiver<blink::mojom::ClipboardHost> receiver); |
| 63 | |
Nancy Xiao | 4f3eae5d6 | 2023-04-25 19:38:59 | [diff] [blame] | 64 | using ClipboardPasteData = content::ClipboardPasteData; |
| 65 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 66 | protected: |
| 67 | // These types and methods are protected for testing. |
| 68 | |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 69 | using IsClipboardPasteAllowedCallback = |
| 70 | RenderFrameHostImpl::IsClipboardPasteAllowedCallback; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 71 | |
Roger Tawa | c617026 | 2022-10-28 23:48:52 | [diff] [blame] | 72 | // Represents the underlying type of the argument passed to |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 73 | // IsClipboardPasteAllowedCallback without the const& part. |
| 74 | using IsClipboardPasteAllowedCallbackArgType = |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 75 | std::optional<ClipboardPasteData>; |
Roger Tawa | c617026 | 2022-10-28 23:48:52 | [diff] [blame] | 76 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 77 | // Keeps track of a request to see if some clipboard content, identified by |
Rakina Zata Amni | 39d8e7e | 2022-10-20 18:18:30 | [diff] [blame] | 78 | // its sequence number, is allowed to be pasted into the RenderFrameHost |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 79 | // that owns this clipboard host. |
| 80 | // |
| 81 | // A request starts in the state incomplete until Complete() is called with |
| 82 | // a value. Callbacks can be added to the request before or after it has |
| 83 | // completed. |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 84 | class CONTENT_EXPORT IsPasteAllowedRequest { |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 85 | public: |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 86 | IsPasteAllowedRequest(); |
| 87 | ~IsPasteAllowedRequest(); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 88 | |
Dominique Fauteux-Chapleau | d3bd410 | 2024-02-21 20:09:41 | [diff] [blame] | 89 | // Adds `callback` to be notified when the request completes. Returns true |
| 90 | // if this is the first callback added and a request should be started, |
| 91 | // returns false otherwise. |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 92 | bool AddCallback(IsClipboardPasteAllowedCallback callback); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 93 | |
Dominique Fauteux-Chapleau | d3bd410 | 2024-02-21 20:09:41 | [diff] [blame] | 94 | // Merge `data` into the existing internal `data_` member so that the |
| 95 | // currently pending request will have the appropriate fields for all added |
| 96 | // callbacks, not just the initial one that created the request. |
| 97 | void AddData(ClipboardPasteData data); |
| 98 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 99 | // Mark this request as completed with the specified result. |
| 100 | // Invoke all callbacks now. |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 101 | void Complete(IsClipboardPasteAllowedCallbackArgType data); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 102 | |
Roger Tawa | 34dd57f8 | 2022-12-15 23:24:20 | [diff] [blame] | 103 | // Returns true if the request has completed. |
Dominique Fauteux-Chapleau | d3bd410 | 2024-02-21 20:09:41 | [diff] [blame] | 104 | bool is_complete() const { return data_allowed_.has_value(); } |
Roger Tawa | 34dd57f8 | 2022-12-15 23:24:20 | [diff] [blame] | 105 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 106 | // Returns true if this request is obsolete. An obsolete request |
| 107 | // is one that is completed, all registered callbacks have been |
| 108 | // called, and is considered old. |
| 109 | // |
| 110 | // |now| represents the current time. It is an argument to ease testing. |
| 111 | bool IsObsolete(base::Time now); |
| 112 | |
Roger Tawa | 34dd57f8 | 2022-12-15 23:24:20 | [diff] [blame] | 113 | // Returns the time at which this request was completed. If called |
| 114 | // before the request is completed the return value is undefined. |
| 115 | base::Time completed_time(); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 116 | |
| 117 | private: |
| 118 | // Calls all the callbacks in |callbacks_| with the current value of |
| 119 | // |allowed_|. |allowed_| must not be empty. |
| 120 | void InvokeCallbacks(); |
| 121 | |
Roger Tawa | 34dd57f8 | 2022-12-15 23:24:20 | [diff] [blame] | 122 | // The time at which the request was completed. Before completion this |
| 123 | // value is undefined. |
| 124 | base::Time completed_time_; |
Roger Tawa | c617026 | 2022-10-28 23:48:52 | [diff] [blame] | 125 | |
Roger Tawa | c617026 | 2022-10-28 23:48:52 | [diff] [blame] | 126 | // This member is null until Complete() is called. |
Dominique Fauteux-Chapleau | d3bd410 | 2024-02-21 20:09:41 | [diff] [blame] | 127 | std::optional<bool> data_allowed_; |
| 128 | |
| 129 | // The data argument to pass to the IsClipboardPasteAllowedCallback. |
| 130 | ClipboardPasteData data_; |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 131 | std::vector<IsClipboardPasteAllowedCallback> callbacks_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | // A paste allowed request is obsolete if it is older than this time. |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 135 | static const base::TimeDelta kIsPasteAllowedRequestTooOld; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 136 | |
Alexander Timin | e3383d0 | 2021-06-24 19:57:59 | [diff] [blame] | 137 | explicit ClipboardHostImpl( |
danakj | c70aec1f | 2022-07-07 15:48:19 | [diff] [blame] | 138 | RenderFrameHost& render_frame_host, |
Alexander Timin | e3383d0 | 2021-06-24 19:57:59 | [diff] [blame] | 139 | mojo::PendingReceiver<blink::mojom::ClipboardHost> receiver); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 140 | |
Aya ElAttar | 84e6ef3 | 2021-03-02 16:29:19 | [diff] [blame] | 141 | // Performs a check to see if pasting `data` is allowed by data transfer |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 142 | // policies and invokes FinishPasteIfAllowed upon completion. |
Aya ElAttar | 84e6ef3 | 2021-03-02 16:29:19 | [diff] [blame] | 143 | void PasteIfPolicyAllowed(ui::ClipboardBuffer clipboard_buffer, |
| 144 | const ui::ClipboardFormatType& data_type, |
Nancy Xiao | 4f3eae5d6 | 2023-04-25 19:38:59 | [diff] [blame] | 145 | ClipboardPasteData clipboard_paste_data, |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 146 | IsClipboardPasteAllowedCallback callback); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 147 | |
| 148 | // Remove obsolete entries from the outstanding requests map. |
| 149 | // A request is obsolete if: |
| 150 | // - its sequence number is less than |seqno| |
| 151 | // - it has no callbacks |
| 152 | // - it is too old |
| 153 | void CleanupObsoleteRequests(); |
| 154 | |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 155 | // Completion callback of PerformPasteIfAllowed(). Sets the allowed |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 156 | // status for the clipboard data corresponding to sequence number |seqno|. |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 157 | void FinishPasteIfAllowed( |
Austin Sullivan | bfe1af7 | 2021-07-20 23:14:14 | [diff] [blame] | 158 | const ui::ClipboardSequenceNumberToken& seqno, |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 159 | std::optional<ClipboardPasteData> clipboard_paste_data); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 160 | |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 161 | const std::map<ui::ClipboardSequenceNumberToken, IsPasteAllowedRequest>& |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 162 | is_paste_allowed_requests_for_testing() { |
| 163 | return is_allowed_requests_; |
| 164 | } |
| 165 | |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 166 | // Called by PerformPasteIfAllowed() when an is allowed request is |
| 167 | // needed. Virtual to be overridden in tests. |
| 168 | virtual void StartIsPasteAllowedRequest( |
| 169 | const ui::ClipboardSequenceNumberToken& seqno, |
| 170 | const ui::ClipboardFormatType& data_type, |
| 171 | ui::ClipboardBuffer clipboard_buffer, |
| 172 | ClipboardPasteData clipboard_paste_data); |
| 173 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 174 | private: |
| 175 | friend class ClipboardHostImplTest; |
| 176 | friend class ClipboardHostImplScanTest; |
| 177 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplTest, |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 178 | IsPasteAllowedRequest_AddCallback); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 179 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplTest, |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 180 | IsPasteAllowedRequest_Complete); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 181 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplTest, |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 182 | IsPasteAllowedRequest_IsObsolete); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 183 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplScanTest, |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 184 | PerformPasteIfAllowed_EmptyData); |
| 185 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplScanTest, PerformPasteIfAllowed); |
Darwin Huang | 6195d04 | 2021-02-12 22:36:00 | [diff] [blame] | 186 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplScanTest, |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 187 | PerformPasteIfAllowed_SameHost_NotStarted); |
Roger Tawa | c774694b | 2023-03-16 20:44:39 | [diff] [blame] | 188 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplScanTest, |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 189 | PerformPasteIfAllowed_External_Started); |
Dominique Fauteux-Chapleau | c174eaa | 2024-02-12 19:29:24 | [diff] [blame] | 190 | FRIEND_TEST_ALL_PREFIXES(ClipboardHostImplScanTest, GetSourceEndpoint); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 191 | |
| 192 | // mojom::ClipboardHost |
| 193 | void GetSequenceNumber(ui::ClipboardBuffer clipboard_buffer, |
| 194 | GetSequenceNumberCallback callback) override; |
| 195 | void IsFormatAvailable(blink::mojom::ClipboardFormat format, |
| 196 | ui::ClipboardBuffer clipboard_buffer, |
| 197 | IsFormatAvailableCallback callback) override; |
| 198 | void ReadAvailableTypes(ui::ClipboardBuffer clipboard_buffer, |
| 199 | ReadAvailableTypesCallback callback) override; |
| 200 | void ReadText(ui::ClipboardBuffer clipboard_buffer, |
| 201 | ReadTextCallback callback) override; |
| 202 | void ReadHtml(ui::ClipboardBuffer clipboard_buffer, |
| 203 | ReadHtmlCallback callback) override; |
| 204 | void ReadSvg(ui::ClipboardBuffer clipboard_buffer, |
| 205 | ReadSvgCallback callback) override; |
| 206 | void ReadRtf(ui::ClipboardBuffer clipboard_buffer, |
| 207 | ReadRtfCallback callback) override; |
Austin Sullivan | aa06098 | 2021-06-25 17:49:30 | [diff] [blame] | 208 | void ReadPng(ui::ClipboardBuffer clipboard_buffer, |
| 209 | ReadPngCallback callback) override; |
Joel Hockey | 4c0cb8c | 2021-02-22 02:59:59 | [diff] [blame] | 210 | void ReadFiles(ui::ClipboardBuffer clipboard_buffer, |
| 211 | ReadFilesCallback callback) override; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 212 | void ReadCustomData(ui::ClipboardBuffer clipboard_buffer, |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 213 | const std::u16string& type, |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 214 | ReadCustomDataCallback callback) override; |
Anupam Snigdha | 74b68e4 | 2021-08-10 23:35:59 | [diff] [blame] | 215 | void ReadAvailableCustomAndStandardFormats( |
| 216 | ReadAvailableCustomAndStandardFormatsCallback callback) override; |
| 217 | void ReadUnsanitizedCustomFormat( |
| 218 | const std::u16string& format, |
| 219 | ReadUnsanitizedCustomFormatCallback callback) override; |
| 220 | void WriteUnsanitizedCustomFormat(const std::u16string& format, |
| 221 | mojo_base::BigBuffer data) override; |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 222 | void WriteText(const std::u16string& text) override; |
| 223 | void WriteHtml(const std::u16string& markup, const GURL& url) override; |
| 224 | void WriteSvg(const std::u16string& markup) override; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 225 | void WriteSmartPasteMarker() override; |
| 226 | void WriteCustomData( |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 227 | const base::flat_map<std::u16string, std::u16string>& data) override; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 228 | void WriteBookmark(const std::string& url, |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 229 | const std::u16string& title) override; |
danakj | bdf1e0a | 2020-11-10 18:27:47 | [diff] [blame] | 230 | void WriteImage(const SkBitmap& unsafe_bitmap) override; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 231 | void CommitWrite() override; |
Xiaohan Wang | 7f8052e0 | 2022-01-14 18:44:28 | [diff] [blame] | 232 | #if BUILDFLAG(IS_MAC) |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 233 | void WriteStringToFindPboard(const std::u16string& text) override; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 234 | #endif |
| 235 | |
Roger Tawa | 34dd57f8 | 2022-12-15 23:24:20 | [diff] [blame] | 236 | // Checks if the renderer allows pasting. This check is skipped if called |
| 237 | // soon after a successful content allowed request. |
| 238 | bool IsRendererPasteAllowed(ui::ClipboardBuffer clipboard_buffer, |
| 239 | RenderFrameHost& render_frame_host); |
| 240 | |
Dominique Fauteux-Chapleau | f6e59f2 | 2024-02-05 19:57:53 | [diff] [blame] | 241 | // Helpers to be used when checking if data is allowed to be copied. |
| 242 | // If `replacement_data` is null, `clipboard_writer_` will be used to write |
| 243 | // the corresponding text/markup data to the clipboard. If it is not, instead |
| 244 | // write the replacement string to the clipboard as plaintext. This can be |
| 245 | // called asynchronously. |
Dominique Fauteux-Chapleau | 88798b9 | 2024-03-14 20:22:10 | [diff] [blame^] | 246 | void OnCopyTextAllowedResult(const ClipboardPasteData& data, |
Dominique Fauteux-Chapleau | f6e59f2 | 2024-02-05 19:57:53 | [diff] [blame] | 247 | std::optional<std::u16string> replacement_data); |
| 248 | void OnCopyHtmlAllowedResult(const GURL& url, |
Dominique Fauteux-Chapleau | 88798b9 | 2024-03-14 20:22:10 | [diff] [blame^] | 249 | const ClipboardPasteData& data, |
Dominique Fauteux-Chapleau | f6e59f2 | 2024-02-05 19:57:53 | [diff] [blame] | 250 | std::optional<std::u16string> replacement_data); |
Anthony Vallee-Dubois | ac84770 | 2021-12-06 21:00:48 | [diff] [blame] | 251 | |
Dominique Fauteux-Chapleau | f6e59f2 | 2024-02-05 19:57:53 | [diff] [blame] | 252 | using CopyAllowedCallback = base::OnceCallback<void()>; |
Dominique Fauteux-Chapleau | dbb4b709 | 2024-02-01 15:42:37 | [diff] [blame] | 253 | |
Austin Sullivan | fc87089 | 2021-04-29 18:40:11 | [diff] [blame] | 254 | void OnReadPng(ui::ClipboardBuffer clipboard_buffer, |
| 255 | ReadPngCallback callback, |
| 256 | const std::vector<uint8_t>& data); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 257 | |
Dominique Fauteux-Chapleau | 3b7738c | 2024-01-16 21:08:55 | [diff] [blame] | 258 | // Creates a `ui::DataTransferEndpoint` representing the last committed URL. |
Dominique Fauteux-Chapleau | 2cdc6a9 | 2024-01-29 17:39:37 | [diff] [blame] | 259 | std::unique_ptr<ui::DataTransferEndpoint> CreateDataEndpoint(); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 260 | |
Dominique Fauteux-Chapleau | f6e59f2 | 2024-02-05 19:57:53 | [diff] [blame] | 261 | // Creates a `content::ClipboardEndpoint` representing the last committed URL. |
| 262 | ClipboardEndpoint CreateClipboardEndpoint(); |
| 263 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 264 | std::unique_ptr<ui::ScopedClipboardWriter> clipboard_writer_; |
| 265 | |
| 266 | // Outstanding is allowed requests per clipboard contents. Maps a clipboard |
| 267 | // sequence number to an outstanding request. |
Dominique Fauteux-Chapleau | 4407a85d | 2024-01-05 13:18:58 | [diff] [blame] | 268 | std::map<ui::ClipboardSequenceNumberToken, IsPasteAllowedRequest> |
Austin Sullivan | bfe1af7 | 2021-07-20 23:14:14 | [diff] [blame] | 269 | is_allowed_requests_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 270 | |
| 271 | base::WeakPtrFactory<ClipboardHostImpl> weak_ptr_factory_{this}; |
| 272 | }; |
| 273 | |
| 274 | } // namespace content |
| 275 | |
| 276 | #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_HOST_IMPL_H_ |