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 | 7 |
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | |
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'); |
11 | 11 |
12 function url_getter(context, key) { | 12 function url_getter(context, key) { |
13 var f = function() { | 13 var f = function() { |
14 return this[key]; | 14 return this[key]; |
15 }; | 15 }; |
16 return f.bind(context); | 16 return f.bind(context); |
17 } | 17 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 var notification_details = JSON.parse( | 102 var notification_details = JSON.parse( |
103 JSON.stringify(input_notification_details)); | 103 JSON.stringify(input_notification_details)); |
104 var that = this; | 104 var that = this; |
105 replaceNotificationOptionURLs(notification_details, function(success) { | 105 replaceNotificationOptionURLs(notification_details, function(success) { |
106 if (success) { | 106 if (success) { |
107 sendRequest(that.name, | 107 sendRequest(that.name, |
108 [id, notification_details, callback], | 108 [id, notification_details, callback], |
109 that.definition.parameters); | 109 that.definition.parameters); |
110 return; | 110 return; |
111 } | 111 } |
112 lastError.set('Unable to download all specified images.'); | 112 lastError.run('Unable to download all specified images.', |
113 failure_function(callback, id); | 113 failure_function, [callback, id]) |
114 }); | 114 }); |
115 }; | 115 }; |
116 } | 116 } |
117 | 117 |
118 var handleCreate = genHandle(function(callback, id) { callback(id); }); | 118 var handleCreate = genHandle(function(callback, id) { callback(id); }); |
119 var handleUpdate = genHandle(function(callback, id) { callback(false); }); | 119 var handleUpdate = genHandle(function(callback, id) { callback(false); }); |
120 | 120 |
121 var notificationsCustomHook = function(bindingsAPI, extensionId) { | 121 var notificationsCustomHook = function(bindingsAPI, extensionId) { |
122 var apiFunctions = bindingsAPI.apiFunctions; | 122 var apiFunctions = bindingsAPI.apiFunctions; |
123 apiFunctions.setHandleRequest('create', handleCreate); | 123 apiFunctions.setHandleRequest('create', handleCreate); |
124 apiFunctions.setHandleRequest('update', handleCreate); | 124 apiFunctions.setHandleRequest('update', handleCreate); |
125 }; | 125 }; |
126 | 126 |
127 chromeHidden.registerCustomHook('notifications', notificationsCustomHook); | 127 binding.registerCustomHook(notificationsCustomHook); |
| 128 |
| 129 exports.binding = binding.generate(); |
OLD | NEW |