Index: messageResponder.js |
=================================================================== |
--- a/messageResponder.js |
+++ b/messageResponder.js |
@@ -12,16 +12,31 @@ |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
(function(global) |
{ |
+ if (typeof ext == "undefined") |
+ global.ext = require("ext_background"); |
+ |
+ var Utils = require("utils").Utils; |
+ var FilterStorage = require("filterStorage").FilterStorage; |
+ var FilterNotifier = require("filterNotifier").FilterNotifier; |
+ var defaultMatcher = require("matcher").defaultMatcher; |
+ var BlockingFilter = require("filterClasses").BlockingFilter; |
+ var Synchronizer = require("synchronizer").Synchronizer; |
+ |
+ var subscriptionClasses = require("subscriptionClasses"); |
+ var Subscription = subscriptionClasses.Subscription; |
+ var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; |
+ var SpecialSubscription = subscriptionClasses.SpecialSubscription; |
+ |
var subscriptionKeys = ["disabled", "homepage", "lastSuccess", "title", "url", "downloadStatus"]; |
function convertSubscription(subscription) |
{ |
var result = {}; |
for (var i = 0; i < subscriptionKeys.length; i++) |
result[subscriptionKeys[i]] = subscription[subscriptionKeys[i]] |
return result; |
} |
@@ -69,17 +84,17 @@ |
type: messageTypes[type], |
action: action, |
args: args |
}); |
} |
} |
}; |
- ext.onMessage.addListener(function(message, sender, callback) |
+ global.ext.onMessage.addListener(function(message, sender, callback) |
{ |
switch (message.type) |
{ |
case "app.get": |
if (message.what == "issues") |
{ |
var info = require("info"); |
callback({ |
@@ -88,26 +103,33 @@ |
legacySafariVersion: (info.platform == "safari" && ( |
Services.vc.compare(info.platformVersion, "6.0") < 0 || // beforeload breaks websites in Safari 5 |
Services.vc.compare(info.platformVersion, "6.1") == 0 || // extensions are broken in 6.1 and 7.0 |
Services.vc.compare(info.platformVersion, "7.0") == 0)) |
}); |
} |
else if (message.what == "doclink") |
callback(Utils.getDocLink(message.link)); |
+ else if (message.what == "localeInfo") |
+ { |
+ callback({ |
+ locale: Utils.appLocale, |
+ isRTL: Utils.chromeRegistry.isLocaleRTL("adblockplus") |
+ }); |
+ } |
else |
callback(null); |
break; |
case "app.open": |
if (message.what == "options") |
{ |
- if (typeof UI != "undefined") |
- UI.openFiltersDialog(); |
+ if (typeof global.openOptions == "function") |
+ global.openOptions(); |
else |
- global.openOptions(); |
+ require("ui").UI.openFiltersDialog(); |
} |
break; |
case "subscriptions.get": |
var subscriptions = FilterStorage.subscriptions.filter(function(s) |
{ |
if (message.ignoreDisabled && s.disabled) |
return false; |
if (s instanceof DownloadableSubscription && message.downloadable) |