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

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

Issue 12378077: Attempting to fix problems in 11571014. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 9 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 require('json_schema'); 10 require('json_schema');
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 " send a response after the listener returns "; 114 " send a response after the listener returns ";
115 } else { 115 } else {
116 errorMsg = 116 errorMsg =
117 "Cannot send a response more than once per " + eventName + 117 "Cannot send a response more than once per " + eventName +
118 " listener per document"; 118 " listener per document";
119 } 119 }
120 errorMsg += " (message was sent by extension " + sourceExtensionId; 120 errorMsg += " (message was sent by extension " + sourceExtensionId;
121 if (sourceExtensionId != targetExtensionId) 121 if (sourceExtensionId != targetExtensionId)
122 errorMsg += " for extension " + targetExtensionId; 122 errorMsg += " for extension " + targetExtensionId;
123 errorMsg += ")."; 123 errorMsg += ").";
124 lastError.set(errorMsg); 124 lastError.set(errorMsg, chrome);
125 console.error("Could not send response: " + errorMsg); 125 console.error("Could not send response: " + errorMsg);
126 } 126 }
127 127
128 // Helper function for dispatchOnConnect 128 // Helper function for dispatchOnConnect
129 function dispatchOnRequest(portId, channelName, sender, 129 function dispatchOnRequest(portId, channelName, sender,
130 sourceExtensionId, targetExtensionId, 130 sourceExtensionId, targetExtensionId,
131 isExternal) { 131 isExternal) {
132 var isSendMessage = channelName == chromeHidden.kMessageChannel; 132 var isSendMessage = channelName == chromeHidden.kMessageChannel;
133 var requestEvent = (isSendMessage ? 133 var requestEvent = (isSendMessage ?
134 (isExternal ? 134 (isExternal ?
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // Called by native code when a channel has been closed. 226 // Called by native code when a channel has been closed.
227 chromeHidden.Port.dispatchOnDisconnect = function( 227 chromeHidden.Port.dispatchOnDisconnect = function(
228 portId, connectionInvalid) { 228 portId, connectionInvalid) {
229 var port = ports[portId]; 229 var port = ports[portId];
230 if (port) { 230 if (port) {
231 // Update the renderer's port bookkeeping, without notifying the browser. 231 // Update the renderer's port bookkeeping, without notifying the browser.
232 CloseChannel(portId, false); 232 CloseChannel(portId, false);
233 if (connectionInvalid) { 233 if (connectionInvalid) {
234 var errorMsg = 234 var errorMsg =
235 "Could not establish connection. Receiving end does not exist."; 235 "Could not establish connection. Receiving end does not exist.";
236 lastError.set(errorMsg); 236 lastError.set(errorMsg, chrome);
237 console.error("Port error: " + errorMsg); 237 console.error("Port error: " + errorMsg);
238 } 238 }
239 try { 239 try {
240 port.onDisconnect.dispatch(port); 240 port.onDisconnect.dispatch(port);
241 } finally { 241 } finally {
242 port.destroy_(); 242 port.destroy_();
243 lastError.clear(); 243 lastError.clear(chrome);
244 } 244 }
245 } 245 }
246 }; 246 };
247 247
248 // Called by native code when a message has been sent to the given port. 248 // Called by native code when a message has been sent to the given port.
249 chromeHidden.Port.dispatchOnMessage = function(msg, portId) { 249 chromeHidden.Port.dispatchOnMessage = function(msg, portId) {
250 var port = ports[portId]; 250 var port = ports[portId];
251 if (port) { 251 if (port) {
252 if (msg) { 252 if (msg) {
253 msg = json.parse(msg); 253 msg = json.parse(msg);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 var targetId = null; 314 var targetId = null;
315 if (lastArg >= 0) 315 if (lastArg >= 0)
316 targetId = args[lastArg--]; 316 targetId = args[lastArg--];
317 317
318 if (lastArg != -1) 318 if (lastArg != -1)
319 throw new Error('Invalid arguments to ' + functionName + '.'); 319 throw new Error('Invalid arguments to ' + functionName + '.');
320 return [targetId, request, responseCallback]; 320 return [targetId, request, responseCallback];
321 } 321 }
322 322
323 exports.sendMessageUpdateArguments = sendMessageUpdateArguments; 323 exports.sendMessageUpdateArguments = sendMessageUpdateArguments;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698