| 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 #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/pickle.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 21 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
| 22 #include "ui/base/clipboard/custom_data_helper.h" | 22 #include "ui/base/clipboard/custom_data_helper.h" |
| 23 #include "webkit/glue/scoped_clipboard_writer_glue.h" | 23 #include "webkit/glue/scoped_clipboard_writer_glue.h" |
| 24 #include "webkit/glue/webdropdata.h" | 24 #include "webkit/glue/webdropdata.h" |
| 25 #include "webkit/glue/webkit_glue.h" | 25 #include "webkit/glue/webkit_glue.h" |
| 26 | 26 |
| 27 #if WEBKIT_USING_CG | |
| 28 #include "skia/ext/skia_utils_mac.h" | |
| 29 #endif | |
| 30 | |
| 31 using WebKit::WebClipboard; | 27 using WebKit::WebClipboard; |
| 32 using WebKit::WebData; | 28 using WebKit::WebData; |
| 33 using WebKit::WebDragData; | 29 using WebKit::WebDragData; |
| 34 using WebKit::WebImage; | 30 using WebKit::WebImage; |
| 35 using WebKit::WebString; | 31 using WebKit::WebString; |
| 36 using WebKit::WebURL; | 32 using WebKit::WebURL; |
| 37 using WebKit::WebVector; | 33 using WebKit::WebVector; |
| 38 | 34 |
| 39 namespace webkit_glue { | 35 namespace webkit_glue { |
| 40 | 36 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 scw.WriteBookmark(title, url.spec()); | 203 scw.WriteBookmark(title, url.spec()); |
| 208 scw.WriteHTML(UTF8ToUTF16(URLToMarkup(url, title)), ""); | 204 scw.WriteHTML(UTF8ToUTF16(URLToMarkup(url, title)), ""); |
| 209 scw.WriteText(UTF8ToUTF16(std::string(url.spec()))); | 205 scw.WriteText(UTF8ToUTF16(std::string(url.spec()))); |
| 210 } | 206 } |
| 211 | 207 |
| 212 void WebClipboardImpl::writeImage( | 208 void WebClipboardImpl::writeImage( |
| 213 const WebImage& image, const WebURL& url, const WebString& title) { | 209 const WebImage& image, const WebURL& url, const WebString& title) { |
| 214 ScopedClipboardWriterGlue scw(client_); | 210 ScopedClipboardWriterGlue scw(client_); |
| 215 | 211 |
| 216 if (!image.isNull()) { | 212 if (!image.isNull()) { |
| 217 #if WEBKIT_USING_SKIA | |
| 218 const SkBitmap& bitmap = image.getSkBitmap(); | 213 const SkBitmap& bitmap = image.getSkBitmap(); |
| 219 #elif WEBKIT_USING_CG | |
| 220 const SkBitmap& bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); | |
| 221 #endif | |
| 222 SkAutoLockPixels locked(bitmap); | 214 SkAutoLockPixels locked(bitmap); |
| 223 scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size()); | 215 scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size()); |
| 224 } | 216 } |
| 225 | 217 |
| 226 if (!url.isEmpty()) { | 218 if (!url.isEmpty()) { |
| 227 scw.WriteBookmark(title, url.spec()); | 219 scw.WriteBookmark(title, url.spec()); |
| 228 #if !defined(OS_MACOSX) | 220 #if !defined(OS_MACOSX) |
| 229 // When writing the image, we also write the image markup so that pasting | 221 // When writing the image, we also write the image markup so that pasting |
| 230 // into rich text editors, such as Gmail, reveals the image. We also don't | 222 // into rich text editors, such as Gmail, reveals the image. We also don't |
| 231 // want to call writeText(), since some applications (WordPad) don't pick | 223 // want to call writeText(), since some applications (WordPad) don't pick |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 break; | 261 break; |
| 270 #endif | 262 #endif |
| 271 default: | 263 default: |
| 272 NOTREACHED(); | 264 NOTREACHED(); |
| 273 return false; | 265 return false; |
| 274 } | 266 } |
| 275 return true; | 267 return true; |
| 276 } | 268 } |
| 277 | 269 |
| 278 } // namespace webkit_glue | 270 } // namespace webkit_glue |
| OLD | NEW |