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_PROVIDER_WIN_H_ | 5 #ifndef UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_WIN_H_ |
6 #define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_WIN_H_ | 6 #define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_WIN_H_ |
7 | 7 |
8 #include <objidl.h> | 8 #include <objidl.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #include <string> | 10 #include <string> |
(...skipping 23 matching lines...) Expand all Loading... |
34 virtual void OnWaitForData() = 0; | 34 virtual void OnWaitForData() = 0; |
35 virtual void OnDataObjectDisposed() = 0; | 35 virtual void OnDataObjectDisposed() = 0; |
36 protected: | 36 protected: |
37 virtual ~Observer() { } | 37 virtual ~Observer() { } |
38 }; | 38 }; |
39 | 39 |
40 DataObjectImpl(); | 40 DataObjectImpl(); |
41 | 41 |
42 // Accessors. | 42 // Accessors. |
43 void set_observer(Observer* observer) { observer_ = observer; } | 43 void set_observer(Observer* observer) { observer_ = observer; } |
| 44 void set_in_drag_loop(bool in_drag_loop) { in_drag_loop_ = in_drag_loop; } |
44 | 45 |
45 // Number of known formats. | 46 // Number of known formats. |
46 size_t size() const { return contents_.size(); } | 47 size_t size() const { return contents_.size(); } |
47 | 48 |
48 // DownloadFileObserver implementation: | 49 // DownloadFileObserver implementation: |
49 virtual void OnDownloadCompleted(const base::FilePath& file_path); | 50 virtual void OnDownloadCompleted(const base::FilePath& file_path); |
50 virtual void OnDownloadAborted(); | 51 virtual void OnDownloadAborted(); |
51 | 52 |
52 // IDataObject implementation: | 53 // IDataObject implementation: |
53 HRESULT __stdcall GetData(FORMATETC* format_etc, STGMEDIUM* medium); | 54 HRESULT __stdcall GetData(FORMATETC* format_etc, STGMEDIUM* medium); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void StopDownloads(); | 88 void StopDownloads(); |
88 | 89 |
89 // Removes from contents_ the first data that matches |format|. | 90 // Removes from contents_ the first data that matches |format|. |
90 void RemoveData(const FORMATETC& format); | 91 void RemoveData(const FORMATETC& format); |
91 | 92 |
92 // Our internal representation of stored data & type info. | 93 // Our internal representation of stored data & type info. |
93 struct StoredDataInfo { | 94 struct StoredDataInfo { |
94 FORMATETC format_etc; | 95 FORMATETC format_etc; |
95 STGMEDIUM* medium; | 96 STGMEDIUM* medium; |
96 bool owns_medium; | 97 bool owns_medium; |
97 bool in_delay_rendering; | |
98 scoped_refptr<DownloadFileProvider> downloader; | 98 scoped_refptr<DownloadFileProvider> downloader; |
99 | 99 |
100 StoredDataInfo(CLIPFORMAT cf, STGMEDIUM* medium) | 100 StoredDataInfo(CLIPFORMAT cf, STGMEDIUM* medium) |
101 : medium(medium), | 101 : medium(medium), |
102 owns_medium(true), | 102 owns_medium(true) { |
103 in_delay_rendering(false) { | |
104 format_etc.cfFormat = cf; | 103 format_etc.cfFormat = cf; |
105 format_etc.dwAspect = DVASPECT_CONTENT; | 104 format_etc.dwAspect = DVASPECT_CONTENT; |
106 format_etc.lindex = -1; | 105 format_etc.lindex = -1; |
107 format_etc.ptd = NULL; | 106 format_etc.ptd = NULL; |
108 format_etc.tymed = medium ? medium->tymed : TYMED_HGLOBAL; | 107 format_etc.tymed = medium ? medium->tymed : TYMED_HGLOBAL; |
109 } | 108 } |
110 | 109 |
111 StoredDataInfo(FORMATETC* format_etc, STGMEDIUM* medium) | 110 StoredDataInfo(FORMATETC* format_etc, STGMEDIUM* medium) |
112 : format_etc(*format_etc), | 111 : format_etc(*format_etc), |
113 medium(medium), | 112 medium(medium), |
114 owns_medium(true), | 113 owns_medium(true) { |
115 in_delay_rendering(false) { | |
116 } | 114 } |
117 | 115 |
118 ~StoredDataInfo() { | 116 ~StoredDataInfo() { |
119 if (owns_medium) { | 117 if (owns_medium) { |
120 ReleaseStgMedium(medium); | 118 ReleaseStgMedium(medium); |
121 delete medium; | 119 delete medium; |
122 } | 120 } |
123 if (downloader.get()) | 121 if (downloader.get()) |
124 downloader->Stop(); | 122 downloader->Stop(); |
125 } | 123 } |
126 }; | 124 }; |
127 | 125 |
128 typedef std::vector<StoredDataInfo*> StoredData; | 126 typedef std::vector<StoredDataInfo*> StoredData; |
129 StoredData contents_; | 127 StoredData contents_; |
130 | 128 |
131 base::win::ScopedComPtr<IDataObject> source_object_; | 129 base::win::ScopedComPtr<IDataObject> source_object_; |
132 | 130 |
133 bool is_aborting_; | 131 bool is_aborting_; |
| 132 bool in_drag_loop_; |
134 bool in_async_mode_; | 133 bool in_async_mode_; |
135 bool async_operation_started_; | 134 bool async_operation_started_; |
136 Observer* observer_; | 135 Observer* observer_; |
137 }; | 136 }; |
138 | 137 |
139 class UI_EXPORT OSExchangeDataProviderWin : public OSExchangeData::Provider { | 138 class UI_EXPORT OSExchangeDataProviderWin : public OSExchangeData::Provider { |
140 public: | 139 public: |
141 // Returns true if source has plain text that is a valid url. | 140 // Returns true if source has plain text that is a valid url. |
142 static bool HasPlainTextURL(IDataObject* source); | 141 static bool HasPlainTextURL(IDataObject* source); |
143 | 142 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 std::string* file_contents) const; | 180 std::string* file_contents) const; |
182 virtual bool GetHtml(string16* html, GURL* base_url) const; | 181 virtual bool GetHtml(string16* html, GURL* base_url) const; |
183 virtual bool HasString() const; | 182 virtual bool HasString() const; |
184 virtual bool HasURL() const; | 183 virtual bool HasURL() const; |
185 virtual bool HasFile() const; | 184 virtual bool HasFile() const; |
186 virtual bool HasFileContents() const; | 185 virtual bool HasFileContents() const; |
187 virtual bool HasHtml() const; | 186 virtual bool HasHtml() const; |
188 virtual bool HasCustomFormat(OSExchangeData::CustomFormat format) const; | 187 virtual bool HasCustomFormat(OSExchangeData::CustomFormat format) const; |
189 virtual void SetDownloadFileInfo( | 188 virtual void SetDownloadFileInfo( |
190 const OSExchangeData::DownloadFileInfo& download_info); | 189 const OSExchangeData::DownloadFileInfo& download_info); |
| 190 virtual void SetInDragLoop(bool in_drag_loop) OVERRIDE; |
191 #if defined(USE_AURA) | 191 #if defined(USE_AURA) |
192 virtual void SetDragImage(const gfx::ImageSkia& image, | 192 virtual void SetDragImage(const gfx::ImageSkia& image, |
193 const gfx::Vector2d& cursor_offset) OVERRIDE; | 193 const gfx::Vector2d& cursor_offset) OVERRIDE; |
194 virtual const gfx::ImageSkia& GetDragImage() const OVERRIDE; | 194 virtual const gfx::ImageSkia& GetDragImage() const OVERRIDE; |
195 virtual const gfx::Vector2d& GetDragImageOffset() const OVERRIDE; | 195 virtual const gfx::Vector2d& GetDragImageOffset() const OVERRIDE; |
196 #endif | 196 #endif |
197 | 197 |
198 private: | 198 private: |
199 scoped_refptr<DataObjectImpl> data_; | 199 scoped_refptr<DataObjectImpl> data_; |
200 base::win::ScopedComPtr<IDataObject> source_object_; | 200 base::win::ScopedComPtr<IDataObject> source_object_; |
201 | 201 |
202 #if defined(USE_AURA) | 202 #if defined(USE_AURA) |
203 // Drag image and offset data. Only used for Ash. | 203 // Drag image and offset data. Only used for Ash. |
204 gfx::ImageSkia drag_image_; | 204 gfx::ImageSkia drag_image_; |
205 gfx::Vector2d drag_image_offset_; | 205 gfx::Vector2d drag_image_offset_; |
206 #endif | 206 #endif |
207 | 207 |
208 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderWin); | 208 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderWin); |
209 }; | 209 }; |
210 | 210 |
211 } // namespace ui | 211 } // namespace ui |
212 | 212 |
213 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_WIN_H_ | 213 #endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_WIN_H_ |
OLD | NEW |