Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: webkit/glue/webclipboard_impl.cc

Issue 8591034: Implement WebClipboard::writeDataObject. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webclipboard_impl.h ('k') | webkit/tools/test_shell/mock_webclipboard_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
19 #include "ui/base/clipboard/clipboard.h" 20 #include "ui/base/clipboard/clipboard.h"
20 #include "webkit/glue/scoped_clipboard_writer_glue.h" 21 #include "webkit/glue/scoped_clipboard_writer_glue.h"
21 #include "webkit/glue/webkit_glue.h" 22 #include "webkit/glue/webkit_glue.h"
22 23
23 #if WEBKIT_USING_CG 24 #if WEBKIT_USING_CG
24 #include "skia/ext/skia_utils_mac.h" 25 #include "skia/ext/skia_utils_mac.h"
25 #endif 26 #endif
26 27
27 using WebKit::WebClipboard; 28 using WebKit::WebClipboard;
28 using WebKit::WebData; 29 using WebKit::WebData;
30 using WebKit::WebDragData;
29 using WebKit::WebImage; 31 using WebKit::WebImage;
30 using WebKit::WebString; 32 using WebKit::WebString;
31 using WebKit::WebURL; 33 using WebKit::WebURL;
32 using WebKit::WebVector; 34 using WebKit::WebVector;
33 35
34 namespace webkit_glue { 36 namespace webkit_glue {
35 37
36 // Static 38 // Static
37 std::string WebClipboardImpl::URLToMarkup(const WebURL& url, 39 std::string WebClipboardImpl::URLToMarkup(const WebURL& url,
38 const WebString& title) { 40 const WebString& title) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // want to call writeText(), since some applications (WordPad) don't pick 215 // want to call writeText(), since some applications (WordPad) don't pick
214 // the image if there is also a text format on the clipboard. 216 // the image if there is also a text format on the clipboard.
215 // We also don't want to write HTML on a Mac, since Mail.app prefers to use 217 // We also don't want to write HTML on a Mac, since Mail.app prefers to use
216 // the image markup over attaching the actual image. See 218 // the image markup over attaching the actual image. See
217 // http://crbug.com/33016 for details. 219 // http://crbug.com/33016 for details.
218 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), ""); 220 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), "");
219 #endif 221 #endif
220 } 222 }
221 } 223 }
222 224
225 void WebClipboardImpl::writeDataObject(const WebDragData& data) {
226 // TODO(dcheng): This actually results in a double clear of the clipboard.
227 // Once in WebKit, and once here when the clipboard writer goes out of scope.
228 // The same is true of the other WebClipboard::write* methods.
229 ScopedClipboardWriterGlue scw(ClipboardGetClipboard());
230
231 // TODO(dcheng): Properly support text/uri-list here.
232 scw.WriteText(data.plainText());
233 scw.WriteHTML(data.htmlText(), "");
234 }
235
223 bool WebClipboardImpl::ConvertBufferType(Buffer buffer, 236 bool WebClipboardImpl::ConvertBufferType(Buffer buffer,
224 ui::Clipboard::Buffer* result) { 237 ui::Clipboard::Buffer* result) {
225 switch (buffer) { 238 switch (buffer) {
226 case BufferStandard: 239 case BufferStandard:
227 *result = ui::Clipboard::BUFFER_STANDARD; 240 *result = ui::Clipboard::BUFFER_STANDARD;
228 break; 241 break;
229 case BufferSelection: 242 case BufferSelection:
230 #if defined(USE_X11) && !defined(USE_AURA) 243 #if defined(USE_X11) && !defined(USE_AURA)
231 *result = ui::Clipboard::BUFFER_SELECTION; 244 *result = ui::Clipboard::BUFFER_SELECTION;
232 break; 245 break;
233 #endif 246 #endif
234 default: 247 default:
235 NOTREACHED(); 248 NOTREACHED();
236 return false; 249 return false;
237 } 250 }
238 return true; 251 return true;
239 } 252 }
240 253
241 } // namespace webkit_glue 254 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webclipboard_impl.h ('k') | webkit/tools/test_shell/mock_webclipboard_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698