Chromium Code Reviews| 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/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" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 if (!image.isNull()) { | 172 if (!image.isNull()) { |
| 173 #if WEBKIT_USING_SKIA | 173 #if WEBKIT_USING_SKIA |
| 174 const SkBitmap& bitmap = image.getSkBitmap(); | 174 const SkBitmap& bitmap = image.getSkBitmap(); |
| 175 #elif WEBKIT_USING_CG | 175 #elif WEBKIT_USING_CG |
| 176 const SkBitmap& bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); | 176 const SkBitmap& bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); |
| 177 #endif | 177 #endif |
| 178 SkAutoLockPixels locked(bitmap); | 178 SkAutoLockPixels locked(bitmap); |
| 179 scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size()); | 179 scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 // When writing the image, we also write the image markup so that pasting | |
| 183 // into rich text editors, such as Gmail, reveals the image. We also don't | |
| 184 // want to call writeText(), since some applications (WordPad) don't pick the | |
| 185 // image if there is also a text format on the clipboard. | |
| 186 if (!url.isEmpty()) { | 182 if (!url.isEmpty()) { |
| 187 scw.WriteBookmark(title, url.spec()); | 183 scw.WriteBookmark(title, url.spec()); |
| 184 #if !defined(OS_MACOSX) | |
| 185 // When writing the image, we also write the image markup so that pasting | |
| 186 // into rich text editors, such as Gmail, reveals the image. We also don't | |
| 187 // want to call writeText(), since some applications (WordPad) don't pick | |
| 188 // the image if there is also a text format on the clipboard. | |
| 189 // We also don't want to write HTML on a Mac, since Mail.app prefers to use | |
| 190 // the image markup over attaching the actual image. | |
|
Nico
2011/06/09 16:11:38
nit: Maybe add "See http://crbug.com/33016"
| |
| 188 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), ""); | 191 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), ""); |
| 192 #endif | |
| 189 } | 193 } |
| 190 } | 194 } |
| 191 | 195 |
| 192 void WebClipboardImpl::writeData(const WebString& type, | 196 void WebClipboardImpl::writeData(const WebString& type, |
| 193 const WebString& data, | 197 const WebString& data, |
| 194 const WebString& metadata) { | 198 const WebString& metadata) { |
| 195 // TODO(dcheng): Implement this stub. | 199 // TODO(dcheng): Implement this stub. |
| 196 } | 200 } |
| 197 | 201 |
| 198 WebVector<WebString> WebClipboardImpl::readAvailableTypes( | 202 WebVector<WebString> WebClipboardImpl::readAvailableTypes( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 break; | 248 break; |
| 245 #endif | 249 #endif |
| 246 default: | 250 default: |
| 247 NOTREACHED(); | 251 NOTREACHED(); |
| 248 return false; | 252 return false; |
| 249 } | 253 } |
| 250 return true; | 254 return true; |
| 251 } | 255 } |
| 252 | 256 |
| 253 } // namespace webkit_glue | 257 } // namespace webkit_glue |
| OLD | NEW |