| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 #include "platform/clipboard/ClipboardUtilities.h" | 36 #include "platform/clipboard/ClipboardUtilities.h" |
| 37 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
| 38 #include "public/platform/WebClipboard.h" | 38 #include "public/platform/WebClipboard.h" |
| 39 #include "public/platform/WebDragData.h" | 39 #include "public/platform/WebDragData.h" |
| 40 #include "wtf/HashSet.h" | 40 #include "wtf/HashSet.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 DataObject* DataObject::createFromPasteboard(PasteMode pasteMode) { | 44 DataObject* DataObject::createFromPasteboard(PasteMode pasteMode) { |
| 45 DataObject* dataObject = create(); | 45 DataObject* dataObject = create(); |
| 46 #if ENABLE(ASSERT) | 46 #if DCHECK_IS_ON() |
| 47 HashSet<String> typesSeen; | 47 HashSet<String> typesSeen; |
| 48 #endif | 48 #endif |
| 49 WebClipboard::Buffer buffer = Pasteboard::generalPasteboard()->buffer(); | 49 WebClipboard::Buffer buffer = Pasteboard::generalPasteboard()->buffer(); |
| 50 uint64_t sequenceNumber = | 50 uint64_t sequenceNumber = |
| 51 Platform::current()->clipboard()->sequenceNumber(buffer); | 51 Platform::current()->clipboard()->sequenceNumber(buffer); |
| 52 bool ignored; | 52 bool ignored; |
| 53 WebVector<WebString> webTypes = | 53 WebVector<WebString> webTypes = |
| 54 Platform::current()->clipboard()->readAvailableTypes(buffer, &ignored); | 54 Platform::current()->clipboard()->readAvailableTypes(buffer, &ignored); |
| 55 for (const WebString& type : webTypes) { | 55 for (const WebString& type : webTypes) { |
| 56 if (pasteMode == PlainTextOnly && type != mimeTypeTextPlain) | 56 if (pasteMode == PlainTextOnly && type != mimeTypeTextPlain) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 m_itemList[i]->type() == type) { | 126 m_itemList[i]->type() == type) { |
| 127 // Per the spec, type must be unique among all items of kind 'string'. | 127 // Per the spec, type must be unique among all items of kind 'string'. |
| 128 m_itemList.remove(i); | 128 m_itemList.remove(i); |
| 129 return; | 129 return; |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 Vector<String> DataObject::types() const { | 134 Vector<String> DataObject::types() const { |
| 135 Vector<String> results; | 135 Vector<String> results; |
| 136 #if ENABLE(ASSERT) | 136 #if DCHECK_IS_ON() |
| 137 HashSet<String> typesSeen; | 137 HashSet<String> typesSeen; |
| 138 #endif | 138 #endif |
| 139 bool containsFiles = false; | 139 bool containsFiles = false; |
| 140 for (const auto& item : m_itemList) { | 140 for (const auto& item : m_itemList) { |
| 141 switch (item->kind()) { | 141 switch (item->kind()) { |
| 142 case DataObjectItem::StringKind: | 142 case DataObjectItem::StringKind: |
| 143 // Per the spec, type must be unique among all items of kind 'string'. | 143 // Per the spec, type must be unique among all items of kind 'string'. |
| 144 results.push_back(item->type()); | 144 results.push_back(item->type()); |
| 145 ASSERT(typesSeen.add(item->type()).isNewEntry); | 145 ASSERT(typesSeen.add(item->type()).isNewEntry); |
| 146 break; | 146 break; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 item.title = originalItem->title(); | 358 item.title = originalItem->title(); |
| 359 item.baseURL = originalItem->baseURL(); | 359 item.baseURL = originalItem->baseURL(); |
| 360 itemList[i] = item; | 360 itemList[i] = item; |
| 361 } | 361 } |
| 362 data.swapItems(itemList); | 362 data.swapItems(itemList); |
| 363 return data; | 363 return data; |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace blink | 366 } // namespace blink |
| OLD | NEW |