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

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 102473005: Refresh for the Chrome notifications image template. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac unit test Created 7 years 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 | « no previous file | chrome/renderer/resources/extensions/notifications_custom_bindings.js » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/notifications/notifications_api.h" 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Converts an object with width, height, and data in RGBA format into an 49 // Converts an object with width, height, and data in RGBA format into an
50 // gfx::Image (in ARGB format). 50 // gfx::Image (in ARGB format).
51 bool NotificationBitmapToGfxImage( 51 bool NotificationBitmapToGfxImage(
52 api::notifications::NotificationBitmap* notification_bitmap, 52 api::notifications::NotificationBitmap* notification_bitmap,
53 gfx::Image* return_image) { 53 gfx::Image* return_image) {
54 if (!notification_bitmap) 54 if (!notification_bitmap)
55 return false; 55 return false;
56 56
57 // Ensure a sane set of dimensions. 57 // Ensure a sane set of dimensions.
58 const int max_width = message_center::kNotificationPreferredImageSize; 58 const int max_width = message_center::kNotificationPreferredImageWidth;
59 const int max_height = 59 const int max_height = message_center::kNotificationPreferredImageHeight;
60 message_center::kNotificationPreferredImageRatio * max_width;
61 const int BYTES_PER_PIXEL = 4; 60 const int BYTES_PER_PIXEL = 4;
62 61
63 const int width = notification_bitmap->width; 62 const int width = notification_bitmap->width;
64 const int height = notification_bitmap->height; 63 const int height = notification_bitmap->height;
65 64
66 if (width < 0 || height < 0 || width > max_width || height > max_height) 65 if (width < 0 || height < 0 || width > max_width || height > max_height)
67 return false; 66 return false;
68 67
69 // Ensure we have rgba data. 68 // Ensure we have rgba data.
70 std::string* rgba_data = notification_bitmap->data.get(); 69 std::string* rgba_data = notification_bitmap->data.get();
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 ? api::notifications::PERMISSION_LEVEL_GRANTED 623 ? api::notifications::PERMISSION_LEVEL_GRANTED
625 : api::notifications::PERMISSION_LEVEL_DENIED; 624 : api::notifications::PERMISSION_LEVEL_DENIED;
626 625
627 SetResult(new base::StringValue(api::notifications::ToString(result))); 626 SetResult(new base::StringValue(api::notifications::ToString(result)));
628 SendResponse(true); 627 SendResponse(true);
629 628
630 return true; 629 return true;
631 } 630 }
632 631
633 } // namespace extensions 632 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/notifications_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698