1 /* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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. 29 */ 30 31 #ifndef WebDragData_h 32 #define WebDragData_h 33 34 #include "WebCommon.h" 35 36 #if WEBKIT_IMPLEMENTATION 37 namespace WebCore { class ChromiumDataObject; } 38 namespace WTF { template <typename T> class PassRefPtr; } 39 #endif 40 41 namespace WebKit { 42 43 class WebData; 44 class WebDragDataPrivate; 45 class WebString; 46 class WebURL; 47 template <typename T> class WebVector; 48 49 // Holds data that may be exchanged through a drag-n-drop operation. It is 50 // inexpensive to copy a WebDragData object. 51 class WebDragData { 52 public: 53 ~WebDragData() { reset(); } 54 55 WebDragData() : m_private(0) { } 56 WebDragData(const WebDragData& d) : m_private(0) { assign(d); } 57 WebDragData& operator=(const WebDragData& d) 58 { 59 assign(d); 60 return *this; 61 } 62 63 WEBKIT_API void initialize(); 64 WEBKIT_API void reset(); 65 WEBKIT_API void assign(const WebDragData&); 66 67 bool isNull() const { return !m_private; } 68 69 WEBKIT_API WebString url() const; 70 WEBKIT_API void setURL(const WebURL&); 71 72 WEBKIT_API WebString urlTitle() const; 73 WEBKIT_API void setURLTitle(const WebString&); 74 75 WEBKIT_API WebString downloadMetadata() const; 76 WEBKIT_API void setDownloadMetadata(const WebString&); 77 78 WEBKIT_API WebString fileExtension() const; 79 WEBKIT_API void setFileExtension(const WebString&); 80 81 WEBKIT_API bool containsFilenames() const; 82 WEBKIT_API void filenames(WebVector<WebString>&) const; 83 WEBKIT_API void setFilenames(const WebVector<WebString>&); 84 WEBKIT_API void appendToFilenames(const WebString&); 85 86 WEBKIT_API WebString plainText() const; 87 WEBKIT_API void setPlainText(const WebString&); 88 89 WEBKIT_API WebString htmlText() const; 90 WEBKIT_API void setHTMLText(const WebString&); 91 92 WEBKIT_API WebURL htmlBaseURL() const; 93 WEBKIT_API void setHTMLBaseURL(const WebURL&); 94 95 WEBKIT_API WebString fileContentFilename() const; 96 WEBKIT_API void setFileContentFilename(const WebString&); 97 98 WEBKIT_API WebData fileContent() const; 99 WEBKIT_API void setFileContent(const WebData&); 100 101 #if WEBKIT_IMPLEMENTATION 102 WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&); 103 WebDragData& operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&); 104 operator WTF::PassRefPtr<WebCore::ChromiumDataObject>() const; 105 #endif 106 107 private: 108 void assign(WebDragDataPrivate*); 109 void ensureMutable(); 110 WebDragDataPrivate* m_private; 111 }; 112 113 } // namespace WebKit 114 115 #endif 116