Bug 559939 (part 1) - Add basic context menu for <video> elements [r=mfinkle]

This commit is contained in:
Matt Brubeck 2010-08-25 14:20:45 -07:00
parent 5ba7dc4c6d
commit 0c2f1c9500
3 changed files with 19 additions and 7 deletions

View File

@ -563,6 +563,12 @@
<richlistitem class="context-command" id="context-share-image" type="image-shareable" onclick="ContextCommands.shareMedia();">
<label value="&contextShareImage.label;"/>
</richlistitem>
<richlistitem class="context-command" id="context-save-video" type="video" onclick="ContextCommands.saveImage();">
<label value="&contextSaveVideo.label;"/>
</richlistitem>
<richlistitem class="context-command" id="context-share-video" type="video-shareable" onclick="ContextCommands.shareMedia();">
<label value="&contextShareVideo.label;"/>
</richlistitem>
<richlistitem class="context-command" id="context-editbookmark" type="edit-bookmark" onclick="ContextCommands.editBookmark();">
<label value="&contextEditBookmark.label;"/>
</richlistitem>

View File

@ -786,8 +786,10 @@ var ContextHandler = {
// See if the user clicked on an image.
if (popupNode instanceof Ci.nsIImageLoadingContent && popupNode.currentURI) {
state.types.push("image");
state.mediaURL = popupNode.currentURI.spec;
state.label = state.mediaURL;
state.label = state.mediaURL = popupNode.currentURI.spec;
} else if (popupNode instanceof Ci.nsIDOMHTMLVideoElement) {
state.types.push("video");
state.label = state.mediaURL = popupNode.src;
}
}
@ -852,12 +854,14 @@ ContextHandler.registerType("link-shareable", function(aState, aElement) {
return Util.isShareableScheme(aState.linkProtocol);
});
ContextHandler.registerType("image-shareable", function(aState, aElement) {
if (!aState.mediaURL)
return false;
["image", "video"].forEach(function(aType) {
ContextHandler.registerType(aType+"-shareable", function(aState, aElement) {
if (aState.types.indexOf(aType) == -1)
return false;
let protocol = ContextHandler._getProtocol(ContextHandler._getURI(aState.mediaURL));
return Util.isShareableScheme(protocol);
let protocol = ContextHandler._getProtocol(ContextHandler._getURI(aState.mediaURL));
return Util.isShareableScheme(protocol);
});
});
ContextHandler.registerType("image-loaded", function(aState, aElement) {

View File

@ -90,6 +90,8 @@
<!ENTITY contextSaveImage.label "Save Image">
<!ENTITY contextShareLink.label "Share Link">
<!ENTITY contextShareImage.label "Share Image">
<!ENTITY contextSaveVideo.label "Save Video">
<!ENTITY contextShareVideo.label "Share Video">
<!ENTITY contextEditBookmark.label "Edit">
<!ENTITY contextRemoveBookmark.label "Remove">