| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef DataObjectItem_h | 31 #ifndef DataObjectItem_h |
| 32 #define DataObjectItem_h | 32 #define DataObjectItem_h |
| 33 | 33 |
| 34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
| 35 #include "core/fileapi/File.h" | 35 #include "core/fileapi/File.h" |
| 36 #include "platform/SharedBuffer.h" | 36 #include "platform/SharedBuffer.h" |
| 37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
| 38 #include "platform/weborigin/KURL.h" | 38 #include "platform/weborigin/KURL.h" |
| 39 #include "wtf/RefCounted.h" | 39 #include "wtf/Forward.h" |
| 40 #include "wtf/RefPtr.h" | |
| 41 #include "wtf/text/WTFString.h" | |
| 42 | 40 |
| 43 namespace blink { | 41 namespace blink { |
| 44 | 42 |
| 45 class Blob; | 43 class Blob; |
| 46 | 44 |
| 47 class CORE_EXPORT DataObjectItem : public RefCountedWillBeGarbageCollectedFinali
zed<DataObjectItem> { | 45 class CORE_EXPORT DataObjectItem : public GarbageCollectedFinalized<DataObjectIt
em> { |
| 48 public: | 46 public: |
| 49 enum Kind { | 47 enum Kind { |
| 50 StringKind, | 48 StringKind, |
| 51 FileKind | 49 FileKind |
| 52 }; | 50 }; |
| 53 | 51 |
| 54 static PassRefPtrWillBeRawPtr<DataObjectItem> createFromString(const String&
type, const String& data); | 52 static DataObjectItem* createFromString(const String& type, const String& da
ta); |
| 55 static PassRefPtrWillBeRawPtr<DataObjectItem> createFromFile(File*); | 53 static DataObjectItem* createFromFile(File*); |
| 56 static PassRefPtrWillBeRawPtr<DataObjectItem> createFromURL(const String& ur
l, const String& title); | 54 static DataObjectItem* createFromURL(const String& url, const String& title)
; |
| 57 static PassRefPtrWillBeRawPtr<DataObjectItem> createFromHTML(const String& h
tml, const KURL& baseURL); | 55 static DataObjectItem* createFromHTML(const String& html, const KURL& baseUR
L); |
| 58 static PassRefPtrWillBeRawPtr<DataObjectItem> createFromSharedBuffer(const S
tring& filename, PassRefPtr<SharedBuffer>); | 56 static DataObjectItem* createFromSharedBuffer(const String& filename, PassRe
fPtr<SharedBuffer>); |
| 59 static PassRefPtrWillBeRawPtr<DataObjectItem> createFromPasteboard(const Str
ing& type, uint64_t sequenceNumber); | 57 static DataObjectItem* createFromPasteboard(const String& type, uint64_t seq
uenceNumber); |
| 60 | 58 |
| 61 Kind kind() const { return m_kind; } | 59 Kind kind() const { return m_kind; } |
| 62 String type() const { return m_type; } | 60 String type() const { return m_type; } |
| 63 String getAsString() const; | 61 String getAsString() const; |
| 64 Blob* getAsFile() const; | 62 Blob* getAsFile() const; |
| 65 | 63 |
| 66 // Used to support legacy DataTransfer APIs and renderer->browser serializat
ion. | 64 // Used to support legacy DataTransfer APIs and renderer->browser serializat
ion. |
| 67 PassRefPtr<SharedBuffer> sharedBuffer() const { return m_sharedBuffer; } | 65 PassRefPtr<SharedBuffer> sharedBuffer() const { return m_sharedBuffer; } |
| 68 String title() const { return m_title; } | 66 String title() const { return m_title; } |
| 69 KURL baseURL() const { return m_baseURL; } | 67 KURL baseURL() const { return m_baseURL; } |
| 70 bool isFilename() const; | 68 bool isFilename() const; |
| 71 | 69 |
| 72 DECLARE_TRACE(); | 70 DECLARE_TRACE(); |
| 73 | 71 |
| 74 private: | 72 private: |
| 75 enum DataSource { | 73 enum DataSource { |
| 76 PasteboardSource, | 74 PasteboardSource, |
| 77 InternalSource, | 75 InternalSource, |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 DataObjectItem(Kind, const String& type); | 78 DataObjectItem(Kind, const String& type); |
| 81 DataObjectItem(Kind, const String& type, uint64_t sequenceNumber); | 79 DataObjectItem(Kind, const String& type, uint64_t sequenceNumber); |
| 82 | 80 |
| 83 DataSource m_source; | 81 DataSource m_source; |
| 84 Kind m_kind; | 82 Kind m_kind; |
| 85 String m_type; | 83 String m_type; |
| 86 | 84 |
| 87 String m_data; | 85 String m_data; |
| 88 PersistentWillBeMember<File> m_file; | 86 Member<File> m_file; |
| 89 RefPtr<SharedBuffer> m_sharedBuffer; | 87 RefPtr<SharedBuffer> m_sharedBuffer; |
| 90 // Optional metadata. Currently used for URL, HTML, and dragging files in. | 88 // Optional metadata. Currently used for URL, HTML, and dragging files in. |
| 91 String m_title; | 89 String m_title; |
| 92 KURL m_baseURL; | 90 KURL m_baseURL; |
| 93 | 91 |
| 94 uint64_t m_sequenceNumber; // Only valid when m_source == PasteboardSource | 92 uint64_t m_sequenceNumber; // Only valid when m_source == PasteboardSource |
| 95 }; | 93 }; |
| 96 | 94 |
| 97 } // namespace blink | 95 } // namespace blink |
| 98 | 96 |
| 99 #endif // DataObjectItem_h | 97 #endif // DataObjectItem_h |
| OLD | NEW |