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. 29, 2013, 2:33 p.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,29 +295,43 @@
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 =
+ {
+ 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);
+ E("tooltipPreviewBox").hidden = false;
+ },
+ onCacheEntryDoomed: function(status)
+ {
+ }
+ };
+ try
+ {
+ cacheSession.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, cacheListener);
}
- catch (e) {
- showPreview = false;
+ catch (e)
+ {
+ Cu.reportError(e);
}
}
- if (showPreview) {
- E("tooltipPreviewBox").hidden = false;
- E("tooltipPreview").setAttribute("src", "");
- E("tooltipPreview").setAttribute("src", item.location);
- }
- else
- E("tooltipPreviewBox").hidden = true;
+ E("tooltipPreviewBox").hidden = true;
}
const visual = {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld