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> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
14 #include <objidl.h> | 14 #include <objidl.h> |
15 #elif defined(TOOLKIT_GTK) | 15 #elif defined(TOOLKIT_GTK) |
16 #include <gtk/gtk.h> | 16 #include <gtk/gtk.h> |
17 #endif | 17 #endif |
18 | 18 |
19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
20 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "ui/base/clipboard/clipboard.h" | 22 #include "ui/base/clipboard/clipboard.h" |
23 #include "ui/base/dragdrop/download_file_interface.h" | 23 #include "ui/base/dragdrop/download_file_interface.h" |
24 #include "ui/base/ui_export.h" | 24 #include "ui/base/ui_base_export.h" |
25 | 25 |
26 class GURL; | 26 class GURL; |
27 class Pickle; | 27 class Pickle; |
28 | 28 |
29 namespace gfx { | 29 namespace gfx { |
30 class ImageSkia; | 30 class ImageSkia; |
31 class Vector2d; | 31 class Vector2d; |
32 } | 32 } |
33 | 33 |
34 namespace ui { | 34 namespace ui { |
35 | 35 |
36 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
37 // | 37 // |
38 // OSExchangeData | 38 // OSExchangeData |
39 // An object that holds interchange data to be sent out to OS services like | 39 // An object that holds interchange data to be sent out to OS services like |
40 // clipboard, drag and drop, etc. This object exposes an API that clients can | 40 // clipboard, drag and drop, etc. This object exposes an API that clients can |
41 // use to specify raw data and its high level type. This object takes care of | 41 // use to specify raw data and its high level type. This object takes care of |
42 // translating that into something the OS can understand. | 42 // translating that into something the OS can understand. |
43 // | 43 // |
44 /////////////////////////////////////////////////////////////////////////////// | 44 /////////////////////////////////////////////////////////////////////////////// |
45 | 45 |
46 // NOTE: Support for html and file contents is required by TabContentViewWin. | 46 // NOTE: Support for html and file contents is required by TabContentViewWin. |
47 // TabContentsViewGtk uses a different class to handle drag support that does | 47 // TabContentsViewGtk uses a different class to handle drag support that does |
48 // not use OSExchangeData. As such, file contents and html support is only | 48 // not use OSExchangeData. As such, file contents and html support is only |
49 // compiled on windows. | 49 // compiled on windows. |
50 class UI_EXPORT OSExchangeData { | 50 class UI_BASE_EXPORT OSExchangeData { |
51 public: | 51 public: |
52 // CustomFormats are used for non-standard data types. For example, bookmark | 52 // CustomFormats are used for non-standard data types. For example, bookmark |
53 // nodes are written using a CustomFormat. | 53 // nodes are written using a CustomFormat. |
54 // TODO(dcheng): Remove this completely and just use Clipboard::FormatType. | 54 // TODO(dcheng): Remove this completely and just use Clipboard::FormatType. |
55 typedef Clipboard::FormatType CustomFormat; | 55 typedef Clipboard::FormatType CustomFormat; |
56 | 56 |
57 // Enumeration of the known formats. | 57 // Enumeration of the known formats. |
58 enum Format { | 58 enum Format { |
59 STRING = 1 << 0, | 59 STRING = 1 << 0, |
60 URL = 1 << 1, | 60 URL = 1 << 1, |
61 FILE_NAME = 1 << 2, | 61 FILE_NAME = 1 << 2, |
62 PICKLED_DATA = 1 << 3, | 62 PICKLED_DATA = 1 << 3, |
63 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
64 FILE_CONTENTS = 1 << 4, | 64 FILE_CONTENTS = 1 << 4, |
65 #endif | 65 #endif |
66 #if defined(OS_WIN) || defined(USE_AURA) | 66 #if defined(OS_WIN) || defined(USE_AURA) |
67 HTML = 1 << 5, | 67 HTML = 1 << 5, |
68 #endif | 68 #endif |
69 }; | 69 }; |
70 | 70 |
71 // Encapsulates the info about a file to be downloaded. | 71 // Encapsulates the info about a file to be downloaded. |
72 struct UI_EXPORT DownloadFileInfo { | 72 struct UI_BASE_EXPORT DownloadFileInfo { |
73 DownloadFileInfo(const base::FilePath& filename, | 73 DownloadFileInfo(const base::FilePath& filename, |
74 DownloadFileProvider* downloader); | 74 DownloadFileProvider* downloader); |
75 ~DownloadFileInfo(); | 75 ~DownloadFileInfo(); |
76 | 76 |
77 base::FilePath filename; | 77 base::FilePath filename; |
78 scoped_refptr<DownloadFileProvider> downloader; | 78 scoped_refptr<DownloadFileProvider> downloader; |
79 }; | 79 }; |
80 | 80 |
81 // Encapsulates the info about a file. | 81 // Encapsulates the info about a file. |
82 struct UI_EXPORT FileInfo { | 82 struct UI_BASE_EXPORT FileInfo { |
83 FileInfo(const base::FilePath& path, const base::FilePath& display_name); | 83 FileInfo(const base::FilePath& path, const base::FilePath& display_name); |
84 ~FileInfo(); | 84 ~FileInfo(); |
85 | 85 |
86 // The path of the file. | 86 // The path of the file. |
87 base::FilePath path; | 87 base::FilePath path; |
88 // The display name of the file. This field is optional. | 88 // The display name of the file. This field is optional. |
89 base::FilePath display_name; | 89 base::FilePath display_name; |
90 }; | 90 }; |
91 | 91 |
92 // Provider defines the platform specific part of OSExchangeData that | 92 // Provider defines the platform specific part of OSExchangeData that |
93 // interacts with the native system. | 93 // interacts with the native system. |
94 class UI_EXPORT Provider { | 94 class UI_BASE_EXPORT Provider { |
95 public: | 95 public: |
96 Provider() {} | 96 Provider() {} |
97 virtual ~Provider() {} | 97 virtual ~Provider() {} |
98 | 98 |
99 virtual Provider* Clone() const = 0; | 99 virtual Provider* Clone() const = 0; |
100 | 100 |
101 virtual void SetString(const base::string16& data) = 0; | 101 virtual void SetString(const base::string16& data) = 0; |
102 virtual void SetURL(const GURL& url, const base::string16& title) = 0; | 102 virtual void SetURL(const GURL& url, const base::string16& title) = 0; |
103 virtual void SetFilename(const base::FilePath& path) = 0; | 103 virtual void SetFilename(const base::FilePath& path) = 0; |
104 virtual void SetFilenames( | 104 virtual void SetFilenames( |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 private: | 230 private: |
231 // Provides the actual data. | 231 // Provides the actual data. |
232 scoped_ptr<Provider> provider_; | 232 scoped_ptr<Provider> provider_; |
233 | 233 |
234 DISALLOW_COPY_AND_ASSIGN(OSExchangeData); | 234 DISALLOW_COPY_AND_ASSIGN(OSExchangeData); |
235 }; | 235 }; |
236 | 236 |
237 } // namespace ui | 237 } // namespace ui |
238 | 238 |
239 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ | 239 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ |
OLD | NEW |