#ifndef DataObjectItem_h
#define DataObjectItem_h
#include "core/fileapi/File.h"
#include "heap/Handle.h"
#include "platform/SharedBuffer.h"
#include "platform/weborigin/KURL.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class Blob;
class DataObjectItem : public RefCountedWillBeGarbageCollectedFinalized<DataObjectItem> {
public:
enum Kind {
StringKind,
FileKind
};
static PassRefPtrWillBeRawPtr<DataObjectItem> createFromString(const String& type, const String& data);
static PassRefPtrWillBeRawPtr<DataObjectItem> createFromFile(PassRefPtrWillBeRawPtr<File>);
static PassRefPtrWillBeRawPtr<DataObjectItem> createFromURL(const String& url, const String& title);
static PassRefPtrWillBeRawPtr<DataObjectItem> createFromHTML(const String& html, const KURL& baseURL);
static PassRefPtrWillBeRawPtr<DataObjectItem> createFromSharedBuffer(const String& filename, PassRefPtr<SharedBuffer>);
static PassRefPtrWillBeRawPtr<DataObjectItem> createFromPasteboard(const String& type, uint64_t sequenceNumber);
Kind kind() const { return m_kind; }
String type() const { return m_type; }
String getAsString() const;
PassRefPtrWillBeRawPtr<Blob> getAsFile() const;
PassRefPtr<SharedBuffer> sharedBuffer() const { return m_sharedBuffer; }
String title() const { return m_title; }
KURL baseURL() const { return m_baseURL; }
bool isFilename() const;
void trace(Visitor*);
private:
enum DataSource {
PasteboardSource,
InternalSource,
};
DataObjectItem(Kind, const String& type);
DataObjectItem(Kind, const String& type, uint64_t sequenceNumber);
DataSource m_source;
Kind m_kind;
String m_type;
String m_data;
RefPtrWillBeMember<File> m_file;
RefPtr<SharedBuffer> m_sharedBuffer;
String m_title;
KURL m_baseURL;
uint64_t m_sequenceNumber;
};
}
#endif