OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ | 5 #ifndef UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ |
6 #define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ | 6 #define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
76 FILE_CONTENTS = 1 << 4, | 76 FILE_CONTENTS = 1 << 4, |
77 #endif | 77 #endif |
78 #if defined(OS_WIN) || defined(USE_AURA) | 78 #if defined(OS_WIN) || defined(USE_AURA) |
79 HTML = 1 << 5, | 79 HTML = 1 << 5, |
80 #endif | 80 #endif |
81 }; | 81 }; |
82 | 82 |
83 // Encapsulates the info about a file to be downloaded. | 83 // Encapsulates the info about a file to be downloaded. |
84 struct UI_EXPORT DownloadFileInfo { | 84 struct UI_EXPORT DownloadFileInfo { |
85 DownloadFileInfo(const FilePath& filename, | 85 DownloadFileInfo(const base::FilePath& filename, |
86 DownloadFileProvider* downloader); | 86 DownloadFileProvider* downloader); |
87 ~DownloadFileInfo(); | 87 ~DownloadFileInfo(); |
88 | 88 |
89 FilePath filename; | 89 base::FilePath filename; |
90 scoped_refptr<DownloadFileProvider> downloader; | 90 scoped_refptr<DownloadFileProvider> downloader; |
91 }; | 91 }; |
92 | 92 |
93 // Encapsulates the info about a file. | 93 // Encapsulates the info about a file. |
94 struct UI_EXPORT FileInfo { | 94 struct UI_EXPORT FileInfo { |
95 FileInfo(const FilePath& path, const FilePath& display_name); | 95 FileInfo(const base::FilePath& path, const base::FilePath& display_name); |
96 ~FileInfo(); | 96 ~FileInfo(); |
97 | 97 |
98 // The path of the file. | 98 // The path of the file. |
99 FilePath path; | 99 base::FilePath path; |
100 // The display name of the file. This field is optional. | 100 // The display name of the file. This field is optional. |
101 FilePath display_name; | 101 base::FilePath display_name; |
102 }; | 102 }; |
103 | 103 |
104 // Provider defines the platform specific part of OSExchangeData that | 104 // Provider defines the platform specific part of OSExchangeData that |
105 // interacts with the native system. | 105 // interacts with the native system. |
106 class UI_EXPORT Provider { | 106 class UI_EXPORT Provider { |
107 public: | 107 public: |
108 Provider() {} | 108 Provider() {} |
109 virtual ~Provider() {} | 109 virtual ~Provider() {} |
110 | 110 |
111 virtual void SetString(const string16& data) = 0; | 111 virtual void SetString(const string16& data) = 0; |
112 virtual void SetURL(const GURL& url, const string16& title) = 0; | 112 virtual void SetURL(const GURL& url, const string16& title) = 0; |
113 virtual void SetFilename(const FilePath& path) = 0; | 113 virtual void SetFilename(const base::FilePath& path) = 0; |
114 virtual void SetFilenames( | 114 virtual void SetFilenames( |
115 const std::vector<FileInfo>& file_names) = 0; | 115 const std::vector<FileInfo>& file_names) = 0; |
116 virtual void SetPickledData(CustomFormat format, const Pickle& data) = 0; | 116 virtual void SetPickledData(CustomFormat format, const Pickle& data) = 0; |
117 | 117 |
118 virtual bool GetString(string16* data) const = 0; | 118 virtual bool GetString(string16* data) const = 0; |
119 virtual bool GetURLAndTitle(GURL* url, string16* title) const = 0; | 119 virtual bool GetURLAndTitle(GURL* url, string16* title) const = 0; |
120 virtual bool GetFilename(FilePath* path) const = 0; | 120 virtual bool GetFilename(base::FilePath* path) const = 0; |
121 virtual bool GetFilenames( | 121 virtual bool GetFilenames( |
122 std::vector<FileInfo>* file_names) const = 0; | 122 std::vector<FileInfo>* file_names) const = 0; |
123 virtual bool GetPickledData(CustomFormat format, Pickle* data) const = 0; | 123 virtual bool GetPickledData(CustomFormat format, Pickle* data) const = 0; |
124 | 124 |
125 virtual bool HasString() const = 0; | 125 virtual bool HasString() const = 0; |
126 virtual bool HasURL() const = 0; | 126 virtual bool HasURL() const = 0; |
127 virtual bool HasFile() const = 0; | 127 virtual bool HasFile() const = 0; |
128 virtual bool HasCustomFormat( | 128 virtual bool HasCustomFormat( |
129 OSExchangeData::CustomFormat format) const = 0; | 129 OSExchangeData::CustomFormat format) const = 0; |
130 | 130 |
131 #if defined(OS_WIN) | 131 #if defined(OS_WIN) |
132 virtual void SetFileContents(const FilePath& filename, | 132 virtual void SetFileContents(const base::FilePath& filename, |
133 const std::string& file_contents) = 0; | 133 const std::string& file_contents) = 0; |
134 virtual bool GetFileContents(FilePath* filename, | 134 virtual bool GetFileContents(base::FilePath* filename, |
135 std::string* file_contents) const = 0; | 135 std::string* file_contents) const = 0; |
136 virtual bool HasFileContents() const = 0; | 136 virtual bool HasFileContents() const = 0; |
137 virtual void SetDownloadFileInfo(const DownloadFileInfo& download) = 0; | 137 virtual void SetDownloadFileInfo(const DownloadFileInfo& download) = 0; |
138 #endif | 138 #endif |
139 | 139 |
140 #if defined(OS_WIN) || defined(USE_AURA) | 140 #if defined(OS_WIN) || defined(USE_AURA) |
141 virtual void SetHtml(const string16& html, const GURL& base_url) = 0; | 141 virtual void SetHtml(const string16& html, const GURL& base_url) = 0; |
142 virtual bool GetHtml(string16* html, GURL* base_url) const = 0; | 142 virtual bool GetHtml(string16* html, GURL* base_url) const = 0; |
143 virtual bool HasHtml() const = 0; | 143 virtual bool HasHtml() const = 0; |
144 #endif | 144 #endif |
(...skipping 30 matching lines...) Expand all Loading... |
175 // following types of data. In cases where more data is held, the | 175 // following types of data. In cases where more data is held, the |
176 // order in which these functions are called is _important_! | 176 // order in which these functions are called is _important_! |
177 // ---> The order types are added to an OSExchangeData object controls | 177 // ---> The order types are added to an OSExchangeData object controls |
178 // the order of enumeration in our IEnumFORMATETC implementation! | 178 // the order of enumeration in our IEnumFORMATETC implementation! |
179 // This comes into play when selecting the best (most preferable) | 179 // This comes into play when selecting the best (most preferable) |
180 // data type for insertion into a DropTarget. | 180 // data type for insertion into a DropTarget. |
181 void SetString(const string16& data); | 181 void SetString(const string16& data); |
182 // A URL can have an optional title in some exchange formats. | 182 // A URL can have an optional title in some exchange formats. |
183 void SetURL(const GURL& url, const string16& title); | 183 void SetURL(const GURL& url, const string16& title); |
184 // A full path to a file. | 184 // A full path to a file. |
185 void SetFilename(const FilePath& path); | 185 void SetFilename(const base::FilePath& path); |
186 // Full path to one or more files. See also SetFilenames() in Provider. | 186 // Full path to one or more files. See also SetFilenames() in Provider. |
187 void SetFilenames( | 187 void SetFilenames( |
188 const std::vector<FileInfo>& file_names); | 188 const std::vector<FileInfo>& file_names); |
189 // Adds pickled data of the specified format. | 189 // Adds pickled data of the specified format. |
190 void SetPickledData(CustomFormat format, const Pickle& data); | 190 void SetPickledData(CustomFormat format, const Pickle& data); |
191 | 191 |
192 // These functions retrieve data of the specified type. If data exists, the | 192 // These functions retrieve data of the specified type. If data exists, the |
193 // functions return and the result is in the out parameter. If the data does | 193 // functions return and the result is in the out parameter. If the data does |
194 // not exist, the out parameter is not touched. The out parameter cannot be | 194 // not exist, the out parameter is not touched. The out parameter cannot be |
195 // NULL. | 195 // NULL. |
196 bool GetString(string16* data) const; | 196 bool GetString(string16* data) const; |
197 bool GetURLAndTitle(GURL* url, string16* title) const; | 197 bool GetURLAndTitle(GURL* url, string16* title) const; |
198 // Return the path of a file, if available. | 198 // Return the path of a file, if available. |
199 bool GetFilename(FilePath* path) const; | 199 bool GetFilename(base::FilePath* path) const; |
200 bool GetFilenames( | 200 bool GetFilenames( |
201 std::vector<FileInfo>* file_names) const; | 201 std::vector<FileInfo>* file_names) const; |
202 bool GetPickledData(CustomFormat format, Pickle* data) const; | 202 bool GetPickledData(CustomFormat format, Pickle* data) const; |
203 | 203 |
204 // Test whether or not data of certain types is present, without actually | 204 // Test whether or not data of certain types is present, without actually |
205 // returning anything. | 205 // returning anything. |
206 bool HasString() const; | 206 bool HasString() const; |
207 bool HasURL() const; | 207 bool HasURL() const; |
208 bool HasFile() const; | 208 bool HasFile() const; |
209 bool HasCustomFormat(CustomFormat format) const; | 209 bool HasCustomFormat(CustomFormat format) const; |
210 | 210 |
211 // Returns true if this OSExchangeData has data for ALL the formats in | 211 // Returns true if this OSExchangeData has data for ALL the formats in |
212 // |formats| and ALL the custom formats in |custom_formats|. | 212 // |formats| and ALL the custom formats in |custom_formats|. |
213 bool HasAllFormats(int formats, | 213 bool HasAllFormats(int formats, |
214 const std::set<CustomFormat>& custom_formats) const; | 214 const std::set<CustomFormat>& custom_formats) const; |
215 | 215 |
216 // Returns true if this OSExchangeData has data in any of the formats in | 216 // Returns true if this OSExchangeData has data in any of the formats in |
217 // |formats| or any custom format in |custom_formats|. | 217 // |formats| or any custom format in |custom_formats|. |
218 bool HasAnyFormat(int formats, | 218 bool HasAnyFormat(int formats, |
219 const std::set<CustomFormat>& custom_formats) const; | 219 const std::set<CustomFormat>& custom_formats) const; |
220 | 220 |
221 #if defined(OS_WIN) | 221 #if defined(OS_WIN) |
222 // Adds the bytes of a file (CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR). | 222 // Adds the bytes of a file (CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR). |
223 void SetFileContents(const FilePath& filename, | 223 void SetFileContents(const base::FilePath& filename, |
224 const std::string& file_contents); | 224 const std::string& file_contents); |
225 bool GetFileContents(FilePath* filename, | 225 bool GetFileContents(base::FilePath* filename, |
226 std::string* file_contents) const; | 226 std::string* file_contents) const; |
227 | 227 |
228 // Adds a download file with full path (CF_HDROP). | 228 // Adds a download file with full path (CF_HDROP). |
229 void SetDownloadFileInfo(const DownloadFileInfo& download); | 229 void SetDownloadFileInfo(const DownloadFileInfo& download); |
230 #endif | 230 #endif |
231 | 231 |
232 #if defined(OS_WIN) || defined(USE_AURA) | 232 #if defined(OS_WIN) || defined(USE_AURA) |
233 // Adds a snippet of HTML. |html| is just raw html but this sets both | 233 // Adds a snippet of HTML. |html| is just raw html but this sets both |
234 // text/html and CF_HTML. | 234 // text/html and CF_HTML. |
235 void SetHtml(const string16& html, const GURL& base_url); | 235 void SetHtml(const string16& html, const GURL& base_url); |
236 bool GetHtml(string16* html, GURL* base_url) const; | 236 bool GetHtml(string16* html, GURL* base_url) const; |
237 #endif | 237 #endif |
238 | 238 |
239 private: | 239 private: |
240 // Provides the actual data. | 240 // Provides the actual data. |
241 scoped_ptr<Provider> provider_; | 241 scoped_ptr<Provider> provider_; |
242 | 242 |
243 DISALLOW_COPY_AND_ASSIGN(OSExchangeData); | 243 DISALLOW_COPY_AND_ASSIGN(OSExchangeData); |
244 }; | 244 }; |
245 | 245 |
246 } // namespace ui | 246 } // namespace ui |
247 | 247 |
248 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ | 248 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ |
OLD | NEW |