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

Unified Diff: chrome/renderer/resources/extensions/storage_custom_bindings.js

Issue 10535030: Allow updateArgumentsPostValidate to support callbacks and added / removed arguments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Proper syntax Created 8 years, 6 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: chrome/renderer/resources/extensions/storage_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/storage_custom_bindings.js b/chrome/renderer/resources/extensions/storage_custom_bindings.js
index 7d8eaa1ef6307c0f382d329d81941d0bef25be00..9b0ece5e5982c8625de72b820b7660ee0a5ba388 100644
--- a/chrome/renderer/resources/extensions/storage_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/storage_custom_bindings.js
@@ -5,6 +5,8 @@
// Custom bindings for the storage API.
var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
+var normalizeArgumentsAndValidate =
+ require('schemaUtils').normalizeArgumentsAndValidate
var sendRequest = require('sendRequest').sendRequest;
chromeHidden.registerCustomType('storage.StorageArea', function() {
@@ -22,18 +24,20 @@ chromeHidden.registerCustomType('storage.StorageArea', function() {
// TODO(kalman): Put as a method on CustomBindingsObject and re-use (or
// even generate) for other APIs that need to do this. Same for other
// callers of registerCustomType().
+ var self = this;
function bindApiFunction(functionName) {
- this[functionName] = function() {
- var schema = this.parameters[functionName];
- chromeHidden.validate(arguments, schema);
+ self[functionName] = function() {
+ var funSchema = this.functionSchemas[functionName];
+ var args = Array.prototype.slice.call(arguments);
+ args = normalizeArgumentsAndValidate(args, funSchema);
return sendRequest(
'storage.' + functionName,
- [namespace].concat(Array.prototype.slice.call(arguments)),
- extendSchema(schema));
+ [namespace].concat(args),
+ extendSchema(funSchema.definition.parameters));
};
}
var apiFunctions = ['get', 'set', 'remove', 'clear', 'getBytesInUse'];
- apiFunctions.forEach(bindApiFunction.bind(this));
+ apiFunctions.forEach(bindApiFunction);
}
return StorageArea;
« no previous file with comments | « chrome/renderer/resources/extensions/send_request.js ('k') | chrome/renderer/resources/extensions/types_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698