OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
15 #include <objidl.h> | 15 #include <objidl.h> |
16 #elif !defined(OS_MACOSX) | 16 #elif !defined(OS_MACOSX) |
17 #include <gtk/gtk.h> | 17 #include <gtk/gtk.h> |
18 #endif | 18 #endif |
19 | 19 |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "base/file_path.h" | 21 #include "base/file_path.h" |
22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
23 #include "ui/base/dragdrop/download_file_interface.h" | 23 #include "ui/base/dragdrop/download_file_interface.h" |
| 24 #include "ui/ui_api.h" |
24 | 25 |
25 class GURL; | 26 class GURL; |
26 class Pickle; | 27 class Pickle; |
27 | 28 |
28 namespace ui { | 29 namespace ui { |
29 | 30 |
30 /////////////////////////////////////////////////////////////////////////////// | 31 /////////////////////////////////////////////////////////////////////////////// |
31 // | 32 // |
32 // OSExchangeData | 33 // OSExchangeData |
33 // An object that holds interchange data to be sent out to OS services like | 34 // An object that holds interchange data to be sent out to OS services like |
34 // clipboard, drag and drop, etc. This object exposes an API that clients can | 35 // clipboard, drag and drop, etc. This object exposes an API that clients can |
35 // use to specify raw data and its high level type. This object takes care of | 36 // use to specify raw data and its high level type. This object takes care of |
36 // translating that into something the OS can understand. | 37 // translating that into something the OS can understand. |
37 // | 38 // |
38 /////////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////////// |
39 | 40 |
40 // NOTE: Support for html and file contents is required by TabContentViewWin. | 41 // NOTE: Support for html and file contents is required by TabContentViewWin. |
41 // TabContentsViewGtk uses a different class to handle drag support that does | 42 // TabContentsViewGtk uses a different class to handle drag support that does |
42 // not use OSExchangeData. As such, file contents and html support is only | 43 // not use OSExchangeData. As such, file contents and html support is only |
43 // compiled on windows. | 44 // compiled on windows. |
44 class OSExchangeData { | 45 class UI_API OSExchangeData { |
45 public: | 46 public: |
46 // CustomFormats are used for non-standard data types. For example, bookmark | 47 // CustomFormats are used for non-standard data types. For example, bookmark |
47 // nodes are written using a CustomFormat. | 48 // nodes are written using a CustomFormat. |
48 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
49 typedef CLIPFORMAT CustomFormat; | 50 typedef CLIPFORMAT CustomFormat; |
50 #elif !defined(OS_MACOSX) | 51 #elif !defined(OS_MACOSX) |
51 typedef GdkAtom CustomFormat; | 52 typedef GdkAtom CustomFormat; |
52 #endif | 53 #endif |
53 | 54 |
54 // Enumeration of the known formats. | 55 // Enumeration of the known formats. |
55 enum Format { | 56 enum Format { |
56 STRING = 1 << 0, | 57 STRING = 1 << 0, |
57 URL = 1 << 1, | 58 URL = 1 << 1, |
58 FILE_NAME = 1 << 2, | 59 FILE_NAME = 1 << 2, |
59 PICKLED_DATA = 1 << 3, | 60 PICKLED_DATA = 1 << 3, |
60 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
61 FILE_CONTENTS = 1 << 4, | 62 FILE_CONTENTS = 1 << 4, |
62 HTML = 1 << 5, | 63 HTML = 1 << 5, |
63 #endif | 64 #endif |
64 }; | 65 }; |
65 | 66 |
66 // Encapsulates the info about a file to be downloaded. | 67 // Encapsulates the info about a file to be downloaded. |
67 struct DownloadFileInfo { | 68 struct UI_API DownloadFileInfo { |
68 DownloadFileInfo(const FilePath& filename, | 69 DownloadFileInfo(const FilePath& filename, |
69 DownloadFileProvider* downloader); | 70 DownloadFileProvider* downloader); |
70 ~DownloadFileInfo(); | 71 ~DownloadFileInfo(); |
71 | 72 |
72 FilePath filename; | 73 FilePath filename; |
73 scoped_refptr<DownloadFileProvider> downloader; | 74 scoped_refptr<DownloadFileProvider> downloader; |
74 }; | 75 }; |
75 | 76 |
76 // Provider defines the platform specific part of OSExchangeData that | 77 // Provider defines the platform specific part of OSExchangeData that |
77 // interacts with the native system. | 78 // interacts with the native system. |
78 class Provider { | 79 class UI_API Provider { |
79 public: | 80 public: |
80 Provider() {} | 81 Provider() {} |
81 virtual ~Provider() {} | 82 virtual ~Provider() {} |
82 | 83 |
83 virtual void SetString(const string16& data) = 0; | 84 virtual void SetString(const string16& data) = 0; |
84 virtual void SetURL(const GURL& url, const string16& title) = 0; | 85 virtual void SetURL(const GURL& url, const string16& title) = 0; |
85 virtual void SetFilename(const FilePath& path) = 0; | 86 virtual void SetFilename(const FilePath& path) = 0; |
86 virtual void SetPickledData(CustomFormat format, const Pickle& data) = 0; | 87 virtual void SetPickledData(CustomFormat format, const Pickle& data) = 0; |
87 | 88 |
88 virtual bool GetString(string16* data) const = 0; | 89 virtual bool GetString(string16* data) const = 0; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 190 |
190 // Provides the actual data. | 191 // Provides the actual data. |
191 scoped_ptr<Provider> provider_; | 192 scoped_ptr<Provider> provider_; |
192 | 193 |
193 DISALLOW_COPY_AND_ASSIGN(OSExchangeData); | 194 DISALLOW_COPY_AND_ASSIGN(OSExchangeData); |
194 }; | 195 }; |
195 | 196 |
196 } // namespace ui | 197 } // namespace ui |
197 | 198 |
198 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ | 199 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_H_ |
OLD | NEW |