Home | History | Annotate | Download | only in public
      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 WebURL 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 WebURL downloadURL() const;
     76     WEBKIT_API void setDownloadURL(const WebURL&);
     77     WEBKIT_API WebString downloadMetadata() const;
     78     WEBKIT_API void setDownloadMetadata(const WebString&);
     79 
     80     WEBKIT_API WebString fileExtension() const;
     81     WEBKIT_API void setFileExtension(const WebString&);
     82 
     83     WEBKIT_API bool hasFileNames() const;
     84     WEBKIT_API void fileNames(WebVector<WebString>&) const;
     85     WEBKIT_API void setFileNames(const WebVector<WebString>&);
     86     WEBKIT_API void appendToFileNames(const WebString&);
     87 
     88     WEBKIT_API WebString plainText() const;
     89     WEBKIT_API void setPlainText(const WebString&);
     90 
     91     WEBKIT_API WebString htmlText() const;
     92     WEBKIT_API void setHTMLText(const WebString&);
     93 
     94     WEBKIT_API WebURL htmlBaseURL() const;
     95     WEBKIT_API void setHTMLBaseURL(const WebURL&);
     96 
     97     WEBKIT_API WebString fileContentFileName() const;
     98     WEBKIT_API void setFileContentFileName(const WebString&);
     99 
    100     WEBKIT_API WebData fileContent() const;
    101     WEBKIT_API void setFileContent(const WebData&);
    102 
    103 #if WEBKIT_IMPLEMENTATION
    104     WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&);
    105     WebDragData& operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&);
    106     operator WTF::PassRefPtr<WebCore::ChromiumDataObject>() const;
    107 #endif
    108 
    109 private:
    110     void assign(WebDragDataPrivate*);
    111     void ensureMutable();
    112     WebDragDataPrivate* m_private;
    113 };
    114 
    115 } // namespace WebKit
    116 
    117 #endif
    118