mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 791654 - Add Save Video/Audio to context menus. r=wesj
This commit is contained in:
parent
132caaa2c6
commit
05533aa7f8
@ -499,6 +499,30 @@ var BrowserApp = {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
NativeWindow.contextmenus.add(
|
||||
function(aTarget) {
|
||||
if (aTarget instanceof HTMLVideoElement) {
|
||||
// If a video element is zero width or height, its essentially
|
||||
// an HTMLAudioElement.
|
||||
if (aTarget.videoWidth == 0 || aTarget.videoHeight == 0 )
|
||||
return Strings.browser.GetStringFromName("contextmenu.saveAudio");
|
||||
return Strings.browser.GetStringFromName("contextmenu.saveVideo");
|
||||
} else if (aTarget instanceof HTMLAudioElement) {
|
||||
return Strings.browser.GetStringFromName("contextmenu.saveAudio");
|
||||
}
|
||||
return Strings.browser.GetStringFromName("contextmenu.saveVideo");
|
||||
}, NativeWindow.contextmenus.mediaSaveableContext,
|
||||
function(aTarget) {
|
||||
let url = aTarget.currentSrc || aTarget.src;
|
||||
let filePickerTitleKey = (aTarget instanceof HTMLVideoElement &&
|
||||
(aTarget.videoWidth != 0 && aTarget.videoHeight != 0))
|
||||
? "SaveVideoTitle" : "SaveAudioTitle";
|
||||
// Skipped trying to pull MIME type out of cache for now
|
||||
ContentAreaUtils.internalSave(url, null, null, null, null, false,
|
||||
filePickerTitleKey, null, aTarget.ownerDocument.documentURIObject,
|
||||
aTarget.ownerDocument, true, null);
|
||||
});
|
||||
},
|
||||
|
||||
onAppUpdated: function() {
|
||||
@ -1546,6 +1570,13 @@ var NativeWindow = {
|
||||
}
|
||||
},
|
||||
|
||||
mediaSaveableContext: {
|
||||
matches: function mediaSaveableContextMatches(aElement) {
|
||||
return (aElement instanceof HTMLVideoElement ||
|
||||
aElement instanceof HTMLAudioElement);
|
||||
}
|
||||
},
|
||||
|
||||
mediaContext: function(aMode) {
|
||||
return {
|
||||
matches: function(aElt) {
|
||||
|
@ -235,6 +235,8 @@ contextmenu.playMedia=Play
|
||||
contextmenu.pauseMedia=Pause
|
||||
contextmenu.shareMedia=Share Video
|
||||
contextmenu.showControls2=Show Controls
|
||||
contextmenu.saveVideo=Save Video
|
||||
contextmenu.saveAudio=Save Audio
|
||||
|
||||
contextmenu.copy=Copy
|
||||
contextmenu.copyAll=Copy All
|
||||
|
Loading…
Reference in New Issue
Block a user