| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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) {} | |
| 24 | 19 |
| 25 // Main browser window | 20 // Main browser window |
| 26 var mainWin = parent; | 21 var mainWin = parent; |
| 27 | 22 |
| 28 // The window handler currently in use | 23 // The window handler currently in use |
| 29 var requestNotifier = null; | 24 var requestNotifier = null; |
| 30 | 25 |
| 31 var cacheStorageSession = null; | 26 var cacheStorage = 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.
| |
| 32 var noFlash = false; | 27 var noFlash = false; |
| 33 | 28 |
| 34 // Matcher for disabled filters | 29 // Matcher for disabled filters |
| 35 var disabledMatcher = new CombinedMatcher(); | 30 var disabledMatcher = new CombinedMatcher(); |
| 36 | 31 |
| 37 // Cached string values | 32 // Cached string values |
| 38 var docDomainThirdParty = null; | 33 var docDomainThirdParty = null; |
| 39 var docDomainFirstParty = null; | 34 var docDomainFirstParty = null; |
| 40 | 35 |
| 41 function init() { | 36 function init() { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 while (sourceElement.firstChild) | 288 while (sourceElement.firstChild) |
| 294 sourceElement.removeChild(sourceElement.firstChild); | 289 sourceElement.removeChild(sourceElement.firstChild); |
| 295 for (let i = 0; i < subscriptions.length; i++) | 290 for (let i = 0; i < subscriptions.length; i++) |
| 296 setMultilineContent(sourceElement, subscriptions[i].title, true); | 291 setMultilineContent(sourceElement, subscriptions[i].title, true); |
| 297 } | 292 } |
| 298 } | 293 } |
| 299 | 294 |
| 300 var showPreview = Prefs.previewimages && !("tooltip" in item); | 295 var showPreview = Prefs.previewimages && !("tooltip" in item); |
| 301 showPreview = showPreview && item.typeDescr == "IMAGE"; | 296 showPreview = showPreview && item.typeDescr == "IMAGE"; |
| 302 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil ter instanceof WhitelistFilter); | 297 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil ter instanceof WhitelistFilter); |
| 303 E("tooltipPreviewBox").hidden = true; | 298 E("tooltipPreviewBox").hidden = true; |
|
saroyanm
2014/07/01 08:37:37
Moved tooltip IMG wrapper here because, during the
| |
| 304 if (showPreview) | 299 if (showPreview) |
| 305 { | 300 { |
| 306 if (!cacheStorageSession) | 301 if (!cacheStorage) |
| 307 { | 302 { |
| 308 //Use cache V2 API from Gecko 32 | 303 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null); |
|
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 // Cache v2 API is enabled by default starting with Gecko 32 | |
| 309 if (Services.vc.compare(Utils.platformVersion, "32.0") >= 0) | 305 if (Services.vc.compare(Utils.platformVersion, "32.0") >= 0) |
| 310 { | 306 { |
| 311 let cacheService = Cc["@mozilla.org/netwerk/cache-storage-service;1"].ge tService(Ci.nsICacheStorageService); | 307 let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInf o.jsm", null); |
| 312 cacheStorageSession = cacheService.diskCacheStorage(LoadContextInfo.defa ult, false); | 308 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.default, true); |
|
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..
| |
| 309 } | |
| 310 else | |
| 311 cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_AN YWHERE, true); | |
| 312 } | |
| 313 | |
| 314 let showTooltipPreview = function () | |
| 315 { | |
| 316 E("tooltipPreview").setAttribute("src", item.location); | |
| 317 E("tooltipPreviewBox").hidden = false; | |
| 318 }; | |
| 319 try | |
| 320 { | |
| 321 if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage) | |
| 322 { | |
| 323 cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheS torage.OPEN_READONLY, { | |
| 324 onCacheEntryCheck: function (entry, appCache) | |
| 325 { | |
| 326 return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; | |
| 327 }, | |
| 328 onCacheEntryAvailable: function (entry, isNew, appCache, status) { | |
| 329 if (!isNew) | |
| 330 showTooltipPreview(); | |
| 331 } | |
| 332 }); | |
| 313 } | 333 } |
| 314 else | 334 else |
| 315 { | 335 { |
| 316 let cacheService = Cc["@mozilla.org/network/cache-service;1"].getService (Ci.nsICacheService); | 336 cacheStorage.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, { |
| 317 cacheStorageSession = cacheService.createSession("HTTP", Ci.nsICache.STO RE_ANYWHERE, true); | 337 onCacheEntryAvailable: function(descriptor, accessGranted, status) |
| 338 { | |
| 339 if (!descriptor) | |
| 340 return; | |
| 341 descriptor.close(); | |
| 342 showTooltipPreview(); | |
| 343 }, | |
| 344 onCacheEntryDoomed: function(status) | |
| 345 { | |
| 346 } | |
| 347 }); | |
| 318 } | 348 } |
| 319 } | |
| 320 | |
| 321 let cacheListener = | |
| 322 { | |
| 323 onCacheEntryAvailable: function(entry, accessGranted, status) | |
| 324 { | |
| 325 if (!entry) | |
| 326 return; | |
| 327 | |
| 328 entry.close(); | |
| 329 // Show preview here since this is asynchronous now | |
| 330 // and we have a valid entry | |
| 331 E("tooltipPreview").setAttribute("src", item.location); | |
| 332 E("tooltipPreviewBox").hidden = false; | |
| 333 }, | |
| 334 onCacheEntryCheck: function (entry, appcache) { | |
| 335 return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; | |
| 336 }, | |
| 337 onCacheEntryDoomed: function(status) | |
| 338 { | |
| 339 } | |
| 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 | |
| 342 try | |
| 343 { | |
| 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); | |
| 349 } | 349 } |
| 350 catch (e) | 350 catch (e) |
| 351 { | 351 { |
| 352 Cu.reportError(e); | 352 Cu.reportError(e); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 const visual = { | 357 const visual = { |
| 358 OTHER: true, | 358 OTHER: true, |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1257 return {tooltip: this.itemsDummyTooltip}; | 1257 return {tooltip: this.itemsDummyTooltip}; |
| 1258 }, | 1258 }, |
| 1259 | 1259 |
| 1260 invalidateItem: function(item) | 1260 invalidateItem: function(item) |
| 1261 { | 1261 { |
| 1262 let row = this.data.indexOf(item); | 1262 let row = this.data.indexOf(item); |
| 1263 if (row >= 0) | 1263 if (row >= 0) |
| 1264 this.boxObject.invalidateRow(row); | 1264 this.boxObject.invalidateRow(row); |
| 1265 } | 1265 } |
| 1266 } | 1266 } |
| LEFT | RIGHT |