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

Side by Side Diff: chrome/browser/notifications/notification_conversion_helper.cc

Issue 1135213004: Returning error when NotificationConversionHelper::NotificationBitmapToGfxImage() get failed in not… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/notifications/notification_conversion_helper.h" 5 #include "chrome/browser/notifications/notification_conversion_helper.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 vector_as_array(rgba_bitmap_data.get()))); 135 vector_as_array(rgba_bitmap_data.get())));
136 sk_bitmap.unlockPixels(); 136 sk_bitmap.unlockPixels();
137 137
138 notification_bitmap->data = rgba_bitmap_data.Pass(); 138 notification_bitmap->data = rgba_bitmap_data.Pass();
139 return; 139 return;
140 } 140 }
141 141
142 bool NotificationConversionHelper::NotificationBitmapToGfxImage( 142 bool NotificationConversionHelper::NotificationBitmapToGfxImage(
143 float max_scale, 143 float max_scale,
144 const gfx::Size& target_size_dips, 144 const gfx::Size& target_size_dips,
145 extensions::api::notifications::NotificationBitmap* notification_bitmap, 145 extensions::api::notifications::NotificationBitmap* notification_bitmap,
dewittj 2015/05/22 16:42:24 Let's change this to take a const extensions::api:
Deepak 2015/05/23 14:03:40 Done.
146 gfx::Image* return_image) { 146 gfx::Image* return_image) {
147 if (!notification_bitmap) 147 DCHECK(notification_bitmap);
148 return false;
149 148
150 const int max_device_pixel_width = target_size_dips.width() * max_scale; 149 const int max_device_pixel_width = target_size_dips.width() * max_scale;
151 const int max_device_pixel_height = target_size_dips.height() * max_scale; 150 const int max_device_pixel_height = target_size_dips.height() * max_scale;
152 151
153 const int BYTES_PER_PIXEL = 4; 152 const int BYTES_PER_PIXEL = 4;
154 153
155 const int width = notification_bitmap->width; 154 const int width = notification_bitmap->width;
156 const int height = notification_bitmap->height; 155 const int height = notification_bitmap->height;
157 156
158 if (width < 0 || height < 0 || width > max_device_pixel_width || 157 if (width < 0 || height < 0 || width > max_device_pixel_width ||
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return "image"; 207 return "image";
209 case message_center::NOTIFICATION_TYPE_MULTIPLE: 208 case message_center::NOTIFICATION_TYPE_MULTIPLE:
210 return "list"; 209 return "list";
211 case message_center::NOTIFICATION_TYPE_PROGRESS: 210 case message_center::NOTIFICATION_TYPE_PROGRESS:
212 return "progress"; 211 return "progress";
213 default: 212 default:
214 NOTREACHED(); 213 NOTREACHED();
215 return ""; 214 return "";
216 } 215 }
217 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698