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 #if BLINK_IMPLEMENTATION
40 namespace WebCore { class DataObject; }
41 namespace WTF { template <typename T> class PassRefPtr; }
46 class WebDragDataPrivate;
47 template <typename T> class WebVector;
49 // Holds data that may be exchanged through a drag-n-drop operation. It is
50 // inexpensive to copy a WebDragData object.
55 // String data with an associated MIME type. Depending on the MIME type, there may be
56 // optional metadata attributes as well.
58 // Stores the name of one file being dragged into the renderer.
60 // An image being dragged out of the renderer. Contains a buffer holding the image data
61 // as well as the suggested name for saving the image to.
62 StorageTypeBinaryData,
65 StorageType storageType;
67 // Only valid when storageType == StorageTypeString.
71 // Only valid when storageType == StorageTypeFilename.
72 WebString filenameData;
73 WebString displayNameData;
75 // Only valid when storageType == StorageTypeBinaryData.
78 // Title associated with a link when stringType == "text/uri-list".
79 // Filename when storageType == StorageTypeBinaryData.
82 // Only valid when stringType == "text/html".
86 ~WebDragData() { reset(); }
88 WebDragData() : m_private(0) { }
89 WebDragData(const WebDragData& d) : m_private(0) { assign(d); }
90 WebDragData& operator=(const WebDragData& d)
96 BLINK_EXPORT void initialize();
97 BLINK_EXPORT void reset();
98 BLINK_EXPORT void assign(const WebDragData&);
100 bool isNull() const { return !m_private; }
102 BLINK_EXPORT WebVector<Item> items() const;
103 BLINK_EXPORT void setItems(const WebVector<Item>&);
104 BLINK_EXPORT void addItem(const Item&);
106 BLINK_EXPORT WebString filesystemId() const;
107 BLINK_EXPORT void setFilesystemId(const WebString&);
109 #if BLINK_IMPLEMENTATION
110 WebDragData(const WTF::PassRefPtr<WebCore::DataObject>&);
111 WebDragData& operator=(const WTF::PassRefPtr<WebCore::DataObject>&);
112 operator WTF::PassRefPtr<WebCore::DataObject>() const;
116 void assign(WebDragDataPrivate*);
117 void ensureMutable();
118 WebDragDataPrivate* m_private;