| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "core/clipboard/DataObject.h" | 33 #include "core/clipboard/DataObject.h" |
| 34 #include "core/clipboard/DataTransferItem.h" | 34 #include "core/clipboard/DataTransferItem.h" |
| 35 #include "heap/Handle.h" |
| 35 #include "modules/filesystem/DraggedIsolatedFileSystem.h" | 36 #include "modules/filesystem/DraggedIsolatedFileSystem.h" |
| 36 #include "platform/clipboard/ClipboardMimeTypes.h" | 37 #include "platform/clipboard/ClipboardMimeTypes.h" |
| 37 #include "public/platform/WebData.h" | 38 #include "public/platform/WebData.h" |
| 38 #include "public/platform/WebDragData.h" | 39 #include "public/platform/WebDragData.h" |
| 39 #include "public/platform/WebString.h" | 40 #include "public/platform/WebString.h" |
| 40 #include "public/platform/WebURL.h" | 41 #include "public/platform/WebURL.h" |
| 41 #include "public/platform/WebVector.h" | 42 #include "public/platform/WebVector.h" |
| 42 #include "wtf/HashMap.h" | 43 #include "wtf/HashMap.h" |
| 43 #include "wtf/PassRefPtr.h" | 44 #include "wtf/PassRefPtr.h" |
| 44 | 45 |
| 45 using namespace WebCore; | 46 using namespace WebCore; |
| 46 | 47 |
| 47 namespace blink { | 48 namespace blink { |
| 48 | 49 |
| 49 class WebDragDataPrivate : public DataObject { | |
| 50 }; | |
| 51 | |
| 52 void WebDragData::initialize() | 50 void WebDragData::initialize() |
| 53 { | 51 { |
| 54 assign(static_cast<WebDragDataPrivate*>(DataObject::create().leakRef())); | 52 m_private = DataObject::create(); |
| 55 } | 53 } |
| 56 | 54 |
| 57 void WebDragData::reset() | 55 void WebDragData::reset() |
| 58 { | 56 { |
| 59 assign(0); | 57 m_private.reset(); |
| 60 } | 58 } |
| 61 | 59 |
| 62 void WebDragData::assign(const WebDragData& other) | 60 void WebDragData::assign(const WebDragData& other) |
| 63 { | 61 { |
| 64 WebDragDataPrivate* p = const_cast<WebDragDataPrivate*>(other.m_private); | 62 m_private = other.m_private; |
| 65 if (p) | 63 } |
| 66 p->ref(); | 64 |
| 67 assign(p); | 65 WebDragData::WebDragData(const PassRefPtrWillBeRawPtr<WebCore::DataObject>& obje
ct) |
| 66 { |
| 67 m_private = object; |
| 68 } |
| 69 |
| 70 WebDragData& WebDragData::operator=(const PassRefPtrWillBeRawPtr<WebCore::DataOb
ject>& object) |
| 71 { |
| 72 m_private = object; |
| 73 return *this; |
| 74 } |
| 75 |
| 76 DataObject* WebDragData::getValue() const |
| 77 { |
| 78 return m_private.get(); |
| 79 } |
| 80 |
| 81 void WebDragData::ensureMutable() |
| 82 { |
| 83 ASSERT(!isNull()); |
| 68 } | 84 } |
| 69 | 85 |
| 70 WebVector<WebDragData::Item> WebDragData::items() const | 86 WebVector<WebDragData::Item> WebDragData::items() const |
| 71 { | 87 { |
| 72 Vector<Item> itemList; | 88 Vector<Item> itemList; |
| 73 for (size_t i = 0; i < m_private->length(); ++i) { | 89 for (size_t i = 0; i < m_private->length(); ++i) { |
| 74 DataObjectItem* originalItem = m_private->item(i).get(); | 90 DataObjectItem* originalItem = m_private->item(i).get(); |
| 75 WebDragData::Item item; | 91 WebDragData::Item item; |
| 76 if (originalItem->kind() == DataObjectItem::StringKind) { | 92 if (originalItem->kind() == DataObjectItem::StringKind) { |
| 77 item.storageType = Item::StorageTypeString; | 93 item.storageType = Item::StorageTypeString; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return; | 141 return; |
| 126 case Item::StorageTypeBinaryData: | 142 case Item::StorageTypeBinaryData: |
| 127 // This should never happen when dragging in. | 143 // This should never happen when dragging in. |
| 128 ASSERT_NOT_REACHED(); | 144 ASSERT_NOT_REACHED(); |
| 129 } | 145 } |
| 130 } | 146 } |
| 131 | 147 |
| 132 WebString WebDragData::filesystemId() const | 148 WebString WebDragData::filesystemId() const |
| 133 { | 149 { |
| 134 ASSERT(!isNull()); | 150 ASSERT(!isNull()); |
| 135 DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_pr
ivate); | 151 DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_pr
ivate.get()); |
| 136 if (filesystem) | 152 if (filesystem) |
| 137 return filesystem->filesystemId(); | 153 return filesystem->filesystemId(); |
| 138 return WebString(); | 154 return WebString(); |
| 139 } | 155 } |
| 140 | 156 |
| 141 void WebDragData::setFilesystemId(const WebString& filesystemId) | 157 void WebDragData::setFilesystemId(const WebString& filesystemId) |
| 142 { | 158 { |
| 143 // The ID is an opaque string, given by and validated by chromium port. | 159 // The ID is an opaque string, given by and validated by chromium port. |
| 144 ensureMutable(); | 160 ensureMutable(); |
| 145 ASSERT(m_private); | 161 DraggedIsolatedFileSystem::provideTo(*m_private.get(), DraggedIsolatedFileSy
stem::supplementName(), DraggedIsolatedFileSystem::create(filesystemId)); |
| 146 DraggedIsolatedFileSystem::provideTo(*m_private, DraggedIsolatedFileSystem::
supplementName(), DraggedIsolatedFileSystem::create(filesystemId)); | |
| 147 } | |
| 148 | |
| 149 WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::DataObject>& data) | |
| 150 : m_private(static_cast<WebDragDataPrivate*>(data.leakRef())) | |
| 151 { | |
| 152 } | |
| 153 | |
| 154 WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::DataObject>&
data) | |
| 155 { | |
| 156 assign(static_cast<WebDragDataPrivate*>(data.leakRef())); | |
| 157 return *this; | |
| 158 } | |
| 159 | |
| 160 WebDragData::operator WTF::PassRefPtr<WebCore::DataObject>() const | |
| 161 { | |
| 162 return PassRefPtr<DataObject>(const_cast<WebDragDataPrivate*>(m_private)); | |
| 163 } | |
| 164 | |
| 165 void WebDragData::assign(WebDragDataPrivate* p) | |
| 166 { | |
| 167 // p is already ref'd for us by the caller | |
| 168 if (m_private) | |
| 169 m_private->deref(); | |
| 170 m_private = p; | |
| 171 } | |
| 172 | |
| 173 void WebDragData::ensureMutable() | |
| 174 { | |
| 175 ASSERT(!isNull()); | |
| 176 ASSERT(m_private->hasOneRef()); | |
| 177 } | 162 } |
| 178 | 163 |
| 179 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |