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

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

Issue 11745015: Update references to the extension messaging APIs to point to the "runtime" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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/extension_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/extension_custom_bindings.js b/chrome/renderer/resources/extensions/extension_custom_bindings.js
index a4145f3c840408fcb9f8d50cdad7a55056995699..4311ee9e386632c86935d8f9627f24b79f60dcfc 100644
--- a/chrome/renderer/resources/extensions/extension_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/extension_custom_bindings.js
@@ -70,16 +70,23 @@ chromeHidden.registerCustomHook('extension',
});
// Alias several messaging deprecated APIs to their runtime counterparts.
- chrome.extension.connect = chrome.runtime.connect;
- chrome.extension.sendMessage = chrome.runtime.sendMessage;
- chrome.extension.onConnect = chrome.runtime.onConnect;
- chrome.extension.onMessage = chrome.runtime.onMessage;
- if (contextType == 'BLESSED_EXTENSION') {
- chrome.extension.connectNative = chrome.runtime.connectNative;
- chrome.extension.sendNativeMessage = chrome.runtime.sendNativeMessage;
- chrome.extension.onConnectExternal = chrome.runtime.onConnectExternal;
- chrome.extension.onMessageExternal = chrome.runtime.onMessageExternal;
- }
+ var mayNeedAlias = [
+ // Types
+ 'Port',
+ // Functions
+ 'connect', 'sendMessage', 'connectNative', 'sendNativeMessage',
+ // Events
+ 'onConnect', 'onConnectExternal', 'onMessage', 'onMessageExternal'
+ ];
+ mayNeedAlias.forEach(function(alias) {
+ try {
+ // Deliberately accessing runtime[alias] rather than testing its
+ // existence, since accessing may throw an exception if this context
+ // doesn't have access.
+ if (chrome.runtime[alias])
+ chrome.extension[alias] = chrome.runtime[alias];
+ } catch(e) {}
+ });
apiFunctions.setUpdateArgumentsPreValidate('sendRequest',
sendMessageUpdateArguments.bind(null, 'sendRequest'));
« no previous file with comments | « chrome/renderer/extensions/miscellaneous_bindings.cc ('k') | chrome/renderer/resources/extensions/miscellaneous_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698