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

Side by Side Diff: Source/core/clipboard/DataObject.cpp

Issue 925913002: Fixed WebDragData's wrong dependency. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « Source/core/clipboard/DataObject.h ('k') | Source/core/clipboard/DraggedIsolatedFileSystem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, 2012 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 #include "core/clipboard/DataObject.h" 32 #include "core/clipboard/DataObject.h"
33 33
34 #include "core/clipboard/DraggedIsolatedFileSystem.h"
34 #include "core/clipboard/Pasteboard.h" 35 #include "core/clipboard/Pasteboard.h"
35 #include "platform/clipboard/ClipboardMimeTypes.h" 36 #include "platform/clipboard/ClipboardMimeTypes.h"
36 #include "platform/clipboard/ClipboardUtilities.h" 37 #include "platform/clipboard/ClipboardUtilities.h"
37 #include "public/platform/Platform.h" 38 #include "public/platform/Platform.h"
38 #include "public/platform/WebClipboard.h" 39 #include "public/platform/WebClipboard.h"
40 #include "public/platform/WebDragData.h"
39 41
40 namespace blink { 42 namespace blink {
41 43
42 PassRefPtrWillBeRawPtr<DataObject> DataObject::createFromPasteboard(PasteMode pa steMode) 44 PassRefPtrWillBeRawPtr<DataObject> DataObject::createFromPasteboard(PasteMode pa steMode)
43 { 45 {
44 RefPtrWillBeRawPtr<DataObject> dataObject = create(); 46 RefPtrWillBeRawPtr<DataObject> dataObject = create();
45 blink::WebClipboard::Buffer buffer = Pasteboard::generalPasteboard()->buffer (); 47 blink::WebClipboard::Buffer buffer = Pasteboard::generalPasteboard()->buffer ();
46 uint64_t sequenceNumber = blink::Platform::current()->clipboard()->sequenceN umber(buffer); 48 uint64_t sequenceNumber = blink::Platform::current()->clipboard()->sequenceN umber(buffer);
47 bool ignored; 49 bool ignored;
48 blink::WebVector<blink::WebString> webTypes = blink::Platform::current()->cl ipboard()->readAvailableTypes(buffer, &ignored); 50 blink::WebVector<blink::WebString> webTypes = blink::Platform::current()->cl ipboard()->readAvailableTypes(buffer, &ignored);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 249 }
248 250
249 DEFINE_TRACE(DataObject) 251 DEFINE_TRACE(DataObject)
250 { 252 {
251 #if ENABLE(OILPAN) 253 #if ENABLE(OILPAN)
252 visitor->trace(m_itemList); 254 visitor->trace(m_itemList);
253 HeapSupplementable<DataObject>::trace(visitor); 255 HeapSupplementable<DataObject>::trace(visitor);
254 #endif 256 #endif
255 } 257 }
256 258
259 PassRefPtrWillBeRawPtr<DataObject> DataObject::create(WebDragData data)
260 {
261 RefPtrWillBeRawPtr<DataObject> dataObject = create();
262
263 WebVector<WebDragData::Item> items = data.items();
264 for (unsigned i = 0; i < items.size(); ++i) {
265 WebDragData::Item item = items[i];
266
267 switch (item.storageType) {
268 case WebDragData::Item::StorageTypeString:
269 if (String(item.stringType) == mimeTypeTextURIList)
270 dataObject->setURLAndTitle(item.stringData, item.title);
271 else if (String(item.stringType) == mimeTypeTextHTML)
272 dataObject->setHTMLAndBaseURL(item.stringData, item.baseURL);
273 else
274 dataObject->setData(item.stringType, item.stringData);
275 break;
276 case WebDragData::Item::StorageTypeFilename:
277 dataObject->addFilename(item.filenameData, item.displayNameData);
278 break;
279 case WebDragData::Item::StorageTypeBinaryData:
280 // This should never happen when dragging in.
281 break;
282 case WebDragData::Item::StorageTypeFileSystemFile:
283 {
284 // FIXME: The file system URL may refer a user visible file, see http://crbug.com/429077
285 FileMetadata fileMetadata;
286 fileMetadata.length = item.fileSystemFileSize;
287 dataObject->add(File::createForFileSystemFile(item.fileSystemURL , fileMetadata, File::IsNotUserVisible));
288 }
289 break;
290 }
291 }
292
293 if (!data.filesystemId().isNull())
294 DraggedIsolatedFileSystem::prepareForDataObject(dataObject.get(), data.f ilesystemId());
295 return dataObject.release();
296 }
297
298 WebDragData DataObject::toWebDragData()
299 {
300 WebDragData data;
301 data.initialize();
302 WebVector<WebDragData::Item> itemList(length());
303
304 for (size_t i = 0; i < length(); ++i) {
305 DataObjectItem* originalItem = item(i).get();
306 WebDragData::Item item;
307 if (originalItem->kind() == DataObjectItem::StringKind) {
308 item.storageType = WebDragData::Item::StorageTypeString;
309 item.stringType = originalItem->type();
310 item.stringData = originalItem->getAsString();
311 } else if (originalItem->kind() == DataObjectItem::FileKind) {
312 if (originalItem->sharedBuffer()) {
313 item.storageType = WebDragData::Item::StorageTypeBinaryData;
314 item.binaryData = originalItem->sharedBuffer();
315 } else if (originalItem->isFilename()) {
316 Blob* blob = originalItem->getAsFile();
317 if (blob->isFile()) {
318 File* file = toFile(blob);
319 if (file->hasBackingFile()) {
320 item.storageType = WebDragData::Item::StorageTypeFilenam e;
321 item.filenameData = file->path();
322 item.displayNameData = file->name();
323 } else if (!file->fileSystemURL().isEmpty()) {
324 item.storageType = WebDragData::Item::StorageTypeFileSys temFile;
325 item.fileSystemURL = file->fileSystemURL();
326 item.fileSystemFileSize = file->size();
327 } else {
328 // FIXME: support dragging constructed Files across rend erers, see http://crbug.com/394955
329 item.storageType = WebDragData::Item::StorageTypeString;
330 item.stringType = "text/plain";
331 item.stringData = file->name();
332 }
333 } else {
334 ASSERT_NOT_REACHED();
335 }
336 } else {
337 ASSERT_NOT_REACHED();
338 }
339 } else {
340 ASSERT_NOT_REACHED();
341 }
342 item.title = originalItem->title();
343 item.baseURL = originalItem->baseURL();
344 itemList[i] = item;
345 }
346 data.swapItems(itemList);
347 return data;
348 }
349
257 } // namespace blink 350 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/clipboard/DataObject.h ('k') | Source/core/clipboard/DraggedIsolatedFileSystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698