Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 16 matching lines...) Expand all Loading... | |
| 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 "core/clipboard/DataTransferItem.h" | 31 #include "core/clipboard/DataTransferItem.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/V8Binding.h" | 33 #include "bindings/core/v8/V8Binding.h" |
| 34 #include "core/clipboard/DataObjectItem.h" | 34 #include "core/clipboard/DataObjectItem.h" |
| 35 #include "core/clipboard/DataTransfer.h" | 35 #include "core/clipboard/DataTransfer.h" |
| 36 #include "core/dom/StringCallback.h" | 36 #include "core/dom/StringCallback.h" |
| 37 #include "core/dom/TaskRunnerHelper.h" | |
| 37 #include "wtf/StdLibExtras.h" | 38 #include "wtf/StdLibExtras.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 DataTransferItem* DataTransferItem::create(DataTransfer* dataTransfer, | 42 DataTransferItem* DataTransferItem::create(DataTransfer* dataTransfer, |
| 42 DataObjectItem* item) { | 43 DataObjectItem* item) { |
| 43 return new DataTransferItem(dataTransfer, item); | 44 return new DataTransferItem(dataTransfer, item); |
| 44 } | 45 } |
| 45 | 46 |
| 46 String DataTransferItem::kind() const { | 47 String DataTransferItem::kind() const { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 64 return m_item->type(); | 65 return m_item->type(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void DataTransferItem::getAsString(ExecutionContext* context, | 68 void DataTransferItem::getAsString(ExecutionContext* context, |
| 68 StringCallback* callback) const { | 69 StringCallback* callback) const { |
| 69 if (!m_dataTransfer->canReadData()) | 70 if (!m_dataTransfer->canReadData()) |
| 70 return; | 71 return; |
| 71 if (!callback || m_item->kind() != DataObjectItem::StringKind) | 72 if (!callback || m_item->kind() != DataObjectItem::StringKind) |
| 72 return; | 73 return; |
| 73 | 74 |
| 74 StringCallback::scheduleCallback(callback, context, m_item->getAsString(), | 75 StringCallback::scheduleCallback(TaskType::UserInteraction, callback, context, |
|
haraken
2016/12/18 13:30:30
It looks like StringCallback is used only here. Ma
tzik
2016/12/18 21:44:26
Yes, we can. Let me do it in a separate CL.
| |
| 76 m_item->getAsString(), | |
| 75 "DataTransferItem.getAsString"); | 77 "DataTransferItem.getAsString"); |
| 76 } | 78 } |
| 77 | 79 |
| 78 Blob* DataTransferItem::getAsFile() const { | 80 Blob* DataTransferItem::getAsFile() const { |
| 79 if (!m_dataTransfer->canReadData()) | 81 if (!m_dataTransfer->canReadData()) |
| 80 return nullptr; | 82 return nullptr; |
| 81 | 83 |
| 82 return m_item->getAsFile(); | 84 return m_item->getAsFile(); |
| 83 } | 85 } |
| 84 | 86 |
| 85 DataTransferItem::DataTransferItem(DataTransfer* dataTransfer, | 87 DataTransferItem::DataTransferItem(DataTransfer* dataTransfer, |
| 86 DataObjectItem* item) | 88 DataObjectItem* item) |
| 87 : m_dataTransfer(dataTransfer), m_item(item) {} | 89 : m_dataTransfer(dataTransfer), m_item(item) {} |
| 88 | 90 |
| 89 DEFINE_TRACE(DataTransferItem) { | 91 DEFINE_TRACE(DataTransferItem) { |
| 90 visitor->trace(m_dataTransfer); | 92 visitor->trace(m_dataTransfer); |
| 91 visitor->trace(m_item); | 93 visitor->trace(m_item); |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |