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

Side by Side Diff: chrome/renderer/resources/extensions/miscellaneous_bindings.js

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This contains unprivileged javascript APIs for extensions and apps. It 5 // This contains unprivileged javascript APIs for extensions and apps. It
6 // can be loaded by any extension-related context, such as content scripts or 6 // can be loaded by any extension-related context, such as content scripts or
7 // background pages. See user_script_slave.cc for script that is loaded by 7 // background pages. See user_script_slave.cc for script that is loaded by
8 // content scripts only. 8 // content scripts only.
9 9
10 // TODO(kalman): factor requiring chrome out of here. 10 // TODO(kalman): factor requiring chrome out of here.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // Helper function for dispatchOnRequest. 95 // Helper function for dispatchOnRequest.
96 function handleSendRequestError(isSendMessage, 96 function handleSendRequestError(isSendMessage,
97 responseCallbackPreserved, 97 responseCallbackPreserved,
98 sourceExtensionId, 98 sourceExtensionId,
99 targetExtensionId, 99 targetExtensionId,
100 sourceUrl) { 100 sourceUrl) {
101 var errorMsg = []; 101 var errorMsg = [];
102 var eventName = isSendMessage ? "runtime.onMessage" : "extension.onRequest"; 102 var eventName = isSendMessage ? "runtime.onMessage" : "extension.onRequest";
103 if (isSendMessage && !responseCallbackPreserved) { 103 if (isSendMessage && !responseCallbackPreserved) {
104 errorMsg.push( 104 $Array.push(errorMsg,
105 "The chrome." + eventName + " listener must return true if you " + 105 "The chrome." + eventName + " listener must return true if you " +
106 "want to send a response after the listener returns"); 106 "want to send a response after the listener returns");
107 } else { 107 } else {
108 errorMsg.push( 108 $Array.push(errorMsg,
109 "Cannot send a response more than once per chrome." + eventName + 109 "Cannot send a response more than once per chrome." + eventName +
110 " listener per document"); 110 " listener per document");
111 } 111 }
112 errorMsg.push("(message was sent by extension" + sourceExtensionId); 112 $Array.push(errorMsg, "(message was sent by extension" + sourceExtensionId);
113 if (sourceExtensionId != "" && sourceExtensionId != targetExtensionId) 113 if (sourceExtensionId != "" && sourceExtensionId != targetExtensionId)
114 errorMsg.push("for extension " + targetExtensionId); 114 $Array.push(errorMsg, "for extension " + targetExtensionId);
115 if (sourceUrl != "") 115 if (sourceUrl != "")
116 errorMsg.push("for URL " + sourceUrl); 116 $Array.push(errorMsg, "for URL " + sourceUrl);
117 lastError.set(eventName, errorMsg.join(" ") + ").", null, chrome); 117 lastError.set(eventName, errorMsg.join(" ") + ").", null, chrome);
118 } 118 }
119 119
120 // Helper function for dispatchOnConnect 120 // Helper function for dispatchOnConnect
121 function dispatchOnRequest(portId, channelName, sender, 121 function dispatchOnRequest(portId, channelName, sender,
122 sourceExtensionId, targetExtensionId, sourceUrl, 122 sourceExtensionId, targetExtensionId, sourceUrl,
123 isExternal) { 123 isExternal) {
124 var isSendMessage = channelName == kMessageChannel; 124 var isSendMessage = channelName == kMessageChannel;
125 var requestEvent = null; 125 var requestEvent = null;
126 if (isSendMessage) { 126 if (isSendMessage) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 port = null; 311 port = null;
312 } 312 }
313 }); 313 });
314 }; 314 };
315 315
316 function sendMessageUpdateArguments(functionName) { 316 function sendMessageUpdateArguments(functionName) {
317 // Align missing (optional) function arguments with the arguments that 317 // Align missing (optional) function arguments with the arguments that
318 // schema validation is expecting, e.g. 318 // schema validation is expecting, e.g.
319 // extension.sendRequest(req) -> extension.sendRequest(null, req) 319 // extension.sendRequest(req) -> extension.sendRequest(null, req)
320 // extension.sendRequest(req, cb) -> extension.sendRequest(null, req, cb) 320 // extension.sendRequest(req, cb) -> extension.sendRequest(null, req, cb)
321 var args = Array.prototype.splice.call(arguments, 1); // skip functionName 321 var args = $Array.splice(arguments, 1); // skip functionName
322 var lastArg = args.length - 1; 322 var lastArg = args.length - 1;
323 323
324 // responseCallback (last argument) is optional. 324 // responseCallback (last argument) is optional.
325 var responseCallback = null; 325 var responseCallback = null;
326 if (typeof(args[lastArg]) == 'function') 326 if (typeof(args[lastArg]) == 'function')
327 responseCallback = args[lastArg--]; 327 responseCallback = args[lastArg--];
328 328
329 // request (second argument) is required. 329 // request (second argument) is required.
330 var request = args[lastArg--]; 330 var request = args[lastArg--];
331 331
(...skipping 13 matching lines...) Expand all
345 exports.Port = Port; 345 exports.Port = Port;
346 exports.createPort = createPort; 346 exports.createPort = createPort;
347 exports.sendMessageImpl = sendMessageImpl; 347 exports.sendMessageImpl = sendMessageImpl;
348 exports.sendMessageUpdateArguments = sendMessageUpdateArguments; 348 exports.sendMessageUpdateArguments = sendMessageUpdateArguments;
349 349
350 // For C++ code to call. 350 // For C++ code to call.
351 exports.hasPort = hasPort; 351 exports.hasPort = hasPort;
352 exports.dispatchOnConnect = dispatchOnConnect; 352 exports.dispatchOnConnect = dispatchOnConnect;
353 exports.dispatchOnDisconnect = dispatchOnDisconnect; 353 exports.dispatchOnDisconnect = dispatchOnDisconnect;
354 exports.dispatchOnMessage = dispatchOnMessage; 354 exports.dispatchOnMessage = dispatchOnMessage;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698