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

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: 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
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
159 // WriteBitmapFromPixels expects 32-bit data.
160 if (bitmap.config() != SkBitmap::kARGB_8888_Config)
dcheng 2014/05/19 19:44:59 Hm... are you aware of any cases where we don't pa
piman 2014/05/19 19:45:56 Can't it be arbitrary? E.g. what if the png is gra
dcheng 2014/05/19 19:51:01 I'm not an expert in this area, but this is the de
piman 2014/05/19 22:50:00 I'm not sure we want to make assumptions about cod
piman 2014/05/20 06:48:47 OK, replaced by a DCHECK.
161 return;
158 SkAutoLockPixels locked(bitmap); 162 SkAutoLockPixels locked(bitmap);
159 scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size()); 163 void *pixels = bitmap.getPixels();
164 // TODO(piman): this should not be NULL, but it is. crbug.com/369621
165 if (!pixels)
166 return;
167 scw.WriteBitmapFromPixels(pixels, image.size());
160 } 168 }
161 169
162 if (!url.isEmpty()) { 170 if (!url.isEmpty()) {
163 scw.WriteBookmark(title, url.spec()); 171 scw.WriteBookmark(title, url.spec());
164 #if !defined(OS_MACOSX) 172 #if !defined(OS_MACOSX)
165 // When writing the image, we also write the image markup so that pasting 173 // 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 174 // 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 175 // want to call writeText(), since some applications (WordPad) don't pick
168 // the image if there is also a text format on the clipboard. 176 // 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 177 // 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; 221 return false;
214 #endif 222 #endif
215 default: 223 default:
216 NOTREACHED(); 224 NOTREACHED();
217 return false; 225 return false;
218 } 226 }
219 return true; 227 return true;
220 } 228 }
221 229
222 } // namespace content 230 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698