1 // Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
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.
30 // ---------------------------------------------------------------------------
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
37 #ifndef CEF_INCLUDE_CEF_DRAG_DATA_H_
38 #define CEF_INCLUDE_CEF_DRAG_DATA_H_
41 #include "include/cef_base.h"
42 #include "include/cef_stream.h"
46 // Class used to represent drag data. The methods of this class may be called
49 /*--cef(source=library)--*/
50 class CefDragData : public virtual CefBase {
53 // Create a new CefDragData object.
56 static CefRefPtr<CefDragData> Create();
59 // Returns a copy of the current object.
62 virtual CefRefPtr<CefDragData> Clone() =0;
65 // Returns true if this object is read-only.
68 virtual bool IsReadOnly() =0;
71 // Returns true if the drag data is a link.
74 virtual bool IsLink() =0;
77 // Returns true if the drag data is a text or html fragment.
80 virtual bool IsFragment() =0;
83 // Returns true if the drag data is a file.
86 virtual bool IsFile() =0;
89 // Return the link URL that is being dragged.
92 virtual CefString GetLinkURL() =0;
95 // Return the title associated with the link being dragged.
98 virtual CefString GetLinkTitle() =0;
101 // Return the metadata, if any, associated with the link being dragged.
104 virtual CefString GetLinkMetadata() =0;
107 // Return the plain text fragment that is being dragged.
110 virtual CefString GetFragmentText() =0;
113 // Return the text/html fragment that is being dragged.
116 virtual CefString GetFragmentHtml() =0;
119 // Return the base URL that the fragment came from. This value is used for
120 // resolving relative URLs and may be empty.
123 virtual CefString GetFragmentBaseURL() =0;
126 // Return the name of the file being dragged out of the browser window.
129 virtual CefString GetFileName() =0;
132 // Write the contents of the file being dragged out of the web view into
133 // |writer|. Returns the number of bytes sent to |writer|. If |writer| is
134 // NULL this method will return the size of the file contents in bytes.
135 // Call GetFileName() to get a suggested name for the file.
137 /*--cef(optional_param=writer)--*/
138 virtual size_t GetFileContents(CefRefPtr<CefStreamWriter> writer) =0;
141 // Retrieve the list of file names that are being dragged into the browser
145 virtual bool GetFileNames(std::vector<CefString>& names) =0;
148 // Set the link URL that is being dragged.
150 /*--cef(optional_param=url)--*/
151 virtual void SetLinkURL(const CefString& url) =0;
154 // Set the title associated with the link being dragged.
156 /*--cef(optional_param=title)--*/
157 virtual void SetLinkTitle(const CefString& title) =0;
160 // Set the metadata associated with the link being dragged.
162 /*--cef(optional_param=data)--*/
163 virtual void SetLinkMetadata(const CefString& data) =0;
166 // Set the plain text fragment that is being dragged.
168 /*--cef(optional_param=text)--*/
169 virtual void SetFragmentText(const CefString& text) =0;
172 // Set the text/html fragment that is being dragged.
174 /*--cef(optional_param=html)--*/
175 virtual void SetFragmentHtml(const CefString& html) =0;
178 // Set the base URL that the fragment came from.
180 /*--cef(optional_param=base_url)--*/
181 virtual void SetFragmentBaseURL(const CefString& base_url) =0;
184 // Reset the file contents. You should do this before calling
185 // CefBrowserHost::DragTargetDragEnter as the web view does not allow us to
186 // drag in this kind of data.
189 virtual void ResetFileContents() =0;
192 // Add a file that is being dragged into the webview.
194 /*--cef(optional_param=display_name)--*/
195 virtual void AddFile(const CefString& path, const CefString& display_name) =0;
198 #endif // CEF_INCLUDE_CEF_DRAG_DATA_H_