Chromium Code Reviews| Index: chrome/renderer/resources/extensions/binding.js |
| diff --git a/chrome/renderer/resources/extensions/binding.js b/chrome/renderer/resources/extensions/binding.js |
| index 9fdb392e9aae13d9e6bee6836718a4ecaecd2efa..c0f2a74a39a4d9d3cf2fd8211ec9537cd6c6bfa0 100644 |
| --- a/chrome/renderer/resources/extensions/binding.js |
| +++ b/chrome/renderer/resources/extensions/binding.js |
| @@ -15,15 +15,18 @@ var extensionId = process.GetExtensionId(); |
| var manifestVersion = process.GetManifestVersion(); |
| var schemaRegistry = requireNative('schema_registry'); |
| var schemaUtils = require('schemaUtils'); |
| -var sendRequest = require('sendRequest').sendRequest; |
| var utils = require('utils'); |
| +var sendRequestHandler = require('sendRequest'); |
| +var sendRequest = sendRequestHandler.sendRequest; |
| +var logActivity = requireNative('activityLogger').LogActivity; |
| // Stores the name and definition of each API function, with methods to |
| // modify their behaviour (such as a custom way to handle requests to the |
| // API, a custom callback, etc). |
| -function APIFunctions() { |
| +function APIFunctions(namespace) { |
| this.apiFunctions_ = {}; |
| this.unavailableApiFunctions_ = {}; |
| + this.namespace = namespace; |
| } |
| APIFunctions.prototype.register = function(apiName, apiFunction) { |
| @@ -48,7 +51,17 @@ APIFunctions.prototype.setHook_ = |
| APIFunctions.prototype.setHandleRequest = |
| function(apiName, customizedFunction) { |
| - return this.setHook_(apiName, 'handleRequest', customizedFunction); |
| + var prefix = this.namespace; |
| + return this.setHook_(apiName, 'handleRequest', |
| + function() { |
| + var ret = customizedFunction.apply(this, arguments); |
| + // Logs API calls to the Activity Log if it doesn't go through an |
| + // ExtensionFunction. |
| + if (!sendRequestHandler.getRequestStatus()) |
| + logActivity(extensionId, prefix + "." + apiName, |
| + Array.prototype.slice.call(arguments)); |
| + return ret; |
| + }); |
| }; |
| APIFunctions.prototype.setUpdateArgumentsPostValidate = |
| @@ -121,7 +134,7 @@ var platform = getPlatform(); |
| function Binding(schema) { |
| this.schema_ = schema; |
| - this.apiFunctions_ = new APIFunctions(); |
| + this.apiFunctions_ = new APIFunctions(schema.namespace); |
| this.customEvent_ = null; |
| this.customTypes_ = {}; |
| this.customHooks_ = []; |
| @@ -243,6 +256,7 @@ Binding.prototype = { |
| // Setup Functions. |
| if (schema.functions) { |
| + var doubleLogging = "abcdefg"; |
| forEach(schema.functions, function(i, functionDef) { |
| if (functionDef.name in mod) { |
| throw new Error('Function ' + functionDef.name + |
| @@ -286,6 +300,8 @@ Binding.prototype = { |
| if (this.updateArgumentsPostValidate) |
| args = this.updateArgumentsPostValidate.apply(this, args); |
| + sendRequestHandler.setRequestStatus(false); |
| + |
| var retval; |
| if (this.handleRequest) { |
| retval = this.handleRequest.apply(this, args); |
| @@ -296,6 +312,7 @@ Binding.prototype = { |
| retval = sendRequest(this.name, args, |
| this.definition.parameters, |
| optArgs); |
| + sendRequestHandler.setRequestStatus(false); |
|
Matt Perry
2013/03/15 23:33:21
move this outside this block.
felt
2013/03/15 23:40:17
Done.
|
| } |
| // Validate return value if defined - only in debug. |