Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: Source/core/dom/Clipboard.h

Issue 153343003: Move Clipboard-related code from core/dom to core/clipboard (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/dom/Clipboard.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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.
6 *
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.
11 *
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.
16 *
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.
21 *
22 */
23
24 #ifndef Clipboard_h
25 #define Clipboard_h
26
27 #include "bindings/v8/ScriptWrappable.h"
28 #include "core/dom/ClipboardAccessPolicy.h"
29 #include "core/fetch/ResourcePtr.h"
30 #include "core/page/DragActions.h"
31 #include "platform/geometry/IntPoint.h"
32 #include "wtf/Forward.h"
33 #include "wtf/RefCounted.h"
34 #include "wtf/RefPtr.h"
35 #include "wtf/Vector.h"
36
37 namespace WebCore {
38
39 class DataObject;
40 class DataTransferItemList;
41 class DragImage;
42 class Element;
43 class ExceptionState;
44 class FileList;
45 class Frame;
46 class ImageResource;
47 class Node;
48 class Range;
49
50 // State available during IE's events for drag and drop and copy/paste
51 class Clipboard : public RefCounted<Clipboard>, public ScriptWrappable {
52 public:
53 // Whether this clipboard is serving a drag-drop or copy-paste request.
54 enum ClipboardType {
55 CopyAndPaste,
56 DragAndDrop,
57 };
58
59 static PassRefPtr<Clipboard> create(ClipboardType, ClipboardAccessPolicy, Pa ssRefPtr<DataObject>);
60 ~Clipboard();
61
62 bool isForCopyAndPaste() const { return m_clipboardType == CopyAndPaste; }
63 bool isForDragAndDrop() const { return m_clipboardType == DragAndDrop; }
64
65 String dropEffect() const { return dropEffectIsUninitialized() ? "none" : m_ dropEffect; }
66 void setDropEffect(const String&);
67 bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitializ ed"; }
68 String effectAllowed() const { return m_effectAllowed; }
69 void setEffectAllowed(const String&);
70
71 void clearData(const String& type = String());
72 String getData(const String& type) const;
73 bool setData(const String& type, const String& data);
74
75 // extensions beyond IE's API
76 Vector<String> types() const;
77 PassRefPtr<FileList> files() const;
78
79 IntPoint dragLocation() const { return m_dragLoc; }
80 void setDragImage(Element*, int x, int y, ExceptionState&);
81 ImageResource* dragImageResource() const { return m_dragImage.get(); }
82 void setDragImageResource(ImageResource*, const IntPoint&);
83 Node* dragImageElement() const { return m_dragImageElement.get(); }
84 void setDragImageElement(Node*, const IntPoint&);
85
86 PassOwnPtr<DragImage> createDragImage(IntPoint& dragLocation, Frame*) const;
87 void declareAndWriteDragImage(Element*, const KURL&, const String& title);
88 void writeURL(const KURL&, const String&);
89 void writeRange(Range*, Frame*);
90 void writePlainText(const String&);
91
92 bool hasData();
93
94 void setAccessPolicy(ClipboardAccessPolicy);
95 bool canReadTypes() const;
96 bool canReadData() const;
97 bool canWriteData() const;
98 // Note that the spec doesn't actually allow drag image modification outside the dragstart
99 // event. This capability is maintained for backwards compatiblity for ports that have
100 // supported this in the past. On many ports, attempting to set a drag image outside the
101 // dragstart operation is a no-op anyway.
102 bool canSetDragImage() const;
103
104 DragOperation sourceOperation() const;
105 DragOperation destinationOperation() const;
106 void setSourceOperation(DragOperation);
107 void setDestinationOperation(DragOperation);
108
109 bool hasDropZoneType(const String&);
110
111 PassRefPtr<DataTransferItemList> items();
112
113 PassRefPtr<DataObject> dataObject() const;
114
115 private:
116 Clipboard(ClipboardType, ClipboardAccessPolicy, PassRefPtr<DataObject>);
117
118 void setDragImage(ImageResource*, Node*, const IntPoint&);
119
120 bool hasFileOfType(const String&) const;
121 bool hasStringOfType(const String&) const;
122
123 // Instead of using this member directly, prefer to use the can*() methods a bove.
124 ClipboardAccessPolicy m_policy;
125 String m_dropEffect;
126 String m_effectAllowed;
127 ClipboardType m_clipboardType;
128 RefPtr<DataObject> m_dataObject;
129
130 IntPoint m_dragLoc;
131 ResourcePtr<ImageResource> m_dragImage;
132 RefPtr<Node> m_dragImageElement;
133 };
134
135 DragOperation convertDropZoneOperationToDragOperation(const String& dragOperatio n);
136 String convertDragOperationToDropZoneOperation(DragOperation);
137
138 } // namespace WebCore
139
140 #endif // Clipboard_h
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/dom/Clipboard.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698