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

Unified Diff: chrome/content/ui/sidebar.js

Issue 6349471881363456: Fixed: Topic 12380 - No image preview in list of blockable items (Closed)
Patch Set: Created Nov. 14, 2013, 11:13 a.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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/sidebar.js
===================================================================
--- a/chrome/content/ui/sidebar.js
+++ b/chrome/content/ui/sidebar.js
@@ -295,26 +295,44 @@
var showPreview = Prefs.previewimages && !("tooltip" in item);
showPreview = showPreview && item.typeDescr == "IMAGE";
showPreview = showPreview && (!item.filter || item.filter.disabled || item.filter instanceof WhitelistFilter);
- if (showPreview) {
+ if (showPreview)
+ {
// Check whether image is in cache (stolen from ImgLikeOpera)
- if (!cacheSession) {
+ if (!cacheSession)
+ {
var cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService);
cacheSession = cacheService.createSession("HTTP", Ci.nsICache.STORE_ANYWHERE, true);
}
- try {
- var descriptor = cacheSession.openCacheEntry(item.location, Ci.nsICache.ACCESS_READ, false);
- descriptor.close();
+ let cacheListener = {
Wladimir Palant 2013/11/26 11:35:31 Style nit: this bracket should be on the next line
Thomas Greiner 2013/11/29 14:35:44 Done.
+ onCacheEntryAvailable: function(descriptor, accessGranted, status)
+ {
+ if (!descriptor)
+ return;
+
+ descriptor.close();
+ // Show preview here since this is asynchronous now
+ // and we have a valid descriptor
+ E("tooltipPreview").setAttribute("src", item.location);
+ },
+ onCacheEntryDoomed: function(status)
+ {
+ }
+ };
+ try
+ {
+ cacheSession.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, cacheListener);
}
- catch (e) {
+ catch (e)
+ {
showPreview = false;
Wladimir Palant 2013/11/26 11:35:31 This should normally never happen, please add Cu.r
Thomas Greiner 2013/11/29 14:35:44 Done.
}
}
- if (showPreview) {
+ if (showPreview)
+ {
E("tooltipPreviewBox").hidden = false;
E("tooltipPreview").setAttribute("src", "");
- E("tooltipPreview").setAttribute("src", item.location);
}
else
E("tooltipPreviewBox").hidden = true;
Wladimir Palant 2013/11/26 11:35:31 We should not show the preview box at all if we ar
Thomas Greiner 2013/11/29 14:35:44 Done.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld