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

Side by Side Diff: chrome/renderer/resources/extensions/notification_custom_bindings.js

Issue 12313142: Revert 184837 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 notification API. 5 // Custom bindings for the notification API.
6 6
7 var binding = require('binding').Binding.create('experimental.notification'); 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
8
9 var sendRequest = require('sendRequest').sendRequest; 8 var sendRequest = require('sendRequest').sendRequest;
10 var imageUtil = require('imageUtil'); 9 var imageUtil = require('imageUtil');
11 var lastError = require('lastError'); 10 var lastError = require('lastError');
12 var json = require('json');
13 11
14 function url_getter(context, key) { 12 function url_getter(context, key) {
15 var f = function() { 13 var f = function() {
16 return this[key]; 14 return this[key];
17 }; 15 };
18 return f.bind(context); 16 return f.bind(context);
19 } 17 }
20 18
21 function url_setter(context, key) { 19 function url_setter(context, key) {
22 var f = function(val) { 20 var f = function(val) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 92 }
95 callback(true); 93 callback(true);
96 } 94 }
97 }); 95 });
98 } 96 }
99 97
100 function genHandle(failure_function) { 98 function genHandle(failure_function) {
101 return function(id, input_notification_details, callback) { 99 return function(id, input_notification_details, callback) {
102 // TODO(dewittj): Remove this hack. This is used as a way to deep 100 // TODO(dewittj): Remove this hack. This is used as a way to deep
103 // copy a complex JSON object. 101 // copy a complex JSON object.
104 var notification_details = json.parse( 102 var notification_details = JSON.parse(
105 json.stringify(input_notification_details)); 103 JSON.stringify(input_notification_details));
106 var that = this; 104 var that = this;
107 replaceNotificationOptionURLs(notification_details, function(success) { 105 replaceNotificationOptionURLs(notification_details, function(success) {
108 if (success) { 106 if (success) {
109 sendRequest(that.name, 107 sendRequest(that.name,
110 [id, notification_details, callback], 108 [id, notification_details, callback],
111 that.definition.parameters); 109 that.definition.parameters);
112 return; 110 return;
113 } 111 }
114 lastError.set('Unable to download all specified images.'); 112 lastError.set('Unable to download all specified images.');
115 failure_function(callback, id); 113 failure_function(callback, id);
116 }); 114 });
117 }; 115 };
118 } 116 }
119 117
120 var handleCreate = genHandle(function(callback, id) { callback(id); }); 118 var handleCreate = genHandle(function(callback, id) { callback(id); });
121 var handleUpdate = genHandle(function(callback, id) { callback(false); }); 119 var handleUpdate = genHandle(function(callback, id) { callback(false); });
122 120
123 var experimentalNotificationCustomHook = function(bindingsAPI, extensionId) { 121 var experimentalNotificationCustomHook = function(bindingsAPI, extensionId) {
124 var apiFunctions = bindingsAPI.apiFunctions; 122 var apiFunctions = bindingsAPI.apiFunctions;
125 apiFunctions.setHandleRequest('create', handleCreate); 123 apiFunctions.setHandleRequest('create', handleCreate);
126 apiFunctions.setHandleRequest('update', handleCreate); 124 apiFunctions.setHandleRequest('update', handleCreate);
127 }; 125 };
128 126
129 binding.registerCustomHook(experimentalNotificationCustomHook); 127 chromeHidden.registerCustomHook('experimental.notification',
130 128 experimentalNotificationCustomHook);
131 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698