Bug 1111147 - update nsContextMenu for EME, r=florian

This commit is contained in:
Gijs Kruitbosch 2015-02-10 02:04:06 +00:00
parent 33d9d68dcd
commit 0b91575095
5 changed files with 36 additions and 1 deletions

View File

@ -415,3 +415,10 @@
label="&inspectContextMenu.label;"
accesskey="&inspectContextMenu.accesskey;"
oncommand="gContextMenu.inspectNode();"/>
<menuseparator id="context-media-eme-separator" hidden="true"/>
<menuitem id="context-media-eme-learnmore"
class="menuitem-iconic"
hidden="true"
label="&emeLearnMoreContextMenu.label;"
accesskey="&emeLearnMoreContextMenu.accesskey;"
onclick="gContextMenu.drmLearnMore(event);"/>

View File

@ -478,6 +478,8 @@ nsContextMenu.prototype = {
var statsShowing = this.onVideo && this.target.mozMediaStatisticsShowing;
this.showItem("context-video-showstats", this.onVideo && this.target.controls && !statsShowing);
this.showItem("context-video-hidestats", this.onVideo && this.target.controls && statsShowing);
this.showItem("context-media-eme-learnmore", this.onDRMMedia);
this.showItem("context-media-eme-separator", this.onDRMMedia);
// Disable them when there isn't a valid media source loaded.
if (onMedia) {
@ -499,7 +501,7 @@ nsContextMenu.prototype = {
this.setItemAttr("context-media-showcontrols", "disabled", hasError);
this.setItemAttr("context-media-hidecontrols", "disabled", hasError);
if (this.onVideo) {
let canSaveSnapshot = this.target.readyState >= this.target.HAVE_CURRENT_DATA;
let canSaveSnapshot = !this.onDRMMedia && this.target.readyState >= this.target.HAVE_CURRENT_DATA;
this.setItemAttr("context-video-saveimage", "disabled", !canSaveSnapshot);
this.setItemAttr("context-video-fullscreen", "disabled", hasError);
this.setItemAttr("context-video-showstats", "disabled", hasError);
@ -562,6 +564,7 @@ nsContextMenu.prototype = {
this.onCanvas = false;
this.onVideo = false;
this.onAudio = false;
this.onDRMMedia = false;
this.onTextInput = false;
this.onNumeric = false;
this.onKeywordField = false;
@ -640,6 +643,9 @@ nsContextMenu.prototype = {
if (this.isMediaURLReusable(mediaURL)) {
this.mediaURL = mediaURL;
}
if (this.target.isEncrypted) {
this.onDRMMedia = true;
}
// Firefox always creates a HTMLVideoElement when loading an ogg file
// directly. If the media is actually audio, be smarter and provide a
// context menu with audio operations.
@ -656,6 +662,9 @@ nsContextMenu.prototype = {
if (this.isMediaURLReusable(mediaURL)) {
this.mediaURL = mediaURL;
}
if (this.target.isEncrypted) {
this.onDRMMedia = true;
}
}
else if (editFlags & (SpellCheckHelper.INPUT | SpellCheckHelper.TEXTAREA)) {
this.onTextInput = (editFlags & SpellCheckHelper.TEXTINPUT) !== 0;
@ -1698,6 +1707,17 @@ nsContextMenu.prototype = {
clipboard.copyString(this.mediaURL, document);
},
drmLearnMore: function(aEvent) {
let drmInfoURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content";
let dest = whereToOpenLink(aEvent);
// Don't ever want this to open in the same tab as it'll unload the
// DRM'd video, which is going to be a bad idea in most cases.
if (dest == "current") {
dest = "tab";
}
openUILinkIn(drmInfoURL, dest);
},
get imageURL() {
if (this.onImage)
return this.mediaURL;

View File

@ -837,3 +837,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY processHang.terminatePlugin.accessKey "P">
<!ENTITY processHang.terminateProcess.label "Kill Web Process">
<!ENTITY processHang.terminateProcess.accessKey "K">
<!ENTITY emeLearnMoreContextMenu.label "Learn more about DRM…">
<!ENTITY emeLearnMoreContextMenu.accesskey "D">

View File

@ -669,6 +669,7 @@ this.BrowserUITelemetry = {
"spell-add-dictionaries-main", "spell-dictionaries",
"spell-dictionaries-menu", "spell-add-dictionaries",
"bidi-text-direction-toggle", "bidi-page-direction-toggle", "inspect",
"media-eme-learn-more"
]),
_contextMenuInteractions: {},

View File

@ -79,3 +79,7 @@
height: 16px;
margin: 7px;
}
#context-media-eme-learnmore {
list-style-image: url("chrome://browser/skin/drm-icon.svg#chains");
}