OLD | NEW |
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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/common/extensions/api/notification_provider.h" | 10 #include "chrome/common/extensions/api/notification_provider.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 return false; | 161 return false; |
162 | 162 |
163 const size_t rgba_data_length = rgba_data->length(); | 163 const size_t rgba_data_length = rgba_data->length(); |
164 const size_t rgba_area = width * height; | 164 const size_t rgba_area = width * height; |
165 | 165 |
166 if (rgba_data_length != rgba_area * BYTES_PER_PIXEL) | 166 if (rgba_data_length != rgba_area * BYTES_PER_PIXEL) |
167 return false; | 167 return false; |
168 | 168 |
169 SkBitmap bitmap; | 169 SkBitmap bitmap; |
170 // Allocate the actual backing store with the sanitized dimensions. | 170 // Allocate the actual backing store with the sanitized dimensions. |
171 if (!bitmap.allocN32Pixels(width, height)) | 171 if (!bitmap.tryAllocN32Pixels(width, height)) |
172 return false; | 172 return false; |
173 | 173 |
174 // Ensure that our bitmap and our data now refer to the same number of pixels. | 174 // Ensure that our bitmap and our data now refer to the same number of pixels. |
175 if (rgba_data_length != bitmap.getSafeSize()) | 175 if (rgba_data_length != bitmap.getSafeSize()) |
176 return false; | 176 return false; |
177 | 177 |
178 uint32_t* pixels = bitmap.getAddr32(0, 0); | 178 uint32_t* pixels = bitmap.getAddr32(0, 0); |
179 const char* c_rgba_data = rgba_data->data(); | 179 const char* c_rgba_data = rgba_data->data(); |
180 | 180 |
181 for (size_t t = 0; t < rgba_area; ++t) { | 181 for (size_t t = 0; t < rgba_area; ++t) { |
(...skipping 22 matching lines...) Expand all Loading... |
204 return "image"; | 204 return "image"; |
205 case message_center::NOTIFICATION_TYPE_MULTIPLE: | 205 case message_center::NOTIFICATION_TYPE_MULTIPLE: |
206 return "list"; | 206 return "list"; |
207 case message_center::NOTIFICATION_TYPE_PROGRESS: | 207 case message_center::NOTIFICATION_TYPE_PROGRESS: |
208 return "progress"; | 208 return "progress"; |
209 default: | 209 default: |
210 NOTREACHED(); | 210 NOTREACHED(); |
211 return ""; | 211 return ""; |
212 } | 212 } |
213 } | 213 } |
OLD | NEW |