| 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..83cfd2fd9da6820519b905fcab517235faf2f61c 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.getCalledSendRequest())
|
| + 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.clearCalledSendRequest();
|
| +
|
| var retval;
|
| if (this.handleRequest) {
|
| retval = this.handleRequest.apply(this, args);
|
| @@ -297,6 +313,7 @@ Binding.prototype = {
|
| this.definition.parameters,
|
| optArgs);
|
| }
|
| + sendRequestHandler.clearCalledSendRequest();
|
|
|
| // Validate return value if defined - only in debug.
|
| if (chromeHidden.validateCallbacks &&
|
|
|