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/V8BindingForCore.h" | 33 #include "bindings/core/v8/V8BindingForCore.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/ExecutionContext.h" |
37 #include "core/dom/StringCallback.h" | 37 #include "core/dom/FunctionStringCallback.h" |
38 #include "core/dom/TaskRunnerHelper.h" | 38 #include "core/dom/TaskRunnerHelper.h" |
39 #include "core/probe/CoreProbes.h" | 39 #include "core/probe/CoreProbes.h" |
40 #include "platform/wtf/StdLibExtras.h" | 40 #include "platform/wtf/StdLibExtras.h" |
41 #include "platform/wtf/text/WTFString.h" | 41 #include "platform/wtf/text/WTFString.h" |
42 #include "public/platform/WebTraceLocation.h" | 42 #include "public/platform/WebTraceLocation.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 DataTransferItem* DataTransferItem::Create(DataTransfer* data_transfer, | 46 DataTransferItem* DataTransferItem::Create(DataTransfer* data_transfer, |
47 DataObjectItem* item) { | 47 DataObjectItem* item) { |
(...skipping 15 matching lines...) Expand all Loading... |
63 return String(); | 63 return String(); |
64 } | 64 } |
65 | 65 |
66 String DataTransferItem::type() const { | 66 String DataTransferItem::type() const { |
67 if (!data_transfer_->CanReadTypes()) | 67 if (!data_transfer_->CanReadTypes()) |
68 return String(); | 68 return String(); |
69 return item_->GetType(); | 69 return item_->GetType(); |
70 } | 70 } |
71 | 71 |
72 static void RunGetAsStringTask(ExecutionContext* context, | 72 static void RunGetAsStringTask(ExecutionContext* context, |
73 StringCallback* callback, | 73 FunctionStringCallback* callback, |
74 const String& data) { | 74 const String& data) { |
75 probe::AsyncTask async_task(context, callback); | 75 probe::AsyncTask async_task(context, callback); |
76 if (context) | 76 if (context) |
77 callback->handleEvent(data); | 77 callback->handleEvent(data); |
78 } | 78 } |
79 | 79 |
80 void DataTransferItem::getAsString(ScriptState* script_state, | 80 void DataTransferItem::getAsString(ScriptState* script_state, |
81 StringCallback* callback) const { | 81 FunctionStringCallback* callback) const { |
82 if (!data_transfer_->CanReadData()) | 82 if (!data_transfer_->CanReadData()) |
83 return; | 83 return; |
84 if (!callback || item_->Kind() != DataObjectItem::kStringKind) | 84 if (!callback || item_->Kind() != DataObjectItem::kStringKind) |
85 return; | 85 return; |
86 | 86 |
87 ExecutionContext* context = ExecutionContext::From(script_state); | 87 ExecutionContext* context = ExecutionContext::From(script_state); |
88 probe::AsyncTaskScheduled(context, "DataTransferItem.getAsString", callback); | 88 probe::AsyncTaskScheduled(context, "DataTransferItem.getAsString", callback); |
89 TaskRunnerHelper::Get(TaskType::kUserInteraction, script_state) | 89 TaskRunnerHelper::Get(TaskType::kUserInteraction, script_state) |
90 ->PostTask(BLINK_FROM_HERE, | 90 ->PostTask(BLINK_FROM_HERE, |
91 WTF::Bind(&RunGetAsStringTask, WrapWeakPersistent(context), | 91 WTF::Bind(&RunGetAsStringTask, WrapWeakPersistent(context), |
(...skipping 10 matching lines...) Expand all Loading... |
102 DataTransferItem::DataTransferItem(DataTransfer* data_transfer, | 102 DataTransferItem::DataTransferItem(DataTransfer* data_transfer, |
103 DataObjectItem* item) | 103 DataObjectItem* item) |
104 : data_transfer_(data_transfer), item_(item) {} | 104 : data_transfer_(data_transfer), item_(item) {} |
105 | 105 |
106 DEFINE_TRACE(DataTransferItem) { | 106 DEFINE_TRACE(DataTransferItem) { |
107 visitor->Trace(data_transfer_); | 107 visitor->Trace(data_transfer_); |
108 visitor->Trace(item_); | 108 visitor->Trace(item_); |
109 } | 109 } |
110 | 110 |
111 } // namespace blink | 111 } // namespace blink |
OLD | NEW |