Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKit / UIProcess / Cocoa / WebPasteboardProxyCocoa.mm
index 576d243..1710df1 100644 (file)
 #import "SandboxExtension.h"
 #import "WebProcessProxy.h"
 #import <WebCore/Color.h>
+#import <WebCore/Pasteboard.h>
+#import <WebCore/PasteboardItemInfo.h>
 #import <WebCore/PlatformPasteboard.h>
 #import <WebCore/SharedBuffer.h>
-#import <WebCore/URL.h>
-
-using namespace WebCore;
+#import <wtf/URL.h>
 
 namespace WebKit {
+using namespace WebCore;
 
 void WebPasteboardProxy::getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes)
 {
@@ -69,6 +70,11 @@ void WebPasteboardProxy::getPasteboardStringForType(const String& pasteboardName
     string = PlatformPasteboard(pasteboardName).stringForType(pasteboardType);
 }
 
+void WebPasteboardProxy::getPasteboardStringsForType(const String& pasteboardName, const String& pasteboardType, Vector<String>& strings)
+{
+    strings = PlatformPasteboard(pasteboardName).allStringsForType(pasteboardType);
+}
+
 void WebPasteboardProxy::getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, SharedMemory::Handle& handle, uint64_t& size)
 {
     RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).bufferForType(pasteboardType);
@@ -119,25 +125,28 @@ void WebPasteboardProxy::setPasteboardTypes(const String& pasteboardName, const
     newChangeCount = PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
 }
 
-void WebPasteboardProxy::setPasteboardPathnamesForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames, uint64_t& newChangeCount)
+void WebPasteboardProxy::setPasteboardURL(IPC::Connection& connection, const PasteboardURL& pasteboardURL, const String& pasteboardName, uint64_t& newChangeCount)
 {
     for (auto* webProcessProxy : m_webProcessProxyList) {
         if (!webProcessProxy->hasConnection(connection))
             continue;
-        
-        for (const auto& pathname : pathnames) {
-            if (!webProcessProxy->checkURLReceivedFromWebProcess(pathname)) {
-                connection.markCurrentlyDispatchedMessageAsInvalid();
-                newChangeCount = 0;
-                return;
-            }
+
+        if (!webProcessProxy->checkURLReceivedFromWebProcess(pasteboardURL.url.string())) {
+            newChangeCount = 0;
+            return;
         }
-        newChangeCount = PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);
+
+        newChangeCount = PlatformPasteboard(pasteboardName).setURL(pasteboardURL);
         return;
     }
     newChangeCount = 0;
 }
 
+void WebPasteboardProxy::setPasteboardColor(const String& pasteboardName, const WebCore::Color& color, uint64_t& newChangeCount)
+{
+    newChangeCount = PlatformPasteboard(pasteboardName).setColor(color);
+}
+
 void WebPasteboardProxy::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string, uint64_t& newChangeCount)
 {
     newChangeCount = PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);
@@ -159,9 +168,9 @@ void WebPasteboardProxy::getNumberOfFiles(const String& pasteboardName, uint64_t
     numberOfFiles = PlatformPasteboard(pasteboardName).numberOfFiles();
 }
 
-void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(const String& pasteboardName, Vector<String>& types)
+void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, Vector<String>& types)
 {
-    types = PlatformPasteboard(pasteboardName).typesSafeForDOMToReadAndWrite();
+    types = PlatformPasteboard(pasteboardName).typesSafeForDOMToReadAndWrite(origin);
 }
 
 void WebPasteboardProxy::writeCustomData(const WebCore::PasteboardCustomData& data, const String& pasteboardName, uint64_t& newChangeCount)
@@ -169,7 +178,7 @@ void WebPasteboardProxy::writeCustomData(const WebCore::PasteboardCustomData& da
     newChangeCount = PlatformPasteboard(pasteboardName).write(data);
 }
 
-#if PLATFORM(IOS)
+#if PLATFORM(IOS_FAMILY)
 void WebPasteboardProxy::getPasteboardTypesByFidelityForItemAtIndex(uint64_t index, const String& pasteboardName, Vector<String>& types)
 {
     PlatformPasteboard(pasteboardName).getTypesByFidelityForItemAtIndex(types, index);
@@ -200,9 +209,9 @@ void WebPasteboardProxy::readStringFromPasteboard(uint64_t index, const String&
     value = PlatformPasteboard(pasteboardName).readString(index, pasteboardType);
 }
 
-void WebPasteboardProxy::readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String& url, String& title)
+void WebPasteboardProxy::readURLFromPasteboard(uint64_t index, const String& pasteboardName, String& url, String& title)
 {
-    url = PlatformPasteboard(pasteboardName).readURL(index, pasteboardType, title);
+    url = PlatformPasteboard(pasteboardName).readURL(index, title);
 }
 
 void WebPasteboardProxy::readBufferFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, SharedMemory::Handle& handle, uint64_t& size)
@@ -225,9 +234,14 @@ void WebPasteboardProxy::getPasteboardItemsCount(const String& pasteboardName, u
     itemsCount = PlatformPasteboard(pasteboardName).count();
 }
 
-void WebPasteboardProxy::getFilenamesForDataInteraction(const String& pasteboardName, Vector<String>& filenames)
+void WebPasteboardProxy::allPasteboardItemInfo(const String& pasteboardName, Vector<PasteboardItemInfo>& allInfo)
+{
+    allInfo = PlatformPasteboard(pasteboardName).allPasteboardItemInfo();
+}
+
+void WebPasteboardProxy::informationForItemAtIndex(int index, const String& pasteboardName, PasteboardItemInfo& info)
 {
-    filenames = PlatformPasteboard(pasteboardName).filenamesForDataInteraction();
+    info = PlatformPasteboard(pasteboardName).informationForItemAtIndex(index);
 }
 
 void WebPasteboardProxy::updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName)