Bug 1616881 - remove saveImageURL which, besides the now-dead CPOW checks, just calls internalSave, r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D70684
This commit is contained in:
@@ -96,129 +96,6 @@ function saveURL(
|
||||
);
|
||||
}
|
||||
|
||||
// Just like saveURL, but will get some info off the image before
|
||||
// calling internalSave
|
||||
// Clientele: (Make sure you don't break any of these)
|
||||
// - Context -> Save Image As...
|
||||
const imgICache = Ci.imgICache;
|
||||
const nsISupportsCString = Ci.nsISupportsCString;
|
||||
|
||||
/**
|
||||
* Offers to save an image URL to the file system.
|
||||
*
|
||||
* @param aURL (string)
|
||||
* The URL of the image to be saved.
|
||||
* @param aFileName (string)
|
||||
* The suggested filename for the saved file.
|
||||
* @param aFilePickerTitleKey (string, optional)
|
||||
* Localized string key for an alternate title for the file
|
||||
* picker. If set to null, this will default to something sensible.
|
||||
* @param aShouldBypassCache (bool)
|
||||
* If true, the image will always be retrieved from the server instead
|
||||
* of the network or image caches.
|
||||
* @param aSkipPrompt (bool)
|
||||
* If true, we will attempt to save the file with the suggested
|
||||
* filename to the default downloads folder without showing the
|
||||
* file picker.
|
||||
* @param aReferrerInfo (nsIReferrerInfo, optional)
|
||||
* the referrerInfo object to use, or null if no referrer should be sent.
|
||||
* @param aDoc (Document, deprecated, optional)
|
||||
* The content document that the save is being initiated from. If this
|
||||
* is omitted, then aIsContentWindowPrivate must be provided.
|
||||
* @param aContentType (string, optional)
|
||||
* The content type of the image.
|
||||
* @param aContentDisp (string, optional)
|
||||
* The content disposition of the image.
|
||||
* @param aIsContentWindowPrivate (bool)
|
||||
* Whether or not the containing window is in private browsing mode.
|
||||
* Does not need to be provided is aDoc is passed.
|
||||
*/
|
||||
function saveImageURL(
|
||||
aURL,
|
||||
aFileName,
|
||||
aFilePickerTitleKey,
|
||||
aShouldBypassCache,
|
||||
aSkipPrompt,
|
||||
aReferrerInfo,
|
||||
aDoc,
|
||||
aContentType,
|
||||
aContentDisp,
|
||||
aIsContentWindowPrivate,
|
||||
aPrincipal
|
||||
) {
|
||||
forbidCPOW(aURL, "saveImageURL", "aURL");
|
||||
forbidCPOW(aReferrerInfo, "saveImageURL", "aReferrerInfo");
|
||||
|
||||
if (aDoc && aIsContentWindowPrivate == undefined) {
|
||||
if (Cu.isCrossProcessWrapper(aDoc)) {
|
||||
Deprecated.warning(
|
||||
"saveImageURL should not be passed document CPOWs. " +
|
||||
"The caller should pass in the content type and " +
|
||||
"disposition themselves",
|
||||
"https://bugzilla.mozilla.org/show_bug.cgi?id=1243643"
|
||||
);
|
||||
}
|
||||
// This will definitely not work for in-browser code or multi-process compatible
|
||||
// add-ons due to bug 1233497, which makes unsafe CPOW usage throw by default.
|
||||
Deprecated.warning(
|
||||
"saveImageURL should be passed the private state of " +
|
||||
"the containing window.",
|
||||
"https://bugzilla.mozilla.org/show_bug.cgi?id=1243643"
|
||||
);
|
||||
aIsContentWindowPrivate = PrivateBrowsingUtils.isContentWindowPrivate(
|
||||
aDoc.defaultView
|
||||
);
|
||||
}
|
||||
|
||||
// We'd better have the private state by now.
|
||||
if (aIsContentWindowPrivate == undefined) {
|
||||
throw new Error(
|
||||
"saveImageURL couldn't compute private state of content window"
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!aShouldBypassCache &&
|
||||
aDoc &&
|
||||
!Cu.isCrossProcessWrapper(aDoc) &&
|
||||
!aContentType &&
|
||||
!aContentDisp
|
||||
) {
|
||||
try {
|
||||
var imageCache = Cc["@mozilla.org/image/tools;1"]
|
||||
.getService(Ci.imgITools)
|
||||
.getImgCacheForDocument(aDoc);
|
||||
var props = imageCache.findEntryProperties(
|
||||
makeURI(aURL, getCharsetforSave(null)),
|
||||
aDoc
|
||||
);
|
||||
if (props) {
|
||||
aContentType = props.get("type", nsISupportsCString);
|
||||
aContentDisp = props.get("content-disposition", nsISupportsCString);
|
||||
}
|
||||
} catch (e) {
|
||||
// Failure to get type and content-disposition off the image is non-fatal
|
||||
}
|
||||
}
|
||||
|
||||
internalSave(
|
||||
aURL,
|
||||
null,
|
||||
aFileName,
|
||||
aContentDisp,
|
||||
aContentType,
|
||||
aShouldBypassCache,
|
||||
aFilePickerTitleKey,
|
||||
null,
|
||||
aReferrerInfo,
|
||||
aDoc,
|
||||
aSkipPrompt,
|
||||
null,
|
||||
aIsContentWindowPrivate,
|
||||
aPrincipal
|
||||
);
|
||||
}
|
||||
|
||||
// This is like saveDocument, but takes any browser/frame-like element
|
||||
// and saves the current document inside it,
|
||||
// whether in-process or out-of-process.
|
||||
|
||||
Reference in New Issue
Block a user