1 // Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 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 12 // distribution. 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. 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 // 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. 35 // 36 37 #ifndef CEF_INCLUDE_CEF_DRAG_DATA_H_ 38 #define CEF_INCLUDE_CEF_DRAG_DATA_H_ 39 #pragma once 40 41 #include <vector> 42 #include "include/cef_base.h" 43 #include "include/cef_image.h" 44 #include "include/cef_stream.h" 45 46 /// 47 // Class used to represent drag data. The methods of this class may be called 48 // on any thread. 49 /// 50 /*--cef(source=library)--*/ 51 class CefDragData : public virtual CefBaseRefCounted { 52 public: 53 /// 54 // Create a new CefDragData object. 55 /// 56 /*--cef()--*/ 57 static CefRefPtr<CefDragData> Create(); 58 59 /// 60 // Returns a copy of the current object. 61 /// 62 /*--cef()--*/ 63 virtual CefRefPtr<CefDragData> Clone() = 0; 64 65 /// 66 // Returns true if this object is read-only. 67 /// 68 /*--cef()--*/ 69 virtual bool IsReadOnly() = 0; 70 71 /// 72 // Returns true if the drag data is a link. 73 /// 74 /*--cef()--*/ 75 virtual bool IsLink() = 0; 76 77 /// 78 // Returns true if the drag data is a text or html fragment. 79 /// 80 /*--cef()--*/ 81 virtual bool IsFragment() = 0; 82 83 /// 84 // Returns true if the drag data is a file. 85 /// 86 /*--cef()--*/ 87 virtual bool IsFile() = 0; 88 89 /// 90 // Return the link URL that is being dragged. 91 /// 92 /*--cef()--*/ 93 virtual CefString GetLinkURL() = 0; 94 95 /// 96 // Return the title associated with the link being dragged. 97 /// 98 /*--cef()--*/ 99 virtual CefString GetLinkTitle() = 0; 100 101 /// 102 // Return the metadata, if any, associated with the link being dragged. 103 /// 104 /*--cef()--*/ 105 virtual CefString GetLinkMetadata() = 0; 106 107 /// 108 // Return the plain text fragment that is being dragged. 109 /// 110 /*--cef()--*/ 111 virtual CefString GetFragmentText() = 0; 112 113 /// 114 // Return the text/html fragment that is being dragged. 115 /// 116 /*--cef()--*/ 117 virtual CefString GetFragmentHtml() = 0; 118 119 /// 120 // Return the base URL that the fragment came from. This value is used for 121 // resolving relative URLs and may be empty. 122 /// 123 /*--cef()--*/ 124 virtual CefString GetFragmentBaseURL() = 0; 125 126 /// 127 // Return the name of the file being dragged out of the browser window. 128 /// 129 /*--cef()--*/ 130 virtual CefString GetFileName() = 0; 131 132 /// 133 // Write the contents of the file being dragged out of the web view into 134 // |writer|. Returns the number of bytes sent to |writer|. If |writer| is 135 // NULL this method will return the size of the file contents in bytes. 136 // Call GetFileName() to get a suggested name for the file. 137 /// 138 /*--cef(optional_param=writer)--*/ 139 virtual size_t GetFileContents(CefRefPtr<CefStreamWriter> writer) = 0; 140 141 /// 142 // Retrieve the list of file names that are being dragged into the browser 143 // window. 144 /// 145 /*--cef()--*/ 146 virtual bool GetFileNames(std::vector<CefString>& names) = 0; 147 148 /// 149 // Set the link URL that is being dragged. 150 /// 151 /*--cef(optional_param=url)--*/ 152 virtual void SetLinkURL(const CefString& url) = 0; 153 154 /// 155 // Set the title associated with the link being dragged. 156 /// 157 /*--cef(optional_param=title)--*/ 158 virtual void SetLinkTitle(const CefString& title) = 0; 159 160 /// 161 // Set the metadata associated with the link being dragged. 162 /// 163 /*--cef(optional_param=data)--*/ 164 virtual void SetLinkMetadata(const CefString& data) = 0; 165 166 /// 167 // Set the plain text fragment that is being dragged. 168 /// 169 /*--cef(optional_param=text)--*/ 170 virtual void SetFragmentText(const CefString& text) = 0; 171 172 /// 173 // Set the text/html fragment that is being dragged. 174 /// 175 /*--cef(optional_param=html)--*/ 176 virtual void SetFragmentHtml(const CefString& html) = 0; 177 178 /// 179 // Set the base URL that the fragment came from. 180 /// 181 /*--cef(optional_param=base_url)--*/ 182 virtual void SetFragmentBaseURL(const CefString& base_url) = 0; 183 184 /// 185 // Reset the file contents. You should do this before calling 186 // CefBrowserHost::DragTargetDragEnter as the web view does not allow us to 187 // drag in this kind of data. 188 /// 189 /*--cef()--*/ 190 virtual void ResetFileContents() = 0; 191 192 /// 193 // Add a file that is being dragged into the webview. 194 /// 195 /*--cef(optional_param=display_name)--*/ 196 virtual void AddFile(const CefString& path, 197 const CefString& display_name) = 0; 198 199 /// 200 // Get the image representation of drag data. May return NULL if no image 201 // representation is available. 202 /// 203 /*--cef()--*/ 204 virtual CefRefPtr<CefImage> GetImage() = 0; 205 206 /// 207 // Get the image hotspot (drag start location relative to image dimensions). 208 /// 209 /*--cef()--*/ 210 virtual CefPoint GetImageHotspot() = 0; 211 212 /// 213 // Returns true if an image representation of drag data is available. 214 /// 215 /*--cef()--*/ 216 virtual bool HasImage() = 0; 217 }; 218 219 #endif // CEF_INCLUDE_CEF_DRAG_DATA_H_ 220