Commit 4368f22e authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions] Update last_error.js, send_request.js

BUG=591164

Review URL: https://codereview.chromium.org/1914643003

Cr-Commit-Position: refs/heads/master@{#389840}
parent 6bc322a0
......@@ -32,14 +32,14 @@ binding.registerCustomHook(function(bindingsAPI) {
pendingRequests[id] = callback;
sendRequest(this.name,
[id, sources, target_tab, onRequestResult.bind(null, id)],
this.definition.parameters, {});
this.definition.parameters);
return id;
});
apiFunctions.setHandleRequest('cancelChooseDesktopMedia', function(id) {
if (id in pendingRequests) {
delete pendingRequests[id];
sendRequest(this.name, [id], this.definition.parameters, {});
sendRequest(this.name, [id], this.definition.parameters);
}
});
});
......
......@@ -42,7 +42,7 @@ binding.registerCustomHook(function(bindingsAPI) {
var relativePath = $String.slice(fileEntry.fullPath, 1);
sendRequest.sendRequest(this.name, [id, fileSystemName, relativePath],
this.definition.parameters, {});
this.definition.parameters);
return id;
});
......@@ -57,7 +57,7 @@ binding.registerCustomHook(function(bindingsAPI) {
[true]);
} else {
sendRequest.sendRequest(
this.name, [id, callback], this.definition.parameters, {});
this.name, [id, callback], this.definition.parameters);
}
});
......
......@@ -120,7 +120,7 @@ function genHandle(name, failure_function) {
if (success) {
sendRequest(that.name,
[id, notification_details, callback],
that.definition.parameters, {stack: stack});
that.definition.parameters, {__proto__: null, stack: stack});
return;
}
lastError.run(name,
......
......@@ -27,14 +27,14 @@ binding.registerCustomHook(function(bindingsAPI) {
pendingRequests[id] = callback;
sendRequest(this.name,
[id, sources, request, onRequestResult.bind(null, id)],
this.definition.parameters, {});
this.definition.parameters);
return id;
});
apiFunctions.setHandleRequest('cancelChooseDesktopMedia', function(id) {
if (id in pendingRequests) {
delete pendingRequests[id];
sendRequest(this.name, [id], this.definition.parameters, {});
sendRequest(this.name, [id], this.definition.parameters);
}
});
});
......
......@@ -421,6 +421,7 @@ Binding.prototype = {
retval = $Function.apply(this.handleRequest, this, args);
} else {
var optArgs = {
__proto__: null,
customCallback: this.customCallback
};
retval = sendRequest(this.name, args,
......
......@@ -88,14 +88,15 @@ function createContextMenusHandlers(isWebview) {
};
// To be used with apiFunctions.setHandleRequest
var requestHandlers = {};
var requestHandlers = { __proto__: null };
// To be used with apiFunctions.setCustomCallback
var callbacks = {};
var callbacks = { __proto__: null };
requestHandlers.create = function() {
var createProperties = isWebview ? arguments[1] : arguments[0];
createProperties.generatedId = contextMenuNatives.GetNextContextMenuId();
var optArgs = {
__proto__: null,
customCallback: this.customCallback,
};
sendRequest(this.name, arguments, this.definition.parameters, optArgs);
......
......@@ -68,10 +68,7 @@ function hasError(targetChrome) {
throw new Error('No target chrome to check');
assertRuntimeIsAvailable();
if ('lastError' in targetChrome.runtime)
return true;
return false;
return $Object.hasOwnProperty(targetChrome.runtime, 'lastError');
};
/**
......
......@@ -9,7 +9,7 @@ var natives = requireNative('sendRequest');
var validate = require('schemaUtils').validate;
// All outstanding requests from sendRequest().
var requests = {};
var requests = { __proto__: null };
// Used to prevent double Activity Logging for API calls that use both custom
// bindings and ExtensionFunctions (via sendRequest).
......@@ -88,7 +88,7 @@ function handleResponse(requestId, name, success, responseList, error) {
}
function prepareRequest(args, argSchemas) {
var request = {};
var request = { __proto__: null };
var argCount = args.length;
// Look for callback param.
......@@ -99,11 +99,7 @@ function prepareRequest(args, argSchemas) {
--argCount;
}
request.args = [];
for (var k = 0; k < argCount; k++) {
request.args[k] = args[k];
}
request.args = $Array.slice(args, 0, argCount);
return request;
}
......@@ -119,7 +115,8 @@ function prepareRequest(args, argSchemas) {
function sendRequest(functionName, args, argSchemas, optArgs) {
calledSendRequest = true;
if (!optArgs)
optArgs = {};
optArgs = { __proto__: null };
logging.DCHECK(optArgs.__proto__ == null);
var request = prepareRequest(args, argSchemas);
request.stack = optArgs.stack || exceptionHandler.getExtensionStackTrace();
if (optArgs.customCallback) {
......
......@@ -37,7 +37,7 @@ function StorageArea(namespace, schema) {
'storage.' + functionName,
$Array.concat([namespace], args),
extendSchema(funSchema.definition.parameters),
{preserveNullInObjects: true});
{__proto__: null, preserveNullInObjects: true});
};
}
var apiFunctions = ['get', 'set', 'remove', 'clear', 'getBytesInUse'];
......
......@@ -14,7 +14,7 @@ binding.registerCustomHook(function(api) {
apiFunctions.setHandleRequest('handlerBehaviorChanged', function() {
var args = $Array.slice(arguments);
sendRequest(this.name, args, this.definition.parameters,
{forIOThread: true});
{__proto__: null, forIOThread: true});
});
});
......
......@@ -165,13 +165,13 @@ binding.registerCustomHook(function(api) {
apiFunctions.setHandleRequest('addEventListener', function() {
var args = $Array.slice(arguments);
sendRequest(this.name, args, this.definition.parameters,
{forIOThread: true});
{__proto__: null, forIOThread: true});
});
apiFunctions.setHandleRequest('eventHandled', function() {
var args = $Array.slice(arguments);
sendRequest(this.name, args, this.definition.parameters,
{forIOThread: true});
{__proto__: null, forIOThread: true});
});
});
......
......@@ -33,6 +33,9 @@ void V8ContextNativeHandler::GetAvailability(
Feature::Availability availability = context_->GetAvailability(api_name);
v8::Local<v8::Object> ret = v8::Object::New(isolate);
v8::Maybe<bool> maybe =
ret->SetPrototype(context_->v8_context(), v8::Null(isolate));
CHECK(maybe.IsJust() && maybe.FromJust());
ret->Set(v8::String::NewFromUtf8(isolate, "is_available"),
v8::Boolean::New(isolate, availability.is_available()));
ret->Set(v8::String::NewFromUtf8(isolate, "message"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment