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

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

Issue 16174005: Implement externally_connectable! Web pages can now communicate directly with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: absolute path... 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/runtime_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/runtime_custom_bindings.js b/chrome/renderer/resources/extensions/runtime_custom_bindings.js
index 85f04764c24e92c85afaa7f46b22883698e5f574..66245c9e3deb39a2d814997cc33e42d4067d335b 100644
--- a/chrome/renderer/resources/extensions/runtime_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/runtime_custom_bindings.js
@@ -82,22 +82,21 @@ binding.registerCustomHook(function(binding, id, contextType) {
});
apiFunctions.setHandleRequest('connect', function(targetId, connectInfo) {
+ // Don't let orphaned content scripts communicate with their extension.
+ // http://crbug.com/168263
+ if (unloadEvent.wasDispatched)
+ throw new Error('Error connecting to extension ' + targetId);
+
if (!targetId)
targetId = runtime.id;
+
var name = '';
if (connectInfo && connectInfo.name)
name = connectInfo.name;
- // Don't let orphaned content scripts communicate with their extension.
- // http://crbug.com/168263
- if (!unloadEvent.wasDispatched) {
- var portId = runtimeNatives.OpenChannelToExtension(runtime.id,
- targetId,
- name);
- if (portId >= 0)
- return miscBindings.createPort(portId, name);
- }
- throw new Error('Error connecting to extension ' + targetId);
+ var portId = runtimeNatives.OpenChannelToExtension(targetId, name);
+ if (portId >= 0)
+ return miscBindings.createPort(portId, name);
});
//

Powered by Google App Engine
This is Rietveld 408576698