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

Side by Side Diff: content/renderer/webclipboard_impl.cc

Issue 289573002: Workaround bad bitmaps in clibpoard code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: if->DCHECK Created 6 years, 7 months 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 | « content/renderer/renderer_clipboard_client.cc ('k') | no next file » | 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) 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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return false; 220 return false;
214 #endif 221 #endif
215 default: 222 default:
216 NOTREACHED(); 223 NOTREACHED();
217 return false; 224 return false;
218 } 225 }
219 return true; 226 return true;
220 } 227 }
221 228
222 } // namespace content 229 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_clipboard_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698