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

Unified Diff: trunk/src/chrome/renderer/resources/extensions/notifications_custom_bindings.js

Issue 296113009: Revert 272211 "Allow high-res bitmaps to be passed in from notif..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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 side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/renderer/resources/extensions/notifications_custom_bindings.js
===================================================================
--- trunk/src/chrome/renderer/resources/extensions/notifications_custom_bindings.js (revision 272269)
+++ trunk/src/chrome/renderer/resources/extensions/notifications_custom_bindings.js (working copy)
@@ -3,75 +3,66 @@
// found in the LICENSE file.
// Custom bindings for the notifications API.
-//
var binding = require('binding').Binding.create('notifications');
var sendRequest = require('sendRequest').sendRequest;
var imageUtil = require('imageUtil');
var lastError = require('lastError');
-var notificationsPrivate = requireNative('notifications_private');
-function imageDataSetter(context, key) {
+function image_data_setter(context, key) {
var f = function(val) {
this[key] = val;
};
return $Function.bind(f, context);
}
-// A URL Spec is an object with the following keys:
-// path: The resource to be downloaded.
-// width: (optional) The maximum width of the image to be downloaded in device
-// pixels.
-// height: (optional) The maximum height of the image to be downloaded in
-// device pixels.
-// callback: A function to be called when the URL is complete. It
-// should accept an ImageData object and set the appropriate
-// field in |notificationDetails|.
-function getUrlSpecs(imageSizes, notificationDetails) {
- var urlSpecs = [];
+function replaceNotificationOptionURLs(notification_details, callback) {
+ // A URL Spec is an object with the following keys:
+ // path: The resource to be downloaded.
+ // width: (optional) The maximum width of the image to be downloaded.
+ // height: (optional) The maximum height of the image to be downloaded.
+ // callback: A function to be called when the URL is complete. It
+ // should accept an ImageData object and set the appropriate
+ // field in the output of create.
+ // TODO(dewittj): Try to remove hard-coding of image sizes.
// |iconUrl| might be optional for notification updates.
- if (notificationDetails.iconUrl) {
- $Array.push(urlSpecs, {
- path: notificationDetails.iconUrl,
- width: imageSizes.icon.width * imageSizes.scaleFactor,
- height: imageSizes.icon.height * imageSizes.scaleFactor,
- callback: imageDataSetter(notificationDetails, 'iconBitmap')
+ var url_specs = [];
+ if (notification_details.iconUrl) {
+ $Array.push(url_specs, {
+ path: notification_details.iconUrl,
+ width: 80,
+ height: 80,
+ callback: image_data_setter(notification_details, 'iconBitmap')
});
}
// |imageUrl| is optional.
- if (notificationDetails.imageUrl) {
- $Array.push(urlSpecs, {
- path: notificationDetails.imageUrl,
- width: imageSizes.image.width * imageSizes.scaleFactor,
- height: imageSizes.image.height * imageSizes.scaleFactor,
- callback: imageDataSetter(notificationDetails, 'imageBitmap')
+ if (notification_details.imageUrl) {
+ $Array.push(url_specs, {
+ path: notification_details.imageUrl,
+ width: 360,
+ height: 240,
+ callback: image_data_setter(notification_details, 'imageBitmap')
});
}
// Each button has an optional icon.
- var buttonList = notificationDetails.buttons;
- if (buttonList && typeof buttonList.length === 'number') {
- var numButtons = buttonList.length;
- for (var i = 0; i < numButtons; i++) {
- if (buttonList[i].iconUrl) {
- $Array.push(urlSpecs, {
- path: buttonList[i].iconUrl,
- width: imageSizes.buttonIcon.width * imageSizes.scaleFactor,
- height: imageSizes.buttonIcon.height * imageSizes.scaleFactor,
- callback: imageDataSetter(buttonList[i], 'iconBitmap')
+ var button_list = notification_details.buttons;
+ if (button_list && typeof button_list.length === 'number') {
+ var num_buttons = button_list.length;
+ for (var i = 0; i < num_buttons; i++) {
+ if (button_list[i].iconUrl) {
+ $Array.push(url_specs, {
+ path: button_list[i].iconUrl,
+ width: 16,
+ height: 16,
+ callback: image_data_setter(button_list[i], 'iconBitmap')
});
}
}
}
- return urlSpecs;
-}
-
-function replaceNotificationOptionURLs(notification_details, callback) {
- var imageSizes = notificationsPrivate.GetNotificationImageSizes();
- var url_specs = getUrlSpecs(imageSizes, notification_details);
if (!url_specs.length) {
callback(true);
return;

Powered by Google App Engine
This is Rietveld 408576698