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

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

Issue 9192029: Bindings layer for declarative events API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some stuff that apitests in followup CL discovered Created 8 years, 11 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/schema_generated_bindings.js
diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js
index 413476272c462cfa1d4e332edc3ff488334285c4..82c82de33eb3b2aa9ab02aedad5bbf6a21d6c625 100644
--- a/chrome/renderer/resources/extensions/schema_generated_bindings.js
+++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js
@@ -183,6 +183,24 @@ var chrome = chrome || {};
opt_args.forIOThread);
}
+ function getFunctionDefinition(namespace, functionName) {
+ var filterNamespace = function(val) {return val.namespace === namespace;};
+ var apiSchema = chromeHidden.apiDefinitions.filter(filterNamespace)[0];
+ var filterFunctionName = function (val) {return val.name === functionName;};
not at google - send to devlin 2012/02/01 07:23:12 This is expensive, O(number of APIs * number of fu
battre 2012/02/01 17:35:39 I have moved this logic into the custom bindings.
+ return apiSchema.functions.filter(filterFunctionName)[0];
+ }
+
+ // Sends an API request like sendRequest() but performs schema validation
+ // first.
+ // |qualifiedFunctionName| is the full function name including the api name.
+ chromeHidden.validatingSendRequest = function(qualifiedFunctionName, args) {
Aaron Boodman 2012/02/01 00:27:25 I don't think this really validates. sendRequest d
not at google - send to devlin 2012/02/01 00:47:57 I think we should get sendRequest to do the lookup
battre 2012/02/01 17:35:39 Please have a look at the new implementation. This
+ var lastSeparator = qualifiedFunctionName.lastIndexOf(".");
+ var functionName = qualifiedFunctionName.substr(lastSeparator + 1);
+ var namespace = qualifiedFunctionName.substr(0, lastSeparator);
+ var functionDef = getFunctionDefinition(namespace, functionName);
+ return sendRequest(qualifiedFunctionName, args, functionDef.parameters);
+ };
+
// TODO(kalman): It's a shame to need to define this function here, since it's
// only used in 2 APIs (browserAction and pageAction). It would be nice to
// only load this if one of those APIs has been loaded.
@@ -355,6 +373,7 @@ var chrome = chrome || {};
chromeHidden.onLoad.addListener(function(extensionId, isExtensionProcess,
isIncognitoProcess) {
var apiDefinitions = GetExtensionAPIDefinition();
+ chromeHidden.apiDefinitions = apiDefinitions;
not at google - send to devlin 2012/02/01 07:23:12 When the logic from event.js is moved into experim
// Read api definitions and setup api functions in the chrome namespace.
// TODO(rafaelw): Consider defining a json schema for an api definition
@@ -459,10 +478,11 @@ var chrome = chrome || {};
var customEvent = customEvents[apiDef.namespace];
if (customEvent) {
module[eventDef.name] = new customEvent(
- eventName, eventDef.parameters, eventDef.extraParameters);
+ eventName, eventDef.parameters, eventDef.extraParameters,
+ eventDef.options);
} else {
module[eventDef.name] = new chrome.Event(
- eventName, eventDef.parameters);
+ eventName, eventDef.parameters, eventDef.options);
}
});
}

Powered by Google App Engine
This is Rietveld 408576698