| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/stl_util.h" | |
| 13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/common/extensions/api/notification_provider.h" | 13 #include "chrome/common/extensions/api/notification_provider.h" |
| 15 #include "chrome/common/extensions/api/notifications/notification_style.h" | 14 #include "chrome/common/extensions/api/notifications/notification_style.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
| 17 #include "ui/gfx/image/image_skia_rep.h" | 16 #include "ui/gfx/image/image_skia_rep.h" |
| 18 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
| 19 | 18 |
| 20 void NotificationConversionHelper::NotificationToNotificationOptions( | 19 void NotificationConversionHelper::NotificationToNotificationOptions( |
| 21 const Notification& notification, | 20 const Notification& notification, |
| 22 extensions::api::notifications::NotificationOptions* options) { | 21 extensions::api::notifications::NotificationOptions* options) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 notification_bitmap->height = sk_bitmap.height(); | 122 notification_bitmap->height = sk_bitmap.height(); |
| 124 int pixel_count = sk_bitmap.width() * sk_bitmap.height(); | 123 int pixel_count = sk_bitmap.width() * sk_bitmap.height(); |
| 125 const int BYTES_PER_PIXEL = 4; | 124 const int BYTES_PER_PIXEL = 4; |
| 126 | 125 |
| 127 uint32_t* bitmap_pixels = sk_bitmap.getAddr32(0, 0); | 126 uint32_t* bitmap_pixels = sk_bitmap.getAddr32(0, 0); |
| 128 const unsigned char* bitmap = | 127 const unsigned char* bitmap = |
| 129 reinterpret_cast<const unsigned char*>(bitmap_pixels); | 128 reinterpret_cast<const unsigned char*>(bitmap_pixels); |
| 130 scoped_ptr<std::vector<char>> rgba_bitmap_data( | 129 scoped_ptr<std::vector<char>> rgba_bitmap_data( |
| 131 new std::vector<char>(pixel_count * BYTES_PER_PIXEL)); | 130 new std::vector<char>(pixel_count * BYTES_PER_PIXEL)); |
| 132 | 131 |
| 133 gfx::ConvertSkiaToRGBA(bitmap, pixel_count, | 132 gfx::ConvertSkiaToRGBA(bitmap, pixel_count, reinterpret_cast<unsigned char*>( |
| 134 reinterpret_cast<unsigned char*>( | 133 rgba_bitmap_data->data())); |
| 135 vector_as_array(rgba_bitmap_data.get()))); | |
| 136 sk_bitmap.unlockPixels(); | 134 sk_bitmap.unlockPixels(); |
| 137 | 135 |
| 138 notification_bitmap->data = rgba_bitmap_data.Pass(); | 136 notification_bitmap->data = rgba_bitmap_data.Pass(); |
| 139 return; | 137 return; |
| 140 } | 138 } |
| 141 | 139 |
| 142 bool NotificationConversionHelper::NotificationBitmapToGfxImage( | 140 bool NotificationConversionHelper::NotificationBitmapToGfxImage( |
| 143 float max_scale, | 141 float max_scale, |
| 144 const gfx::Size& target_size_dips, | 142 const gfx::Size& target_size_dips, |
| 145 const extensions::api::notifications::NotificationBitmap& | 143 const extensions::api::notifications::NotificationBitmap& |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return "image"; | 204 return "image"; |
| 207 case message_center::NOTIFICATION_TYPE_MULTIPLE: | 205 case message_center::NOTIFICATION_TYPE_MULTIPLE: |
| 208 return "list"; | 206 return "list"; |
| 209 case message_center::NOTIFICATION_TYPE_PROGRESS: | 207 case message_center::NOTIFICATION_TYPE_PROGRESS: |
| 210 return "progress"; | 208 return "progress"; |
| 211 default: | 209 default: |
| 212 NOTREACHED(); | 210 NOTREACHED(); |
| 213 return ""; | 211 return ""; |
| 214 } | 212 } |
| 215 } | 213 } |
| OLD | NEW |