Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/common.js

Issue 4549521954570240: Added backwards compatibility for Chrome's old messaging API (Closed)
Patch Set: Handled case when chrome.runtime isn't present Created Nov. 17, 2013, 1:21 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common.js
===================================================================
--- a/chrome/common.js
+++ b/chrome/common.js
@@ -56,7 +56,7 @@
var MessageEventTarget = function()
{
- WrappedEventTarget.call(this, chrome.runtime.onMessage);
+ WrappedEventTarget.call(this, (chrome.runtime || {}).onMessage || chrome.extension.onRequest);
};
MessageEventTarget.prototype = {
__proto__: WrappedEventTarget.prototype,
@@ -68,18 +68,13 @@
}
};
+
/* API */
ext = {
backgroundPage: {
- sendMessage: function(message, responseCallback)
- {
- chrome.runtime.sendMessage(message, responseCallback);
- },
- getWindow: function()
- {
- return chrome.extension.getBackgroundPage();
- }
+ sendMessage: (chrome.runtime || {}).sendMessage || chrome.extension.sendRequest,
+ getWindow: chrome.extension.getBackgroundPage
},
getURL: chrome.extension.getURL,
onMessage: new MessageEventTarget(),
« no previous file with comments | « chrome/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld