Bug 1246907 - Open link in a Container Tab - in the context menu, r=Gijs

This commit is contained in:
Andrea Marchesini 2016-02-12 11:16:41 +00:00
parent abb77819a9
commit e8d7e4ce11
3 changed files with 29 additions and 2 deletions

View File

@ -57,7 +57,29 @@
<menuitem id="context-openlinkintab"
label="&openLinkCmdInTab.label;"
accesskey="&openLinkCmdInTab.accesskey;"
oncommand="gContextMenu.openLinkInTab();"/>
usercontextid="0"
oncommand="gContextMenu.openLinkInTab(event);"/>
<menu id="context-openlinkinusercontext-menu"
label="&openLinkCmdInContainerTab.label;"
accesskey="&openLinkCmdInContainerTab.accesskey;"
hidden="true">
<menupopup oncommand="gContextMenu.openLinkInTab(event);">
<menuitem label="&userContextPersonal.label;"
usercontextid="1"
accesskey="&userContextPersonal.accesskey;"/>
<menuitem label="&userContextWork.label;"
usercontextid="2"
accesskey="&userContextWork.accesskey;"/>
<menuitem label="&userContextBanking.label;"
usercontextid="3"
accesskey="&userContextBanking.accesskey;"/>
<menuitem label="&userContextShopping.label;"
usercontextid="4"
accesskey="&userContextShopping.accesskey;"/>
</menupopup>
</menu>
<menuitem id="context-openlink"
label="&openLinkCmd.label;"
accesskey="&openLinkCmd.accesskey;"

View File

@ -144,9 +144,11 @@ nsContextMenu.prototype = {
var shouldShow = this.onSaveableLink || isMailtoInternal || this.onPlainTextLink;
var isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
var showContainers = Services.prefs.getBoolPref("privacy.userContext.enabled");
this.showItem("context-openlink", shouldShow && !isWindowPrivate);
this.showItem("context-openlinkprivate", shouldShow);
this.showItem("context-openlinkintab", shouldShow);
this.showItem("context-openlinkinusercontext-menu", shouldShow && showContainers);
this.showItem("context-openlinkincurrent", this.onPlainTextLink);
this.showItem("context-sep-open", shouldShow);
},
@ -960,7 +962,7 @@ nsContextMenu.prototype = {
},
// Open linked-to URL in a new tab.
openLinkInTab: function() {
openLinkInTab: function(event) {
urlSecurityCheck(this.linkURL, this.principal);
let referrerURI = gContextMenuContentData.documentURIObject;
@ -981,6 +983,7 @@ nsContextMenu.prototype = {
let params = this._openLinkInParameters({
allowMixedContent: persistAllowMixedContentInChildTab,
userContextId: event.target.getAttribute('usercontextid'),
});
openLinkIn(this.linkURL, "tab", params);
},

View File

@ -528,6 +528,8 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY openFrameCmdInTab.accesskey "T">
<!ENTITY openFrameCmd.label "Open Frame in New Window">
<!ENTITY openFrameCmd.accesskey "W">
<!ENTITY openLinkCmdInContainerTab.label "Open Link in New Container Tab">
<!ENTITY openLinkCmdInContainerTab.accesskey "C">
<!ENTITY showOnlyThisFrameCmd.label "Show Only This Frame">
<!ENTITY showOnlyThisFrameCmd.accesskey "S">
<!ENTITY reloadCmd.commandkey "r">