Diff
Modified: trunk/Source/WebCore/ChangeLog (259150 => 259151)
--- trunk/Source/WebCore/ChangeLog 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebCore/ChangeLog 2020-03-28 03:05:01 UTC (rev 259151)
@@ -1,3 +1,18 @@
+2020-03-27 Wenson Hsieh <[email protected]>
+
+ Web content processes should not be able to arbitrarily request pasteboard data from the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=209657
+ <rdar://problem/59611585>
+
+ Reviewed by Geoff Garen.
+
+ Match macOS behavior in the iOS implementation of Pasteboard::createForCopyAndPaste by using the name of the
+ general pasteboard by default, when initializing a Pasteboard for copying and pasting. In WebKit2, this allows
+ us to grant permission to the web process when reading from the general pasteboard.
+
+ * platform/ios/PasteboardIOS.mm:
+ (WebCore::Pasteboard::createForCopyAndPaste):
+
2020-03-27 Zalan Bujtas <[email protected]>
REGRESSION (r256577): Previous page continues to display after navigating to media document
Modified: trunk/Source/WebCore/PAL/ChangeLog (259150 => 259151)
--- trunk/Source/WebCore/PAL/ChangeLog 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebCore/PAL/ChangeLog 2020-03-28 03:05:01 UTC (rev 259151)
@@ -1,3 +1,16 @@
+2020-03-27 Wenson Hsieh <[email protected]>
+
+ Web content processes should not be able to arbitrarily request pasteboard data from the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=209657
+ <rdar://problem/59611585>
+
+ Reviewed by Geoff Garen.
+
+ Soft-link the string constant `UIPasteboardNameGeneral`. See WebKit/ChangeLog for more details.
+
+ * pal/ios/UIKitSoftLink.h:
+ * pal/ios/UIKitSoftLink.mm:
+
2020-03-20 Tim Horton <[email protected]>
Upstream a variety of Cocoa-platform HAVE and ENABLE macros
Modified: trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h (259150 => 259151)
--- trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h 2020-03-28 03:05:01 UTC (rev 259151)
@@ -41,6 +41,7 @@
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UIApplicationDidEnterBackgroundNotification, NSNotificationName)
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UIContentSizeCategoryDidChangeNotification, NSNotificationName)
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UIFontTextStyleCallout, UIFontTextStyle)
+SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UIPasteboardNameGeneral, UIPasteboardName)
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, UIKit, UITextEffectsBeneathStatusBarWindowLevel, UIWindowLevel)
SOFT_LINK_CLASS_FOR_HEADER(PAL, NSParagraphStyle)
SOFT_LINK_CLASS_FOR_HEADER(PAL, NSShadow)
Modified: trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm (259150 => 259151)
--- trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -41,6 +41,7 @@
SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UIApplicationDidEnterBackgroundNotification, NSNotificationName)
SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UIContentSizeCategoryDidChangeNotification, NSNotificationName)
SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UIFontTextStyleCallout, UIFontTextStyle)
+SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UIPasteboardNameGeneral, UIPasteboardName)
SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, UIKit, UITextEffectsBeneathStatusBarWindowLevel, UIWindowLevel)
SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, NSParagraphStyle)
SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, NSShadow)
Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (259150 => 259151)
--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -38,6 +38,7 @@
#import "UTIUtilities.h"
#import "WebNSAttributedStringExtras.h"
#import <MobileCoreServices/MobileCoreServices.h>
+#import <pal/ios/UIKitSoftLink.h>
#import <wtf/URL.h>
#import <wtf/text/StringHash.h>
@@ -106,7 +107,7 @@
std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste()
{
- return makeUnique<Pasteboard>(changeCountForPasteboard());
+ return makeUnique<Pasteboard>(PAL::get_UIKit_UIPasteboardNameGeneral());
}
void Pasteboard::write(const PasteboardWebContent& content)
Modified: trunk/Source/WebKit/ChangeLog (259150 => 259151)
--- trunk/Source/WebKit/ChangeLog 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/ChangeLog 2020-03-28 03:05:01 UTC (rev 259151)
@@ -1,3 +1,171 @@
+2020-03-27 Wenson Hsieh <[email protected]>
+
+ Web content processes should not be able to arbitrarily request pasteboard data from the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=209657
+ <rdar://problem/59611585>
+
+ Reviewed by Geoff Garen.
+
+ This patch adds a mechanism to prevent the UI process from sending pasteboard data to the web process in
+ response to WebPasteboardProxy IPC messages, unless the user (or the WebKit client, on behalf of the user) has
+ explicitly made the contents of the pasteboard available to a page in that web process. We determine the latter
+ by maintaining information about the `changeCount`s of each pasteboard we allow each web process to read. This
+ mapping is updated when either the user interacts with trusted UI (context menus, DOM paste menu) for pasting,
+ or an API client calls into -[WKWebView paste:], as is the case when pasting via the callout bar on iOS or
+ pasting via keyboard shortcuts (i.e. cmd + V) on macOS and iOS.
+
+ See per-change comments below for more details. Under normal circumstances, there should be no change in
+ behavior; refer to the radar for more context.
+
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::WebPageProxy::grantAccessToCurrentPasteboardData):
+
+ Add a helper method to grant access to the data currently on the pasteboard with the given name; for now, this
+ grants access to all related pages that reside in the same web process, but this may be refactored in a future
+ change to make the mapping granular to each WebPageProxy rather than WebProcessProxy.
+
+ (Note: it is _critical_ that this method is never invoked as a result of IPC from the web process.)
+
+ * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+ (WebKit::WebPasteboardProxy::grantAccessToCurrentData):
+
+ Helper method to grant access to the current contents on the named pasteboard. Calling this method updates
+ `m_pasteboardNameToChangeCountAndProcessesMap`, such that the given web process is able to read from the
+ pasteboard with the given name, as long as the `changeCount` is still the same. To implement this behavior,
+ we either (1) add the process to an existing `WeakHashSet` of process proxies in the case where the
+ `changeCount` is the same as it was when we added the existing `WeakHashSet`, or in all other cases, (2) add a
+ replace the current (changeCount, processes) pair with the new change count and a weak set containing only the
+ given WebProcessProxy.
+
+ (WebKit::WebPasteboardProxy::revokeAccessToAllData):
+
+ Helper method to revoke all pasteboard access for the given WebProcessProxy. Called when resetting state, e.g.
+ after web process termination.
+
+ (WebKit::WebPasteboardProxy::canAccessPasteboardData const):
+
+ Private helper method to check whether an IPC message can access pasteboard data, based on the IPC::Connection
+ used to receive the message. This helper method returns true if either the WebKit client has used SPI
+ (both DOMPasteAllowed and _javascript_CanAccessClipboard) to grant unmitigated access to the clipboard from the
+ web process, or access has been previously granted due to user interaction in the UI process or API calls made
+ directly by the WebKit client.
+
+ (WebKit::WebPasteboardProxy::didModifyContentsOfPasteboard):
+
+ Private helper method to update the pasteboard changeCount that has been granted to a given web process, in the
+ case where that web process was also responsible for writing data to the pasteboard and the pasteboard
+ changeCount prior to modifying the pasteboard was still valid. In other words, we should always allow a web
+ process to read contents it has just written. This allows us to maintain the use case where a WKWebView client
+ copies and pastes using back-to-back API calls:
+
+ ```
+ [webView copy:nil];
+ [webView paste:nil];
+ ```
+
+ (WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):
+
+ Add a FIXME to add the `canAccessPasteboardData` check here as well. We can't do this yet because the web
+ process currently relies on being able to read the full list of pasteboard path names when dragging over the
+ page, but this will be fixed in a followup patch in the near future (see https://webkit.org/b/209671).
+
+ (WebKit::WebPasteboardProxy::getPasteboardStringForType):
+ (WebKit::WebPasteboardProxy::getPasteboardStringsForType):
+ (WebKit::WebPasteboardProxy::getPasteboardBufferForType):
+ (WebKit::WebPasteboardProxy::getPasteboardColor):
+ (WebKit::WebPasteboardProxy::getPasteboardURL):
+
+ In all the call sites where we ask for pasteboard data (with the exception of getPasteboardPathnamesForType, for
+ the time being), check whether we're allowed to read pasteboard data by consulting canAccessPasteboardData. If
+ not, return early with no data.
+
+ (WebKit::WebPasteboardProxy::addPasteboardTypes):
+ (WebKit::WebPasteboardProxy::setPasteboardTypes):
+ (WebKit::WebPasteboardProxy::setPasteboardURL):
+ (WebKit::WebPasteboardProxy::setPasteboardColor):
+ (WebKit::WebPasteboardProxy::setPasteboardStringForType):
+
+ In all the call sites where we knowingly mutate the pasteboard (and bump the changeCount as a result),
+ additionally update the changeCount to which we've granted access on behalf of the web process that is modifying
+ the pasteboard.
+
+ (WebKit::WebPasteboardProxy::urlStringSuitableForLoading):
+ (WebKit::WebPasteboardProxy::setPasteboardBufferForType):
+ (WebKit::WebPasteboardProxy::writeCustomData):
+ (WebKit::WebPasteboardProxy::readStringFromPasteboard):
+ (WebKit::WebPasteboardProxy::readURLFromPasteboard):
+ (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
+ (WebKit::WebPasteboardProxy::writeURLToPasteboard):
+ (WebKit::WebPasteboardProxy::writeWebContentToPasteboard):
+ (WebKit::WebPasteboardProxy::writeImageToPasteboard):
+ (WebKit::WebPasteboardProxy::writeStringToPasteboard):
+
+ (See comments above).
+
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::performDragOperation):
+
+ When performing a drop on macOS, grant temporary access to the drag pasteboard.
+
+ (WebKit::WebViewImpl::requestDOMPasteAccess):
+ (WebKit::WebViewImpl::handleDOMPasteRequestWithResult):
+
+ If the user has granted DOM paste access, additionally grant access to the general pasteboard.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::isPasteCommandName):
+ (WebKit::WebPageProxy::executeEditCommand):
+
+ When executing an edit command on behalf of a WebKit client, check to see if it is a paste command (one of
+ the four that are defined in EditorCommand.cpp). If so, we grant access to the current contents of the general
+ pasteboard.
+
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPasteboardProxy.cpp:
+ (WebKit::WebPasteboardProxy::webProcessProxyForConnection const):
+
+ Add a helper method to map a given IPC::Connection to a WebProcessProxy. While we have a list of WebProcessProxy
+ objects, we know a priori that at most one of them will have the given connection, so returning a single
+ `WebProcessProxy*` here is sufficient (rather than a list of `WebProcessProxy*`s).
+
+ (WebKit::WebPasteboardProxy::allPasteboardItemInfo):
+ (WebKit::WebPasteboardProxy::informationForItemAtIndex):
+ (WebKit::WebPasteboardProxy::getPasteboardItemsCount):
+ (WebKit::WebPasteboardProxy::readURLFromPasteboard):
+ (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
+ (WebKit::WebPasteboardProxy::readStringFromPasteboard):
+ (WebKit::WebPasteboardProxy::urlStringSuitableForLoading):
+
+ Update interface stubs for non-Cocoa platforms.
+
+ * UIProcess/WebPasteboardProxy.h:
+ * UIProcess/WebPasteboardProxy.messages.in:
+
+ Decorate more IPC endpoints with `WantsConnection`, so that we can reason about the `IPC::Connection`s used to
+ receive pasteboard messages.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _handleDOMPasteRequestWithResult:]):
+
+ If the user has granted DOM paste access, additionally grant access to the general pasteboard.
+
+ (-[WKContentView dropInteraction:performDrop:]):
+
+ When performing a drop on iOS, grant temporary access to the drag pasteboard.
+
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::willPerformPasteCommand):
+ * UIProcess/libwpe/WebPasteboardProxyLibWPE.cpp:
+ (WebKit::WebPasteboardProxy::readStringFromPasteboard):
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::platformDidSelectItemFromActiveContextMenu):
+
+ Grant pasteboard access when using the context menu to paste on macOS.
+
+ (WebKit::WebPageProxy::willPerformPasteCommand):
+
+ Grant pasteboard access when triggering the "Paste" edit command using WebKit SPI.
+
2020-03-27 Chris Dumez <[email protected]>
[iOS] Delay process suspension for a while after loading an app link
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -36,6 +36,7 @@
#import "SafeBrowsingWarning.h"
#import "SharedBufferDataReference.h"
#import "WebPageMessages.h"
+#import "WebPasteboardProxy.h"
#import "WebProcessProxy.h"
#import "WebsiteDataStore.h"
#import <WebCore/DragItem.h>
@@ -79,6 +80,14 @@
completionHandler(WebCore::loadRecentSearches(name));
}
+void WebPageProxy::grantAccessToCurrentPasteboardData(const String& pasteboardName)
+{
+ if (!hasRunningProcess())
+ return;
+
+ WebPasteboardProxy::singleton().grantAccessToCurrentData(m_process.get(), pasteboardName);
+}
+
void WebPageProxy::beginSafeBrowsingCheck(const URL& url, bool forMainFrameNavigation, WebFramePolicyListenerProxy& listener)
{
#if HAVE(SAFE_BROWSING)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -28,6 +28,8 @@
#import "Connection.h"
#import "SandboxExtension.h"
+#import "WebPageProxy.h"
+#import "WebPreferences.h"
#import "WebProcessProxy.h"
#import <WebCore/Color.h>
#import <WebCore/Pasteboard.h>
@@ -41,6 +43,81 @@
namespace WebKit {
using namespace WebCore;
+void WebPasteboardProxy::grantAccessToCurrentData(WebProcessProxy& process, const String& pasteboardName)
+{
+ if (!m_webProcessProxyList.contains(&process))
+ return;
+
+ if (pasteboardName.isEmpty()) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ auto changeCount = PlatformPasteboard(pasteboardName).changeCount();
+ auto changeCountsAndProcesses = m_pasteboardNameToChangeCountAndProcessesMap.find(pasteboardName);
+ if (changeCountsAndProcesses != m_pasteboardNameToChangeCountAndProcessesMap.end() && changeCountsAndProcesses->value.first == changeCount) {
+ changeCountsAndProcesses->value.second.add(process);
+ return;
+ }
+
+ WeakHashSet<WebProcessProxy> processes;
+ processes.add(process);
+ m_pasteboardNameToChangeCountAndProcessesMap.set(pasteboardName, std::make_pair(changeCount, WTFMove(processes)));
+}
+
+void WebPasteboardProxy::revokeAccessToAllData(WebProcessProxy& process)
+{
+ for (auto& changeCountAndProcesses : m_pasteboardNameToChangeCountAndProcessesMap.values())
+ changeCountAndProcesses.second.remove(process);
+}
+
+bool WebPasteboardProxy::canAccessPasteboardData(IPC::Connection& connection, const String& pasteboardName) const
+{
+ if (pasteboardName.isEmpty()) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ auto* process = webProcessProxyForConnection(connection);
+ if (!process)
+ return false;
+
+ for (auto* page : process->pages()) {
+ auto& preferences = page->preferences();
+ if (!preferences.domPasteAllowed() || !preferences._javascript_CanAccessClipboard())
+ continue;
+
+ // If a web page already allows _javascript_ to programmatically read pasteboard data,
+ // then it is possible for any other web page residing in the same web process to send
+ // IPC messages that can read pasteboard data by pretending to be the page that has
+ // allowed unmitigated pasteboard access from script. As such, there is no security
+ // benefit in limiting the scope of pasteboard data access to only the web page that
+ // enables programmatic pasteboard access.
+ return true;
+ }
+
+ auto changeCountAndProcesses = m_pasteboardNameToChangeCountAndProcessesMap.find(pasteboardName);
+ if (changeCountAndProcesses == m_pasteboardNameToChangeCountAndProcessesMap.end())
+ return false;
+
+ auto& [changeCount, processes] = changeCountAndProcesses->value;
+ return changeCount == PlatformPasteboard(pasteboardName).changeCount() && processes.contains(*process);
+}
+
+void WebPasteboardProxy::didModifyContentsOfPasteboard(IPC::Connection& connection, const String& pasteboardName, int64_t previousChangeCount, int64_t newChangeCount)
+{
+ auto* process = webProcessProxyForConnection(connection);
+ if (!process)
+ return;
+
+ auto changeCountAndProcesses = m_pasteboardNameToChangeCountAndProcessesMap.find(pasteboardName);
+ if (changeCountAndProcesses != m_pasteboardNameToChangeCountAndProcessesMap.end() && previousChangeCount == changeCountAndProcesses->value.first) {
+ WeakHashSet<WebProcessProxy> processes;
+ processes.add(process);
+ changeCountAndProcesses->value = std::make_pair(newChangeCount, WTFMove(processes));
+ }
+}
+
void WebPasteboardProxy::getPasteboardTypes(const String& pasteboardName, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
{
Vector<String> pasteboardTypes;
@@ -55,12 +132,10 @@
if (pasteboardType.isNull())
return completionHandler({ }, { });
+ // FIXME: This should consult canAccessPasteboardData() as well, and avoid responding with file paths if it returns false.
Vector<String> pathnames;
SandboxExtension::HandleArray sandboxExtensions;
- for (auto* webProcessProxy : m_webProcessProxyList) {
- if (!webProcessProxy->hasConnection(connection))
- continue;
-
+ if (webProcessProxyForConnection(connection)) {
PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType);
#if PLATFORM(MAC)
@@ -77,8 +152,11 @@
completionHandler(WTFMove(pathnames), WTFMove(sandboxExtensions));
}
-void WebPasteboardProxy::getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&& completionHandler)
+void WebPasteboardProxy::getPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&& completionHandler)
{
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ });
+
ASSERT(!pasteboardType.isNull());
if (pasteboardType.isNull())
return completionHandler({ });
@@ -86,21 +164,27 @@
completionHandler(PlatformPasteboard(pasteboardName).stringForType(pasteboardType));
}
-void WebPasteboardProxy::getPasteboardStringsForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+void WebPasteboardProxy::getPasteboardStringsForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
{
ASSERT(!pasteboardType.isNull());
if (pasteboardType.isNull())
return completionHandler({ });
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ });
+
completionHandler(PlatformPasteboard(pasteboardName).allStringsForType(pasteboardType));
}
-void WebPasteboardProxy::getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler)
+void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler)
{
ASSERT(!pasteboardType.isNull());
if (pasteboardType.isNull())
return completionHandler({ }, 0);
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ }, 0);
+
RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).bufferForType(pasteboardType);
if (!buffer)
return completionHandler({ }, 0);
@@ -121,52 +205,70 @@
completionHandler(PlatformPasteboard(pasteboardName).changeCount());
}
-void WebPasteboardProxy::getPasteboardColor(const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&& completionHandler)
+void WebPasteboardProxy::getPasteboardColor(IPC::Connection& connection, const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&& completionHandler)
{
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ });
+
completionHandler(PlatformPasteboard(pasteboardName).color());
}
-void WebPasteboardProxy::getPasteboardURL(const String& pasteboardName, CompletionHandler<void(const String&)>&& completionHandler)
+void WebPasteboardProxy::getPasteboardURL(IPC::Connection& connection, const String& pasteboardName, CompletionHandler<void(const String&)>&& completionHandler)
{
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ });
+
completionHandler(PlatformPasteboard(pasteboardName).url().string());
}
-void WebPasteboardProxy::addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler)
+void WebPasteboardProxy::addPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler)
{
- completionHandler(PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes));
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
+ auto newChangeCount = PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, previousChangeCount);
+ completionHandler(newChangeCount);
}
-void WebPasteboardProxy::setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler)
+void WebPasteboardProxy::setPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&& completionHandler)
{
- completionHandler(PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes));
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
+ auto newChangeCount = PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
+ completionHandler(newChangeCount);
}
void WebPasteboardProxy::setPasteboardURL(IPC::Connection& connection, const PasteboardURL& pasteboardURL, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler)
{
- for (auto* webProcessProxy : m_webProcessProxyList) {
- if (!webProcessProxy->hasConnection(connection))
- continue;
-
+ if (auto* webProcessProxy = webProcessProxyForConnection(connection)) {
if (!webProcessProxy->checkURLReceivedFromWebProcess(pasteboardURL.url.string()))
return completionHandler(0);
- return completionHandler(PlatformPasteboard(pasteboardName).setURL(pasteboardURL));
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
+ auto newChangeCount = PlatformPasteboard(pasteboardName).setURL(pasteboardURL);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
+ return completionHandler(newChangeCount);
}
completionHandler(0);
}
-void WebPasteboardProxy::setPasteboardColor(const String& pasteboardName, const WebCore::Color& color, CompletionHandler<void(int64_t)>&& completionHandler)
+void WebPasteboardProxy::setPasteboardColor(IPC::Connection& connection, const String& pasteboardName, const WebCore::Color& color, CompletionHandler<void(int64_t)>&& completionHandler)
{
- completionHandler(PlatformPasteboard(pasteboardName).setColor(color));
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
+ auto newChangeCount = PlatformPasteboard(pasteboardName).setColor(color);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
+ completionHandler(newChangeCount);
}
-void WebPasteboardProxy::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string, CompletionHandler<void(int64_t)>&& completionHandler)
+void WebPasteboardProxy::setPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const String& string, CompletionHandler<void(int64_t)>&& completionHandler)
{
ASSERT(!pasteboardType.isNull());
if (pasteboardType.isNull())
return completionHandler(0);
- completionHandler(PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType));
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
+ auto newChangeCount = PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
+ completionHandler(newChangeCount);
}
void WebPasteboardProxy::containsURLStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(bool)>&& completionHandler)
@@ -174,8 +276,11 @@
completionHandler(PlatformPasteboard(pasteboardName).containsURLStringSuitableForLoading());
}
-void WebPasteboardProxy::urlStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
+void WebPasteboardProxy::urlStringSuitableForLoading(IPC::Connection& connection, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
{
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ }, { });
+
String title;
auto urlString = PlatformPasteboard(pasteboardName).urlStringSuitableForLoading(title);
completionHandler(WTFMove(urlString), WTFMove(title));
@@ -187,8 +292,12 @@
if (pasteboardType.isNull())
return completionHandler(0);
- if (handle.isNull())
- return completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType));
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
+ if (handle.isNull()) {
+ auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
+ return completionHandler(newChangeCount);
+ }
// SharedMemory::Handle::size() is rounded up to the nearest page.
MESSAGE_CHECK(size <= handle.size(), completionHandler(0));
@@ -197,7 +306,9 @@
if (!sharedMemoryBuffer)
return completionHandler(0);
auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(size));
- completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType));
+ auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
+ completionHandler(newChangeCount);
}
void WebPasteboardProxy::getNumberOfFiles(const String& pasteboardName, CompletionHandler<void(uint64_t)>&& completionHandler)
@@ -214,9 +325,12 @@
completionHandler(PlatformPasteboard(pasteboardName).typesSafeForDOMToReadAndWrite(origin));
}
-void WebPasteboardProxy::writeCustomData(const Vector<PasteboardCustomData>& data, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler)
+void WebPasteboardProxy::writeCustomData(IPC::Connection& connection, const Vector<PasteboardCustomData>& data, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler)
{
- completionHandler(PlatformPasteboard(pasteboardName).write(data));
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
+ auto newChangeCount = PlatformPasteboard(pasteboardName).write(data);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
+ completionHandler(newChangeCount);
}
void WebPasteboardProxy::allPasteboardItemInfo(const String& pasteboardName, int64_t changeCount, CompletionHandler<void(Optional<Vector<PasteboardItemInfo>>&&)>&& completionHandler)
@@ -234,28 +348,37 @@
completionHandler(PlatformPasteboard(pasteboardName).count());
}
-void WebPasteboardProxy::readStringFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&& completionHandler)
+void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&& completionHandler)
{
ASSERT(!pasteboardType.isNull());
if (pasteboardType.isNull())
return completionHandler({ });
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ });
+
completionHandler(PlatformPasteboard(pasteboardName).readString(index, pasteboardType));
}
-void WebPasteboardProxy::readURLFromPasteboard(size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
+void WebPasteboardProxy::readURLFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
{
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ }, { });
+
String title;
String url = "" title);
completionHandler(WTFMove(url), WTFMove(title));
}
-void WebPasteboardProxy::readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)
+void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)
{
ASSERT(!pasteboardType.isNull());
if (pasteboardType.isNull())
return completionHandler({ }, 0);
+ if (!canAccessPasteboardData(connection, pasteboardName))
+ return completionHandler({ }, 0);
+
RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).readBuffer(index, pasteboardType);
if (!buffer)
return completionHandler({ }, 0);
@@ -278,24 +401,32 @@
#if PLATFORM(IOS_FAMILY)
-void WebPasteboardProxy::writeURLToPasteboard(const PasteboardURL& url, const String& pasteboardName)
+void WebPasteboardProxy::writeURLToPasteboard(IPC::Connection& connection, const PasteboardURL& url, const String& pasteboardName)
{
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
PlatformPasteboard(pasteboardName).write(url);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount());
}
-void WebPasteboardProxy::writeWebContentToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName)
+void WebPasteboardProxy::writeWebContentToPasteboard(IPC::Connection& connection, const WebCore::PasteboardWebContent& content, const String& pasteboardName)
{
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
PlatformPasteboard(pasteboardName).write(content);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount());
}
-void WebPasteboardProxy::writeImageToPasteboard(const WebCore::PasteboardImage& pasteboardImage, const String& pasteboardName)
+void WebPasteboardProxy::writeImageToPasteboard(IPC::Connection& connection, const WebCore::PasteboardImage& pasteboardImage, const String& pasteboardName)
{
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
PlatformPasteboard(pasteboardName).write(pasteboardImage);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount());
}
-void WebPasteboardProxy::writeStringToPasteboard(const String& pasteboardType, const String& text, const String& pasteboardName)
+void WebPasteboardProxy::writeStringToPasteboard(IPC::Connection& connection, const String& pasteboardType, const String& text, const String& pasteboardName)
{
+ auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
PlatformPasteboard(pasteboardName).write(pasteboardType, text);
+ didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, PlatformPasteboard(pasteboardName).changeCount());
}
void WebPasteboardProxy::updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -4037,7 +4037,9 @@
m_page->createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
}
- m_page->performDragOperation(*dragData, draggingInfo.draggingPasteboard.name, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
+ String draggingPasteboardName = draggingInfo.draggingPasteboard.name;
+ m_page->grantAccessToCurrentPasteboardData(draggingPasteboardName);
+ m_page->performDragOperation(*dragData, draggingPasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
delete dragData;
return true;
@@ -4331,6 +4333,7 @@
NSData *data = "" dataForType:@(WebCore::PasteboardCustomData::cocoaType())];
auto buffer = WebCore::SharedBuffer::create(data);
if (WebCore::PasteboardCustomData::fromSharedBuffer(buffer.get()).origin() == originIdentifier) {
+ m_page->grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral);
completion(WebCore::DOMPasteAccessResponse::GrantedForGesture);
return;
}
@@ -4347,6 +4350,9 @@
void WebViewImpl::handleDOMPasteRequestWithResult(WebCore::DOMPasteAccessResponse response)
{
+ if (response == WebCore::DOMPasteAccessResponse::GrantedForCommand || response == WebCore::DOMPasteAccessResponse::GrantedForGesture)
+ m_page->grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral);
+
if (auto handler = std::exchange(m_domPasteRequestHandler, { }))
handler(response);
[m_domPasteMenu removeAllItems];
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-03-28 03:05:01 UTC (rev 259151)
@@ -124,6 +124,7 @@
#include "WebPageInspectorController.h"
#include "WebPageMessages.h"
#include "WebPageProxyMessages.h"
+#include "WebPasteboardProxy.h"
#include "WebPaymentCoordinatorProxy.h"
#include "WebPopupItem.h"
#include "WebPopupMenuProxy.h"
@@ -2279,6 +2280,17 @@
send(Messages::WebPage::SelectAll());
}
+static bool isPasteCommandName(const String& commandName)
+{
+ static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> pasteCommandNames = HashSet<String, ASCIICaseInsensitiveHash> {
+ "Paste",
+ "PasteAndMatchStyle",
+ "PasteAsQuotation",
+ "PasteAsPlainText"
+ };
+ return pasteCommandNames->contains(commandName);
+}
+
void WebPageProxy::executeEditCommand(const String& commandName, const String& argument, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
{
if (!hasRunningProcess()) {
@@ -2286,6 +2298,9 @@
return;
}
+ if (isPasteCommandName(commandName))
+ willPerformPasteCommand();
+
auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::executeEditCommand"_s));
send(Messages::WebPage::ExecuteEditCommandWithCallback(commandName, argument, callbackID));
}
@@ -2297,6 +2312,9 @@
if (!hasRunningProcess())
return;
+ if (isPasteCommandName(commandName))
+ willPerformPasteCommand();
+
if (commandName == ignoreSpellingCommandName)
++m_pendingLearnOrIgnoreWordMessageCount;
@@ -6539,6 +6557,8 @@
if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
++m_pendingLearnOrIgnoreWordMessageCount;
+ platformDidSelectItemFromActiveContextMenu(item);
+
send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item));
}
@@ -7592,6 +7612,10 @@
pageClient().clearAllEditCommands();
+#if PLATFORM(COCOA)
+ WebPasteboardProxy::singleton().revokeAccessToAllData(m_process.get());
+#endif
+
auto resetStateReason = terminationReason == ProcessTerminationReason::NavigationSwap ? ResetStateReason::NavigationSwap : ResetStateReason::WebProcessExited;
resetState(resetStateReason);
@@ -9999,6 +10023,22 @@
}
#endif
+#if ENABLE(CONTEXT_MENUS) && !PLATFORM(MAC)
+
+void WebPageProxy::platformDidSelectItemFromActiveContextMenu(const WebContextMenuItemData&)
+{
+}
+
+#endif
+
+#if !PLATFORM(COCOA)
+
+void WebPageProxy::willPerformPasteCommand()
+{
+}
+
+#endif
+
} // namespace WebKit
#undef MERGE_WHEEL_EVENTS
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-03-28 03:05:01 UTC (rev 259151)
@@ -1714,6 +1714,14 @@
void isNavigatingToAppBoundDomainTesting(CompletionHandler<void(bool)>&&);
NavigatingToAppBoundDomain isNavigatingToAppBoundDomain() const { return m_isNavigatingToAppBoundDomain; }
+#if PLATFORM(COCOA)
+ void grantAccessToCurrentPasteboardData(const String& pasteboardName);
+#endif
+
+#if ENABLE(CONTEXT_MENUS)
+ void platformDidSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
+#endif
+
private:
WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
void platformInitialize();
@@ -1933,6 +1941,7 @@
#endif
void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&);
+ void willPerformPasteCommand();
// Back/Forward list management
void backForwardAddItem(BackForwardListItemState&&);
Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp 2020-03-28 03:05:01 UTC (rev 259151)
@@ -68,6 +68,15 @@
m_webProcessProxyList.remove(&webProcessProxy);
}
+WebProcessProxy* WebPasteboardProxy::webProcessProxyForConnection(IPC::Connection& connection) const
+{
+ for (auto* webProcessProxy : m_webProcessProxyList) {
+ if (webProcessProxy->hasConnection(connection))
+ return webProcessProxy;
+ }
+ return nullptr;
+}
+
#if !PLATFORM(COCOA)
void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(const String&, const String&, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
@@ -75,7 +84,7 @@
completionHandler({ });
}
-void WebPasteboardProxy::writeCustomData(const Vector<WebCore::PasteboardCustomData>&, const String&, CompletionHandler<void(int64_t)>&& completionHandler)
+void WebPasteboardProxy::writeCustomData(IPC::Connection&, const Vector<WebCore::PasteboardCustomData>&, const String&, CompletionHandler<void(int64_t)>&& completionHandler)
{
completionHandler(0);
}
@@ -95,12 +104,12 @@
completionHandler(0);
}
-void WebPasteboardProxy::readURLFromPasteboard(size_t, const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
+void WebPasteboardProxy::readURLFromPasteboard(IPC::Connection&, size_t, const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
{
completionHandler({ }, { });
}
-void WebPasteboardProxy::readBufferFromPasteboard(size_t, const String&, const String&, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)
+void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)
{
completionHandler({ }, 0);
}
@@ -107,7 +116,7 @@
#if !USE(LIBWPE)
-void WebPasteboardProxy::readStringFromPasteboard(size_t, const String&, const String&, CompletionHandler<void(String&&)>&& completionHandler)
+void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(String&&)>&& completionHandler)
{
completionHandler({ });
}
@@ -124,7 +133,7 @@
completionHandler(false);
}
-void WebPasteboardProxy::urlStringSuitableForLoading(const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
+void WebPasteboardProxy::urlStringSuitableForLoading(IPC::Connection&, const String&, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
{
completionHandler({ }, { });
}
Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h 2020-03-28 03:05:01 UTC (rev 259151)
@@ -30,7 +30,9 @@
#include "SharedMemory.h"
#include <WebCore/SharedBuffer.h>
#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#include <wtf/WeakHashSet.h>
namespace WebCore {
class Color;
@@ -56,6 +58,11 @@
void addWebProcessProxy(WebProcessProxy&);
void removeWebProcessProxy(WebProcessProxy&);
+#if PLATFORM(COCOA)
+ void revokeAccessToAllData(WebProcessProxy&);
+ void grantAccessToCurrentData(WebProcessProxy&, const String& pasteboardName);
+#endif
+
#if PLATFORM(GTK)
void setPrimarySelectionOwner(WebFrameProxy*);
void didDestroyFrame(WebFrameProxy*);
@@ -64,16 +71,18 @@
private:
WebPasteboardProxy();
- typedef HashSet<WebProcessProxy*> WebProcessProxyList;
+ using WebProcessProxyList = HashSet<WebProcessProxy*>;
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
+ WebProcessProxy* webProcessProxyForConnection(IPC::Connection&) const;
+
#if PLATFORM(IOS_FAMILY)
- void writeURLToPasteboard(const WebCore::PasteboardURL&, const String& pasteboardName);
- void writeWebContentToPasteboard(const WebCore::PasteboardWebContent&, const String& pasteboardName);
- void writeImageToPasteboard(const WebCore::PasteboardImage&, const String& pasteboardName);
- void writeStringToPasteboard(const String& pasteboardType, const String&, const String& pasteboardName);
+ void writeURLToPasteboard(IPC::Connection&, const WebCore::PasteboardURL&, const String& pasteboardName);
+ void writeWebContentToPasteboard(IPC::Connection&, const WebCore::PasteboardWebContent&, const String& pasteboardName);
+ void writeImageToPasteboard(IPC::Connection&, const WebCore::PasteboardImage&, const String& pasteboardName);
+ void writeStringToPasteboard(IPC::Connection&, const String& pasteboardType, const String&, const String& pasteboardName);
void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName);
#endif
#if PLATFORM(COCOA)
@@ -80,32 +89,32 @@
void getNumberOfFiles(const String& pasteboardName, CompletionHandler<void(uint64_t)>&&);
void getPasteboardTypes(const String& pasteboardName, CompletionHandler<void(Vector<String>&&)>&&);
void getPasteboardPathnamesForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&& pathnames, SandboxExtension::HandleArray&&)>&&);
- void getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&&);
- void getPasteboardStringsForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&&);
- void getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&&);
+ void getPasteboardStringForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&&);
+ void getPasteboardStringsForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&&);
+ void getPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&&);
void getPasteboardChangeCount(const String& pasteboardName, CompletionHandler<void(int64_t)>&&);
- void getPasteboardColor(const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&&);
- void getPasteboardURL(const String& pasteboardName, CompletionHandler<void(const String&)>&&);
- void addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&);
- void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&);
+ void getPasteboardColor(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&&);
+ void getPasteboardURL(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(const String&)>&&);
+ void addPasteboardTypes(IPC::Connection&, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&);
+ void setPasteboardTypes(IPC::Connection&, const String& pasteboardName, const Vector<String>& pasteboardTypes, CompletionHandler<void(int64_t)>&&);
void setPasteboardURL(IPC::Connection&, const WebCore::PasteboardURL&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&);
- void setPasteboardColor(const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&);
- void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, CompletionHandler<void(int64_t)>&&);
+ void setPasteboardColor(IPC::Connection&, const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&);
+ void setPasteboardStringForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const String&, CompletionHandler<void(int64_t)>&&);
void setPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, CompletionHandler<void(int64_t)>&&);
#endif
- void readStringFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&&);
- void readURLFromPasteboard(size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&);
- void readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&&);
+ void readStringFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&&);
+ void readURLFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&);
+ void readBufferFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&&);
void getPasteboardItemsCount(const String& pasteboardName, CompletionHandler<void(uint64_t)>&&);
void informationForItemAtIndex(size_t index, const String& pasteboardName, int64_t changeCount, CompletionHandler<void(Optional<WebCore::PasteboardItemInfo>&&)>&&);
void allPasteboardItemInfo(const String& pasteboardName, int64_t changeCount, CompletionHandler<void(Optional<Vector<WebCore::PasteboardItemInfo>>&&)>&&);
- void writeCustomData(const Vector<WebCore::PasteboardCustomData>&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&);
+ void writeCustomData(IPC::Connection&, const Vector<WebCore::PasteboardCustomData>&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&);
void typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&&);
void containsStringSafeForDOMToReadForType(const String&, const String& pasteboardName, CompletionHandler<void(bool)>&&);
void containsURLStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(bool)>&&);
- void urlStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&);
+ void urlStringSuitableForLoading(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&);
#if PLATFORM(GTK)
void writeToClipboard(const String& pasteboardName, const WebSelectionData&);
@@ -121,7 +130,16 @@
void writeStringToPasteboard(const String& pasteboardType, const String&);
#endif
+#if PLATFORM(COCOA)
+ bool canAccessPasteboardData(IPC::Connection&, const String& pasteboardName) const;
+ void didModifyContentsOfPasteboard(IPC::Connection&, const String& pasteboardName, int64_t previousChangeCount, int64_t newChangeCount);
+#endif
+
WebProcessProxyList m_webProcessProxyList;
+
+#if PLATFORM(COCOA)
+ HashMap<String, std::pair<int64_t, WeakHashSet<WebProcessProxy>>> m_pasteboardNameToChangeCountAndProcessesMap;
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in 2020-03-28 03:05:01 UTC (rev 259151)
@@ -22,21 +22,21 @@
messages -> WebPasteboardProxy NotRefCounted {
#if PLATFORM(IOS_FAMILY)
- WriteURLToPasteboard(struct WebCore::PasteboardURL url, String pasteboardName)
- WriteWebContentToPasteboard(struct WebCore::PasteboardWebContent content, String pasteboardName)
- WriteImageToPasteboard(struct WebCore::PasteboardImage pasteboardImage, String pasteboardName)
- WriteStringToPasteboard(String pasteboardType, String text, String pasteboardName)
+ WriteURLToPasteboard(struct WebCore::PasteboardURL url, String pasteboardName) WantsConnection
+ WriteWebContentToPasteboard(struct WebCore::PasteboardWebContent content, String pasteboardName) WantsConnection
+ WriteImageToPasteboard(struct WebCore::PasteboardImage pasteboardImage, String pasteboardName) WantsConnection
+ WriteStringToPasteboard(String pasteboardType, String text, String pasteboardName) WantsConnection
UpdateSupportedTypeIdentifiers(Vector<String> identifiers, String pasteboardName)
#endif
- WriteCustomData(Vector<WebCore::PasteboardCustomData> data, String pasteboardName) -> (int64_t changeCount) Synchronous
+ WriteCustomData(Vector<WebCore::PasteboardCustomData> data, String pasteboardName) -> (int64_t changeCount) Synchronous WantsConnection
TypesSafeForDOMToReadAndWrite(String pasteboardName, String origin) -> (Vector<String> types) Synchronous
AllPasteboardItemInfo(String pasteboardName, int64_t changeCount) -> (Optional<Vector<WebCore::PasteboardItemInfo>> allInfo) Synchronous
InformationForItemAtIndex(uint64_t index, String pasteboardName, int64_t changeCount) -> (Optional<WebCore::PasteboardItemInfo> info) Synchronous
GetPasteboardItemsCount(String pasteboardName) -> (uint64_t itemsCount) Synchronous
- ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string) Synchronous
- ReadURLFromPasteboard(uint64_t index, String pasteboardName) -> (String url, String title) Synchronous
- ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous
+ ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string) Synchronous WantsConnection
+ ReadURLFromPasteboard(uint64_t index, String pasteboardName) -> (String url, String title) Synchronous WantsConnection
+ ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous WantsConnection
ContainsStringSafeForDOMToReadForType(String type, String pasteboardName) -> (bool result) Synchronous
#if PLATFORM(COCOA)
@@ -44,20 +44,20 @@
GetNumberOfFiles(String pasteboardName) -> (uint64_t numberOfFiles) Synchronous
GetPasteboardTypes(String pasteboardName) -> (Vector<String> types) Synchronous
GetPasteboardPathnamesForType(String pasteboardName, String pasteboardType) -> (Vector<String> pathnames, WebKit::SandboxExtension::HandleArray sandboxExtensions) Synchronous WantsConnection
- GetPasteboardStringForType(String pasteboardName, String pasteboardType) -> (String string) Synchronous
- GetPasteboardStringsForType(String pasteboardName, String pasteboardType) -> (Vector<String> strings) Synchronous
- GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous
+ GetPasteboardStringForType(String pasteboardName, String pasteboardType) -> (String string) Synchronous WantsConnection
+ GetPasteboardStringsForType(String pasteboardName, String pasteboardType) -> (Vector<String> strings) Synchronous WantsConnection
+ GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous WantsConnection
GetPasteboardChangeCount(String pasteboardName) -> (int64_t changeCount) Synchronous
- GetPasteboardColor(String pasteboardName) -> (WebCore::Color color) Synchronous
- GetPasteboardURL(String pasteboardName) -> (String urlString) Synchronous
- AddPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous
- SetPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous
+ GetPasteboardColor(String pasteboardName) -> (WebCore::Color color) Synchronous WantsConnection
+ GetPasteboardURL(String pasteboardName) -> (String urlString) Synchronous WantsConnection
+ AddPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous WantsConnection
+ SetPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (int64_t changeCount) Synchronous WantsConnection
SetPasteboardURL(struct WebCore::PasteboardURL pasteboardURL, String pasteboardName) -> (int64_t changeCount) Synchronous WantsConnection
- SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous
- SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (int64_t changeCount) Synchronous
+ SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous WantsConnection
+ SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (int64_t changeCount) Synchronous WantsConnection
SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (int64_t changeCount) Synchronous WantsConnection
ContainsURLStringSuitableForLoading(String pasteboardName) -> (bool result) Synchronous
- URLStringSuitableForLoading(String pasteboardName) -> (String url, String title) Synchronous
+ URLStringSuitableForLoading(String pasteboardName) -> (String url, String title) Synchronous WantsConnection
#endif
#if PLATFORM(GTK)
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -3631,6 +3631,9 @@
- (BOOL)_handleDOMPasteRequestWithResult:(WebCore::DOMPasteAccessResponse)response
{
+ if (response == WebCore::DOMPasteAccessResponse::GrantedForCommand || response == WebCore::DOMPasteAccessResponse::GrantedForGesture)
+ _page->grantAccessToCurrentPasteboardData(UIPasteboardNameGeneral);
+
if (auto pasteHandler = WTFMove(_domPasteRequestHandler)) {
[self hideGlobalMenuController];
pasteHandler(response);
@@ -7878,8 +7881,10 @@
WebKit::SandboxExtension::Handle sandboxExtensionHandle;
WebKit::SandboxExtension::HandleArray sandboxExtensionForUpload;
+ auto dragPasteboardName = WebCore::Pasteboard::nameOfDragPasteboard();
+ retainedSelf->_page->grantAccessToCurrentPasteboardData(dragPasteboardName);
retainedSelf->_page->createSandboxExtensionsIfNeeded(filenames, sandboxExtensionHandle, sandboxExtensionForUpload);
- retainedSelf->_page->performDragOperation(capturedDragData, WebCore::Pasteboard::nameOfDragPasteboard(), WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
+ retainedSelf->_page->performDragOperation(capturedDragData, dragPasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
if (shouldSnapshotView) {
retainedSelf->_visibleContentViewSnapshot = [retainedSelf snapshotViewAfterScreenUpdates:NO];
[retainedSelf->_visibleContentViewSnapshot setFrame:[retainedSelf bounds]];
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -1570,6 +1570,11 @@
}
#endif
+void WebPageProxy::willPerformPasteCommand()
+{
+ grantAccessToCurrentPasteboardData(UIPasteboardNameGeneral);
+}
+
} // namespace WebKit
#undef RELEASE_LOG_IF_ALLOWED
Modified: trunk/Source/WebKit/UIProcess/libwpe/WebPasteboardProxyLibWPE.cpp (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/libwpe/WebPasteboardProxyLibWPE.cpp 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/libwpe/WebPasteboardProxyLibWPE.cpp 2020-03-28 03:05:01 UTC (rev 259151)
@@ -40,7 +40,7 @@
completionHandler(WTFMove(pasteboardTypes));
}
-void WebPasteboardProxy::readStringFromPasteboard(size_t index, const String& pasteboardType, const String&, CompletionHandler<void(String&&)>&& completionHandler)
+void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String&, CompletionHandler<void(String&&)>&& completionHandler)
{
completionHandler(PlatformPasteboard().readString(index, pasteboardType));
}
Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (259150 => 259151)
--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2020-03-28 02:47:07 UTC (rev 259150)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2020-03-28 03:05:01 UTC (rev 259151)
@@ -654,6 +654,21 @@
#endif
+#if ENABLE(CONTEXT_MENUS)
+
+void WebPageProxy::platformDidSelectItemFromActiveContextMenu(const WebContextMenuItemData& item)
+{
+ if (item.action() == ContextMenuItemTagPaste)
+ grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral);
+}
+
+#endif
+
+void WebPageProxy::willPerformPasteCommand()
+{
+ grantAccessToCurrentPasteboardData(NSPasteboardNameGeneral);
+}
+
} // namespace WebKit
#endif // PLATFORM(MAC)