2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "WebCommon.h"
36 #include "WebString.h"
39 namespace WebCore { class DataObject; }
43 class WebDragDataPrivate;
44 template <typename T> class WebVector;
46 // Holds data that may be exchanged through a drag-n-drop operation. It is
47 // inexpensive to copy a WebDragData object.
52 // String data with an associated MIME type. Depending on the MIME type, there may be
53 // optional metadata attributes as well.
55 // Stores the name of one file being dragged into the renderer.
57 // An image being dragged out of the renderer. Contains a buffer holding the image data
58 // as well as the suggested name for saving the image to.
59 StorageTypeBinaryData,
60 // Stores the filesystem URL of one file being dragged into the renderer.
61 StorageTypeFileSystemFile,
64 StorageType storageType;
66 // Only valid when storageType == StorageTypeString.
70 // Only valid when storageType == StorageTypeFilename.
71 WebString filenameData;
72 WebString displayNameData;
74 // Only valid when storageType == StorageTypeBinaryData.
77 // Title associated with a link when stringType == "text/uri-list".
78 // Filename when storageType == StorageTypeBinaryData.
81 // Only valid when storageType == StorageTypeFileSystemFile.
83 long long fileSystemFileSize;
85 // Only valid when stringType == "text/html".
90 WebDragData(const WebDragData& object) { assign(object); }
91 WebDragData& operator=(const WebDragData& object)
96 ~WebDragData() { reset(); }
98 bool isNull() const { return m_private.isNull(); }
100 BLINK_EXPORT void initialize();
101 BLINK_EXPORT void reset();
102 BLINK_EXPORT void assign(const WebDragData&);
104 BLINK_EXPORT WebVector<Item> items() const;
105 BLINK_EXPORT void setItems(const WebVector<Item>&);
106 BLINK_EXPORT void addItem(const Item&);
108 BLINK_EXPORT WebString filesystemId() const;
109 BLINK_EXPORT void setFilesystemId(const WebString&);
111 #if BLINK_IMPLEMENTATION
112 explicit WebDragData(const PassRefPtrWillBeRawPtr<WebCore::DataObject>&);
113 WebDragData& operator=(const PassRefPtrWillBeRawPtr<WebCore::DataObject>&);
114 WebCore::DataObject* getValue() const;
118 void ensureMutable();
119 WebPrivatePtr<WebCore::DataObject> m_private;