diff --git a/mobile/chrome/content/ContextCommands.js b/mobile/chrome/content/ContextCommands.js index af6c41e15ec..7b6e7ff3643 100644 --- a/mobile/chrome/content/ContextCommands.js +++ b/mobile/chrome/content/ContextCommands.js @@ -52,8 +52,16 @@ var ContextCommands = { }, saveImage: function cc_saveImage() { - let browser = ContextHelper.popupState.target; - ContentAreaUtils.saveImageURL(ContextHelper.popupState.mediaURL, null, "SaveImageTitle", false, true, browser.documentURI); + let popupState = ContextHelper.popupState; + let browser = popupState.target; + + // Bug 638523 + // Using directly SaveImageURL fails here since checking the cache for a + // remote page seems to not work (could it be nsICacheSession prohibition)? + ContentAreaUtils.internalSave(popupState.mediaURL, null, null, + popupState.contentDisposition, + popupState.contentType, false, "SaveImageTitle", + null, browser.documentURI, false, null); }, shareLink: function cc_shareLink() { diff --git a/mobile/chrome/content/content.js b/mobile/chrome/content/content.js index 604f6d722fd..89f703a1dd8 100644 --- a/mobile/chrome/content/content.js +++ b/mobile/chrome/content/content.js @@ -804,6 +804,20 @@ var ContextHandler = { if (popupNode instanceof Ci.nsIImageLoadingContent && popupNode.currentURI) { state.types.push("image"); state.label = state.mediaURL = popupNode.currentURI.spec; + + // Retrieve the type of image from the cache since the url can fail to + // provide valuable informations + try { + let imageCache = Cc["@mozilla.org/image/cache;1"].getService(Ci.imgICache); + let props = imageCache.findEntryProperties(popupNode.currentURI, content.document.characterSet); + if (props) { + state.contentType = String(props.get("type", Ci.nsISupportsCString)); + state.contentDisposition = String(props.get("content-disposition", Ci.nsISupportsCString)); + } + } catch (e) { + // Failure to get type and content-disposition off the image is non-fatal + } + } else if (popupNode instanceof Ci.nsIDOMHTMLMediaElement) { state.label = state.mediaURL = (popupNode.currentSrc || popupNode.src); state.types.push((popupNode.paused || popupNode.ended) ? "media-paused" : "media-playing");