Left: | ||
Right: |
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 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 18 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
19 let LoadContextInfo = null; | |
20 try | |
21 { | |
22 ({LoadContextInfo}) = Cu.import("resource://gre/modules/LoadContextInfo.jsm", {}); | |
Wladimir Palant
2014/07/01 11:58:33
Please use null rather than {} for the context par
saroyanm
2014/07/01 16:45:47
Done.
| |
23 } catch (e) {} | |
19 | 24 |
20 // Main browser window | 25 // Main browser window |
21 var mainWin = parent; | 26 var mainWin = parent; |
22 | 27 |
23 // The window handler currently in use | 28 // The window handler currently in use |
24 var requestNotifier = null; | 29 var requestNotifier = null; |
25 | 30 |
26 var cacheSession = null; | 31 var cacheStorageSession = null; |
saroyanm
2014/07/01 08:37:37
Not sure if I should use more general name for thi
Wladimir Palant
2014/07/01 11:58:33
This variable name is now a mix of the old and new
saroyanm
2014/07/01 16:45:47
Done.
| |
27 var noFlash = false; | 32 var noFlash = false; |
28 | 33 |
29 // Matcher for disabled filters | 34 // Matcher for disabled filters |
30 var disabledMatcher = new CombinedMatcher(); | 35 var disabledMatcher = new CombinedMatcher(); |
31 | 36 |
32 // Cached string values | 37 // Cached string values |
33 var docDomainThirdParty = null; | 38 var docDomainThirdParty = null; |
34 var docDomainFirstParty = null; | 39 var docDomainFirstParty = null; |
35 | 40 |
36 function init() { | 41 function init() { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 while (sourceElement.firstChild) | 293 while (sourceElement.firstChild) |
289 sourceElement.removeChild(sourceElement.firstChild); | 294 sourceElement.removeChild(sourceElement.firstChild); |
290 for (let i = 0; i < subscriptions.length; i++) | 295 for (let i = 0; i < subscriptions.length; i++) |
291 setMultilineContent(sourceElement, subscriptions[i].title, true); | 296 setMultilineContent(sourceElement, subscriptions[i].title, true); |
292 } | 297 } |
293 } | 298 } |
294 | 299 |
295 var showPreview = Prefs.previewimages && !("tooltip" in item); | 300 var showPreview = Prefs.previewimages && !("tooltip" in item); |
296 showPreview = showPreview && item.typeDescr == "IMAGE"; | 301 showPreview = showPreview && item.typeDescr == "IMAGE"; |
297 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil ter instanceof WhitelistFilter); | 302 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil ter instanceof WhitelistFilter); |
303 E("tooltipPreviewBox").hidden = true; | |
saroyanm
2014/07/01 08:37:37
Moved tooltip IMG wrapper here because, during the
| |
298 if (showPreview) | 304 if (showPreview) |
299 { | 305 { |
300 // Check whether image is in cache (stolen from ImgLikeOpera) | 306 if (!cacheStorageSession) |
301 if (!cacheSession) | |
302 { | 307 { |
303 var cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(C i.nsICacheService); | 308 //Use cache V2 API from Gecko 32 |
Wladimir Palant
2014/07/01 11:58:33
This implies that a) we will always use Cache v2 A
saroyanm
2014/07/01 16:45:47
Thought to use hardcoding solution after reading c
Wladimir Palant
2014/07/02 05:00:03
Unfortunately, checking for component existence do
| |
304 cacheSession = cacheService.createSession("HTTP", Ci.nsICache.STORE_ANYWHE RE, true); | 309 if (Services.vc.compare(Utils.platformVersion, "32.0") >= 0) |
310 { | |
311 let cacheService = Cc["@mozilla.org/netwerk/cache-storage-service;1"].ge tService(Ci.nsICacheStorageService); | |
312 cacheStorageSession = cacheService.diskCacheStorage(LoadContextInfo.defa ult, false); | |
Wladimir Palant
2014/07/01 11:58:33
You only need LoadContextInfo here, meaning that y
Wladimir Palant
2014/07/01 12:00:46
From the source code it seems that diskCacheStorag
saroyanm
2014/07/01 16:45:47
I tried to avoid loading LoadContextInfo for each
Wladimir Palant
2014/07/02 05:00:03
It won't be loaded for each item - setting the cac
saroyanm
2014/07/02 07:03:41
Ohh yes sure, thanks..
| |
313 } | |
314 else | |
315 { | |
316 let cacheService = Cc["@mozilla.org/network/cache-service;1"].getService (Ci.nsICacheService); | |
317 cacheStorageSession = cacheService.createSession("HTTP", Ci.nsICache.STO RE_ANYWHERE, true); | |
318 } | |
305 } | 319 } |
306 | 320 |
307 let cacheListener = | 321 let cacheListener = |
308 { | 322 { |
309 onCacheEntryAvailable: function(descriptor, accessGranted, status) | 323 onCacheEntryAvailable: function(entry, accessGranted, status) |
310 { | 324 { |
311 if (!descriptor) | 325 if (!entry) |
312 return; | 326 return; |
313 | 327 |
314 descriptor.close(); | 328 entry.close(); |
315 // Show preview here since this is asynchronous now | 329 // Show preview here since this is asynchronous now |
316 // and we have a valid descriptor | 330 // and we have a valid entry |
317 E("tooltipPreview").setAttribute("src", item.location); | 331 E("tooltipPreview").setAttribute("src", item.location); |
318 E("tooltipPreviewBox").hidden = false; | 332 E("tooltipPreviewBox").hidden = false; |
319 }, | 333 }, |
334 onCacheEntryCheck: function (entry, appcache) { | |
335 return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; | |
336 }, | |
320 onCacheEntryDoomed: function(status) | 337 onCacheEntryDoomed: function(status) |
321 { | 338 { |
322 } | 339 } |
323 }; | 340 }; |
Wladimir Palant
2014/07/01 11:58:33
I don't think that using the same listener for bot
saroyanm
2014/07/01 16:45:47
What you think do we need onCacheEntryDoomed here
Wladimir Palant
2014/07/02 05:00:03
Yes, it is part of the interface - we might get er
saroyanm
2014/07/02 07:03:41
I see.
| |
341 | |
324 try | 342 try |
325 { | 343 { |
326 cacheSession.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, c acheListener); | 344 //Use cache V2 API from Gecko 32 |
345 if (Services.vc.compare(Utils.platformVersion, "32.0") >= 0) | |
Wladimir Palant
2014/07/01 11:58:33
Please don't duplicate the branch condition here.
saroyanm
2014/07/01 16:45:47
Done.
| |
346 cacheStorageSession.asyncOpenURI(Utils.makeURI(item.location), "", Ci.ns ICacheStorage.OPEN_READONLY, cacheListener); | |
347 else | |
348 cacheStorageSession.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCES S_READ, cacheListener); | |
327 } | 349 } |
328 catch (e) | 350 catch (e) |
329 { | 351 { |
330 Cu.reportError(e); | 352 Cu.reportError(e); |
331 } | 353 } |
332 } | 354 } |
333 | |
334 E("tooltipPreviewBox").hidden = true; | |
335 } | 355 } |
336 | 356 |
337 const visual = { | 357 const visual = { |
338 OTHER: true, | 358 OTHER: true, |
339 IMAGE: true, | 359 IMAGE: true, |
340 SUBDOCUMENT: true | 360 SUBDOCUMENT: true |
341 } | 361 } |
342 | 362 |
343 /** | 363 /** |
344 * Updates context menu before it is shown. | 364 * Updates context menu before it is shown. |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 return {tooltip: this.itemsDummyTooltip}; | 1257 return {tooltip: this.itemsDummyTooltip}; |
1238 }, | 1258 }, |
1239 | 1259 |
1240 invalidateItem: function(item) | 1260 invalidateItem: function(item) |
1241 { | 1261 { |
1242 let row = this.data.indexOf(item); | 1262 let row = this.data.indexOf(item); |
1243 if (row >= 0) | 1263 if (row >= 0) |
1244 this.boxObject.invalidateRow(row); | 1264 this.boxObject.invalidateRow(row); |
1245 } | 1265 } |
1246 } | 1266 } |
OLD | NEW |