Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataObjectItem.cpp

Issue 2674953003: Only generate suggested filenames when actually dragging an image. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/DataObjectItem.h" 31 #include "core/clipboard/DataObjectItem.h"
32 32
33 #include "core/clipboard/Pasteboard.h" 33 #include "core/clipboard/Pasteboard.h"
34 #include "core/fileapi/Blob.h" 34 #include "core/fileapi/Blob.h"
35 #include "platform/clipboard/ClipboardMimeTypes.h" 35 #include "platform/clipboard/ClipboardMimeTypes.h"
36 #include "platform/network/mime/MIMETypeRegistry.h"
36 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
37 #include "public/platform/WebClipboard.h" 38 #include "public/platform/WebClipboard.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 DataObjectItem* DataObjectItem::createFromString(const String& type, 42 DataObjectItem* DataObjectItem::createFromString(const String& type,
42 const String& data) { 43 const String& data) {
43 DataObjectItem* item = new DataObjectItem(StringKind, type); 44 DataObjectItem* item = new DataObjectItem(StringKind, type);
44 item->m_data = data; 45 item->m_data = data;
45 return item; 46 return item;
(...skipping 24 matching lines...) Expand all
70 71
71 DataObjectItem* DataObjectItem::createFromHTML(const String& html, 72 DataObjectItem* DataObjectItem::createFromHTML(const String& html,
72 const KURL& baseURL) { 73 const KURL& baseURL) {
73 DataObjectItem* item = new DataObjectItem(StringKind, mimeTypeTextHTML); 74 DataObjectItem* item = new DataObjectItem(StringKind, mimeTypeTextHTML);
74 item->m_data = html; 75 item->m_data = html;
75 item->m_baseURL = baseURL; 76 item->m_baseURL = baseURL;
76 return item; 77 return item;
77 } 78 }
78 79
79 DataObjectItem* DataObjectItem::createFromSharedBuffer( 80 DataObjectItem* DataObjectItem::createFromSharedBuffer(
80 const String& name, 81 PassRefPtr<SharedBuffer> buffer,
81 PassRefPtr<SharedBuffer> buffer) { 82 const KURL& sourceURL,
82 DataObjectItem* item = new DataObjectItem(FileKind, String()); 83 const String& filenameExtension,
84 const AtomicString& contentDisposition) {
85 DataObjectItem* item = new DataObjectItem(
86 FileKind,
87 MIMETypeRegistry::getWellKnownMIMETypeForExtension(filenameExtension));
83 item->m_sharedBuffer = buffer; 88 item->m_sharedBuffer = buffer;
84 item->m_title = name; 89 item->m_filenameExtension = filenameExtension;
90 // TODO(dcheng): Rename these fields to be more generically named.
91 item->m_title = contentDisposition;
92 item->m_baseURL = sourceURL;
85 return item; 93 return item;
86 } 94 }
87 95
88 DataObjectItem* DataObjectItem::createFromPasteboard(const String& type, 96 DataObjectItem* DataObjectItem::createFromPasteboard(const String& type,
89 uint64_t sequenceNumber) { 97 uint64_t sequenceNumber) {
90 if (type == mimeTypeImagePng) 98 if (type == mimeTypeImagePng)
91 return new DataObjectItem(FileKind, type, sequenceNumber); 99 return new DataObjectItem(FileKind, type, sequenceNumber);
92 return new DataObjectItem(StringKind, type, sequenceNumber); 100 return new DataObjectItem(StringKind, type, sequenceNumber);
93 } 101 }
94 102
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 185
178 String DataObjectItem::fileSystemId() const { 186 String DataObjectItem::fileSystemId() const {
179 return m_fileSystemId; 187 return m_fileSystemId;
180 } 188 }
181 189
182 DEFINE_TRACE(DataObjectItem) { 190 DEFINE_TRACE(DataObjectItem) {
183 visitor->trace(m_file); 191 visitor->trace(m_file);
184 } 192 }
185 193
186 } // namespace blink 194 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/clipboard/DataObjectItem.h ('k') | third_party/WebKit/Source/core/clipboard/DataTransfer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698