Web Inspector: "Reload Web Inspector" button no longer partially works
[WebKit-https.git] / Source / WebKit / UIProcess / WebPasteboardProxy.h
1 /*
2  * Copyright (C) 2014 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 "MessageReceiver.h"
29 #include "SandboxExtension.h"
30 #include "SharedMemory.h"
31 #include <wtf/Forward.h>
32 #include <wtf/HashSet.h>
33
34 namespace WebCore {
35 class Color;
36 struct PasteboardCustomData;
37 struct PasteboardImage;
38 struct PasteboardItemInfo;
39 struct PasteboardURL;
40 struct PasteboardWebContent;
41 }
42
43 namespace WebKit {
44
45 class WebFrameProxy;
46 class WebProcessProxy;
47 struct WebSelectionData;
48
49 class WebPasteboardProxy : public IPC::MessageReceiver {
50     WTF_MAKE_NONCOPYABLE(WebPasteboardProxy);
51     friend LazyNeverDestroyed<WebPasteboardProxy>;
52 public:
53     static WebPasteboardProxy& singleton();
54
55     void addWebProcessProxy(WebProcessProxy&);
56     void removeWebProcessProxy(WebProcessProxy&);
57
58 #if PLATFORM(GTK)
59     void setPrimarySelectionOwner(WebFrameProxy*);
60     void didDestroyFrame(WebFrameProxy*);
61 #endif
62
63 private:
64     WebPasteboardProxy();
65     
66     typedef HashSet<WebProcessProxy*> WebProcessProxyList;
67
68     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
69     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
70
71 #if PLATFORM(IOS_FAMILY)
72     void getPasteboardTypesByFidelityForItemAtIndex(uint64_t index, const String& pasteboardName, Vector<String>& types);
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);
77     void readStringFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, WTF::String&);
78     void readURLFromPasteboard(uint64_t index, const String& pasteboardName, String& url, String& title);
79     void readBufferFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, SharedMemory::Handle&, uint64_t& size);
80     void getPasteboardItemsCount(const String& pasteboardName, uint64_t& itemsCount);
81     void allPasteboardItemInfo(const String& pasteboardName, Vector<WebCore::PasteboardItemInfo>&);
82     void informationForItemAtIndex(int index, const String& pasteboardName, WebCore::PasteboardItemInfo& filename);
83     void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName);
84 #endif
85 #if PLATFORM(COCOA)
86     void getNumberOfFiles(const String& pasteboardName, uint64_t& numberOfFiles);
87     void getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes);
88     void getPasteboardPathnamesForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, Vector<String>& pathnames, SandboxExtension::HandleArray&);
89     void getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, String&);
90     void getPasteboardStringsForType(const String& pasteboardName, const String& pasteboardType, Vector<String>&);
91     void getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, SharedMemory::Handle&, uint64_t& size);
92     void pasteboardCopy(const String& fromPasteboard, const String& toPasteboard, uint64_t& newChangeCount);
93     void getPasteboardChangeCount(const String& pasteboardName, uint64_t& changeCount);
94     void getPasteboardUniqueName(String& pasteboardName);
95     void getPasteboardColor(const String& pasteboardName, WebCore::Color&);
96     void getPasteboardURL(const String& pasteboardName, WTF::String&);
97     void addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount);
98     void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount);
99     void setPasteboardURL(IPC::Connection&, const WebCore::PasteboardURL&, const String& pasteboardName, uint64_t& newChangeCount);
100     void setPasteboardColor(const String&, const WebCore::Color&, uint64_t&);
101     void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, uint64_t& newChangeCount);
102     void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, uint64_t& newChangeCount);
103 #endif
104
105     void writeCustomData(const WebCore::PasteboardCustomData&, const String& pasteboardName, uint64_t& newChangeCount);
106     void typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, Vector<String>& types);
107
108 #if PLATFORM(GTK)
109     void writeToClipboard(const String& pasteboardName, const WebSelectionData&);
110     void readFromClipboard(const String& pasteboardName, WebSelectionData&);
111
112     WebFrameProxy* m_primarySelectionOwner { nullptr };
113     WebFrameProxy* m_frameWritingToClipboard { nullptr };
114 #endif // PLATFORM(GTK)
115
116 #if PLATFORM(WPE)
117     void getPasteboardTypes(Vector<String>& pasteboardTypes);
118     void readStringFromPasteboard(uint64_t index, const String& pasteboardType, WTF::String&);
119     void writeWebContentToPasteboard(const WebCore::PasteboardWebContent&);
120     void writeStringToPasteboard(const String& pasteboardType, const String&);
121 #endif
122
123     WebProcessProxyList m_webProcessProxyList;
124 };
125
126 } // namespace WebKit