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"
38 #include "WebVector.h"
42 template <typename T
> class WebVector
;
44 // Holds data that may be exchanged through a drag-n-drop operation. It is
45 // inexpensive to copy a WebDragData object.
50 // String data with an associated MIME type. Depending on the MIME type, there may be
51 // optional metadata attributes as well.
53 // Stores the name of one file being dragged into the renderer.
55 // An image being dragged out of the renderer. Contains a buffer holding the image data
56 // as well as the suggested name for saving the image to.
57 StorageTypeBinaryData
,
58 // Stores the filesystem URL of one file being dragged into the renderer.
59 StorageTypeFileSystemFile
,
62 StorageType storageType
;
64 // Only valid when storageType == StorageTypeString.
68 // Only valid when storageType == StorageTypeFilename.
69 WebString filenameData
;
70 WebString displayNameData
;
72 // Only valid when storageType == StorageTypeBinaryData.
75 // Title associated with a link when stringType == "text/uri-list".
76 // Filename when storageType == StorageTypeBinaryData.
79 // Only valid when storageType == StorageTypeFileSystemFile.
81 long long fileSystemFileSize
;
83 // Only valid when stringType == "text/html".
89 , m_modifierKeyState(0)
92 WebDragData(const WebDragData
& object
)
93 : m_valid(object
.m_valid
)
94 , m_itemList(object
.m_itemList
)
95 , m_modifierKeyState(object
.m_modifierKeyState
)
96 , m_filesystemId(object
.m_filesystemId
)
99 WebDragData
& operator=(const WebDragData
& object
)
101 m_valid
= object
.m_valid
;
102 m_itemList
= object
.m_itemList
;
103 m_modifierKeyState
= object
.m_modifierKeyState
;
104 m_filesystemId
= object
.m_filesystemId
;
110 WebVector
<Item
> items() const
115 BLINK_PLATFORM_EXPORT
void setItems(WebVector
<Item
> itemList
);
116 // FIXME: setItems is slow because setItems copies WebVector.
117 // Instead, use swapItems.
118 void swapItems(WebVector
<Item
>& itemList
)
120 m_itemList
.swap(itemList
);
123 void initialize() { m_valid
= true; }
124 bool isNull() const { return !m_valid
; }
125 void reset() { m_itemList
= WebVector
<Item
>(); m_valid
= false; }
127 BLINK_PLATFORM_EXPORT
void addItem(const Item
&);
129 WebString
filesystemId() const
131 return m_filesystemId
;
134 void setFilesystemId(const WebString
& filesystemId
)
136 // The ID is an opaque string, given by and validated by chromium port.
137 m_filesystemId
= filesystemId
;
142 WebVector
<Item
> m_itemList
;
143 int m_modifierKeyState
; // State of Shift/Ctrl/Alt/Meta keys.
144 WebString m_filesystemId
;