OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Custom bindings for the notifications API. | 5 // Custom bindings for the notifications API. |
6 var binding = require('binding').Binding.create('notifications'); | 6 var binding = require('binding').Binding.create('notifications'); |
7 | 7 |
8 var sendRequest = require('sendRequest').sendRequest; | 8 var sendRequest = require('sendRequest').sendRequest; |
9 var imageUtil = require('imageUtil'); | 9 var imageUtil = require('imageUtil'); |
10 var lastError = require('lastError'); | 10 var lastError = require('lastError'); |
(...skipping 18 matching lines...) Expand all Loading... |
29 // |iconUrl| is required. | 29 // |iconUrl| is required. |
30 var url_specs = [{ | 30 var url_specs = [{ |
31 path: notification_details.iconUrl, | 31 path: notification_details.iconUrl, |
32 width: 80, | 32 width: 80, |
33 height: 80, | 33 height: 80, |
34 callback: image_data_setter(notification_details, 'iconBitmap') | 34 callback: image_data_setter(notification_details, 'iconBitmap') |
35 }]; | 35 }]; |
36 | 36 |
37 // |imageUrl| is optional. | 37 // |imageUrl| is optional. |
38 if (notification_details.imageUrl) { | 38 if (notification_details.imageUrl) { |
39 url_specs.push({ | 39 $Array.push(url_specs, { |
40 path: notification_details.imageUrl, | 40 path: notification_details.imageUrl, |
41 width: 360, | 41 width: 360, |
42 height: 540, | 42 height: 540, |
43 callback: image_data_setter(notification_details, 'imageBitmap') | 43 callback: image_data_setter(notification_details, 'imageBitmap') |
44 }); | 44 }); |
45 } | 45 } |
46 | 46 |
47 // Each button has an optional icon. | 47 // Each button has an optional icon. |
48 var button_list = notification_details.buttons; | 48 var button_list = notification_details.buttons; |
49 if (button_list && typeof button_list.length === 'number') { | 49 if (button_list && typeof button_list.length === 'number') { |
50 var num_buttons = button_list.length; | 50 var num_buttons = button_list.length; |
51 for (var i = 0; i < num_buttons; i++) { | 51 for (var i = 0; i < num_buttons; i++) { |
52 if (button_list[i].iconUrl) { | 52 if (button_list[i].iconUrl) { |
53 url_specs.push({ | 53 $Array.push(url_specs, { |
54 path: button_list[i].iconUrl, | 54 path: button_list[i].iconUrl, |
55 width: 16, | 55 width: 16, |
56 height: 16, | 56 height: 16, |
57 callback: image_data_setter(button_list[i], 'iconBitmap') | 57 callback: image_data_setter(button_list[i], 'iconBitmap') |
58 }); | 58 }); |
59 } | 59 } |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 var errors = 0; | 63 var errors = 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 var notificationsCustomHook = function(bindingsAPI, extensionId) { | 110 var notificationsCustomHook = function(bindingsAPI, extensionId) { |
111 var apiFunctions = bindingsAPI.apiFunctions; | 111 var apiFunctions = bindingsAPI.apiFunctions; |
112 apiFunctions.setHandleRequest('create', handleCreate); | 112 apiFunctions.setHandleRequest('create', handleCreate); |
113 apiFunctions.setHandleRequest('update', handleUpdate); | 113 apiFunctions.setHandleRequest('update', handleUpdate); |
114 }; | 114 }; |
115 | 115 |
116 binding.registerCustomHook(notificationsCustomHook); | 116 binding.registerCustomHook(notificationsCustomHook); |
117 | 117 |
118 exports.binding = binding.generate(); | 118 exports.binding = binding.generate(); |
OLD | NEW |