Changeset 259151 in webkit
- Timestamp:
- Mar 27, 2020 8:05:01 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r259148 r259151 1 2020-03-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Web content processes should not be able to arbitrarily request pasteboard data from the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=209657 5 <rdar://problem/59611585> 6 7 Reviewed by Geoff Garen. 8 9 Match macOS behavior in the iOS implementation of Pasteboard::createForCopyAndPaste by using the name of the 10 general pasteboard by default, when initializing a Pasteboard for copying and pasting. In WebKit2, this allows 11 us to grant permission to the web process when reading from the general pasteboard. 12 13 * platform/ios/PasteboardIOS.mm: 14 (WebCore::Pasteboard::createForCopyAndPaste): 15 1 16 2020-03-27 Zalan Bujtas <zalan@apple.com> 2 17 -
trunk/Source/WebCore/PAL/ChangeLog
r258772 r259151 1 2020-03-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Web content processes should not be able to arbitrarily request pasteboard data from the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=209657 5 <rdar://problem/59611585> 6 7 Reviewed by Geoff Garen. 8 9 Soft-link the string constant `UIPasteboardNameGeneral`. See WebKit/ChangeLog for more details. 10 11 * pal/ios/UIKitSoftLink.h: 12 * pal/ios/UIKitSoftLink.mm: 13 1 14 2020-03-20 Tim Horton <timothy_horton@apple.com> 2 15 -
trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h
r241828 r259151 42 42 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UIContentSizeCategoryDidChangeNotification, NSNotificationName) 43 43 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UIFontTextStyleCallout, UIFontTextStyle) 44 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UIPasteboardNameGeneral, UIPasteboardName) 44 45 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UITextEffectsBeneathStatusBarWindowLevel, UIWindowLevel) 45 46 SOFT_LINK_CLASS_FOR_HEADER(PAL, NSParagraphStyle) -
trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm
r241828 r259151 42 42 SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UIContentSizeCategoryDidChangeNotification, NSNotificationName) 43 43 SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UIFontTextStyleCallout, UIFontTextStyle) 44 SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UIPasteboardNameGeneral, UIPasteboardName) 44 45 SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UITextEffectsBeneathStatusBarWindowLevel, UIWindowLevel) 45 46 SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, NSParagraphStyle) -
trunk/Source/WebCore/platform/ios/PasteboardIOS.mm
r259020 r259151 39 39 #import "WebNSAttributedStringExtras.h" 40 40 #import <MobileCoreServices/MobileCoreServices.h> 41 #import <pal/ios/UIKitSoftLink.h> 41 42 #import <wtf/URL.h> 42 43 #import <wtf/text/StringHash.h> … … 107 108 std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste() 108 109 { 109 return makeUnique<Pasteboard>( changeCountForPasteboard());110 return makeUnique<Pasteboard>(PAL::get_UIKit_UIPasteboardNameGeneral()); 110 111 } 111 112 -
trunk/Source/WebKit/ChangeLog
r259146 r259151 1 2020-03-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Web content processes should not be able to arbitrarily request pasteboard data from the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=209657 5 <rdar://problem/59611585> 6 7 Reviewed by Geoff Garen. 8 9 This patch adds a mechanism to prevent the UI process from sending pasteboard data to the web process in 10 response to WebPasteboardProxy IPC messages, unless the user (or the WebKit client, on behalf of the user) has 11 explicitly made the contents of the pasteboard available to a page in that web process. We determine the latter 12 by maintaining information about the `changeCount`s of each pasteboard we allow each web process to read. This 13 mapping is updated when either the user interacts with trusted UI (context menus, DOM paste menu) for pasting, 14 or an API client calls into -[WKWebView paste:], as is the case when pasting via the callout bar on iOS or 15 pasting via keyboard shortcuts (i.e. cmd + V) on macOS and iOS. 16 17 See per-change comments below for more details. Under normal circumstances, there should be no change in 18 behavior; refer to the radar for more context. 19 20 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 21 (WebKit::WebPageProxy::grantAccessToCurrentPasteboardData): 22 23 Add a helper method to grant access to the data currently on the pasteboard with the given name; for now, this 24 grants access to all related pages that reside in the same web process, but this may be refactored in a future 25 change to make the mapping granular to each WebPageProxy rather than WebProcessProxy. 26 27 (Note: it is _critical_ that this method is never invoked as a result of IPC from the web process.) 28 29 * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: 30 (WebKit::WebPasteboardProxy::grantAccessToCurrentData): 31 32 Helper method to grant access to the current contents on the named pasteboard. Calling this method updates 33 `m_pasteboardNameToChangeCountAndProcessesMap`, such that the given web process is able to read from the 34 pasteboard with the given name, as long as the `changeCount` is still the same. To implement this behavior, 35 we either (1) add the process to an existing `WeakHashSet` of process proxies in the case where the 36 `changeCount` is the same as it was when we added the existing `WeakHashSet`, or in all other cases, (2) add a 37 replace the current (changeCount, processes) pair with the new change count and a weak set containing only the 38 given WebProcessProxy. 39 40 (WebKit::WebPasteboardProxy::revokeAccessToAllData): 41 42 Helper method to revoke all pasteboard access for the given WebProcessProxy. Called when resetting state, e.g. 43 after web process termination. 44 45 (WebKit::WebPasteboardProxy::canAccessPasteboardData const): 46 47 Private helper method to check whether an IPC message can access pasteboard data, based on the IPC::Connection 48 used to receive the message. This helper method returns true if either the WebKit client has used SPI 49 (both DOMPasteAllowed and JavaScriptCanAccessClipboard) to grant unmitigated access to the clipboard from the 50 web process, or access has been previously granted due to user interaction in the UI process or API calls made 51 directly by the WebKit client. 52 53 (WebKit::WebPasteboardProxy::didModifyContentsOfPasteboard): 54 55 Private helper method to update the pasteboard changeCount that has been granted to a given web process, in the 56 case where that web process was also responsible for writing data to the pasteboard and the pasteboard 57 changeCount prior to modifying the pasteboard was still valid. In other words, we should always allow a web 58 process to read contents it has just written. This allows us to maintain the use case where a WKWebView client 59 copies and pastes using back-to-back API calls: 60 61 ``` 62 [webView copy:nil]; 63 [webView paste:nil]; 64 ``` 65 66 (WebKit::WebPasteboardProxy::getPasteboardPathnamesForType): 67 68 Add a FIXME to add the `canAccessPasteboardData` check here as well. We can't do this yet because the web 69 process currently relies on being able to read the full list of pasteboard path names when dragging over the 70 page, but this will be fixed in a followup patch in the near future (see https://webkit.org/b/209671). 71 72 (WebKit::WebPasteboardProxy::getPasteboardStringForType): 73 (WebKit::WebPasteboardProxy::getPasteboardStringsForType): 74 (WebKit::WebPasteboardProxy::getPasteboardBufferForType): 75 (WebKit::WebPasteboardProxy::getPasteboardColor): 76 (WebKit::WebPasteboardProxy::getPasteboardURL): 77 78 In all the call sites where we ask for pasteboard data (with the exception of getPasteboardPathnamesForType, for 79 the time being), check whether we're allowed to read pasteboard data by consulting canAccessPasteboardData. If 80 not, return early with no data. 81 82 (WebKit::WebPasteboardProxy::addPasteboardTypes): 83 (WebKit::WebPasteboardProxy::setPasteboardTypes): 84 (WebKit::WebPasteboardProxy::setPasteboardURL): 85 (WebKit::WebPasteboardProxy::setPasteboardColor): 86 (WebKit::WebPasteboardProxy::setPasteboardStringForType): 87 88 In all the call sites where we knowingly mutate the pasteboard (and bump the changeCount as a result), 89 additionally update the changeCount to which we've granted access on behalf of the web process that is modifying 90 the pasteboard. 91 92 (WebKit::WebPasteboardProxy::urlStringSuitableForLoading): 93 (WebKit::WebPasteboardProxy::setPasteboardBufferForType): 94 (WebKit::WebPasteboardProxy::writeCustomData): 95 (WebKit::WebPasteboardProxy::readStringFromPasteboard): 96 (WebKit::WebPasteboardProxy::readURLFromPasteboard): 97 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 98 (WebKit::WebPasteboardProxy::writeURLToPasteboard): 99 (WebKit::WebPasteboardProxy::writeWebContentToPasteboard): 100 (WebKit::WebPasteboardProxy::writeImageToPasteboard): 101 (WebKit::WebPasteboardProxy::writeStringToPasteboard): 102 103 (See comments above). 104 105 * UIProcess/Cocoa/WebViewImpl.mm: 106 (WebKit::WebViewImpl::performDragOperation): 107 108 When performing a drop on macOS, grant temporary access to the drag pasteboard. 109 110 (WebKit::WebViewImpl::requestDOMPasteAccess): 111 (WebKit::WebViewImpl::handleDOMPasteRequestWithResult): 112 113 If the user has granted DOM paste access, additionally grant access to the general pasteboard. 114 115 * UIProcess/WebPageProxy.cpp: 116 (WebKit::isPasteCommandName): 117 (WebKit::WebPageProxy::executeEditCommand): 118 119 When executing an edit command on behalf of a WebKit client, check to see if it is a paste command (one of 120 the four that are defined in EditorCommand.cpp). If so, we grant access to the current contents of the general 121 pasteboard. 122 123 * UIProcess/WebPageProxy.h: 124 * UIProcess/WebPasteboardProxy.cpp: 125 (WebKit::WebPasteboardProxy::webProcessProxyForConnection const): 126 127 Add a helper method to map a given IPC::Connection to a WebProcessProxy. While we have a list of WebProcessProxy 128 objects, we know a priori that at most one of them will have the given connection, so returning a single 129 `WebProcessProxy*` here is sufficient (rather than a list of `WebProcessProxy*`s). 130 131 (WebKit::WebPasteboardProxy::allPasteboardItemInfo): 132 (WebKit::WebPasteboardProxy::informationForItemAtIndex): 133 (WebKit::WebPasteboardProxy::getPasteboardItemsCount): 134 (WebKit::WebPasteboardProxy::readURLFromPasteboard): 135 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 136 (WebKit::WebPasteboardProxy::readStringFromPasteboard): 137 (WebKit::WebPasteboardProxy::urlStringSuitableForLoading): 138 139 Update interface stubs for non-Cocoa platforms. 140 141 * UIProcess/WebPasteboardProxy.h: 142 * UIProcess/WebPasteboardProxy.messages.in: 143 144 Decorate more IPC endpoints with `WantsConnection`, so that we can reason about the `IPC::Connection`s used to 145 receive pasteboard messages. 146 147 * UIProcess/ios/WKContentViewInteraction.mm: 148 (-[WKContentView _handleDOMPasteRequestWithResult:]): 149 150 If the user has granted DOM paste access, additionally grant access to the general pasteboard. 151 152 (-[WKContentView dropInteraction:performDrop:]): 153 154 When performing a drop on iOS, grant temporary access to the drag pasteboard. 155 156 * UIProcess/ios/WebPageProxyIOS.mm: 157 (WebKit::WebPageProxy::willPerformPasteCommand): 158 * UIProcess/libwpe/WebPasteboardProxyLibWPE.cpp: 159 (WebKit::WebPasteboardProxy::readStringFromPasteboard): 160 * UIProcess/mac/WebPageProxyMac.mm: 161 (WebKit::WebPageProxy::platformDidSelectItemFromActiveContextMenu): 162 163 Grant pasteboard access when using the context menu to paste on macOS. 164 165 (WebKit::WebPageProxy::willPerformPasteCommand): 166 167 Grant pasteboard access when triggering the "Paste" edit command using WebKit SPI. 168 1 169 2020-03-27 Chris Dumez <cdumez@apple.com> 2 170 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r258796 r259151 37 37 #import "SharedBufferDataReference.h" 38 38 #import "WebPageMessages.h" 39 #import "WebPasteboardProxy.h" 39 40 #import "WebProcessProxy.h" 40 41 #import "WebsiteDataStore.h" … … 78 79 79 80 completionHandler(WebCore::loadRecentSearches(name)); 81 } 82 83 void WebPageProxy::grantAccessToCurrentPasteboardData(const String& pasteboardName) 84 { 85 if (!hasRunningProcess()) 86 return; 87 88 WebPasteboardProxy::singleton().grantAccessToCurrentData(m_process.get(), pasteboardName); 80 89 } 81 90 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
r259124 r259151 29 29 #import "Connection.h" 30 30 #import "SandboxExtension.h" 31 #import "WebPageProxy.h" 32 #import "WebPreferences.h" 31 33 #import "WebProcessProxy.h" 32 34 #import <WebCore/Color.h> … … 42 44 using namespace WebCore; 43 45 46 void WebPasteboardProxy::grantAccessToCurrentData(WebProcessProxy& process, const String& pasteboardName) 47 { 48 if (!m_webProcessProxyList.contains(&process)) 49 return; 50 51 if (pasteboardName.isEmpty()) { 52 ASSERT_NOT_REACHED(); 53 return; 54 } 55 56 auto changeCount = PlatformPasteboard(pasteboardName).changeCount(); 57 auto changeCountsAndProcesses = m_pasteboardNameToChangeCountAndProcessesMap.find(pasteboardName); 58 if (changeCountsAndProcesses != m_pasteboardNameToChangeCountAndProcessesMap.end() && changeCountsAndProcesses->value.first == changeCount) { 59 changeCountsAndProcesses->value.second.add(process); 60 return; 61 } 62 63 WeakHashSet<WebProcessProxy> processes; 64 processes.add(process); 65 m_pasteboardNameToChangeCountAndProcessesMap.set(pasteboardName, std::make_pair(changeCount, WTFMove(processes))); 66 } 67 68 void WebPasteboardProxy::revokeAccessToAllData(WebProcessProxy& process) 69 { 70 for (auto& changeCountAndProcesses : m_pasteboardNameToChangeCountAndProcessesMap.values()) 71 changeCountAndProcesses.second.remove(process); 72 } 73 74 bool WebPasteboardProxy::canAccessPasteboardData(IPC::Connection& connection, const String& pasteboardName) const 75 { 76 if (pasteboardName.isEmpty()) { 77 ASSERT_NOT_REACHED(); 78 return false; 79 } 80 81 auto* process = webProcessProxyForConnection(connection); 82 if (!process) 83 return false; 84 85 for (auto* page : process->pages()) { 86 auto& preferences = page->preferences(); 87 if (!preferences.domPasteAllowed() || !preferences.javaScriptCanAccessClipboard()) 88 continue; 89 90 // If a web page already allows JavaScript to programmatically read pasteboard data, 91 // then it is possible for any other web page residing in the same web process to send 92 // IPC messages that can read pasteboard data by pretending to be the page that has 93 // allowed unmitigated pasteboard access from script. As such, there is no security 94 // benefit in limiting the scope of pasteboard data access to only the web page that 95 // enables programmatic pasteboard access. 96 return true; 97 } 98 99 auto changeCountAndProcesses = m_pasteboardNameToChangeCountAndProcessesMap.find(pasteboardName); 100 if (changeCountAndProcesses == m_pasteboardNameToChangeCountAndProcessesMap.end()) 101 return false; 102 103 auto& [changeCount, processes] = changeCountAndProcesses->value; 104 return changeCount == PlatformPasteboard(pasteboardName).changeCount() && processes.contains(*process); 105 } 106 107 void WebPasteboardProxy::didModifyContentsOfPasteboard(IPC::Connection& connection, const String& pasteboardName, int64_t previousChangeCount, int64_t newChangeCount) 108 { 109 auto* process = webProcessProxyForConnection(connection); 110 if (!process) 111 return; 112 113 auto changeCountAndProcesses = m_pasteboardNameToChangeCountAndProcessesMap.find(pasteboardName); 114 if (changeCountAndProcesses != m_pasteboardNameToChangeCountAndProcessesMap.end() && previousChangeCount == changeCountAndProcesses->value.first) { 115 WeakHashSet<WebProcessProxy> processes; 116 processes.add(process); 117 changeCountAndProcesses->value = std::make_pair(newChangeCount, WTFMove(processes)); 118 } 119 } 120 44 121 void WebPasteboardProxy::getPasteboardTypes(const String& pasteboardName, CompletionHandler<void(Vector<String>&&)>&& completionHandler) 45 122 { … … 56 133 return completionHandler({ }, { }); 57 134 135 // FIXME: This should consult canAccessPasteboardData() as well, and avoid responding with file paths if it returns false. 58 136 Vector<String> pathnames; 59 137 SandboxExtension::HandleArray sandboxExtensions; 60 for (auto* webProcessProxy : m_webProcessProxyList) { 61 if (!webProcessProxy->hasConnection(connection)) 62 continue; 63 138 if (webProcessProxyForConnection(connection)) { 64 139 PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType); 65 140 … … 78 153 } 79 154 80 void WebPasteboardProxy::getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&& completionHandler) 81 { 155 void WebPasteboardProxy::getPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&& completionHandler) 156 { 157 if (!canAccessPasteboardData(connection, pasteboardName)) 158 return completionHandler({ }); 159 82 160 ASSERT(!pasteboardType.isNull()); 83 161 if (pasteboardType.isNull()) … … 87 165 } 88 166 89 void WebPasteboardProxy::getPasteboardStringsForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&& completionHandler) 90 { 91 ASSERT(!pasteboardType.isNull()); 92 if (pasteboardType.isNull()) 167 void WebPasteboardProxy::getPasteboardStringsForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&& completionHandler) 168 { 169 ASSERT(!pasteboardType.isNull()); 170 if (pasteboardType.isNull()) 171 return completionHandler({ }); 172 173 if (!canAccessPasteboardData(connection, pasteboardName)) 93 174 return completionHandler({ }); 94 175 … … 96 177 } 97 178 98 void WebPasteboardProxy::getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler) 99 { 100 ASSERT(!pasteboardType.isNull()); 101 if (pasteboardType.isNull()) 179 void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler) 180 { 181 ASSERT(!pasteboardType.isNull()); 182 if (pasteboardType.isNull()) 183 return completionHandler({ }, 0); 184 185 if (!canAccessPasteboardData(connection, pasteboardName)) 102 186 return completionHandler({ }, 0); 103 187 … … 122 206 } 123 207 124 void WebPasteboardProxy::getPasteboardColor(const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&& completionHandler) 125 { 208 void WebPasteboardProxy::getPasteboardColor(IPC::Connection& connection, const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&& completionHandler) 209 { 210 if (!canAccessPasteboardData(connection, pasteboardName)) 211 return completionHandler({ }); 212 126 213 completionHandler(PlatformPasteboard(pasteboardName).color()); 127 214 } 128 215 129 void WebPasteboardProxy::getPasteboardURL(const String& pasteboardName, CompletionHandler<void(const String&)>&& completionHandler) 130 { 216 void WebPasteboardProxy::getPasteboardURL(IPC::Connection& connection, const String& pasteboardName, CompletionHandler<void(const String&)>&& completionHandler) 217 { 218 if (!canAccessPasteboardData(connection, pasteboardName)) 219 return completionHandler({ }); 220 131 221 completionHandler(PlatformPasteboard(pasteboardName).url().string()); 132 222 } 133 223 134 void WebPasteboardProxy::addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler) 135 { 136 completionHandler(PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes)); 137 } 138 139 void WebPasteboardProxy::setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler) 140 { 141 completionHandler(PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes)); 224 void WebPasteboardProxy::addPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler) 225 { 226 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 227 auto newChangeCount = PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes); 228 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, previousChangeCount); 229 completionHandler(newChangeCount); 230 } 231 232 void WebPasteboardProxy::setPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler) 233 { 234 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 235 auto newChangeCount = PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes); 236 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); 237 completionHandler(newChangeCount); 142 238 } 143 239 144 240 void WebPasteboardProxy::setPasteboardURL(IPC::Connection& connection, const PasteboardURL& pasteboardURL, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler) 145 241 { 146 for (auto* webProcessProxy : m_webProcessProxyList) { 147 if (!webProcessProxy->hasConnection(connection)) 148 continue; 149 242 if (auto* webProcessProxy = webProcessProxyForConnection(connection)) { 150 243 if (!webProcessProxy->checkURLReceivedFromWebProcess(pasteboardURL.url.string())) 151 244 return completionHandler(0); 152 245 153 return completionHandler(PlatformPasteboard(pasteboardName).setURL(pasteboardURL)); 246 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 247 auto newChangeCount = PlatformPasteboard(pasteboardName).setURL(pasteboardURL); 248 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); 249 return completionHandler(newChangeCount); 154 250 } 155 251 completionHandler(0); 156 252 } 157 253 158 void WebPasteboardProxy::setPasteboardColor(const String& pasteboardName, const WebCore::Color& color, CompletionHandler<void(int64_t)>&& completionHandler) 159 { 160 completionHandler(PlatformPasteboard(pasteboardName).setColor(color)); 161 } 162 163 void WebPasteboardProxy::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string, CompletionHandler<void(int64_t)>&& completionHandler) 254 void WebPasteboardProxy::setPasteboardColor(IPC::Connection& connection, const String& pasteboardName, const WebCore::Color& color, CompletionHandler<void(int64_t)>&& completionHandler) 255 { 256 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 257 auto newChangeCount = PlatformPasteboard(pasteboardName).setColor(color); 258 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); 259 completionHandler(newChangeCount); 260 } 261 262 void WebPasteboardProxy::setPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const String& string, CompletionHandler<void(int64_t)>&& completionHandler) 164 263 { 165 264 ASSERT(!pasteboardType.isNull()); … … 167 266 return completionHandler(0); 168 267 169 completionHandler(PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType)); 268 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 269 auto newChangeCount = PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType); 270 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); 271 completionHandler(newChangeCount); 170 272 } 171 273 … … 175 277 } 176 278 177 void WebPasteboardProxy::urlStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler) 178 { 279 void WebPasteboardProxy::urlStringSuitableForLoading(IPC::Connection& connection, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler) 280 { 281 if (!canAccessPasteboardData(connection, pasteboardName)) 282 return completionHandler({ }, { }); 283 179 284 String title; 180 285 auto urlString = PlatformPasteboard(pasteboardName).urlStringSuitableForLoading(title); … … 188 293 return completionHandler(0); 189 294 190 if (handle.isNull()) 191 return completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType)); 295 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 296 if (handle.isNull()) { 297 auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType); 298 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); 299 return completionHandler(newChangeCount); 300 } 192 301 193 302 // SharedMemory::Handle::size() is rounded up to the nearest page. … … 198 307 return completionHandler(0); 199 308 auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(size)); 200 completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType)); 309 auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType); 310 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); 311 completionHandler(newChangeCount); 201 312 } 202 313 … … 215 326 } 216 327 217 void WebPasteboardProxy::writeCustomData(const Vector<PasteboardCustomData>& data, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler) 218 { 219 completionHandler(PlatformPasteboard(pasteboardName).write(data)); 328 void WebPasteboardProxy::writeCustomData(IPC::Connection& connection, const Vector<PasteboardCustomData>& data, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler) 329 { 330 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 331 auto newChangeCount = PlatformPasteboard(pasteboardName).write(data); 332 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); 333 completionHandler(newChangeCount); 220 334 } 221 335 … … 235 349 } 236 350 237 void WebPasteboardProxy::readStringFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&& completionHandler) 238 { 239 ASSERT(!pasteboardType.isNull()); 240 if (pasteboardType.isNull()) 351 void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&& completionHandler) 352 { 353 ASSERT(!pasteboardType.isNull()); 354 if (pasteboardType.isNull()) 355 return completionHandler({ }); 356 357 if (!canAccessPasteboardData(connection, pasteboardName)) 241 358 return completionHandler({ }); 242 359 … … 244 361 } 245 362 246 void WebPasteboardProxy::readURLFromPasteboard(size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler) 247 { 363 void WebPasteboardProxy::readURLFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler) 364 { 365 if (!canAccessPasteboardData(connection, pasteboardName)) 366 return completionHandler({ }, { }); 367 248 368 String title; 249 369 String url = PlatformPasteboard(pasteboardName).readURL(index, title); … … 251 371 } 252 372 253 void WebPasteboardProxy::readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler) 254 { 255 ASSERT(!pasteboardType.isNull()); 256 if (pasteboardType.isNull()) 373 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler) 374 { 375 ASSERT(!pasteboardType.isNull()); 376 if (pasteboardType.isNull()) 377 return completionHandler({ }, 0); 378 379 if (!canAccessPasteboardData(connection, pasteboardName)) 257 380 return completionHandler({ }, 0); 258 381 … … 279 402 #if PLATFORM(IOS_FAMILY) 280 403 281 void WebPasteboardProxy::writeURLToPasteboard(const PasteboardURL& url, const String& pasteboardName) 282 { 404 void WebPasteboardProxy::writeURLToPasteboard(IPC::Connection& connection, const PasteboardURL& url, const String& pasteboardName) 405 { 406 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 283 407 PlatformPasteboard(pasteboardName).write(url); 284 } 285 286 void WebPasteboardProxy::writeWebContentToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName) 287 { 408 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount()); 409 } 410 411 void WebPasteboardProxy::writeWebContentToPasteboard(IPC::Connection& connection, const WebCore::PasteboardWebContent& content, const String& pasteboardName) 412 { 413 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 288 414 PlatformPasteboard(pasteboardName).write(content); 289 } 290 291 void WebPasteboardProxy::writeImageToPasteboard(const WebCore::PasteboardImage& pasteboardImage, const String& pasteboardName) 292 { 415 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount()); 416 } 417 418 void WebPasteboardProxy::writeImageToPasteboard(IPC::Connection& connection, const WebCore::PasteboardImage& pasteboardImage, const String& pasteboardName) 419 { 420 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 293 421 PlatformPasteboard(pasteboardName).write(pasteboardImage); 294 } 295 296 void WebPasteboardProxy::writeStringToPasteboard(const String& pasteboardType, const String& text, const String& pasteboardName) 297 { 422 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount()); 423 } 424 425 void WebPasteboardProxy::writeStringToPasteboard(IPC::Connection& connection, const String& pasteboardType, const String& text, const String& pasteboardName) 426 { 427 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 298 428 PlatformPasteboard(pasteboardName).write(pasteboardType, text); 429 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount()); 299 430 } 300 431 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r258796 r259151 4038 4038 } 4039 4039 4040 m_page->performDragOperation(*dragData, draggingInfo.draggingPasteboard.name, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload)); 4040 String draggingPasteboardName = draggingInfo.draggingPasteboard.name; 4041 m_page->grantAccessToCurrentPasteboardData(draggingPasteboardName); 4042 m_page->performDragOperation(*dragData, draggingPasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload)); 4041 4043 delete dragData; 4042 4044 … … 4332 4334 auto buffer = WebCore::SharedBuffer::create(data); 4333 4335 if (WebCore::PasteboardCustomData::fromSharedBuffer(buffer.get()).origin() == originIdentifier) { 4336 m_page->grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral); 4334 4337 completion(WebCore::DOMPasteAccessResponse::GrantedForGesture); 4335 4338 return; … … 4348 4351 void WebViewImpl::handleDOMPasteRequestWithResult(WebCore::DOMPasteAccessResponse response) 4349 4352 { 4353 if (response == WebCore::DOMPasteAccessResponse::GrantedForCommand || response == WebCore::DOMPasteAccessResponse::GrantedForGesture) 4354 m_page->grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral); 4355 4350 4356 if (auto handler = std::exchange(m_domPasteRequestHandler, { })) 4351 4357 handler(response); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r259146 r259151 125 125 #include "WebPageMessages.h" 126 126 #include "WebPageProxyMessages.h" 127 #include "WebPasteboardProxy.h" 127 128 #include "WebPaymentCoordinatorProxy.h" 128 129 #include "WebPopupItem.h" … … 2280 2281 } 2281 2282 2283 static bool isPasteCommandName(const String& commandName) 2284 { 2285 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> pasteCommandNames = HashSet<String, ASCIICaseInsensitiveHash> { 2286 "Paste", 2287 "PasteAndMatchStyle", 2288 "PasteAsQuotation", 2289 "PasteAsPlainText" 2290 }; 2291 return pasteCommandNames->contains(commandName); 2292 } 2293 2282 2294 void WebPageProxy::executeEditCommand(const String& commandName, const String& argument, WTF::Function<void(CallbackBase::Error)>&& callbackFunction) 2283 2295 { … … 2287 2299 } 2288 2300 2301 if (isPasteCommandName(commandName)) 2302 willPerformPasteCommand(); 2303 2289 2304 auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::executeEditCommand"_s)); 2290 2305 send(Messages::WebPage::ExecuteEditCommandWithCallback(commandName, argument, callbackID)); … … 2297 2312 if (!hasRunningProcess()) 2298 2313 return; 2314 2315 if (isPasteCommandName(commandName)) 2316 willPerformPasteCommand(); 2299 2317 2300 2318 if (commandName == ignoreSpellingCommandName) … … 6540 6558 ++m_pendingLearnOrIgnoreWordMessageCount; 6541 6559 6560 platformDidSelectItemFromActiveContextMenu(item); 6561 6542 6562 send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item)); 6543 6563 } … … 7592 7612 7593 7613 pageClient().clearAllEditCommands(); 7614 7615 #if PLATFORM(COCOA) 7616 WebPasteboardProxy::singleton().revokeAccessToAllData(m_process.get()); 7617 #endif 7594 7618 7595 7619 auto resetStateReason = terminationReason == ProcessTerminationReason::NavigationSwap ? ResetStateReason::NavigationSwap : ResetStateReason::WebProcessExited; … … 10000 10024 #endif 10001 10025 10026 #if ENABLE(CONTEXT_MENUS) && !PLATFORM(MAC) 10027 10028 void WebPageProxy::platformDidSelectItemFromActiveContextMenu(const WebContextMenuItemData&) 10029 { 10030 } 10031 10032 #endif 10033 10034 #if !PLATFORM(COCOA) 10035 10036 void WebPageProxy::willPerformPasteCommand() 10037 { 10038 } 10039 10040 #endif 10041 10002 10042 } // namespace WebKit 10003 10043 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r259146 r259151 1715 1715 NavigatingToAppBoundDomain isNavigatingToAppBoundDomain() const { return m_isNavigatingToAppBoundDomain; } 1716 1716 1717 #if PLATFORM(COCOA) 1718 void grantAccessToCurrentPasteboardData(const String& pasteboardName); 1719 #endif 1720 1721 #if ENABLE(CONTEXT_MENUS) 1722 void platformDidSelectItemFromActiveContextMenu(const WebContextMenuItemData&); 1723 #endif 1724 1717 1725 private: 1718 1726 WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&); … … 1934 1942 1935 1943 void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&); 1944 void willPerformPasteCommand(); 1936 1945 1937 1946 // Back/Forward list management -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp
r259124 r259151 69 69 } 70 70 71 WebProcessProxy* WebPasteboardProxy::webProcessProxyForConnection(IPC::Connection& connection) const 72 { 73 for (auto* webProcessProxy : m_webProcessProxyList) { 74 if (webProcessProxy->hasConnection(connection)) 75 return webProcessProxy; 76 } 77 return nullptr; 78 } 79 71 80 #if !PLATFORM(COCOA) 72 81 … … 76 85 } 77 86 78 void WebPasteboardProxy::writeCustomData( const Vector<WebCore::PasteboardCustomData>&, const String&, CompletionHandler<void(int64_t)>&& completionHandler)87 void WebPasteboardProxy::writeCustomData(IPC::Connection&, const Vector<WebCore::PasteboardCustomData>&, const String&, CompletionHandler<void(int64_t)>&& completionHandler) 79 88 { 80 89 completionHandler(0); … … 96 105 } 97 106 98 void WebPasteboardProxy::readURLFromPasteboard( size_t, const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)107 void WebPasteboardProxy::readURLFromPasteboard(IPC::Connection&, size_t, const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler) 99 108 { 100 109 completionHandler({ }, { }); 101 110 } 102 111 103 void WebPasteboardProxy::readBufferFromPasteboard( size_t, const String&, const String&, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)112 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler) 104 113 { 105 114 completionHandler({ }, 0); … … 108 117 #if !USE(LIBWPE) 109 118 110 void WebPasteboardProxy::readStringFromPasteboard( size_t, const String&, const String&, CompletionHandler<void(String&&)>&& completionHandler)119 void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(String&&)>&& completionHandler) 111 120 { 112 121 completionHandler({ }); … … 125 134 } 126 135 127 void WebPasteboardProxy::urlStringSuitableForLoading( const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)136 void WebPasteboardProxy::urlStringSuitableForLoading(IPC::Connection&, const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler) 128 137 { 129 138 completionHandler({ }, { }); -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h
r259124 r259151 31 31 #include <WebCore/SharedBuffer.h> 32 32 #include <wtf/Forward.h> 33 #include <wtf/HashMap.h> 33 34 #include <wtf/HashSet.h> 35 #include <wtf/WeakHashSet.h> 34 36 35 37 namespace WebCore { … … 57 59 void removeWebProcessProxy(WebProcessProxy&); 58 60 61 #if PLATFORM(COCOA) 62 void revokeAccessToAllData(WebProcessProxy&); 63 void grantAccessToCurrentData(WebProcessProxy&, const String& pasteboardName); 64 #endif 65 59 66 #if PLATFORM(GTK) 60 67 void setPrimarySelectionOwner(WebFrameProxy*); … … 65 72 WebPasteboardProxy(); 66 73 67 typedef HashSet<WebProcessProxy*> WebProcessProxyList;74 using WebProcessProxyList = HashSet<WebProcessProxy*>; 68 75 69 76 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; 70 77 void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override; 71 78 79 WebProcessProxy* webProcessProxyForConnection(IPC::Connection&) const; 80 72 81 #if PLATFORM(IOS_FAMILY) 73 void writeURLToPasteboard( const WebCore::PasteboardURL&, const String& pasteboardName);74 void writeWebContentToPasteboard( const WebCore::PasteboardWebContent&, const String& pasteboardName);75 void writeImageToPasteboard( const WebCore::PasteboardImage&, const String& pasteboardName);76 void writeStringToPasteboard( const String& pasteboardType, const String&, const String& pasteboardName);82 void writeURLToPasteboard(IPC::Connection&, const WebCore::PasteboardURL&, const String& pasteboardName); 83 void writeWebContentToPasteboard(IPC::Connection&, const WebCore::PasteboardWebContent&, const String& pasteboardName); 84 void writeImageToPasteboard(IPC::Connection&, const WebCore::PasteboardImage&, const String& pasteboardName); 85 void writeStringToPasteboard(IPC::Connection&, const String& pasteboardType, const String&, const String& pasteboardName); 77 86 void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName); 78 87 #endif … … 81 90 void getPasteboardTypes(const String& pasteboardName, CompletionHandler<void(Vector<String>&&)>&&); 82 91 void getPasteboardPathnamesForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&& pathnames, SandboxExtension::HandleArray&&)>&&); 83 void getPasteboardStringForType( const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&&);84 void getPasteboardStringsForType( const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&&);85 void getPasteboardBufferForType( const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&&);92 void getPasteboardStringForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&&); 93 void getPasteboardStringsForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&&); 94 void getPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&&); 86 95 void getPasteboardChangeCount(const String& pasteboardName, CompletionHandler<void(int64_t)>&&); 87 void getPasteboardColor( const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&&);88 void getPasteboardURL( const String& pasteboardName, CompletionHandler<void(const String&)>&&);89 void addPasteboardTypes( const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&);90 void setPasteboardTypes( const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&);96 void getPasteboardColor(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&&); 97 void getPasteboardURL(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(const String&)>&&); 98 void addPasteboardTypes(IPC::Connection&, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&); 99 void setPasteboardTypes(IPC::Connection&, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&); 91 100 void setPasteboardURL(IPC::Connection&, const WebCore::PasteboardURL&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&); 92 void setPasteboardColor( const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&);93 void setPasteboardStringForType( const String& pasteboardName, const String& pasteboardType, const String&, CompletionHandler<void(int64_t)>&&);101 void setPasteboardColor(IPC::Connection&, const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&); 102 void setPasteboardStringForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const String&, CompletionHandler<void(int64_t)>&&); 94 103 void setPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, CompletionHandler<void(int64_t)>&&); 95 104 #endif 96 105 97 void readStringFromPasteboard( size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&&);98 void readURLFromPasteboard( size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&);99 void readBufferFromPasteboard( size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&&);106 void readStringFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&&); 107 void readURLFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&); 108 void readBufferFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&&); 100 109 void getPasteboardItemsCount(const String& pasteboardName, CompletionHandler<void(uint64_t)>&&); 101 110 void informationForItemAtIndex(size_t index, const String& pasteboardName, int64_t changeCount, CompletionHandler<void(Optional<WebCore::PasteboardItemInfo>&&)>&&); 102 111 void allPasteboardItemInfo(const String& pasteboardName, int64_t changeCount, CompletionHandler<void(Optional<Vector<WebCore::PasteboardItemInfo>>&&)>&&); 103 112 104 void writeCustomData( const Vector<WebCore::PasteboardCustomData>&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&);113 void writeCustomData(IPC::Connection&, const Vector<WebCore::PasteboardCustomData>&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&); 105 114 void typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&&); 106 115 void containsStringSafeForDOMToReadForType(const String&, const String& pasteboardName, CompletionHandler<void(bool)>&&); 107 116 void containsURLStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(bool)>&&); 108 void urlStringSuitableForLoading( const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&);117 void urlStringSuitableForLoading(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&); 109 118 110 119 #if PLATFORM(GTK) … … 122 131 #endif 123 132 133 #if PLATFORM(COCOA) 134 bool canAccessPasteboardData(IPC::Connection&, const String& pasteboardName) const; 135 void didModifyContentsOfPasteboard(IPC::Connection&, const String& pasteboardName, int64_t previousChangeCount, int64_t newChangeCount); 136 #endif 137 124 138 WebProcessProxyList m_webProcessProxyList; 139 140 #if PLATFORM(COCOA) 141 HashMap<String, std::pair<int64_t, WeakHashSet<WebProcessProxy>>> m_pasteboardNameToChangeCountAndProcessesMap; 142 #endif 125 143 }; 126 144 -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
r259124 r259151 23 23 messages -> WebPasteboardProxy NotRefCounted { 24 24 #if PLATFORM(IOS_FAMILY) 25 WriteURLToPasteboard(struct WebCore::PasteboardURL url, String pasteboardName) 26 WriteWebContentToPasteboard(struct WebCore::PasteboardWebContent content, String pasteboardName) 27 WriteImageToPasteboard(struct WebCore::PasteboardImage pasteboardImage, String pasteboardName) 28 WriteStringToPasteboard(String pasteboardType, String text, String pasteboardName) 25 WriteURLToPasteboard(struct WebCore::PasteboardURL url, String pasteboardName) WantsConnection 26 WriteWebContentToPasteboard(struct WebCore::PasteboardWebContent content, String pasteboardName) WantsConnection 27 WriteImageToPasteboard(struct WebCore::PasteboardImage pasteboardImage, String pasteboardName) WantsConnection 28 WriteStringToPasteboard(String pasteboardType, String text, String pasteboardName) WantsConnection 29 29 UpdateSupportedTypeIdentifiers(Vector<String> identifiers, String pasteboardName) 30 30 #endif 31 31 32 WriteCustomData(Vector<WebCore::PasteboardCustomData> data, String pasteboardName) -> (int64_t changeCount) Synchronous 32 WriteCustomData(Vector<WebCore::PasteboardCustomData> data, String pasteboardName) -> (int64_t changeCount) Synchronous WantsConnection 33 33 TypesSafeForDOMToReadAndWrite(String pasteboardName, String origin) -> (Vector<String> types) Synchronous 34 34 AllPasteboardItemInfo(String pasteboardName, int64_t changeCount) -> (Optional<Vector<WebCore::PasteboardItemInfo>> allInfo) Synchronous 35 35 InformationForItemAtIndex(uint64_t index, String pasteboardName, int64_t changeCount) -> (Optional<WebCore::PasteboardItemInfo> info) Synchronous 36 36 GetPasteboardItemsCount(String pasteboardName) -> (uint64_t itemsCount) Synchronous 37 ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string) Synchronous 38 ReadURLFromPasteboard(uint64_t index, String pasteboardName) -> (String url, String title) Synchronous 39 ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous 37 ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string) Synchronous WantsConnection 38 ReadURLFromPasteboard(uint64_t index, String pasteboardName) -> (String url, String title) Synchronous WantsConnection 39 ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous WantsConnection 40 40 ContainsStringSafeForDOMToReadForType(String type, String pasteboardName) -> (bool result) Synchronous 41 41 … … 45 45 GetPasteboardTypes(String pasteboardName) -> (Vector<String> types) Synchronous 46 46 GetPasteboardPathnamesForType(String pasteboardName, String pasteboardType) -> (Vector<String> pathnames, WebKit::SandboxExtension::HandleArray sandboxExtensions) Synchronous WantsConnection 47 GetPasteboardStringForType(String pasteboardName, String pasteboardType) -> (String string) Synchronous 48 GetPasteboardStringsForType(String pasteboardName, String pasteboardType) -> (Vector<String> strings) Synchronous 49 GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous 47 GetPasteboardStringForType(String pasteboardName, String pasteboardType) -> (String string) Synchronous WantsConnection 48 GetPasteboardStringsForType(String pasteboardName, String pasteboardType) -> (Vector<String> strings) Synchronous WantsConnection 49 GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous WantsConnection 50 50 GetPasteboardChangeCount(String pasteboardName) -> (int64_t changeCount) Synchronous 51 GetPasteboardColor(String pasteboardName) -> (WebCore::Color color) Synchronous 52 GetPasteboardURL(String pasteboardName) -> (String urlString) Synchronous 53 AddPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous 54 SetPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous 51 GetPasteboardColor(String pasteboardName) -> (WebCore::Color color) Synchronous WantsConnection 52 GetPasteboardURL(String pasteboardName) -> (String urlString) Synchronous WantsConnection 53 AddPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous WantsConnection 54 SetPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous WantsConnection 55 55 SetPasteboardURL(struct WebCore::PasteboardURL pasteboardURL, String pasteboardName) -> (int64_t changeCount) Synchronous WantsConnection 56 SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous 57 SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (int64_t changeCount) Synchronous 56 SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous WantsConnection 57 SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (int64_t changeCount) Synchronous WantsConnection 58 58 SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (int64_t changeCount) Synchronous WantsConnection 59 59 ContainsURLStringSuitableForLoading(String pasteboardName) -> (bool result) Synchronous 60 URLStringSuitableForLoading(String pasteboardName) -> (String url, String title) Synchronous 60 URLStringSuitableForLoading(String pasteboardName) -> (String url, String title) Synchronous WantsConnection 61 61 #endif 62 62 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r259126 r259151 3632 3632 - (BOOL)_handleDOMPasteRequestWithResult:(WebCore::DOMPasteAccessResponse)response 3633 3633 { 3634 if (response == WebCore::DOMPasteAccessResponse::GrantedForCommand || response == WebCore::DOMPasteAccessResponse::GrantedForGesture) 3635 _page->grantAccessToCurrentPasteboardData(UIPasteboardNameGeneral); 3636 3634 3637 if (auto pasteHandler = WTFMove(_domPasteRequestHandler)) { 3635 3638 [self hideGlobalMenuController]; … … 7879 7882 WebKit::SandboxExtension::Handle sandboxExtensionHandle; 7880 7883 WebKit::SandboxExtension::HandleArray sandboxExtensionForUpload; 7884 auto dragPasteboardName = WebCore::Pasteboard::nameOfDragPasteboard(); 7885 retainedSelf->_page->grantAccessToCurrentPasteboardData(dragPasteboardName); 7881 7886 retainedSelf->_page->createSandboxExtensionsIfNeeded(filenames, sandboxExtensionHandle, sandboxExtensionForUpload); 7882 retainedSelf->_page->performDragOperation(capturedDragData, WebCore::Pasteboard::nameOfDragPasteboard(), WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));7887 retainedSelf->_page->performDragOperation(capturedDragData, dragPasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload)); 7883 7888 if (shouldSnapshotView) { 7884 7889 retainedSelf->_visibleContentViewSnapshot = [retainedSelf snapshotViewAfterScreenUpdates:NO]; -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r259146 r259151 1571 1571 #endif 1572 1572 1573 void WebPageProxy::willPerformPasteCommand() 1574 { 1575 grantAccessToCurrentPasteboardData(UIPasteboardNameGeneral); 1576 } 1577 1573 1578 } // namespace WebKit 1574 1579 -
trunk/Source/WebKit/UIProcess/libwpe/WebPasteboardProxyLibWPE.cpp
r254524 r259151 41 41 } 42 42 43 void WebPasteboardProxy::readStringFromPasteboard( size_t index, const String& pasteboardType, const String&, CompletionHandler<void(String&&)>&& completionHandler)43 void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String&, CompletionHandler<void(String&&)>&& completionHandler) 44 44 { 45 45 completionHandler(PlatformPasteboard().readString(index, pasteboardType)); -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r258507 r259151 655 655 #endif 656 656 657 #if ENABLE(CONTEXT_MENUS) 658 659 void WebPageProxy::platformDidSelectItemFromActiveContextMenu(const WebContextMenuItemData& item) 660 { 661 if (item.action() == ContextMenuItemTagPaste) 662 grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral); 663 } 664 665 #endif 666 667 void WebPageProxy::willPerformPasteCommand() 668 { 669 grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral); 670 } 671 657 672 } // namespace WebKit 658 673
Note: See TracChangeset
for help on using the changeset viewer.