OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 (function(global) | 18 (function(global) |
19 { | 19 { |
| 20 if (typeof ext == "undefined") |
| 21 global.ext = require("ext_background"); |
| 22 |
| 23 var Utils = require("utils").Utils; |
| 24 var FilterStorage = require("filterStorage").FilterStorage; |
| 25 var FilterNotifier = require("filterNotifier").FilterNotifier; |
| 26 var defaultMatcher = require("matcher").defaultMatcher; |
| 27 var BlockingFilter = require("filterClasses").BlockingFilter; |
| 28 var Synchronizer = require("synchronizer").Synchronizer; |
| 29 |
| 30 var subscriptionClasses = require("subscriptionClasses"); |
| 31 var Subscription = subscriptionClasses.Subscription; |
| 32 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; |
| 33 var SpecialSubscription = subscriptionClasses.SpecialSubscription; |
| 34 |
20 var subscriptionKeys = ["disabled", "homepage", "lastSuccess", "title", "url",
"downloadStatus"]; | 35 var subscriptionKeys = ["disabled", "homepage", "lastSuccess", "title", "url",
"downloadStatus"]; |
21 function convertSubscription(subscription) | 36 function convertSubscription(subscription) |
22 { | 37 { |
23 var result = {}; | 38 var result = {}; |
24 for (var i = 0; i < subscriptionKeys.length; i++) | 39 for (var i = 0; i < subscriptionKeys.length; i++) |
25 result[subscriptionKeys[i]] = subscription[subscriptionKeys[i]] | 40 result[subscriptionKeys[i]] = subscription[subscriptionKeys[i]] |
26 return result; | 41 return result; |
27 } | 42 } |
28 | 43 |
29 var changeListeners = null; | 44 var changeListeners = null; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 { | 82 { |
68 pages[i].sendMessage({ | 83 pages[i].sendMessage({ |
69 type: messageTypes[type], | 84 type: messageTypes[type], |
70 action: action, | 85 action: action, |
71 args: args | 86 args: args |
72 }); | 87 }); |
73 } | 88 } |
74 } | 89 } |
75 }; | 90 }; |
76 | 91 |
77 ext.onMessage.addListener(function(message, sender, callback) | 92 global.ext.onMessage.addListener(function(message, sender, callback) |
78 { | 93 { |
79 switch (message.type) | 94 switch (message.type) |
80 { | 95 { |
81 case "app.get": | 96 case "app.get": |
82 if (message.what == "issues") | 97 if (message.what == "issues") |
83 { | 98 { |
84 var info = require("info"); | 99 var info = require("info"); |
85 callback({ | 100 callback({ |
86 seenDataCorruption: "seenDataCorruption" in global ? global.seenData
Corruption : false, | 101 seenDataCorruption: "seenDataCorruption" in global ? global.seenData
Corruption : false, |
87 filterlistsReinitialized: "filterlistsReinitialized" in global ? glo
bal.filterlistsReinitialized : false, | 102 filterlistsReinitialized: "filterlistsReinitialized" in global ? glo
bal.filterlistsReinitialized : false, |
88 legacySafariVersion: (info.platform == "safari" && ( | 103 legacySafariVersion: (info.platform == "safari" && ( |
89 Services.vc.compare(info.platformVersion, "6.0") < 0 || // bef
oreload breaks websites in Safari 5 | 104 Services.vc.compare(info.platformVersion, "6.0") < 0 || // bef
oreload breaks websites in Safari 5 |
90 Services.vc.compare(info.platformVersion, "6.1") == 0 || // ext
ensions are broken in 6.1 and 7.0 | 105 Services.vc.compare(info.platformVersion, "6.1") == 0 || // ext
ensions are broken in 6.1 and 7.0 |
91 Services.vc.compare(info.platformVersion, "7.0") == 0)) | 106 Services.vc.compare(info.platformVersion, "7.0") == 0)) |
92 }); | 107 }); |
93 } | 108 } |
94 else if (message.what == "doclink") | 109 else if (message.what == "doclink") |
95 callback(Utils.getDocLink(message.link)); | 110 callback(Utils.getDocLink(message.link)); |
| 111 else if (message.what == "localeInfo") |
| 112 { |
| 113 callback({ |
| 114 locale: Utils.appLocale, |
| 115 isRTL: Utils.chromeRegistry.isLocaleRTL("adblockplus") |
| 116 }); |
| 117 } |
96 else | 118 else |
97 callback(null); | 119 callback(null); |
98 break; | 120 break; |
99 case "app.open": | 121 case "app.open": |
100 if (message.what == "options") | 122 if (message.what == "options") |
101 { | 123 { |
102 if (typeof UI != "undefined") | 124 if (typeof global.openOptions == "function") |
103 UI.openFiltersDialog(); | 125 global.openOptions(); |
104 else | 126 else |
105 global.openOptions(); | 127 require("ui").UI.openFiltersDialog(); |
106 } | 128 } |
107 break; | 129 break; |
108 case "subscriptions.get": | 130 case "subscriptions.get": |
109 var subscriptions = FilterStorage.subscriptions.filter(function(s) | 131 var subscriptions = FilterStorage.subscriptions.filter(function(s) |
110 { | 132 { |
111 if (message.ignoreDisabled && s.disabled) | 133 if (message.ignoreDisabled && s.disabled) |
112 return false; | 134 return false; |
113 if (s instanceof DownloadableSubscription && message.downloadable) | 135 if (s instanceof DownloadableSubscription && message.downloadable) |
114 return true; | 136 return true; |
115 if (s instanceof SpecialSubscription && message.special) | 137 if (s instanceof SpecialSubscription && message.special) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 173 } |
152 | 174 |
153 if (message.filter) | 175 if (message.filter) |
154 filters.subscription = message.filter; | 176 filters.subscription = message.filter; |
155 else | 177 else |
156 delete filters.subscription; | 178 delete filters.subscription; |
157 break; | 179 break; |
158 } | 180 } |
159 }); | 181 }); |
160 })(this); | 182 })(this); |
OLD | NEW |