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 21 matching lines...) Expand all Loading... |
32 #include "core/clipboard/DataObjectItem.h" | 32 #include "core/clipboard/DataObjectItem.h" |
33 | 33 |
34 #include "core/clipboard/Pasteboard.h" | 34 #include "core/clipboard/Pasteboard.h" |
35 #include "core/fileapi/Blob.h" | 35 #include "core/fileapi/Blob.h" |
36 #include "platform/clipboard/ClipboardMimeTypes.h" | 36 #include "platform/clipboard/ClipboardMimeTypes.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 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromString(const St
ring& type, const String& data) | 42 DataObjectItem* DataObjectItem::createFromString(const String& type, const Strin
g& data) |
43 { | 43 { |
44 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(StringKind, type)); | 44 DataObjectItem* item = new DataObjectItem(StringKind, type); |
45 item->m_data = data; | 45 item->m_data = data; |
46 return item.release(); | 46 return item; |
47 } | 47 } |
48 | 48 |
49 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromFile(File* file
) | 49 DataObjectItem* DataObjectItem::createFromFile(File* file) |
50 { | 50 { |
51 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(FileKind, file->type())); | 51 DataObjectItem* item = new DataObjectItem(FileKind, file->type()); |
52 item->m_file = file; | 52 item->m_file = file; |
53 return item.release(); | 53 return item; |
54 } | 54 } |
55 | 55 |
56 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromURL(const Strin
g& url, const String& title) | 56 DataObjectItem* DataObjectItem::createFromURL(const String& url, const String& t
itle) |
57 { | 57 { |
58 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(StringKind, mimeTypeTextURIList)); | 58 DataObjectItem* item = new DataObjectItem(StringKind, mimeTypeTextURIList); |
59 item->m_data = url; | 59 item->m_data = url; |
60 item->m_title = title; | 60 item->m_title = title; |
61 return item.release(); | 61 return item; |
62 } | 62 } |
63 | 63 |
64 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromHTML(const Stri
ng& html, const KURL& baseURL) | 64 DataObjectItem* DataObjectItem::createFromHTML(const String& html, const KURL& b
aseURL) |
65 { | 65 { |
66 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(StringKind, mimeTypeTextHTML)); | 66 DataObjectItem* item = new DataObjectItem(StringKind, mimeTypeTextHTML); |
67 item->m_data = html; | 67 item->m_data = html; |
68 item->m_baseURL = baseURL; | 68 item->m_baseURL = baseURL; |
69 return item.release(); | 69 return item; |
70 } | 70 } |
71 | 71 |
72 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromSharedBuffer(co
nst String& name, PassRefPtr<SharedBuffer> buffer) | 72 DataObjectItem* DataObjectItem::createFromSharedBuffer(const String& name, PassR
efPtr<SharedBuffer> buffer) |
73 { | 73 { |
74 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(FileKind, String())); | 74 DataObjectItem* item = new DataObjectItem(FileKind, String()); |
75 item->m_sharedBuffer = buffer; | 75 item->m_sharedBuffer = buffer; |
76 item->m_title = name; | 76 item->m_title = name; |
77 return item.release(); | 77 return item; |
78 } | 78 } |
79 | 79 |
80 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromPasteboard(cons
t String& type, uint64_t sequenceNumber) | 80 DataObjectItem* DataObjectItem::createFromPasteboard(const String& type, uint64_
t sequenceNumber) |
81 { | 81 { |
82 if (type == mimeTypeImagePng) | 82 if (type == mimeTypeImagePng) |
83 return adoptRefWillBeNoop(new DataObjectItem(FileKind, type, sequenceNum
ber)); | 83 return new DataObjectItem(FileKind, type, sequenceNumber); |
84 return adoptRefWillBeNoop(new DataObjectItem(StringKind, type, sequenceNumbe
r)); | 84 return new DataObjectItem(StringKind, type, sequenceNumber); |
85 } | 85 } |
86 | 86 |
87 DataObjectItem::DataObjectItem(Kind kind, const String& type) | 87 DataObjectItem::DataObjectItem(Kind kind, const String& type) |
88 : m_source(InternalSource) | 88 : m_source(InternalSource) |
89 , m_kind(kind) | 89 , m_kind(kind) |
90 , m_type(type) | 90 , m_type(type) |
91 , m_sequenceNumber(0) | 91 , m_sequenceNumber(0) |
92 { | 92 { |
93 } | 93 } |
94 | 94 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // we'll need to make sure this works as expected for DragDataChromium. | 167 // we'll need to make sure this works as expected for DragDataChromium. |
168 return m_kind == FileKind && m_file; | 168 return m_kind == FileKind && m_file; |
169 } | 169 } |
170 | 170 |
171 DEFINE_TRACE(DataObjectItem) | 171 DEFINE_TRACE(DataObjectItem) |
172 { | 172 { |
173 visitor->trace(m_file); | 173 visitor->trace(m_file); |
174 } | 174 } |
175 | 175 |
176 } // namespace blink | 176 } // namespace blink |
OLD | NEW |