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 #include "webkit/glue/webclipboard_impl.h" | 5 #include "webkit/glue/webclipboard_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/pickle.h" |
8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
10 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
11 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
20 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
| 22 #include "ui/base/clipboard/custom_data_helper.h" |
21 #include "webkit/glue/scoped_clipboard_writer_glue.h" | 23 #include "webkit/glue/scoped_clipboard_writer_glue.h" |
| 24 #include "webkit/glue/webdropdata.h" |
22 #include "webkit/glue/webkit_glue.h" | 25 #include "webkit/glue/webkit_glue.h" |
23 | 26 |
24 #if WEBKIT_USING_CG | 27 #if WEBKIT_USING_CG |
25 #include "skia/ext/skia_utils_mac.h" | 28 #include "skia/ext/skia_utils_mac.h" |
26 #endif | 29 #endif |
27 | 30 |
28 using WebKit::WebClipboard; | 31 using WebKit::WebClipboard; |
29 using WebKit::WebData; | 32 using WebKit::WebData; |
30 using WebKit::WebDragData; | 33 using WebKit::WebDragData; |
31 using WebKit::WebImage; | 34 using WebKit::WebImage; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 #endif | 239 #endif |
237 } | 240 } |
238 } | 241 } |
239 | 242 |
240 void WebClipboardImpl::writeDataObject(const WebDragData& data) { | 243 void WebClipboardImpl::writeDataObject(const WebDragData& data) { |
241 // TODO(dcheng): This actually results in a double clear of the clipboard. | 244 // TODO(dcheng): This actually results in a double clear of the clipboard. |
242 // Once in WebKit, and once here when the clipboard writer goes out of scope. | 245 // Once in WebKit, and once here when the clipboard writer goes out of scope. |
243 // The same is true of the other WebClipboard::write* methods. | 246 // The same is true of the other WebClipboard::write* methods. |
244 ScopedClipboardWriterGlue scw(client_); | 247 ScopedClipboardWriterGlue scw(client_); |
245 | 248 |
| 249 WebDropData data_object(data); |
246 // TODO(dcheng): Properly support text/uri-list here. | 250 // TODO(dcheng): Properly support text/uri-list here. |
247 scw.WriteText(data.plainText()); | 251 scw.WriteText(data_object.plain_text); |
248 scw.WriteHTML(data.htmlText(), ""); | 252 scw.WriteHTML(data_object.text_html, ""); |
| 253 Pickle pickle; |
| 254 ui::WriteCustomDataToPickle(data_object.custom_data, &pickle); |
| 255 scw.WritePickledData(pickle, ui::Clipboard::GetWebCustomDataFormatType()); |
249 } | 256 } |
250 | 257 |
251 bool WebClipboardImpl::ConvertBufferType(Buffer buffer, | 258 bool WebClipboardImpl::ConvertBufferType(Buffer buffer, |
252 ui::Clipboard::Buffer* result) { | 259 ui::Clipboard::Buffer* result) { |
253 switch (buffer) { | 260 switch (buffer) { |
254 case BufferStandard: | 261 case BufferStandard: |
255 *result = ui::Clipboard::BUFFER_STANDARD; | 262 *result = ui::Clipboard::BUFFER_STANDARD; |
256 break; | 263 break; |
257 case BufferSelection: | 264 case BufferSelection: |
258 #if defined(USE_X11) && !defined(USE_AURA) | 265 #if defined(USE_X11) && !defined(USE_AURA) |
259 *result = ui::Clipboard::BUFFER_SELECTION; | 266 *result = ui::Clipboard::BUFFER_SELECTION; |
260 break; | 267 break; |
261 #endif | 268 #endif |
262 default: | 269 default: |
263 NOTREACHED(); | 270 NOTREACHED(); |
264 return false; | 271 return false; |
265 } | 272 } |
266 return true; | 273 return true; |
267 } | 274 } |
268 | 275 |
269 } // namespace webkit_glue | 276 } // namespace webkit_glue |
OLD | NEW |