зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1754805 - Add "Open in New Container Tab" to places context menu. r=mak,fluent-reviewers,mcheang
Differential Revision: https://phabricator.services.mozilla.com/D138454
This commit is contained in:
Родитель
4c1667cba1
Коммит
619fe7ec67
|
@ -1072,19 +1072,19 @@ var PlacesUIUtils = {
|
|||
* Where to open the URL.
|
||||
* @param {object} aView
|
||||
* The associated view of the node being opened.
|
||||
* @param {boolean} aPrivate
|
||||
* @param {boolean} private
|
||||
* True if the window being opened is private.
|
||||
*/
|
||||
openNodeIn: function PUIU_openNodeIn(aNode, aWhere, aView, aPrivate) {
|
||||
openNodeIn: function PUIU_openNodeIn(aNode, aWhere, aView, private) {
|
||||
let window = aView.ownerWindow;
|
||||
this._openNodeIn(aNode, aWhere, window, aPrivate);
|
||||
this._openNodeIn(aNode, aWhere, window, { private });
|
||||
},
|
||||
|
||||
_openNodeIn: function PUIU__openNodeIn(
|
||||
aNode,
|
||||
aWhere,
|
||||
aWindow,
|
||||
aPrivate = false
|
||||
{ private = false, userContextId = 0 } = {}
|
||||
) {
|
||||
if (
|
||||
aNode &&
|
||||
|
@ -1106,7 +1106,8 @@ var PlacesUIUtils = {
|
|||
allowPopups: isJavaScriptURL,
|
||||
inBackground: this.loadBookmarksInBackground,
|
||||
allowInheritPrincipal: isJavaScriptURL,
|
||||
private: aPrivate,
|
||||
private,
|
||||
userContextId,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -1536,6 +1537,12 @@ var PlacesUIUtils = {
|
|||
document.getElementById("placesContext_open:newprivatewindow").hidden =
|
||||
PrivateBrowsingUtils.isWindowPrivate(window) ||
|
||||
!PrivateBrowsingUtils.enabled;
|
||||
document.getElementById(
|
||||
"placesContext_open:newcontainertab"
|
||||
).hidden = !Services.prefs.getBoolPref(
|
||||
"privacy.userContext.enabled",
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
event.target.ownerGlobal.updateCommands("places");
|
||||
|
@ -1581,6 +1588,28 @@ var PlacesUIUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
createContainerTabMenu(event) {
|
||||
let window = event.target.ownerGlobal;
|
||||
return window.createUserContextMenu(event, { isContextMenu: true });
|
||||
},
|
||||
|
||||
openInContainerTab(event) {
|
||||
let userContextId = parseInt(
|
||||
event.target.getAttribute("data-usercontextid")
|
||||
);
|
||||
let triggerNode = this.lastContextMenuTriggerNode;
|
||||
let isManaged = !!triggerNode.closest("#managed-bookmarks");
|
||||
if (isManaged) {
|
||||
let window = triggerNode.ownerGlobal;
|
||||
window.openTrustedLinkIn(triggerNode.link, "tab", { userContextId });
|
||||
return;
|
||||
}
|
||||
let view = this.getViewForNode(triggerNode);
|
||||
this._openNodeIn(view.selectedNode, "tab", view.ownerWindow, {
|
||||
userContextId,
|
||||
});
|
||||
},
|
||||
|
||||
openSelectionInTabs(event) {
|
||||
let isManaged = !!event.target.parentNode.triggerNode.closest(
|
||||
"#managed-bookmarks"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/usercontext/usercontext.css"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/places/tree-icons.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/places/sidebar.css"?>
|
||||
|
|
|
@ -447,6 +447,13 @@ PlacesController.prototype = {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
aMenuItem.hasAttribute("hide-if-usercontext-disabled") &&
|
||||
!Services.prefs.getBoolPref("privacy.userContext.enabled", false)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let selectiontype =
|
||||
aMenuItem.getAttribute("selection-type") || "single|multiple";
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/usercontext/usercontext.css"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/places/tree-icons.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/places/sidebar.css"?>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/usercontext/usercontext.css"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/places/tree-icons.css"?>
|
||||
|
|
|
@ -27,6 +27,15 @@
|
|||
data-l10n-id="places-open-in-tab"
|
||||
selection-type="single"
|
||||
node-type="link"/>
|
||||
<menu id="placesContext_open:newcontainertab"
|
||||
data-l10n-id="places-open-in-container-tab"
|
||||
selection-type="single"
|
||||
node-type="link"
|
||||
hide-if-private-browsing="true"
|
||||
hide-if-usercontext-disabled="true">
|
||||
<menupopup oncommand="PlacesUIUtils.openInContainerTab(event);"
|
||||
onpopupshowing="return PlacesUIUtils.createContainerTabMenu(event);" />
|
||||
</menu>
|
||||
<menuitem id="placesContext_openContainer:tabs"
|
||||
oncommand="PlacesUIUtils.openSelectionInTabs(event);"
|
||||
data-l10n-id="places-open-all-in-tabs"
|
||||
|
|
|
@ -98,6 +98,7 @@ let checkContextMenu = async (cbfunc, optionItems, doc = document) => {
|
|||
add_task(async function test_bookmark_contextmenu_contents() {
|
||||
let optionItems = [
|
||||
"placesContext_open:newtab",
|
||||
"placesContext_open:newcontainertab",
|
||||
"placesContext_open:newwindow",
|
||||
"placesContext_open:newprivatewindow",
|
||||
"placesContext_show_bookmark:info",
|
||||
|
@ -379,6 +380,7 @@ add_task(async function test_sidebar_multiple_folders_contextmenu_contents() {
|
|||
add_task(async function test_sidebar_bookmark_contextmenu_contents() {
|
||||
let optionItems = [
|
||||
"placesContext_open:newtab",
|
||||
"placesContext_open:newcontainertab",
|
||||
"placesContext_open:newwindow",
|
||||
"placesContext_open:newprivatewindow",
|
||||
"placesContext_show_bookmark:info",
|
||||
|
@ -416,6 +418,7 @@ add_task(async function test_sidebar_bookmark_contextmenu_contents() {
|
|||
add_task(async function test_sidebar_bookmark_search_contextmenu_contents() {
|
||||
let optionItems = [
|
||||
"placesContext_open:newtab",
|
||||
"placesContext_open:newcontainertab",
|
||||
"placesContext_open:newwindow",
|
||||
"placesContext_open:newprivatewindow",
|
||||
"placesContext_showInFolder",
|
||||
|
@ -458,6 +461,7 @@ add_task(async function test_library_bookmark_contextmenu_contents() {
|
|||
let optionItems = [
|
||||
"placesContext_open",
|
||||
"placesContext_open:newtab",
|
||||
"placesContext_open:newcontainertab",
|
||||
"placesContext_open:newwindow",
|
||||
"placesContext_open:newprivatewindow",
|
||||
"placesContext_deleteBookmark",
|
||||
|
@ -492,6 +496,7 @@ add_task(async function test_library_bookmark_search_contextmenu_contents() {
|
|||
let optionItems = [
|
||||
"placesContext_open",
|
||||
"placesContext_open:newtab",
|
||||
"placesContext_open:newcontainertab",
|
||||
"placesContext_open:newwindow",
|
||||
"placesContext_open:newprivatewindow",
|
||||
"placesContext_showInFolder",
|
||||
|
|
|
@ -8,6 +8,9 @@ places-open =
|
|||
places-open-in-tab =
|
||||
.label = Open in New Tab
|
||||
.accesskey = w
|
||||
places-open-in-container-tab =
|
||||
.label = Open in New Container Tab
|
||||
.accesskey = i
|
||||
places-open-all-bookmarks =
|
||||
.label = Open All Bookmarks
|
||||
.accesskey = O
|
||||
|
|
Загрузка…
Ссылка в новой задаче