OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "webkit/glue/webclipboard_impl.h" | 5 #include "webkit/glue/webclipboard_impl.h" |
6 | 6 |
7 #include "base/clipboard.h" | 7 #include "base/clipboard.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.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 "webkit/api/public/WebImage.h" | 13 #include "webkit/api/public/WebImage.h" |
| 14 #include "webkit/api/public/WebSize.h" |
13 #include "webkit/api/public/WebString.h" | 15 #include "webkit/api/public/WebString.h" |
14 #include "webkit/api/public/WebURL.h" | 16 #include "webkit/api/public/WebURL.h" |
15 #include "webkit/glue/scoped_clipboard_writer_glue.h" | 17 #include "webkit/glue/scoped_clipboard_writer_glue.h" |
16 #include "webkit/glue/webkit_glue.h" | 18 #include "webkit/glue/webkit_glue.h" |
17 | 19 |
| 20 #if WEBKIT_USING_CG |
| 21 #include "skia/ext/skia_utils_mac.h" |
| 22 #endif |
| 23 |
18 using WebKit::WebClipboard; | 24 using WebKit::WebClipboard; |
19 using WebKit::WebImage; | 25 using WebKit::WebImage; |
20 using WebKit::WebString; | 26 using WebKit::WebString; |
21 using WebKit::WebURL; | 27 using WebKit::WebURL; |
22 | 28 |
23 namespace webkit_glue { | 29 namespace webkit_glue { |
24 | 30 |
25 // Static | 31 // Static |
26 std::string WebClipboardImpl::URLToMarkup(const WebURL& url, | 32 std::string WebClipboardImpl::URLToMarkup(const WebURL& url, |
27 const WebString& title) { | 33 const WebString& title) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 120 |
115 scw.WriteBookmark(title, url.spec()); | 121 scw.WriteBookmark(title, url.spec()); |
116 scw.WriteHTML(UTF8ToUTF16(URLToMarkup(url, title)), ""); | 122 scw.WriteHTML(UTF8ToUTF16(URLToMarkup(url, title)), ""); |
117 scw.WriteText(UTF8ToUTF16(url.spec())); | 123 scw.WriteText(UTF8ToUTF16(url.spec())); |
118 } | 124 } |
119 | 125 |
120 void WebClipboardImpl::writeImage( | 126 void WebClipboardImpl::writeImage( |
121 const WebImage& image, const WebURL& url, const WebString& title) { | 127 const WebImage& image, const WebURL& url, const WebString& title) { |
122 ScopedClipboardWriterGlue scw(ClipboardGetClipboard()); | 128 ScopedClipboardWriterGlue scw(ClipboardGetClipboard()); |
123 | 129 |
124 #if defined(OS_WIN) || defined(OS_LINUX) | 130 if (!image.isNull()) { |
125 if (!image.isNull()) | 131 #if WEBKIT_USING_SKIA |
126 scw.WriteBitmapFromPixels(image.pixels(), image.size()); | 132 const SkBitmap& bitmap = image.getSkBitmap(); |
| 133 #elif WEBKIT_USING_CG |
| 134 const SkBitmap& bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); |
127 #endif | 135 #endif |
| 136 SkAutoLockPixels locked(bitmap); |
| 137 scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size()); |
| 138 } |
128 | 139 |
129 if (!url.isEmpty()) { | 140 if (!url.isEmpty()) { |
130 scw.WriteBookmark(title, url.spec()); | 141 scw.WriteBookmark(title, url.spec()); |
131 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), ""); | 142 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), ""); |
132 scw.WriteText(UTF8ToUTF16(url.spec())); | 143 scw.WriteText(UTF8ToUTF16(url.spec())); |
133 } | 144 } |
134 } | 145 } |
135 | 146 |
136 } // namespace webkit_glue | 147 } // namespace webkit_glue |
OLD | NEW |