1/*
2 * Copyright (C) 2016 Red Hat Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20#include "PlatformPasteboard.h"
21
22#include "Color.h"
23#include "PasteboardHelper.h"
24#include "SelectionData.h"
25#include "SharedBuffer.h"
26#include <gtk/gtk.h>
27#include <wtf/URL.h>
28
29namespace WebCore {
30
31PlatformPasteboard::PlatformPasteboard(const String& pasteboardName)
32 : m_clipboard(gtk_clipboard_get(gdk_atom_intern(pasteboardName.utf8().data(), TRUE)))
33{
34 ASSERT(m_clipboard);
35}
36
37void PlatformPasteboard::writeToClipboard(const SelectionData& selection, WTF::Function<void()>&& primarySelectionCleared)
38{
39 PasteboardHelper::singleton().writeClipboardContents(m_clipboard, selection, gtk_clipboard_get(GDK_SELECTION_PRIMARY) == m_clipboard ? WTFMove(primarySelectionCleared) : nullptr);
40}
41
42Ref<SelectionData> PlatformPasteboard::readFromClipboard()
43{
44 Ref<SelectionData> selection(SelectionData::create());
45 PasteboardHelper::singleton().getClipboardContents(m_clipboard, selection.get());
46 return selection;
47}
48
49Vector<String> PlatformPasteboard::typesSafeForDOMToReadAndWrite(const String&) const
50{
51 return { };
52}
53
54long PlatformPasteboard::write(const PasteboardCustomData&)
55{
56 return 0;
57}
58
59}
60