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

Unified Diff: chrome/renderer/resources/extensions/miscellaneous_bindings.js

Issue 14301016: Fix a couple of bugs relating to sending Tab info with chrome.runtime.connect and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add key to app1/manifest.json Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/miscellaneous_bindings.js
diff --git a/chrome/renderer/resources/extensions/miscellaneous_bindings.js b/chrome/renderer/resources/extensions/miscellaneous_bindings.js
index 33eb9d96f8620a987823bdbb2f49dbcff08af62c..9a4937d1860c7bb0d79961549097117a031c11fa 100644
--- a/chrome/renderer/resources/extensions/miscellaneous_bindings.js
+++ b/chrome/renderer/resources/extensions/miscellaneous_bindings.js
@@ -105,29 +105,33 @@
};
// Helper function for dispatchOnRequest.
- function handleSendRequestError(isSendMessage, responseCallbackPreserved,
- sourceExtensionId, targetExtensionId) {
- var errorMsg;
+ function handleSendRequestError(isSendMessage,
+ responseCallbackPreserved,
+ sourceExtensionId,
+ targetExtensionId,
+ sourceUrl) {
+ var errorMsg = [];
var eventName = isSendMessage ? "runtime.onMessage" : "extension.onRequest";
if (isSendMessage && !responseCallbackPreserved) {
- errorMsg =
+ errorMsg.push(
"The chrome." + eventName + " listener must return true if you " +
- "want to send a response after the listener returns ";
+ "want to send a response after the listener returns");
} else {
- errorMsg =
+ errorMsg.push(
"Cannot send a response more than once per chrome." + eventName +
- " listener per document";
+ " listener per document");
}
- errorMsg += "(message was sent by extension " + sourceExtensionId;
- if (sourceExtensionId != targetExtensionId)
- errorMsg += " for extension " + targetExtensionId;
- errorMsg += ").";
- lastError.set(eventName, errorMsg, null, chrome);
+ errorMsg.push("(message was sent by extension" + sourceExtensionId);
+ if (sourceExtensionId != "" && sourceExtensionId != targetExtensionId)
+ errorMsg.push("for extension " + targetExtensionId);
+ if (sourceUrl != "")
+ errorMsg.push("for URL " + sourceUrl);
+ lastError.set(eventName, errorMsg.join(" ") + ").", null, chrome);
}
// Helper function for dispatchOnConnect
function dispatchOnRequest(portId, channelName, sender,
- sourceExtensionId, targetExtensionId,
+ sourceExtensionId, targetExtensionId, sourceUrl,
isExternal) {
var isSendMessage = channelName == chromeHidden.kMessageChannel;
var requestEvent = (isSendMessage ?
@@ -182,16 +186,19 @@
"extension.onRequestExternal" : "extension.onRequest"));
logActivity.LogEvent(targetExtensionId,
eventName,
- [sourceExtensionId]);
+ [sourceExtensionId, sourceUrl]);
return true;
}
return false;
}
// Called by native code when a channel has been opened to this context.
- chromeHidden.Port.dispatchOnConnect = function(portId, channelName, tab,
+ chromeHidden.Port.dispatchOnConnect = function(portId,
+ channelName,
+ sourceTab,
sourceExtensionId,
- targetExtensionId) {
+ targetExtensionId,
+ sourceUrl) {
// Only create a new Port if someone is actually listening for a connection.
// In addition to being an optimization, this also fixes a bug where if 2
// channels were opened to and from the same process, closing one would
@@ -205,15 +212,17 @@
// the right event.
var isExternal = sourceExtensionId != extensionId;
- if (tab)
- tab = json.parse(tab);
- var sender = {tab: tab, id: sourceExtensionId};
+ var sender = {id: sourceExtensionId};
+ if (sourceUrl)
+ sender.url = sourceUrl;
+ if (sourceTab)
+ sender.tab = sourceTab;
// Special case for sendRequest/onRequest and sendMessage/onMessage.
if (channelName == chromeHidden.kRequestChannel ||
channelName == chromeHidden.kMessageChannel) {
return dispatchOnRequest(portId, channelName, sender,
- sourceExtensionId, targetExtensionId,
+ sourceExtensionId, targetExtensionId, sourceUrl,
isExternal);
}
« no previous file with comments | « chrome/renderer/extensions/runtime_custom_bindings.cc ('k') | chrome/renderer/resources/extensions/test_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698