2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
27 #include "CachedResourceHandle.h"
28 #include "ClipboardAccessPolicy.h"
29 #include "DragActions.h"
30 #include "DragImage.h"
36 class DataTransferItems;
41 // State available during IE's events for drag and drop and copy/paste
42 class Clipboard : public RefCounted<Clipboard> {
44 // Whether this clipboard is serving a drag-drop or copy-paste request.
50 static PassRefPtr<Clipboard> create(ClipboardAccessPolicy, DragData*, Frame*);
52 virtual ~Clipboard() { }
54 bool isForCopyAndPaste() const { return m_clipboardType == CopyAndPaste; }
55 bool isForDragAndDrop() const { return m_clipboardType == DragAndDrop; }
57 String dropEffect() const { return dropEffectIsUninitialized() ? "none" : m_dropEffect; }
58 void setDropEffect(const String&);
59 bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; }
60 String effectAllowed() const { return m_effectAllowed; }
61 void setEffectAllowed(const String&);
63 virtual void clearData(const String& type) = 0;
64 virtual void clearAllData() = 0;
65 virtual String getData(const String& type, bool& success) const = 0;
66 virtual bool setData(const String& type, const String& data) = 0;
68 // extensions beyond IE's API
69 virtual HashSet<String> types() const = 0;
70 virtual PassRefPtr<FileList> files() const = 0;
72 LayoutPoint dragLocation() const { return m_dragLoc; }
73 CachedImage* dragImage() const { return m_dragImage.get(); }
74 virtual void setDragImage(CachedImage*, const LayoutPoint&) = 0;
75 Node* dragImageElement() const { return m_dragImageElement.get(); }
76 virtual void setDragImageElement(Node*, const LayoutPoint&) = 0;
78 virtual DragImageRef createDragImage(LayoutPoint& dragLocation) const = 0;
79 #if ENABLE(DRAG_SUPPORT)
80 virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0;
82 virtual void writeURL(const KURL&, const String&, Frame*) = 0;
83 virtual void writeRange(Range*, Frame*) = 0;
84 virtual void writePlainText(const String&) = 0;
86 virtual bool hasData() = 0;
88 void setAccessPolicy(ClipboardAccessPolicy);
89 ClipboardAccessPolicy policy() const { return m_policy; }
91 DragOperation sourceOperation() const;
92 DragOperation destinationOperation() const;
93 void setSourceOperation(DragOperation);
94 void setDestinationOperation(DragOperation);
96 bool hasDropZoneType(const String&);
98 void setDragHasStarted() { m_dragStarted = true; }
100 #if ENABLE(DATA_TRANSFER_ITEMS)
101 virtual PassRefPtr<DataTransferItems> items() = 0;
105 Clipboard(ClipboardAccessPolicy, ClipboardType);
107 bool dragStarted() const { return m_dragStarted; }
110 bool hasFileOfType(const String&) const;
111 bool hasStringOfType(const String&) const;
113 ClipboardAccessPolicy m_policy;
115 String m_effectAllowed;
117 ClipboardType m_clipboardType;
120 LayoutPoint m_dragLoc;
121 CachedResourceHandle<CachedImage> m_dragImage;
122 RefPtr<Node> m_dragImageElement;
125 DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation);
126 String convertDragOperationToDropZoneOperation(DragOperation);
128 } // namespace WebCore
130 #endif // Clipboard_h