1/*
2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include <WebCore/LoaderStrategy.h>
29#include <WebCore/PasteboardStrategy.h>
30#include <WebCore/PlatformStrategies.h>
31
32namespace WebKit {
33
34class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::PasteboardStrategy {
35 friend NeverDestroyed<WebPlatformStrategies>;
36public:
37 static void initialize();
38
39private:
40 WebPlatformStrategies();
41
42 // WebCore::PlatformStrategies
43 WebCore::LoaderStrategy* createLoaderStrategy() override;
44 WebCore::PasteboardStrategy* createPasteboardStrategy() override;
45 WebCore::BlobRegistry* createBlobRegistry() override;
46
47 // WebCore::PasteboardStrategy
48#if PLATFORM(IOS_FAMILY)
49 void writeToPasteboard(const WebCore::PasteboardWebContent&, const String& pasteboardName) override;
50 void writeToPasteboard(const WebCore:: PasteboardURL&, const String& pasteboardName) override;
51 void writeToPasteboard(const WebCore::PasteboardImage&, const String& pasteboardName) override;
52 void writeToPasteboard(const String& pasteboardType, const String&, const String& pasteboardName) override;
53 int getPasteboardItemsCount(const String& pasteboardName) override;
54 String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
55 RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
56 URL readURLFromPasteboard(int index, const String& pasteboardName, String& title) override;
57 Vector<WebCore::PasteboardItemInfo> allPasteboardItemInfo(const String& pasteboardName) override;
58 WebCore::PasteboardItemInfo informationForItemAtIndex(int index, const String& pasteboardName) override;
59 void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName) override;
60#endif
61#if PLATFORM(COCOA)
62 int getNumberOfFiles(const String& pasteboardName) override;
63 void getTypes(Vector<String>& types, const String& pasteboardName) override;
64 RefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;
65 void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) override;
66 String stringForType(const String& pasteboardType, const String& pasteboardName) override;
67 Vector<String> allStringsForType(const String& pasteboardType, const String& pasteboardName) override;
68 long changeCount(const String& pasteboardName) override;
69 String uniqueName() override;
70 WebCore::Color color(const String& pasteboardName) override;
71 URL url(const String& pasteboardName) override;
72
73 long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override;
74 long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override;
75 long setBufferForType(WebCore::SharedBuffer*, const String& pasteboardType, const String& pasteboardName) override;
76 long setURL(const WebCore::PasteboardURL&, const String& pasteboardName) override;
77 long setColor(const WebCore::Color&, const String& pasteboardName) override;
78 long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override;
79#endif
80#if PLATFORM(GTK)
81 void writeToClipboard(const String& pasteboardName, const WebCore::SelectionData&) override;
82 Ref<WebCore::SelectionData> readFromClipboard(const String& pasteboardName) override;
83#endif
84#if USE(LIBWPE)
85 void getTypes(Vector<String>& types) override;
86 String readStringFromPasteboard(int index, const String& pasteboardType) override;
87 void writeToPasteboard(const WebCore::PasteboardWebContent&) override;
88 void writeToPasteboard(const String& pasteboardType, const String&) override;
89#endif
90
91 Vector<String> typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin) override;
92 long writeCustomData(const WebCore::PasteboardCustomData&, const String&) override;
93};
94
95} // namespace WebKit
96