зеркало из https://github.com/mozilla/pjs.git
Bug 638523 - Save Image saves htm, not the image [r=mbrubeck]
This commit is contained in:
Родитель
3843609c91
Коммит
8a810c34fc
|
@ -52,8 +52,16 @@ var ContextCommands = {
|
||||||
},
|
},
|
||||||
|
|
||||||
saveImage: function cc_saveImage() {
|
saveImage: function cc_saveImage() {
|
||||||
let browser = ContextHelper.popupState.target;
|
let popupState = ContextHelper.popupState;
|
||||||
ContentAreaUtils.saveImageURL(ContextHelper.popupState.mediaURL, null, "SaveImageTitle", false, true, browser.documentURI);
|
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() {
|
shareLink: function cc_shareLink() {
|
||||||
|
|
|
@ -804,6 +804,20 @@ var ContextHandler = {
|
||||||
if (popupNode instanceof Ci.nsIImageLoadingContent && popupNode.currentURI) {
|
if (popupNode instanceof Ci.nsIImageLoadingContent && popupNode.currentURI) {
|
||||||
state.types.push("image");
|
state.types.push("image");
|
||||||
state.label = state.mediaURL = popupNode.currentURI.spec;
|
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) {
|
} else if (popupNode instanceof Ci.nsIDOMHTMLMediaElement) {
|
||||||
state.label = state.mediaURL = (popupNode.currentSrc || popupNode.src);
|
state.label = state.mediaURL = (popupNode.currentSrc || popupNode.src);
|
||||||
state.types.push((popupNode.paused || popupNode.ended) ? "media-paused" : "media-playing");
|
state.types.push((popupNode.paused || popupNode.ended) ? "media-paused" : "media-playing");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче