| 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 15 matching lines...) Expand all Loading... |
| 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 "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/ExecutionContext.h" |
| 36 #include "core/dom/StringCallback.h" | 37 #include "core/dom/StringCallback.h" |
| 37 #include "core/dom/TaskRunnerHelper.h" | 38 #include "core/dom/TaskRunnerHelper.h" |
| 38 #include "core/probe/CoreProbes.h" | 39 #include "core/probe/CoreProbes.h" |
| 39 #include "public/platform/WebTraceLocation.h" | 40 #include "public/platform/WebTraceLocation.h" |
| 40 #include "wtf/StdLibExtras.h" | 41 #include "wtf/StdLibExtras.h" |
| 41 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 DataTransferItem* DataTransferItem::Create(DataTransfer* data_transfer, | 46 DataTransferItem* DataTransferItem::Create(DataTransfer* data_transfer, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 76 callback->handleEvent(data); | 77 callback->handleEvent(data); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void DataTransferItem::getAsString(ScriptState* script_state, | 80 void DataTransferItem::getAsString(ScriptState* script_state, |
| 80 StringCallback* callback) const { | 81 StringCallback* callback) const { |
| 81 if (!data_transfer_->CanReadData()) | 82 if (!data_transfer_->CanReadData()) |
| 82 return; | 83 return; |
| 83 if (!callback || item_->Kind() != DataObjectItem::kStringKind) | 84 if (!callback || item_->Kind() != DataObjectItem::kStringKind) |
| 84 return; | 85 return; |
| 85 | 86 |
| 86 ExecutionContext* context = script_state->GetExecutionContext(); | 87 ExecutionContext* context = ExecutionContext::From(script_state); |
| 87 probe::AsyncTaskScheduled(context, "DataTransferItem.getAsString", callback); | 88 probe::AsyncTaskScheduled(context, "DataTransferItem.getAsString", callback); |
| 88 TaskRunnerHelper::Get(TaskType::kUserInteraction, script_state) | 89 TaskRunnerHelper::Get(TaskType::kUserInteraction, script_state) |
| 89 ->PostTask(BLINK_FROM_HERE, | 90 ->PostTask(BLINK_FROM_HERE, |
| 90 WTF::Bind(&RunGetAsStringTask, WrapWeakPersistent(context), | 91 WTF::Bind(&RunGetAsStringTask, WrapWeakPersistent(context), |
| 91 WrapPersistent(callback), item_->GetAsString())); | 92 WrapPersistent(callback), item_->GetAsString())); |
| 92 } | 93 } |
| 93 | 94 |
| 94 File* DataTransferItem::getAsFile() const { | 95 File* DataTransferItem::getAsFile() const { |
| 95 if (!data_transfer_->CanReadData()) | 96 if (!data_transfer_->CanReadData()) |
| 96 return nullptr; | 97 return nullptr; |
| 97 | 98 |
| 98 return item_->GetAsFile(); | 99 return item_->GetAsFile(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 DataTransferItem::DataTransferItem(DataTransfer* data_transfer, | 102 DataTransferItem::DataTransferItem(DataTransfer* data_transfer, |
| 102 DataObjectItem* item) | 103 DataObjectItem* item) |
| 103 : data_transfer_(data_transfer), item_(item) {} | 104 : data_transfer_(data_transfer), item_(item) {} |
| 104 | 105 |
| 105 DEFINE_TRACE(DataTransferItem) { | 106 DEFINE_TRACE(DataTransferItem) { |
| 106 visitor->Trace(data_transfer_); | 107 visitor->Trace(data_transfer_); |
| 107 visitor->Trace(item_); | 108 visitor->Trace(item_); |
| 108 } | 109 } |
| 109 | 110 |
| 110 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |