OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/webclipboard_impl.h" | 5 #include "content/renderer/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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 scw.WriteWebSmartPaste(); | 148 scw.WriteWebSmartPaste(); |
149 } | 149 } |
150 | 150 |
151 void WebClipboardImpl::writeImage(const WebImage& image, | 151 void WebClipboardImpl::writeImage(const WebImage& image, |
152 const WebURL& url, | 152 const WebURL& url, |
153 const WebString& title) { | 153 const WebString& title) { |
154 ScopedClipboardWriterGlue scw(client_); | 154 ScopedClipboardWriterGlue scw(client_); |
155 | 155 |
156 if (!image.isNull()) { | 156 if (!image.isNull()) { |
157 const SkBitmap& bitmap = image.getSkBitmap(); | 157 const SkBitmap& bitmap = image.getSkBitmap(); |
| 158 // WriteBitmapFromPixels expects 32-bit data. |
| 159 DCHECK_EQ(bitmap.config(), SkBitmap::kARGB_8888_Config); |
| 160 |
158 SkAutoLockPixels locked(bitmap); | 161 SkAutoLockPixels locked(bitmap); |
159 scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size()); | 162 void *pixels = bitmap.getPixels(); |
| 163 // TODO(piman): this should not be NULL, but it is. crbug.com/369621 |
| 164 if (!pixels) |
| 165 return; |
| 166 scw.WriteBitmapFromPixels(pixels, image.size()); |
160 } | 167 } |
161 | 168 |
162 if (!url.isEmpty()) { | 169 if (!url.isEmpty()) { |
163 scw.WriteBookmark(title, url.spec()); | 170 scw.WriteBookmark(title, url.spec()); |
164 #if !defined(OS_MACOSX) | 171 #if !defined(OS_MACOSX) |
165 // When writing the image, we also write the image markup so that pasting | 172 // When writing the image, we also write the image markup so that pasting |
166 // into rich text editors, such as Gmail, reveals the image. We also don't | 173 // into rich text editors, such as Gmail, reveals the image. We also don't |
167 // want to call writeText(), since some applications (WordPad) don't pick | 174 // want to call writeText(), since some applications (WordPad) don't pick |
168 // the image if there is also a text format on the clipboard. | 175 // the image if there is also a text format on the clipboard. |
169 // We also don't want to write HTML on a Mac, since Mail.app prefers to use | 176 // We also don't want to write HTML on a Mac, since Mail.app prefers to use |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 #endif | 221 #endif |
215 #endif | 222 #endif |
216 default: | 223 default: |
217 NOTREACHED(); | 224 NOTREACHED(); |
218 return false; | 225 return false; |
219 } | 226 } |
220 return true; | 227 return true; |
221 } | 228 } |
222 | 229 |
223 } // namespace content | 230 } // namespace content |
OLD | NEW |