1/*
2 * Copyright (C) 2016 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 "Pasteboard.h"
29#include <wtf/HashMap.h>
30#include <wtf/Vector.h>
31#include <wtf/text/StringHash.h>
32
33namespace WebCore {
34
35class StaticPasteboard final : public Pasteboard {
36public:
37 StaticPasteboard();
38
39 PasteboardCustomData takeCustomData();
40
41 bool isStatic() const final { return true; }
42
43 bool hasData() final;
44 Vector<String> typesSafeForBindings(const String&) final { return m_types; }
45 Vector<String> typesForLegacyUnsafeBindings() final { return m_types; }
46 String readOrigin() final { return { }; }
47 String readString(const String& type) final;
48 String readStringInCustomData(const String& type) final;
49
50 void writeString(const String& type, const String& data) final;
51 void writeStringInCustomData(const String& type, const String& data);
52 void clear() final;
53 void clear(const String& type) final;
54
55 void read(PasteboardPlainText&) final { }
56 void read(PasteboardWebContentReader&, WebContentReadingPolicy) final { }
57
58 void write(const PasteboardURL&) final { }
59 void write(const PasteboardImage&) final { }
60 void write(const PasteboardWebContent&) final { }
61
62 void writeCustomData(const PasteboardCustomData&) final { }
63
64 Pasteboard::FileContentState fileContentState() final { return FileContentState::NoFileOrImageData; }
65 bool canSmartReplace() final { return false; }
66
67 void writeMarkup(const String&) final { }
68 void writePlainText(const String&, SmartReplaceOption) final { }
69
70#if ENABLE(DRAG_SUPPORT)
71 void setDragImage(DragImage, const IntPoint&) final { }
72#endif
73
74private:
75 Vector<String> m_types;
76 HashMap<String, String> m_platformData;
77 HashMap<String, String> m_customData;
78};
79
80}
81
82SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StaticPasteboard)
83 static bool isType(const WebCore::Pasteboard& pasteboard) { return pasteboard.isStatic(); }
84SPECIALIZE_TYPE_TRAITS_END()
85