mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 08:18:41 +09:00
Revert "Issue #756 - Remove Contextual Identity from Basilisk"
This reverts commit ac50c95756.
This commit is contained in:
parent
979a96c49a
commit
a10f2e94ad
46 changed files with 1467 additions and 39 deletions
|
|
@ -1293,6 +1293,17 @@ pref("privacy.trackingprotection.ui.enabled", true);
|
|||
pref("privacy.trackingprotection.ui.enabled", false);
|
||||
#endif
|
||||
|
||||
// Enable Contextual Identity Containers
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("privacy.userContext.enabled", true);
|
||||
pref("privacy.userContext.ui.enabled", true);
|
||||
pref("privacy.usercontext.about_newtab_segregation.enabled", true);
|
||||
#else
|
||||
pref("privacy.userContext.enabled", false);
|
||||
pref("privacy.userContext.ui.enabled", false);
|
||||
pref("privacy.usercontext.about_newtab_segregation.enabled", false);
|
||||
#endif
|
||||
|
||||
#ifndef RELEASE_OR_BETA
|
||||
// At the moment, autostart.2 is used, while autostart.1 is unused.
|
||||
// We leave it here set to false to reset users' defaults and allow
|
||||
|
|
|
|||
|
|
@ -51,11 +51,23 @@
|
|||
label="&openLinkCmdInCurrent.label;"
|
||||
accesskey="&openLinkCmdInCurrent.accesskey;"
|
||||
oncommand="gContextMenu.openLinkInCurrent();"/>
|
||||
# label is dynamically set.
|
||||
# label and data-usercontextid are dynamically set.
|
||||
<menuitem id="context-openlinkincontainertab"
|
||||
accesskey="&openLinkCmdInTab.accesskey;"
|
||||
oncommand="gContextMenu.openLinkInTab(event);"/>
|
||||
<menuitem id="context-openlinkintab"
|
||||
label="&openLinkCmdInTab.label;"
|
||||
accesskey="&openLinkCmdInTab.accesskey;"
|
||||
oncommand="gContextMenu.openLinkInTab();"/>
|
||||
data-usercontextid="0"
|
||||
oncommand="gContextMenu.openLinkInTab(event);"/>
|
||||
|
||||
<menu id="context-openlinkinusercontext-menu"
|
||||
label="&openLinkCmdInContainerTab.label;"
|
||||
accesskey="&openLinkCmdInContainerTab.accesskey;"
|
||||
hidden="true">
|
||||
<menupopup oncommand="gContextMenu.openLinkInTab(event);"
|
||||
onpopupshowing="return gContextMenu.createContainerMenu(event);" />
|
||||
</menu>
|
||||
|
||||
<menuitem id="context-openlink"
|
||||
label="&openLinkCmd.label;"
|
||||
|
|
|
|||
|
|
@ -11,12 +11,19 @@
|
|||
style="border:0px;padding:0px;margin:0px;-moz-appearance:none">
|
||||
<menu id="file-menu" label="&fileMenu.label;"
|
||||
accesskey="&fileMenu.accesskey;">
|
||||
<menupopup id="menu_FilePopup">
|
||||
<menupopup id="menu_FilePopup"
|
||||
onpopupshowing="updateUserContextUIVisibility();">
|
||||
<menuitem id="menu_newNavigatorTab"
|
||||
label="&tabCmd.label;"
|
||||
command="cmd_newNavigatorTab"
|
||||
key="key_newNavigatorTab"
|
||||
accesskey="&tabCmd.accesskey;"/>
|
||||
<menu id="menu_newUserContext"
|
||||
label="&newUserContext.label;"
|
||||
accesskey="&newUserContext.accesskey;"
|
||||
hidden="true">
|
||||
<menupopup onpopupshowing="return createUserContextMenu(event);" />
|
||||
</menu>
|
||||
<menuitem id="menu_newNavigator"
|
||||
label="&newNavigatorCmd.label;"
|
||||
accesskey="&newNavigatorCmd.accesskey;"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ var Cu = Components.utils;
|
|||
var Cc = Components.classes;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/ContextualIdentityService.jsm");
|
||||
Cu.import("resource://gre/modules/NotificationDB.jsm");
|
||||
|
||||
// lazy module getters
|
||||
|
|
@ -831,6 +832,10 @@ function _loadURIWithFlags(browser, uri, params) {
|
|||
}
|
||||
try {
|
||||
if (!mustChangeProcess) {
|
||||
if (params.userContextId) {
|
||||
browser.webNavigation.setOriginAttributesBeforeLoading({ userContextId: params.userContextId });
|
||||
}
|
||||
|
||||
browser.webNavigation.loadURIWithOptions(uri, flags,
|
||||
referrer, referrerPolicy,
|
||||
postData, null, null, triggeringPrincipal);
|
||||
|
|
@ -856,6 +861,10 @@ function _loadURIWithFlags(browser, uri, params) {
|
|||
postData: postData
|
||||
}
|
||||
|
||||
if (params.userContextId) {
|
||||
loadParams.userContextId = params.userContextId;
|
||||
}
|
||||
|
||||
LoadInOtherProcess(browser, loadParams);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -868,6 +877,10 @@ function _loadURIWithFlags(browser, uri, params) {
|
|||
Cu.reportError(e);
|
||||
gBrowser.updateBrowserRemotenessByURL(browser, uri);
|
||||
|
||||
if (params.userContextId) {
|
||||
browser.webNavigation.setOriginAttributesBeforeLoading({ userContextId: params.userContextId });
|
||||
}
|
||||
|
||||
browser.webNavigation.loadURIWithOptions(uri, flags, referrer, referrerPolicy,
|
||||
postData, null, null, triggeringPrincipal);
|
||||
} else {
|
||||
|
|
@ -931,6 +944,16 @@ addEventListener("DOMContentLoaded", function onDCL() {
|
|||
let initBrowser =
|
||||
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
|
||||
|
||||
// The window's first argument is a tab if and only if we are swapping tabs.
|
||||
// We must set the browser's usercontextid before updateBrowserRemoteness(),
|
||||
// so that the newly created remote tab child has the correct usercontextid.
|
||||
if (window.arguments) {
|
||||
let tabToOpen = window.arguments[0];
|
||||
if (tabToOpen instanceof XULElement && tabToOpen.hasAttribute("usercontextid")) {
|
||||
initBrowser.setAttribute("usercontextid", tabToOpen.getAttribute("usercontextid"));
|
||||
}
|
||||
}
|
||||
|
||||
gBrowser.updateBrowserRemoteness(initBrowser, gMultiProcessBrowser);
|
||||
});
|
||||
|
||||
|
|
@ -1115,6 +1138,13 @@ var gBrowserInit = {
|
|||
// make sure it has a docshell
|
||||
gBrowser.docShell;
|
||||
|
||||
// We must set usercontextid before updateBrowserRemoteness()
|
||||
// so that the newly created remote tab child has correct usercontextid
|
||||
if (tabToOpen.hasAttribute("usercontextid")) {
|
||||
let usercontextid = tabToOpen.getAttribute("usercontextid");
|
||||
gBrowser.selectedBrowser.setAttribute("usercontextid", usercontextid);
|
||||
}
|
||||
|
||||
// If the browser that we're swapping in was remote, then we'd better
|
||||
// be able to support remote browsers, and then make our selectedTab
|
||||
// remote.
|
||||
|
|
@ -1140,8 +1170,9 @@ var gBrowserInit = {
|
|||
// [3]: postData (nsIInputStream)
|
||||
// [4]: allowThirdPartyFixup (bool)
|
||||
// [5]: referrerPolicy (int)
|
||||
// [6]: originPrincipal (nsIPrincipal)
|
||||
// [7]: triggeringPrincipal (nsIPrincipal)
|
||||
// [6]: userContextId (int)
|
||||
// [7]: originPrincipal (nsIPrincipal)
|
||||
// [8]: triggeringPrincipal (nsIPrincipal)
|
||||
else if (window.arguments.length >= 3) {
|
||||
let referrerURI = window.arguments[2];
|
||||
if (typeof(referrerURI) == "string") {
|
||||
|
|
@ -1153,11 +1184,13 @@ var gBrowserInit = {
|
|||
}
|
||||
let referrerPolicy = (window.arguments[5] != undefined ?
|
||||
window.arguments[5] : Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
|
||||
let userContextId = (window.arguments[6] != undefined ?
|
||||
window.arguments[6] : Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID);
|
||||
loadURI(uriToLoad, referrerURI, window.arguments[3] || null,
|
||||
window.arguments[4] || false, referrerPolicy,
|
||||
window.arguments[4] || false, referrerPolicy, userContextId,
|
||||
// pass the origin principal (if any) and force its use to create
|
||||
// an initial about:blank viewer if present:
|
||||
window.arguments[6], !!window.arguments[6], window.arguments[7]);
|
||||
window.arguments[7], !!window.arguments[7], window.arguments[8]);
|
||||
window.focus();
|
||||
}
|
||||
// Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3.
|
||||
|
|
@ -2042,7 +2075,7 @@ function BrowserTryToCloseWindow()
|
|||
}
|
||||
|
||||
function loadURI(uri, referrer, postData, allowThirdPartyFixup, referrerPolicy,
|
||||
originPrincipal, forceAboutBlankViewerInCurrent,
|
||||
userContextId, originPrincipal, forceAboutBlankViewerInCurrent,
|
||||
triggeringPrincipal) {
|
||||
try {
|
||||
openLinkIn(uri, "current",
|
||||
|
|
@ -2050,6 +2083,7 @@ function loadURI(uri, referrer, postData, allowThirdPartyFixup, referrerPolicy,
|
|||
referrerPolicy: referrerPolicy,
|
||||
postData: postData,
|
||||
allowThirdPartyFixup: allowThirdPartyFixup,
|
||||
userContextId: userContextId,
|
||||
originPrincipal,
|
||||
triggeringPrincipal,
|
||||
forceAboutBlankViewerInCurrent,
|
||||
|
|
@ -3923,6 +3957,66 @@ function updateEditUIVisibility()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a new tab with the userContextId specified as an attribute of
|
||||
* sourceEvent. This attribute is propagated to the top level originAttributes
|
||||
* living on the tab's docShell.
|
||||
*
|
||||
* @param event
|
||||
* A click event on a userContext File Menu option
|
||||
*/
|
||||
function openNewUserContextTab(event)
|
||||
{
|
||||
openUILinkIn(BROWSER_NEW_TAB_URL, "tab", {
|
||||
userContextId: parseInt(event.target.getAttribute('data-usercontextid')),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates File Menu User Context UI visibility depending on
|
||||
* privacy.userContext.enabled pref state.
|
||||
*/
|
||||
function updateUserContextUIVisibility()
|
||||
{
|
||||
let menu = document.getElementById("menu_newUserContext");
|
||||
menu.hidden = !Services.prefs.getBoolPref("privacy.userContext.enabled");
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
menu.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the User Context UI indicators if the browser is in a non-default context
|
||||
*/
|
||||
function updateUserContextUIIndicator()
|
||||
{
|
||||
let hbox = document.getElementById("userContext-icons");
|
||||
|
||||
let userContextId = gBrowser.selectedBrowser.getAttribute("usercontextid");
|
||||
if (!userContextId) {
|
||||
hbox.setAttribute("data-identity-color", "");
|
||||
hbox.hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
let identity = ContextualIdentityService.getIdentityFromId(userContextId);
|
||||
if (!identity) {
|
||||
hbox.setAttribute("data-identity-color", "");
|
||||
hbox.hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
hbox.setAttribute("data-identity-color", identity.color);
|
||||
|
||||
let label = document.getElementById("userContext-label");
|
||||
label.setAttribute("value", ContextualIdentityService.getUserContextLabel(userContextId));
|
||||
|
||||
let indicator = document.getElementById("userContext-indicator");
|
||||
indicator.setAttribute("data-identity-icon", identity.icon);
|
||||
|
||||
hbox.hidden = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the Character Encoding menu enabled or disabled as appropriate.
|
||||
* To be called when the View menu or the app menu is opened.
|
||||
|
|
@ -4603,6 +4697,7 @@ nsBrowserAccess.prototype = {
|
|||
|
||||
_openURIInNewTab: function(aURI, aReferrer, aReferrerPolicy, aIsPrivate,
|
||||
aIsExternal, aForceNotRemote=false,
|
||||
aUserContextId=Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID,
|
||||
aOpener = null, aTriggeringPrincipal = null) {
|
||||
let win, needToFocusWin;
|
||||
|
||||
|
|
@ -4631,6 +4726,7 @@ nsBrowserAccess.prototype = {
|
|||
triggeringPrincipal: aTriggeringPrincipal,
|
||||
referrerURI: aReferrer,
|
||||
referrerPolicy: aReferrerPolicy,
|
||||
userContextId: aUserContextId,
|
||||
fromExternal: aIsExternal,
|
||||
inBackground: loadInBackground,
|
||||
forceNotRemote: aForceNotRemote,
|
||||
|
|
@ -4707,10 +4803,13 @@ nsBrowserAccess.prototype = {
|
|||
// will do the job of shuttling off the newly opened browser to run in
|
||||
// the right process once it starts loading a URI.
|
||||
let forceNotRemote = !!aOpener;
|
||||
let userContextId = aOpener && aOpener.document
|
||||
? aOpener.document.nodePrincipal.originAttributes.userContextId
|
||||
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
|
||||
let openerWindow = (aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_OPENER) ? null : aOpener;
|
||||
let browser = this._openURIInNewTab(aURI, referrer, referrerPolicy,
|
||||
isPrivate, isExternal,
|
||||
forceNotRemote,
|
||||
forceNotRemote, userContextId,
|
||||
openerWindow, triggeringPrincipal);
|
||||
if (browser)
|
||||
newWindow = browser.contentWindow;
|
||||
|
|
@ -4742,10 +4841,16 @@ nsBrowserAccess.prototype = {
|
|||
|
||||
var isExternal = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
||||
|
||||
var userContextId = aParams.openerOriginAttributes &&
|
||||
("userContextId" in aParams.openerOriginAttributes)
|
||||
? aParams.openerOriginAttributes.userContextId
|
||||
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID
|
||||
|
||||
let browser = this._openURIInNewTab(aURI, aParams.referrer,
|
||||
aParams.referrerPolicy,
|
||||
aParams.isPrivate,
|
||||
isExternal, false,
|
||||
userContextId, null,
|
||||
aParams.triggeringPrincipal);
|
||||
if (browser)
|
||||
return browser.QueryInterface(Ci.nsIFrameLoaderOwner);
|
||||
|
|
@ -5303,6 +5408,11 @@ function handleLinkClick(event, href, linkNode) {
|
|||
triggeringPrincipal: doc.nodePrincipal,
|
||||
};
|
||||
|
||||
// The new tab/window must use the same userContextId
|
||||
if (doc.nodePrincipal.originAttributes.userContextId) {
|
||||
params.userContextId = doc.nodePrincipal.originAttributes.userContextId;
|
||||
}
|
||||
|
||||
openLinkIn(href, where, params);
|
||||
event.preventDefault();
|
||||
return true;
|
||||
|
|
@ -5374,6 +5484,8 @@ function handleDroppedLink(event, urlOrLinks, name)
|
|||
|
||||
let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
|
||||
|
||||
let userContextId = gBrowser.selectedBrowser.getAttribute("usercontextid");
|
||||
|
||||
// event is null if links are dropped in content process.
|
||||
// inBackground should be false, as it's loading into current browser.
|
||||
let inBackground = false;
|
||||
|
|
@ -5397,6 +5509,7 @@ function handleDroppedLink(event, urlOrLinks, name)
|
|||
replace: true,
|
||||
allowThirdPartyFixup: false,
|
||||
postDatas,
|
||||
userContextId,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
<?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/places/places.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/usercontext/usercontext.css" type="text/css"?>
|
||||
#ifdef MOZ_DEVTOOLS
|
||||
<?xml-stylesheet href="chrome://devtools/skin/devtools-browser.css" type="text/css"?>
|
||||
#endif
|
||||
|
|
@ -552,7 +553,12 @@
|
|||
key="key_undoCloseTab"
|
||||
label="&undoCloseTab.label;"
|
||||
observes="History:UndoCloseTab"/>
|
||||
<menuseparator id="alltabs-popup-separator"/>
|
||||
<menuseparator id="alltabs-popup-separator-1"/>
|
||||
<menu id="alltabs_containersTab"
|
||||
label="&newUserContext.label;">
|
||||
<menupopup id="alltabs_containersMenuTab" />
|
||||
</menu>
|
||||
<menuseparator id="alltabs-popup-separator-2"/>
|
||||
</menupopup>
|
||||
</toolbarbutton>
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ var handleContentContextMenu = function (event) {
|
|||
|
||||
let selectionInfo = BrowserUtils.getSelectionDetails(content);
|
||||
|
||||
let loadContext = docShell.QueryInterface(Ci.nsILoadContext);
|
||||
let userContextId = loadContext.originAttributes.userContextId;
|
||||
|
||||
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
let editFlags = SpellCheckHelper.isEditable(event.target, content);
|
||||
let spellInfo;
|
||||
|
|
@ -185,7 +188,7 @@ var handleContentContextMenu = function (event) {
|
|||
principal, docLocation, charSet, baseURI, referrer,
|
||||
referrerPolicy, contentType, contentDisposition,
|
||||
frameOuterWindowID, selectionInfo, disableSetDesktopBg,
|
||||
loginFillInfo, parentAllowsMixedContent },
|
||||
loginFillInfo, parentAllowsMixedContent, userContextId },
|
||||
{ event, popupNode: event.target });
|
||||
}
|
||||
else {
|
||||
|
|
@ -209,6 +212,7 @@ var handleContentContextMenu = function (event) {
|
|||
disableSetDesktopBackground: disableSetDesktopBg,
|
||||
loginFillInfo,
|
||||
parentAllowsMixedContent,
|
||||
userContextId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Components.utils.import("resource://gre/modules/ContextualIdentityService.jsm");
|
||||
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
|
||||
Components.utils.import("resource://gre/modules/LoginManagerContextMenu.jsm");
|
||||
|
|
@ -141,11 +142,28 @@ nsContextMenu.prototype = {
|
|||
this.onPlainTextLink = true;
|
||||
}
|
||||
|
||||
var inContainer = false;
|
||||
if (gContextMenuContentData.userContextId) {
|
||||
inContainer = true;
|
||||
var item = document.getElementById("context-openlinkincontainertab");
|
||||
|
||||
item.setAttribute("data-usercontextid", gContextMenuContentData.userContextId);
|
||||
|
||||
var label =
|
||||
ContextualIdentityService.getUserContextLabel(gContextMenuContentData.userContextId);
|
||||
item.setAttribute("label",
|
||||
gBrowserBundle.formatStringFromName("userContextOpenLink.label",
|
||||
[label], 1));
|
||||
}
|
||||
|
||||
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-openlinkintab", shouldShow && !inContainer);
|
||||
this.showItem("context-openlinkincontainertab", shouldShow && inContainer);
|
||||
this.showItem("context-openlinkinusercontext-menu", shouldShow && !isWindowPrivate && showContainers);
|
||||
this.showItem("context-openlinkincurrent", this.onPlainTextLink);
|
||||
this.showItem("context-sep-open", shouldShow);
|
||||
},
|
||||
|
|
@ -940,6 +958,13 @@ nsContextMenu.prototype = {
|
|||
params[p] = extra[p];
|
||||
}
|
||||
|
||||
// If we want to change userContextId, we must be sure that we don't
|
||||
// propagate the referrer.
|
||||
if ("userContextId" in params &&
|
||||
params.userContextId != gContextMenuContentData.userContextId) {
|
||||
params.noReferrer = true;
|
||||
}
|
||||
|
||||
return params;
|
||||
},
|
||||
|
||||
|
|
@ -957,7 +982,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;
|
||||
|
||||
|
|
@ -978,6 +1003,7 @@ nsContextMenu.prototype = {
|
|||
|
||||
let params = {
|
||||
allowMixedContent: persistAllowMixedContentInChildTab,
|
||||
userContextId: parseInt(event.target.getAttribute('data-usercontextid')),
|
||||
};
|
||||
|
||||
openLinkIn(this.linkURL, "tab", this._openLinkInParameters(params));
|
||||
|
|
@ -1753,4 +1779,8 @@ nsContextMenu.prototype = {
|
|||
menuItem.label = menuLabel;
|
||||
menuItem.accessKey = gNavigatorBundle.getString("contextMenuSearch.accesskey");
|
||||
},
|
||||
createContainerMenu: function(aEvent) {
|
||||
return createUserContextMenu(aEvent, true,
|
||||
gContextMenuContentData.userContextId);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -889,6 +889,33 @@ var RefreshBlocker = {
|
|||
|
||||
RefreshBlocker.init();
|
||||
|
||||
var UserContextIdNotifier = {
|
||||
init() {
|
||||
addEventListener("DOMWindowCreated", this);
|
||||
},
|
||||
|
||||
uninit() {
|
||||
removeEventListener("DOMWindowCreated", this);
|
||||
},
|
||||
|
||||
handleEvent(aEvent) {
|
||||
// When the window is created, we want to inform the tabbrowser about
|
||||
// the userContextId in use in order to update the UI correctly.
|
||||
// Just because we cannot change the userContextId from an active docShell,
|
||||
// we don't need to check DOMContentLoaded again.
|
||||
this.uninit();
|
||||
|
||||
// We use the docShell because content.document can have been loaded before
|
||||
// setting the originAttributes.
|
||||
let loadContext = docShell.QueryInterface(Ci.nsILoadContext);
|
||||
let userContextId = loadContext.originAttributes.userContextId;
|
||||
|
||||
sendAsyncMessage("Browser:WindowCreated", { userContextId });
|
||||
}
|
||||
};
|
||||
|
||||
UserContextIdNotifier.init();
|
||||
|
||||
#ifdef MOZ_WEBEXTENSIONS
|
||||
ExtensionContent.init(this);
|
||||
addEventListener("unload", () => {
|
||||
|
|
|
|||
|
|
@ -826,8 +826,10 @@
|
|||
}
|
||||
|
||||
let unifiedComplete = this.mTabBrowser._unifiedComplete;
|
||||
let userContextId = this.mBrowser.getAttribute("usercontextid") || 0;
|
||||
if (this.mBrowser.registeredOpenURI) {
|
||||
unifiedComplete.unregisterOpenPage(this.mBrowser.registeredOpenURI);
|
||||
unifiedComplete.unregisterOpenPage(this.mBrowser.registeredOpenURI,
|
||||
userContextId);
|
||||
delete this.mBrowser.registeredOpenURI;
|
||||
}
|
||||
// Tabs in private windows aren't registered as "Open" so
|
||||
|
|
@ -835,7 +837,7 @@
|
|||
if (!isBlankPageURL(aLocation.spec) &&
|
||||
(!PrivateBrowsingUtils.isWindowPrivate(window) ||
|
||||
PrivateBrowsingUtils.permanentPrivateBrowsing)) {
|
||||
unifiedComplete.registerOpenPage(aLocation);
|
||||
unifiedComplete.registerOpenPage(aLocation, userContextId);
|
||||
this.mBrowser.registeredOpenURI = aLocation;
|
||||
}
|
||||
}
|
||||
|
|
@ -1240,6 +1242,7 @@
|
|||
this._adjustFocusAfterTabSwitch(this.mCurrentTab);
|
||||
}
|
||||
|
||||
updateUserContextUIIndicator();
|
||||
gIdentityHandler.updateSharingIndicator();
|
||||
|
||||
this.tabContainer._setPositionalAttributes();
|
||||
|
|
@ -1495,6 +1498,7 @@
|
|||
var aSkipAnimation;
|
||||
var aForceNotRemote;
|
||||
var aNoReferrer;
|
||||
var aUserContextId;
|
||||
var aRelatedBrowser;
|
||||
var aOriginPrincipal;
|
||||
var aOpener;
|
||||
|
|
@ -1515,6 +1519,7 @@
|
|||
aSkipAnimation = params.skipAnimation;
|
||||
aForceNotRemote = params.forceNotRemote;
|
||||
aNoReferrer = params.noReferrer;
|
||||
aUserContextId = params.userContextId;
|
||||
aRelatedBrowser = params.relatedBrowser;
|
||||
aOriginPrincipal = params.originPrincipal;
|
||||
aOpener = params.opener;
|
||||
|
|
@ -1537,6 +1542,7 @@
|
|||
allowMixedContent: aAllowMixedContent,
|
||||
forceNotRemote: aForceNotRemote,
|
||||
noReferrer: aNoReferrer,
|
||||
userContextId: aUserContextId,
|
||||
originPrincipal: aOriginPrincipal,
|
||||
relatedBrowser: aRelatedBrowser,
|
||||
opener: aOpener });
|
||||
|
|
@ -1557,6 +1563,7 @@
|
|||
let aTargetTab;
|
||||
let aNewIndex = -1;
|
||||
let aPostDatas = [];
|
||||
let aUserContextId;
|
||||
if (arguments.length == 2 &&
|
||||
typeof arguments[1] == "object") {
|
||||
let params = arguments[1];
|
||||
|
|
@ -1567,6 +1574,7 @@
|
|||
aNewIndex = typeof params.newIndex === "number" ?
|
||||
params.newIndex : aNewIndex;
|
||||
aPostDatas = params.postDatas || aPostDatas;
|
||||
aUserContextId = params.userContextId;
|
||||
}
|
||||
|
||||
if (!aURIs.length)
|
||||
|
|
@ -1615,7 +1623,8 @@
|
|||
ownerTab: owner,
|
||||
skipAnimation: multiple,
|
||||
allowThirdPartyFixup: aAllowThirdPartyFixup,
|
||||
postData: aPostDatas[0]
|
||||
postData: aPostDatas[0],
|
||||
userContextId: aUserContextId
|
||||
});
|
||||
if (aNewIndex !== -1) {
|
||||
this.moveTabTo(firstTabAdded, aNewIndex);
|
||||
|
|
@ -1628,7 +1637,8 @@
|
|||
let tab = this.addTab(aURIs[i], {
|
||||
skipAnimation: true,
|
||||
allowThirdPartyFixup: aAllowThirdPartyFixup,
|
||||
postData: aPostDatas[i]
|
||||
postData: aPostDatas[i],
|
||||
userContextId: aUserContextId
|
||||
});
|
||||
if (targetTabIndex !== -1)
|
||||
this.moveTabTo(tab, ++tabNum);
|
||||
|
|
@ -1901,7 +1911,7 @@
|
|||
<body>
|
||||
<![CDATA[
|
||||
// Supported parameters:
|
||||
// remote, isPreloadBrowser, uriIsAboutBlank, permanentKey
|
||||
// userContextId, remote, isPreloadBrowser, uriIsAboutBlank, permanentKey
|
||||
|
||||
const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
|
|
@ -1913,6 +1923,10 @@
|
|||
b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
|
||||
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
||||
|
||||
if (aParams.userContextId) {
|
||||
b.setAttribute("usercontextid", aParams.userContextId);
|
||||
}
|
||||
|
||||
if (aParams.remote) {
|
||||
b.setAttribute("remote", "true");
|
||||
}
|
||||
|
|
@ -1995,7 +2009,7 @@
|
|||
"use strict";
|
||||
|
||||
// Supported parameters:
|
||||
// forceNotRemote
|
||||
// forceNotRemote, userContextId
|
||||
|
||||
let uriIsAboutBlank = !aURI || aURI == "about:blank";
|
||||
|
||||
|
|
@ -2013,6 +2027,7 @@
|
|||
// Private windows are not included because both the label and the
|
||||
// icon for the tab would be set incorrectly (see bug 1195981).
|
||||
if (aURI == BROWSER_NEW_TAB_URL &&
|
||||
!aParams.userContextId &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
browser = this._getPreloadedBrowser();
|
||||
if (browser) {
|
||||
|
|
@ -2026,6 +2041,7 @@
|
|||
browser = this._createBrowser({permanentKey: aTab.permanentKey,
|
||||
remote: remote,
|
||||
uriIsAboutBlank: uriIsAboutBlank,
|
||||
userContextId: aParams.userContextId,
|
||||
relatedBrowser: aParams.relatedBrowser,
|
||||
opener: aParams.opener});
|
||||
}
|
||||
|
|
@ -2100,6 +2116,7 @@
|
|||
var aAllowMixedContent;
|
||||
var aForceNotRemote;
|
||||
var aNoReferrer;
|
||||
var aUserContextId;
|
||||
var aEventDetail;
|
||||
var aRelatedBrowser;
|
||||
var aOriginPrincipal;
|
||||
|
|
@ -2122,6 +2139,7 @@
|
|||
aAllowMixedContent = params.allowMixedContent;
|
||||
aForceNotRemote = params.forceNotRemote;
|
||||
aNoReferrer = params.noReferrer;
|
||||
aUserContextId = params.userContextId;
|
||||
aEventDetail = params.eventDetail;
|
||||
aRelatedBrowser = params.relatedBrowser;
|
||||
aOriginPrincipal = params.originPrincipal;
|
||||
|
|
@ -2148,6 +2166,11 @@
|
|||
t.setAttribute("label", aURI);
|
||||
}
|
||||
|
||||
if (aUserContextId) {
|
||||
t.setAttribute("usercontextid", aUserContextId);
|
||||
ContextualIdentityService.setTabStyle(t);
|
||||
}
|
||||
|
||||
t.setAttribute("crop", "end");
|
||||
t.setAttribute("onerror", "this.removeAttribute('image');");
|
||||
|
||||
|
|
@ -2197,6 +2220,7 @@
|
|||
// of tab.linkedBrowser.
|
||||
let browserParams = {
|
||||
forceNotRemote: aForceNotRemote,
|
||||
userContextId: aUserContextId,
|
||||
relatedBrowser: aRelatedBrowser,
|
||||
opener: aOpener,
|
||||
};
|
||||
|
|
@ -2575,7 +2599,8 @@
|
|||
listener.destroy();
|
||||
|
||||
if (browser.registeredOpenURI && !aAdoptedByTab) {
|
||||
this._unifiedComplete.unregisterOpenPage(browser.registeredOpenURI);
|
||||
this._unifiedComplete.unregisterOpenPage(browser.registeredOpenURI,
|
||||
browser.getAttribute("usercontextid") || 0);
|
||||
delete browser.registeredOpenURI;
|
||||
}
|
||||
|
||||
|
|
@ -2774,6 +2799,11 @@
|
|||
if (ourBrowser.isRemoteBrowser != otherBrowser.isRemoteBrowser)
|
||||
return;
|
||||
|
||||
// Keep the userContextId if set on other browser
|
||||
if (otherBrowser.hasAttribute("usercontextid")) {
|
||||
ourBrowser.setAttribute("usercontextid", otherBrowser.getAttribute("usercontextid"));
|
||||
}
|
||||
|
||||
// That's gBrowser for the other window, not the tab's browser!
|
||||
var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser;
|
||||
var isPending = aOtherTab.hasAttribute("pending");
|
||||
|
|
@ -2806,6 +2836,10 @@
|
|||
aOurTab.setAttribute("soundplaying", "true");
|
||||
modifiedAttrs.push("soundplaying");
|
||||
}
|
||||
if (aOtherTab.hasAttribute("usercontextid")) {
|
||||
aOurTab.setUserContextId(aOtherTab.getAttribute("usercontextid"));
|
||||
modifiedAttrs.push("usercontextid");
|
||||
}
|
||||
if (aOtherTab.hasAttribute("sharing")) {
|
||||
aOurTab.setAttribute("sharing", aOtherTab.getAttribute("sharing"));
|
||||
modifiedAttrs.push("sharing");
|
||||
|
|
@ -2943,7 +2977,8 @@
|
|||
<![CDATA[
|
||||
// If the current URI is registered as open remove it from the list.
|
||||
if (aOurBrowser.registeredOpenURI) {
|
||||
this._unifiedComplete.unregisterOpenPage(aOurBrowser.registeredOpenURI);
|
||||
this._unifiedComplete.unregisterOpenPage(aOurBrowser.registeredOpenURI,
|
||||
aOurBrowser.getAttribute("usercontextid") || 0);
|
||||
delete aOurBrowser.registeredOpenURI;
|
||||
}
|
||||
|
||||
|
|
@ -3283,6 +3318,10 @@
|
|||
// it in the other window (making it seem to have moved between
|
||||
// windows).
|
||||
let params = { eventDetail: { adoptedTab: aTab } };
|
||||
if (aTab.hasAttribute("usercontextid")) {
|
||||
// new tab must have the same usercontextid as the old one
|
||||
params.userContextId = aTab.getAttribute("usercontextid");
|
||||
}
|
||||
let newTab = this.addTab("about:blank", params);
|
||||
let newBrowser = this.getBrowserForTab(newTab);
|
||||
let newURL = aTab.linkedBrowser.currentURI.spec;
|
||||
|
|
@ -4602,6 +4641,7 @@
|
|||
disableSetDesktopBackground: data.disableSetDesktopBg,
|
||||
loginFillInfo: data.loginFillInfo,
|
||||
parentAllowsMixedContent: data.parentAllowsMixedContent,
|
||||
userContextId: data.userContextId,
|
||||
};
|
||||
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
|
||||
let event = gContextMenuContentData.event;
|
||||
|
|
@ -4628,6 +4668,17 @@
|
|||
}
|
||||
case "Browser:WindowCreated": {
|
||||
let tab = this.getTabForBrowser(browser);
|
||||
if (tab && data.userContextId) {
|
||||
ContextualIdentityService.telemetry(data.userContextId);
|
||||
tab.setUserContextId(data.userContextId);
|
||||
}
|
||||
|
||||
// We don't want to update the container icon and identifier if
|
||||
// this is not the selected browser.
|
||||
if (browser == gBrowser.selectedBrowser) {
|
||||
updateUserContextUIIndicator();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "Findbar:Keypress": {
|
||||
|
|
@ -4811,7 +4862,8 @@
|
|||
for (let tab of this.tabs) {
|
||||
let browser = tab.linkedBrowser;
|
||||
if (browser.registeredOpenURI) {
|
||||
this._unifiedComplete.unregisterOpenPage(browser.registeredOpenURI);
|
||||
this._unifiedComplete.unregisterOpenPage(browser.registeredOpenURI,
|
||||
browser.getAttribute("usercontextid") || 0);
|
||||
delete browser.registeredOpenURI;
|
||||
}
|
||||
let filter = this._tabFilters.get(tab);
|
||||
|
|
@ -5212,7 +5264,7 @@
|
|||
</xul:arrowscrollbox>
|
||||
</content>
|
||||
|
||||
<implementation implements="nsIDOMEventListener">
|
||||
<implementation implements="nsIDOMEventListener, nsIObserver">
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.mTabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth");
|
||||
|
|
@ -5231,9 +5283,17 @@
|
|||
this._tabAnimationLoggingEnabled = false;
|
||||
}
|
||||
this._browserNewtabpageEnabled = Services.prefs.getBoolPref("browser.newtabpage.enabled");
|
||||
this.observe(null, "nsPref:changed", "privacy.userContext.enabled");
|
||||
Services.prefs.addObserver("privacy.userContext.enabled", this, false);
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<destructor>
|
||||
<![CDATA[
|
||||
Services.prefs.removeObserver("privacy.userContext.enabled", this);
|
||||
]]>
|
||||
</destructor>
|
||||
|
||||
<field name="tabbrowser" readonly="true">
|
||||
document.getElementById(this.getAttribute("tabbrowser"));
|
||||
</field>
|
||||
|
|
@ -5259,6 +5319,55 @@
|
|||
<field name="_afterHoveredTab">null</field>
|
||||
<field name="_hoveredTab">null</field>
|
||||
|
||||
<method name="observe">
|
||||
<parameter name="aSubject"/>
|
||||
<parameter name="aTopic"/>
|
||||
<parameter name="aData"/>
|
||||
<body><![CDATA[
|
||||
switch (aTopic) {
|
||||
case "nsPref:changed":
|
||||
// This is the only pref observed.
|
||||
let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
|
||||
|
||||
const newTab = document.getElementById("new-tab-button");
|
||||
const newTab2 = document.getAnonymousElementByAttribute(this, "anonid", "tabs-newtab-button")
|
||||
|
||||
if (containersEnabled) {
|
||||
for (let parent of [newTab, newTab2]) {
|
||||
if (!parent)
|
||||
continue;
|
||||
let popup = document.createElementNS(
|
||||
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
||||
"menupopup");
|
||||
if (parent.id) {
|
||||
popup.id = "newtab-popup";
|
||||
} else {
|
||||
popup.setAttribute("anonid", "newtab-popup");
|
||||
}
|
||||
popup.className = "new-tab-popup";
|
||||
popup.setAttribute("position", "after_end");
|
||||
parent.appendChild(popup);
|
||||
|
||||
gClickAndHoldListenersOnElement.add(parent);
|
||||
parent.setAttribute("type", "menu");
|
||||
}
|
||||
} else {
|
||||
for (let parent of [newTab, newTab2]) {
|
||||
if (!parent)
|
||||
continue;
|
||||
gClickAndHoldListenersOnElement.remove(parent);
|
||||
parent.removeAttribute("type");
|
||||
if (!parent.firstChild)
|
||||
continue;
|
||||
parent.firstChild.remove();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="_isCustomizing" readonly="true">
|
||||
<getter>
|
||||
let root = document.documentElement;
|
||||
|
|
@ -6361,6 +6470,7 @@
|
|||
inBackground = !inBackground;
|
||||
|
||||
let targetTab = this._getDragTargetTab(event, true);
|
||||
let userContextId = this.selectedItem.getAttribute("usercontextid");
|
||||
let replace = !!targetTab;
|
||||
let newIndex = this._getDropIndex(event, true);
|
||||
let urls = links.map(link => link.url);
|
||||
|
|
@ -6370,6 +6480,7 @@
|
|||
allowThirdPartyFixup: true,
|
||||
targetTab,
|
||||
newIndex,
|
||||
userContextId,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -6630,6 +6741,14 @@
|
|||
-->
|
||||
<field name="muteReason">undefined</field>
|
||||
|
||||
<property name="userContextId" readonly="true">
|
||||
<getter>
|
||||
return this.hasAttribute("usercontextid")
|
||||
? parseInt(this.getAttribute("usercontextid"))
|
||||
: 0;
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<property name="soundPlaying" readonly="true">
|
||||
<getter>
|
||||
return this.getAttribute("soundplaying") == "true";
|
||||
|
|
@ -6757,6 +6876,27 @@
|
|||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="setUserContextId">
|
||||
<parameter name="aUserContextId"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (aUserContextId) {
|
||||
if (this.linkedBrowser) {
|
||||
this.linkedBrowser.setAttribute("usercontextid", aUserContextId);
|
||||
}
|
||||
this.setAttribute("usercontextid", aUserContextId);
|
||||
} else {
|
||||
if (this.linkedBrowser) {
|
||||
this.linkedBrowser.removeAttribute("usercontextid");
|
||||
}
|
||||
this.removeAttribute("usercontextid");
|
||||
}
|
||||
|
||||
ContextualIdentityService.setTabStyle(this);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
|
|
@ -6933,9 +7073,30 @@
|
|||
<handlers>
|
||||
<handler event="popupshowing">
|
||||
<![CDATA[
|
||||
if (event.target.getAttribute("id") == "alltabs_containersMenuTab") {
|
||||
createUserContextMenu(event);
|
||||
return;
|
||||
}
|
||||
|
||||
let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
|
||||
|
||||
if (event.target.getAttribute("anonid") == "newtab-popup" ||
|
||||
event.target.id == "newtab-popup") {
|
||||
createUserContextMenu(event);
|
||||
} else {
|
||||
document.getElementById("alltabs-popup-separator-1").hidden = !containersEnabled;
|
||||
let containersTab = document.getElementById("alltabs_containersTab");
|
||||
|
||||
containersTab.hidden = !containersEnabled;
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
containersTab.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
document.getElementById("alltabs_undoCloseTab").disabled =
|
||||
SessionStore.getClosedTabCount(window) == 0;
|
||||
|
||||
var tabcontainer = gBrowser.tabContainer;
|
||||
|
||||
// Listen for changes in the tab bar.
|
||||
tabcontainer.addEventListener("TabAttrModified", this, false);
|
||||
tabcontainer.addEventListener("TabClose", this, false);
|
||||
|
|
@ -6952,6 +7113,9 @@
|
|||
|
||||
<handler event="popuphidden">
|
||||
<![CDATA[
|
||||
if (event.target.getAttribute("id") == "alltabs_containersMenuTab") {
|
||||
return;
|
||||
}
|
||||
|
||||
// clear out the menu popup and remove the listeners
|
||||
for (let i = this.childNodes.length - 1; i > 0; i--) {
|
||||
|
|
@ -6960,6 +7124,9 @@
|
|||
menuItem.tab.mCorrespondingMenuitem = null;
|
||||
this.removeChild(menuItem);
|
||||
}
|
||||
if (menuItem.hasAttribute("usercontextid")) {
|
||||
this.removeChild(menuItem);
|
||||
}
|
||||
}
|
||||
var tabcontainer = gBrowser.tabContainer;
|
||||
tabcontainer.mTabstrip.removeEventListener("scroll", this, false);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
// Services = object with smart getters for common XPCOM services
|
||||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
Components.utils.import("resource://gre/modules/ContextualIdentityService.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
|
@ -175,6 +176,7 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt )
|
|||
* skipTabAnimation (boolean)
|
||||
* allowPinnedTabHostChange (boolean)
|
||||
* allowPopups (boolean)
|
||||
* userContextId (unsigned int)
|
||||
*/
|
||||
function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI) {
|
||||
var params;
|
||||
|
|
@ -220,6 +222,7 @@ function openLinkIn(url, where, params) {
|
|||
var aAllowPinnedTabHostChange = !!params.allowPinnedTabHostChange;
|
||||
var aNoReferrer = params.noReferrer;
|
||||
var aAllowPopups = !!params.allowPopups;
|
||||
var aUserContextId = params.userContextId;
|
||||
var aIndicateErrorPageLoad = params.indicateErrorPageLoad;
|
||||
var aPrincipal = params.originPrincipal;
|
||||
var aTriggeringPrincipal = params.triggeringPrincipal;
|
||||
|
|
@ -265,6 +268,7 @@ function openLinkIn(url, where, params) {
|
|||
function useOAForPrincipal(principal) {
|
||||
if (principal && principal.isCodebasePrincipal) {
|
||||
let attrs = {
|
||||
userContextId: aUserContextId,
|
||||
privateBrowsingId: aIsPrivate || (w && PrivateBrowsingUtils.isWindowPrivate(w)),
|
||||
};
|
||||
return Services.scriptSecurityManager.createCodebasePrincipal(principal.URI, attrs);
|
||||
|
|
@ -311,12 +315,17 @@ function openLinkIn(url, where, params) {
|
|||
createInstance(Ci.nsISupportsPRUint32);
|
||||
referrerPolicySupports.data = aReferrerPolicy;
|
||||
|
||||
var userContextIdSupports = Cc["@mozilla.org/supports-PRUint32;1"].
|
||||
createInstance(Ci.nsISupportsPRUint32);
|
||||
userContextIdSupports.data = aUserContextId;
|
||||
|
||||
sa.appendElement(wuri, /* weak =*/ false);
|
||||
sa.appendElement(charset, /* weak =*/ false);
|
||||
sa.appendElement(referrerURISupports, /* weak =*/ false);
|
||||
sa.appendElement(aPostData, /* weak =*/ false);
|
||||
sa.appendElement(allowThirdPartyFixupSupports, /* weak =*/ false);
|
||||
sa.appendElement(referrerPolicySupports, /* weak =*/ false);
|
||||
sa.appendElement(userContextIdSupports, /* weak =*/ false);
|
||||
sa.appendElement(aPrincipal, /* weak =*/ false);
|
||||
sa.appendElement(aTriggeringPrincipal, /* weak =*/ false);
|
||||
|
||||
|
|
@ -409,7 +418,8 @@ function openLinkIn(url, where, params) {
|
|||
flags: flags,
|
||||
referrerURI: aNoReferrer ? null : aReferrerURI,
|
||||
referrerPolicy: aReferrerPolicy,
|
||||
postData: aPostData
|
||||
postData: aPostData,
|
||||
userContextId: aUserContextId
|
||||
});
|
||||
browserUsedForLoad = aCurrentBrowser;
|
||||
break;
|
||||
|
|
@ -428,6 +438,7 @@ function openLinkIn(url, where, params) {
|
|||
skipAnimation: aSkipTabAnimation,
|
||||
allowMixedContent: aAllowMixedContent,
|
||||
noReferrer: aNoReferrer,
|
||||
userContextId: aUserContextId,
|
||||
originPrincipal: aPrincipal,
|
||||
triggeringPrincipal: aTriggeringPrincipal,
|
||||
});
|
||||
|
|
@ -471,6 +482,74 @@ function checkForMiddleClick(node, event) {
|
|||
}
|
||||
}
|
||||
|
||||
// Populate a menu with user-context menu items. This method should be called
|
||||
// by onpopupshowing passing the event as first argument.
|
||||
function createUserContextMenu(event, isContextMenu = false, excludeUserContextId = 0) {
|
||||
while (event.target.hasChildNodes()) {
|
||||
event.target.removeChild(event.target.firstChild);
|
||||
}
|
||||
|
||||
let bundle = document.getElementById("bundle_browser");
|
||||
let docfrag = document.createDocumentFragment();
|
||||
|
||||
// If we are excluding a userContextId, we want to add a 'no-container' item.
|
||||
if (excludeUserContextId) {
|
||||
let menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("data-usercontextid", "0");
|
||||
menuitem.setAttribute("label", bundle.getString("userContextNone.label"));
|
||||
menuitem.setAttribute("accesskey", bundle.getString("userContextNone.accesskey"));
|
||||
|
||||
// We don't set an oncommand/command attribute because if we have
|
||||
// to exclude a userContextId we are generating the contextMenu and
|
||||
// isContextMenu will be true.
|
||||
|
||||
docfrag.appendChild(menuitem);
|
||||
|
||||
let menuseparator = document.createElement("menuseparator");
|
||||
docfrag.appendChild(menuseparator);
|
||||
}
|
||||
|
||||
ContextualIdentityService.getIdentities().forEach(identity => {
|
||||
if (identity.userContextId == excludeUserContextId) {
|
||||
return;
|
||||
}
|
||||
|
||||
let menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("data-usercontextid", identity.userContextId);
|
||||
menuitem.setAttribute("label", ContextualIdentityService.getUserContextLabel(identity.userContextId));
|
||||
|
||||
if (identity.accessKey) {
|
||||
menuitem.setAttribute("accesskey", bundle.getString(identity.accessKey));
|
||||
}
|
||||
|
||||
menuitem.classList.add("menuitem-iconic");
|
||||
menuitem.setAttribute("data-identity-color", identity.color);
|
||||
|
||||
if (!isContextMenu) {
|
||||
menuitem.setAttribute("command", "Browser:NewUserContextTab");
|
||||
}
|
||||
|
||||
menuitem.setAttribute("data-identity-icon", identity.icon);
|
||||
|
||||
docfrag.appendChild(menuitem);
|
||||
});
|
||||
|
||||
if (!isContextMenu) {
|
||||
docfrag.appendChild(document.createElement("menuseparator"));
|
||||
|
||||
let menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("label",
|
||||
bundle.getString("userContext.aboutPage.label"));
|
||||
menuitem.setAttribute("accesskey",
|
||||
bundle.getString("userContext.aboutPage.accesskey"));
|
||||
menuitem.setAttribute("command", "Browser:OpenAboutContainers");
|
||||
docfrag.appendChild(menuitem);
|
||||
}
|
||||
|
||||
event.target.appendChild(docfrag);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Closes all popups that are ancestors of the node.
|
||||
function closeMenus(node)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
[data-identity-color="blue"] {
|
||||
--identity-tab-color: #0996f8;
|
||||
--identity-icon-color: #00a7e0;
|
||||
}
|
||||
|
||||
[data-identity-color="turquoise"] {
|
||||
--identity-tab-color: #01bdad;
|
||||
--identity-icon-color: #01bdad;
|
||||
}
|
||||
|
||||
[data-identity-color="green"] {
|
||||
--identity-tab-color: #57bd35;
|
||||
--identity-icon-color: #7dc14c;
|
||||
}
|
||||
|
||||
[data-identity-color="yellow"] {
|
||||
--identity-tab-color: #ffcb00;
|
||||
--identity-icon-color: #ffcb00;
|
||||
}
|
||||
|
||||
[data-identity-color="orange"] {
|
||||
--identity-tab-color: #ff9216;
|
||||
--identity-icon-color: #ff9216;
|
||||
}
|
||||
|
||||
[data-identity-color="red"] {
|
||||
--identity-tab-color: #d92215;
|
||||
--identity-icon-color: #d92215;
|
||||
}
|
||||
|
||||
[data-identity-color="pink"] {
|
||||
--identity-tab-color: #ea385e;
|
||||
--identity-icon-color: #ee5195;
|
||||
}
|
||||
|
||||
[data-identity-color="purple"] {
|
||||
--identity-tab-color: #7a2f7a;
|
||||
--identity-icon-color: #7a2f7a;
|
||||
}
|
||||
|
||||
[data-identity-icon="fingerprint"] {
|
||||
--identity-icon: url("chrome://browser/content/usercontext.svg#fingerprint");
|
||||
}
|
||||
|
||||
[data-identity-icon="briefcase"] {
|
||||
--identity-icon: url("chrome://browser/content/usercontext.svg#briefcase");
|
||||
}
|
||||
|
||||
[data-identity-icon="dollar"] {
|
||||
--identity-icon: url("chrome://browser/content/usercontext.svg#dollar");
|
||||
}
|
||||
|
||||
[data-identity-icon="cart"] {
|
||||
--identity-icon: url("chrome://browser/content/usercontext.svg#cart");
|
||||
}
|
||||
|
||||
[data-identity-icon="circle"] {
|
||||
--identity-icon: url("chrome://browser/content/usercontext.svg#circle");
|
||||
}
|
||||
|
||||
#userContext-indicator {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
#userContext-label {
|
||||
margin-inline-end: 3px;
|
||||
color: var(--identity-tab-color);
|
||||
}
|
||||
|
||||
#userContext-icons {
|
||||
-moz-box-align: center;
|
||||
}
|
||||
|
||||
.tabbrowser-tab[usercontextid] {
|
||||
background-image: linear-gradient(to right, transparent 20%, var(--identity-tab-color) 30%, var(--identity-tab-color) 70%, transparent 80%);
|
||||
background-size: auto 2px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.userContext-icon,
|
||||
.menuitem-iconic[data-usercontextid] > .menu-iconic-left > .menu-iconic-icon,
|
||||
.subviewbutton[usercontextid] > .toolbarbutton-icon,
|
||||
#userContext-indicator {
|
||||
background-image: var(--identity-icon);
|
||||
filter: url(chrome://browser/skin/filters.svg#fill);
|
||||
fill: var(--identity-icon-color);
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
browser.jar:
|
||||
content/browser/usercontext/usercontext.css (content/usercontext.css)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
|
@ -23,6 +23,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
|
|||
"resource://gre/modules/CharsetMenu.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
|
||||
"resource://gre/modules/ContextualIdentityService.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "CharsetBundle", function() {
|
||||
const kCharsetBundle = "chrome://global/locale/charsetMenu.properties";
|
||||
|
|
@ -975,6 +977,89 @@ const CustomizableWidgets = [
|
|||
let win = aEvent.view;
|
||||
win.MailIntegration.sendLinkForBrowser(win.gBrowser.selectedBrowser)
|
||||
}
|
||||
}, {
|
||||
id: "containers-panelmenu",
|
||||
type: "view",
|
||||
viewId: "PanelUI-containers",
|
||||
hasObserver: false,
|
||||
onCreated: function(aNode) {
|
||||
let doc = aNode.ownerDocument;
|
||||
let win = doc.defaultView;
|
||||
let items = doc.getElementById("PanelUI-containersItems");
|
||||
|
||||
let onItemCommand = function (aEvent) {
|
||||
let item = aEvent.target;
|
||||
if (item.hasAttribute("usercontextid")) {
|
||||
let userContextId = parseInt(item.getAttribute("usercontextid"));
|
||||
win.openUILinkIn(win.BROWSER_NEW_TAB_URL, "tab", {userContextId});
|
||||
}
|
||||
};
|
||||
items.addEventListener("command", onItemCommand);
|
||||
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(win)) {
|
||||
aNode.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
this.updateVisibility(aNode);
|
||||
|
||||
if (!this.hasObserver) {
|
||||
Services.prefs.addObserver("privacy.userContext.enabled", this, true);
|
||||
this.hasObserver = true;
|
||||
}
|
||||
},
|
||||
onViewShowing: function(aEvent) {
|
||||
let doc = aEvent.target.ownerDocument;
|
||||
|
||||
let items = doc.getElementById("PanelUI-containersItems");
|
||||
|
||||
while (items.firstChild) {
|
||||
items.firstChild.remove();
|
||||
}
|
||||
|
||||
let fragment = doc.createDocumentFragment();
|
||||
let bundle = doc.getElementById("bundle_browser");
|
||||
|
||||
ContextualIdentityService.getIdentities().forEach(identity => {
|
||||
let label = ContextualIdentityService.getUserContextLabel(identity.userContextId);
|
||||
|
||||
let item = doc.createElementNS(kNSXUL, "toolbarbutton");
|
||||
item.setAttribute("label", label);
|
||||
item.setAttribute("usercontextid", identity.userContextId);
|
||||
item.setAttribute("class", "subviewbutton");
|
||||
item.setAttribute("data-identity-color", identity.color);
|
||||
item.setAttribute("data-identity-icon", identity.icon);
|
||||
|
||||
fragment.appendChild(item);
|
||||
});
|
||||
|
||||
fragment.appendChild(doc.createElementNS(kNSXUL, "menuseparator"));
|
||||
|
||||
let item = doc.createElementNS(kNSXUL, "toolbarbutton");
|
||||
item.setAttribute("label", bundle.getString("userContext.aboutPage.label"));
|
||||
item.setAttribute("command", "Browser:OpenAboutContainers");
|
||||
item.setAttribute("class", "subviewbutton");
|
||||
fragment.appendChild(item);
|
||||
|
||||
items.appendChild(fragment);
|
||||
},
|
||||
|
||||
updateVisibility(aNode) {
|
||||
aNode.hidden = !Services.prefs.getBoolPref("privacy.userContext.enabled");
|
||||
},
|
||||
|
||||
observe(aSubject, aTopic, aData) {
|
||||
let {instances} = CustomizableUI.getWidget("containers-panelmenu");
|
||||
for (let {node} of instances) {
|
||||
if (node) {
|
||||
this.updateVisibility(node);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIObserver
|
||||
]),
|
||||
}];
|
||||
|
||||
let preferencesButton = {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
DIRS += [
|
||||
'about',
|
||||
'contextualidentity',
|
||||
'customizableui',
|
||||
'dirprovider',
|
||||
'downloads',
|
||||
|
|
|
|||
176
application/basilisk/components/preferences/containers.js
Normal file
176
application/basilisk/components/preferences/containers.js
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/ContextualIdentityService.jsm");
|
||||
|
||||
const containersBundle = Services.strings.createBundle("chrome://browser/locale/preferences/containers.properties");
|
||||
|
||||
const HTMLNS = "http://www.w3.org/1999/xhtml";
|
||||
|
||||
let gContainersManager = {
|
||||
icons: [
|
||||
"fingerprint",
|
||||
"briefcase",
|
||||
"dollar",
|
||||
"cart",
|
||||
"circle"
|
||||
],
|
||||
|
||||
colors: [
|
||||
"blue",
|
||||
"turquoise",
|
||||
"green",
|
||||
"yellow",
|
||||
"orange",
|
||||
"red",
|
||||
"pink",
|
||||
"purple"
|
||||
],
|
||||
|
||||
onLoad() {
|
||||
let params = window.arguments[0] || {};
|
||||
this.init(params);
|
||||
},
|
||||
|
||||
init(aParams) {
|
||||
this.userContextId = aParams.userContextId || null;
|
||||
this.identity = aParams.identity;
|
||||
|
||||
if (aParams.windowTitle) {
|
||||
document.title = aParams.windowTitle;
|
||||
}
|
||||
|
||||
const iconWrapper = document.getElementById("iconWrapper");
|
||||
iconWrapper.appendChild(this.createIconButtons());
|
||||
|
||||
const colorWrapper = document.getElementById("colorWrapper");
|
||||
colorWrapper.appendChild(this.createColorSwatches());
|
||||
|
||||
if (this.identity.name) {
|
||||
const name = document.getElementById("name");
|
||||
name.value = this.identity.name;
|
||||
this.checkForm();
|
||||
}
|
||||
|
||||
this.setLabelsMinWidth();
|
||||
|
||||
// This is to prevent layout jank caused by the svgs and outlines rendering at different times
|
||||
document.getElementById("containers-content").removeAttribute("hidden");
|
||||
},
|
||||
|
||||
setLabelsMinWidth() {
|
||||
const labelMinWidth = containersBundle.GetStringFromName("containers.labelMinWidth");
|
||||
const labels = [
|
||||
document.getElementById("nameLabel"),
|
||||
document.getElementById("iconLabel"),
|
||||
document.getElementById("colorLabel")
|
||||
];
|
||||
for (let label of labels) {
|
||||
label.style.minWidth = labelMinWidth;
|
||||
}
|
||||
},
|
||||
|
||||
uninit() {
|
||||
},
|
||||
|
||||
// Check if name string as to if the form can be submitted
|
||||
checkForm() {
|
||||
const name = document.getElementById("name");
|
||||
let btnApplyChanges = document.getElementById("btnApplyChanges");
|
||||
if (!name.value) {
|
||||
btnApplyChanges.setAttribute("disabled", true);
|
||||
} else {
|
||||
btnApplyChanges.removeAttribute("disabled");
|
||||
}
|
||||
},
|
||||
|
||||
createIconButtons(defaultIcon) {
|
||||
let radiogroup = document.createElement("radiogroup");
|
||||
radiogroup.setAttribute("id", "icon");
|
||||
radiogroup.className = "icon-buttons";
|
||||
|
||||
for (let icon of this.icons) {
|
||||
let iconSwatch = document.createElement("radio");
|
||||
iconSwatch.id = "iconbutton-" + icon;
|
||||
iconSwatch.name = "icon";
|
||||
iconSwatch.type = "radio";
|
||||
iconSwatch.value = icon;
|
||||
|
||||
if (this.identity.icon && this.identity.icon == icon) {
|
||||
iconSwatch.setAttribute("selected", true);
|
||||
}
|
||||
|
||||
iconSwatch.setAttribute("label",
|
||||
containersBundle.GetStringFromName(`containers.${icon}.label`));
|
||||
let iconElement = document.createElement("hbox");
|
||||
iconElement.className = 'userContext-icon';
|
||||
iconElement.setAttribute("data-identity-icon", icon);
|
||||
|
||||
iconSwatch.appendChild(iconElement);
|
||||
radiogroup.appendChild(iconSwatch);
|
||||
}
|
||||
|
||||
return radiogroup;
|
||||
},
|
||||
|
||||
createColorSwatches(defaultColor) {
|
||||
let radiogroup = document.createElement("radiogroup");
|
||||
radiogroup.setAttribute("id", "color");
|
||||
|
||||
for (let color of this.colors) {
|
||||
let colorSwatch = document.createElement("radio");
|
||||
colorSwatch.id = "colorswatch-" + color;
|
||||
colorSwatch.name = "color";
|
||||
colorSwatch.type = "radio";
|
||||
colorSwatch.value = color;
|
||||
|
||||
if (this.identity.color && this.identity.color == color) {
|
||||
colorSwatch.setAttribute("selected", true);
|
||||
}
|
||||
|
||||
colorSwatch.setAttribute("label",
|
||||
containersBundle.GetStringFromName(`containers.${color}.label`));
|
||||
let iconElement = document.createElement("hbox");
|
||||
iconElement.className = 'userContext-icon';
|
||||
iconElement.setAttribute("data-identity-icon", "circle");
|
||||
iconElement.setAttribute("data-identity-color", color);
|
||||
|
||||
colorSwatch.appendChild(iconElement);
|
||||
radiogroup.appendChild(colorSwatch);
|
||||
}
|
||||
return radiogroup;
|
||||
},
|
||||
|
||||
onApplyChanges() {
|
||||
let icon = document.getElementById("icon").value;
|
||||
let color = document.getElementById("color").value;
|
||||
let name = document.getElementById("name").value;
|
||||
|
||||
if (this.icons.indexOf(icon) == -1) {
|
||||
throw "Internal error. The icon value doesn't match.";
|
||||
}
|
||||
|
||||
if (this.colors.indexOf(color) == -1) {
|
||||
throw "Internal error. The color value doesn't match.";
|
||||
}
|
||||
|
||||
if (this.userContextId) {
|
||||
ContextualIdentityService.update(this.userContextId,
|
||||
name,
|
||||
icon,
|
||||
color);
|
||||
} else {
|
||||
ContextualIdentityService.create(name,
|
||||
icon,
|
||||
color);
|
||||
}
|
||||
window.parent.location.reload()
|
||||
},
|
||||
|
||||
onWindowKeyPress(aEvent) {
|
||||
if (aEvent.keyCode == KeyEvent.DOM_VK_ESCAPE)
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
52
application/basilisk/components/preferences/containers.xul
Normal file
52
application/basilisk/components/preferences/containers.xul
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/preferences/containers.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/containers.dtd" >
|
||||
|
||||
<window id="ContainersDialog" class="windowDialog"
|
||||
windowtype="Browser:Permissions"
|
||||
title="&window.title;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
style="width: &window.width;;"
|
||||
onload="gContainersManager.onLoad();"
|
||||
onunload="gContainersManager.uninit();"
|
||||
persist="screenX screenY width height"
|
||||
onkeypress="gContainersManager.onWindowKeyPress(event);">
|
||||
|
||||
<script src="chrome://global/content/treeUtils.js"/>
|
||||
<script src="chrome://browser/content/preferences/containers.js"/>
|
||||
|
||||
<stringbundle id="bundlePreferences"
|
||||
src="chrome://browser/locale/preferences/preferences.properties"/>
|
||||
|
||||
<keyset>
|
||||
<key key="&windowClose.key;" modifiers="accel" oncommand="window.close();"/>
|
||||
</keyset>
|
||||
|
||||
<vbox class="contentPane largeDialogContainer" flex="1" hidden="true" id="containers-content">
|
||||
<description id="permissionsText" control="url"/>
|
||||
<separator class="thin"/>
|
||||
<hbox align="start">
|
||||
<label id="nameLabel" control="url" value="&name.label;" accesskey="&name.accesskey;"/>
|
||||
<textbox id="name" flex="1" onkeyup="gContainersManager.checkForm();" />
|
||||
</hbox>
|
||||
<hbox align="center" id="iconWrapper">
|
||||
<label id="iconLabel" control="url" value="&icon.label;" accesskey="&icon.accesskey;"/>
|
||||
</hbox>
|
||||
<hbox align="center" id="colorWrapper">
|
||||
<label id="colorLabel" control="url" value="&color.label;" accesskey="&color.accesskey;"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<hbox class="actionButtons" align="right" flex="1">
|
||||
<button id="btnApplyChanges" disabled="true" oncommand="gContainersManager.onApplyChanges();" icon="save"
|
||||
label="&button.ok.label;" accesskey="&button.ok.accesskey;"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</window>
|
||||
|
|
@ -7,8 +7,12 @@ const nsICookie = Components.interfaces.nsICookie;
|
|||
|
||||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm")
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
|
||||
"resource://gre/modules/ContextualIdentityService.jsm");
|
||||
|
||||
var gCookiesWindow = {
|
||||
_cm : Components.classes["@mozilla.org/cookiemanager;1"]
|
||||
.getService(Components.interfaces.nsICookieManager),
|
||||
|
|
@ -34,6 +38,10 @@ var gCookiesWindow = {
|
|||
this._populateList(true);
|
||||
|
||||
document.getElementById("filter").focus();
|
||||
|
||||
if (!Services.prefs.getBoolPref("privacy.userContext.enabled")) {
|
||||
document.getElementById("userContextRow").hidden = true;
|
||||
}
|
||||
},
|
||||
|
||||
uninit: function () {
|
||||
|
|
@ -74,11 +82,24 @@ var gCookiesWindow = {
|
|||
aCookieB.originAttributes);
|
||||
},
|
||||
|
||||
_isPrivateCookie: function (aCookie) {
|
||||
let { userContextId } = aCookie.originAttributes;
|
||||
if (!userContextId) {
|
||||
// Default identity is public.
|
||||
return false;
|
||||
}
|
||||
return !ContextualIdentityService.getIdentityFromId(userContextId).public;
|
||||
},
|
||||
|
||||
observe: function (aCookie, aTopic, aData) {
|
||||
if (aTopic != "cookie-changed")
|
||||
return;
|
||||
|
||||
if (aCookie instanceof Components.interfaces.nsICookie) {
|
||||
if (this._isPrivateCookie(aCookie)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var strippedHost = this._makeStrippedHost(aCookie.host);
|
||||
if (aData == "changed")
|
||||
this._handleCookieChanged(aCookie, strippedHost);
|
||||
|
|
@ -477,6 +498,9 @@ var gCookiesWindow = {
|
|||
while (e.hasMoreElements()) {
|
||||
var cookie = e.getNext();
|
||||
if (cookie && cookie instanceof Components.interfaces.nsICookie) {
|
||||
if (this._isPrivateCookie(cookie)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var strippedHost = this._makeStrippedHost(cookie.host);
|
||||
this._addCookie(strippedHost, cookie, hostCount);
|
||||
|
|
@ -500,9 +524,17 @@ var gCookiesWindow = {
|
|||
return this._bundle.getString("expireAtEndOfSession");
|
||||
},
|
||||
|
||||
_getUserContextString: function(aUserContextId) {
|
||||
if (parseInt(aUserContextId) == 0) {
|
||||
return this._bundle.getString("defaultUserContextLabel");
|
||||
}
|
||||
|
||||
return ContextualIdentityService.getUserContextLabel(aUserContextId);
|
||||
},
|
||||
|
||||
_updateCookieData: function (aItem) {
|
||||
var seln = this._view.selection;
|
||||
var ids = ["name", "value", "host", "path", "isSecure", "expires"];
|
||||
var ids = ["name", "value", "host", "path", "isSecure", "expires", "userContext"];
|
||||
var properties;
|
||||
|
||||
if (aItem && !aItem.container && seln.count > 0) {
|
||||
|
|
@ -511,7 +543,8 @@ var gCookiesWindow = {
|
|||
isDomain: aItem.isDomain ? this._bundle.getString("domainColon")
|
||||
: this._bundle.getString("hostColon"),
|
||||
isSecure: aItem.isSecure ? this._bundle.getString("forSecureOnly")
|
||||
: this._bundle.getString("forAnyConnection") };
|
||||
: this._bundle.getString("forAnyConnection"),
|
||||
userContext: this._getUserContextString(aItem.originAttributes.userContextId) };
|
||||
for (let id of ids) {
|
||||
document.getElementById(id).disabled = false;
|
||||
}
|
||||
|
|
@ -520,7 +553,7 @@ var gCookiesWindow = {
|
|||
var noneSelected = this._bundle.getString("noCookieSelected");
|
||||
properties = { name: noneSelected, value: noneSelected, host: noneSelected,
|
||||
path: noneSelected, expires: noneSelected,
|
||||
isSecure: noneSelected };
|
||||
isSecure: noneSelected, userContext: noneSelected };
|
||||
for (let id of ids) {
|
||||
document.getElementById(id).disabled = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,10 @@
|
|||
<hbox pack="end"><label id="expiresLabel" control="expires" value="&props.expires.label;"/></hbox>
|
||||
<textbox id="expires" readonly="true" class="plain"/>
|
||||
</row>
|
||||
<row align="center" id="userContextRow">
|
||||
<hbox pack="end"><label id="userContextLabel" control="userContext" value="&props.container.label;"/></hbox>
|
||||
<textbox id="userContext" readonly="true" class="plain"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</hbox>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
-moz-binding: url("chrome://browser/content/preferences/handlers.xml#handler-selected");
|
||||
}
|
||||
|
||||
#containersView > richlistitem {
|
||||
-moz-binding: url("chrome://browser/content/preferences/handlers.xml#container");
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the icons appear.
|
||||
* Note: we display the icon box for every item whether or not it has an icon
|
||||
|
|
|
|||
|
|
@ -69,6 +69,29 @@
|
|||
|
||||
</binding>
|
||||
|
||||
<binding id="container">
|
||||
<content>
|
||||
<xul:hbox flex="1" equalsize="always">
|
||||
<xul:hbox flex="1" align="center">
|
||||
<xul:hbox xbl:inherits="data-identity-icon=containerIcon,data-identity-color=containerColor" height="24" width="24" class="userContext-icon"/>
|
||||
<xul:label flex="1" crop="end" xbl:inherits="value=containerName"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox flex="1" align="right">
|
||||
<xul:button anonid="preferencesButton"
|
||||
xbl:inherits="value=userContextId"
|
||||
onclick="gContainersPane.onPeferenceClick(event.originalTarget)">
|
||||
Preferences
|
||||
</xul:button>
|
||||
<xul:button anonid="removeButton"
|
||||
xbl:inherits="value=userContextId"
|
||||
onclick="gContainersPane.onRemoveClick(event.originalTarget)">
|
||||
Remove
|
||||
</xul:button>
|
||||
</xul:hbox>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="offlineapp"
|
||||
extends="chrome://global/content/bindings/listbox.xml#listitem">
|
||||
<content>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
Components.utils.import("resource://gre/modules/ContextualIdentityService.jsm");
|
||||
|
||||
const containersBundle = Services.strings.createBundle("chrome://browser/locale/preferences/containers.properties");
|
||||
|
||||
const defaultContainerIcon = "fingerprint";
|
||||
const defaultContainerColor = "blue";
|
||||
|
||||
let gContainersPane = {
|
||||
|
||||
init() {
|
||||
this._list = document.getElementById("containersView");
|
||||
|
||||
document.getElementById("backContainersLink").addEventListener("click", function () {
|
||||
gotoPref("privacy");
|
||||
});
|
||||
|
||||
this._rebuildView();
|
||||
},
|
||||
|
||||
_rebuildView() {
|
||||
const containers = ContextualIdentityService.getIdentities();
|
||||
while (this._list.firstChild) {
|
||||
this._list.firstChild.remove();
|
||||
}
|
||||
for (let container of containers) {
|
||||
let item = document.createElement("richlistitem");
|
||||
item.setAttribute("containerName", ContextualIdentityService.getUserContextLabel(container.userContextId));
|
||||
item.setAttribute("containerIcon", container.icon);
|
||||
item.setAttribute("containerColor", container.color);
|
||||
item.setAttribute("userContextId", container.userContextId);
|
||||
|
||||
this._list.appendChild(item);
|
||||
}
|
||||
},
|
||||
|
||||
onRemoveClick(button) {
|
||||
let userContextId = button.getAttribute("value");
|
||||
ContextualIdentityService.remove(userContextId);
|
||||
this._rebuildView();
|
||||
},
|
||||
onPeferenceClick(button) {
|
||||
this.openPreferenceDialog(button.getAttribute("value"));
|
||||
},
|
||||
|
||||
onAddButtonClick(button) {
|
||||
this.openPreferenceDialog(null);
|
||||
},
|
||||
|
||||
openPreferenceDialog(userContextId) {
|
||||
let identity = {
|
||||
name: "",
|
||||
icon: defaultContainerIcon,
|
||||
color: defaultContainerColor
|
||||
};
|
||||
let title;
|
||||
if (userContextId) {
|
||||
identity = ContextualIdentityService.getIdentityFromId(userContextId);
|
||||
// This is required to get the translation string from defaults
|
||||
identity.name = ContextualIdentityService.getUserContextLabel(identity.userContextId);
|
||||
title = containersBundle.formatStringFromName("containers.updateContainerTitle", [identity.name], 1);
|
||||
}
|
||||
|
||||
const params = { userContextId, identity, windowTitle: title };
|
||||
gSubDialog.open("chrome://browser/content/preferences/containers.xul",
|
||||
null, params);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
<!-- Containers panel -->
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://browser/content/preferences/in-content/containers.js"/>
|
||||
|
||||
<preferences id="containerPreferences" hidden="true" data-category="paneContainer">
|
||||
<!-- Containers -->
|
||||
<preference id="privacy.userContext.enabled"
|
||||
name="privacy.userContext.enabled"
|
||||
type="bool"/>
|
||||
|
||||
</preferences>
|
||||
|
||||
<hbox hidden="true"
|
||||
class="container-header-links"
|
||||
data-category="paneContainers">
|
||||
<label class="text-link" id="backContainersLink" value="&backLink.label;" />
|
||||
</hbox>
|
||||
|
||||
<hbox id="header-containers"
|
||||
class="header"
|
||||
hidden="true"
|
||||
data-category="paneContainers">
|
||||
<label class="header-name" flex="1">&paneContainers.title;</label>
|
||||
<button class="help-button"
|
||||
aria-label="&helpButton.label;"/>
|
||||
</hbox>
|
||||
|
||||
<!-- Containers -->
|
||||
<groupbox id="browserContainersGroup" data-category="paneContainers" hidden="true">
|
||||
<vbox id="browserContainersbox">
|
||||
|
||||
<richlistbox id="containersView" orient="vertical" persist="lastSelectedType"
|
||||
flex="1">
|
||||
<listheader equalsize="always">
|
||||
<treecol id="typeColumn" label="&label.label;" value="type"
|
||||
persist="sortDirection"
|
||||
flex="1" sortDirection="ascending"/>
|
||||
<treecol id="actionColumn" value="action"
|
||||
persist="sortDirection"
|
||||
flex="1"/>
|
||||
</listheader>
|
||||
</richlistbox>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<hbox flex="1">
|
||||
<button onclick="gContainersPane.onAddButtonClick();" accesskey="&addButton.accesskey;" label="&addButton.label;"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
|
@ -9,6 +9,7 @@ browser.jar:
|
|||
|
||||
content/browser/preferences/in-content/main.js
|
||||
* content/browser/preferences/in-content/privacy.js
|
||||
content/browser/preferences/in-content/containers.js
|
||||
content/browser/preferences/in-content/advanced.js
|
||||
content/browser/preferences/in-content/applications.js
|
||||
* content/browser/preferences/in-content/content.js
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ function init_all() {
|
|||
register_module("paneGeneral", gMainPane);
|
||||
register_module("paneSearch", gSearchPane);
|
||||
register_module("panePrivacy", gPrivacyPane);
|
||||
register_module("paneContainers", gContainersPane);
|
||||
register_module("paneAdvanced", gAdvancedPane);
|
||||
register_module("paneApplications", gApplicationsPane);
|
||||
register_module("paneContent", gContentPane);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
href="chrome://browser/content/preferences/handlers.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/preferences/applications.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/preferences/in-content/search.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/preferences/in-content/containers.css"?>
|
||||
|
||||
<!DOCTYPE page [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
|
||||
|
|
@ -26,6 +27,8 @@
|
|||
<!ENTITY % syncDTD SYSTEM "chrome://browser/locale/preferences/sync.dtd">
|
||||
<!ENTITY % securityDTD SYSTEM
|
||||
"chrome://browser/locale/preferences/security.dtd">
|
||||
<!ENTITY % containersDTD SYSTEM
|
||||
"chrome://browser/locale/preferences/containers.dtd">
|
||||
<!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
|
||||
<!ENTITY % mainDTD SYSTEM "chrome://browser/locale/preferences/main.dtd">
|
||||
<!ENTITY % aboutHomeDTD SYSTEM "chrome://browser/locale/aboutHome.dtd">
|
||||
|
|
@ -43,6 +46,7 @@
|
|||
%syncBrandDTD;
|
||||
%syncDTD;
|
||||
%securityDTD;
|
||||
%containersDTD;
|
||||
%sanitizeDTD;
|
||||
%mainDTD;
|
||||
%aboutHomeDTD;
|
||||
|
|
@ -130,6 +134,12 @@
|
|||
<label class="category-name" flex="1">&panePrivacy.title;</label>
|
||||
</richlistitem>
|
||||
|
||||
<richlistitem id="category-containers"
|
||||
class="category"
|
||||
value="paneContainers"
|
||||
helpTopic="prefs-containers"
|
||||
hidden="true"/>
|
||||
|
||||
<richlistitem id="category-security"
|
||||
class="category"
|
||||
value="paneSecurity"
|
||||
|
|
@ -173,6 +183,7 @@
|
|||
#include main.xul
|
||||
#include search.xul
|
||||
#include privacy.xul
|
||||
#include containers.xul
|
||||
#include advanced.xul
|
||||
#include applications.xul
|
||||
#include content.xul
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
|
||||
"resource://gre/modules/ContextualIdentityService.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
|
|
@ -59,6 +61,59 @@ var gPrivacyPane = {
|
|||
.getService(Components.interfaces.mozIPlacesAutoComplete);
|
||||
},
|
||||
|
||||
/**
|
||||
* Show the Containers UI depending on the privacy.userContext.ui.enabled pref.
|
||||
*/
|
||||
_initBrowserContainers: function () {
|
||||
if (!Services.prefs.getBoolPref("privacy.userContext.ui.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let link = document.getElementById("browserContainersLearnMore");
|
||||
link.href = Services.urlFormatter.formatURLPref("app.support.baseURL") + "containers";
|
||||
|
||||
document.getElementById("browserContainersbox").hidden = false;
|
||||
|
||||
document.getElementById("browserContainersCheckbox").checked =
|
||||
Services.prefs.getBoolPref("privacy.userContext.enabled");
|
||||
},
|
||||
|
||||
_checkBrowserContainers: function(event) {
|
||||
let checkbox = document.getElementById("browserContainersCheckbox");
|
||||
if (checkbox.checked) {
|
||||
Services.prefs.setBoolPref("privacy.userContext.enabled", true);
|
||||
return;
|
||||
}
|
||||
|
||||
let count = ContextualIdentityService.countContainerTabs();
|
||||
if (count == 0) {
|
||||
Services.prefs.setBoolPref("privacy.userContext.enabled", false);
|
||||
return;
|
||||
}
|
||||
|
||||
let bundlePreferences = document.getElementById("bundlePreferences");
|
||||
|
||||
let title = bundlePreferences.getString("disableContainersAlertTitle");
|
||||
let message = PluralForm.get(count, bundlePreferences.getString("disableContainersMsg"))
|
||||
.replace("#S", count)
|
||||
let okButton = PluralForm.get(count, bundlePreferences.getString("disableContainersOkButton"))
|
||||
.replace("#S", count)
|
||||
let cancelButton = bundlePreferences.getString("disableContainersButton2");
|
||||
|
||||
let buttonFlags = (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_0) +
|
||||
(Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_1);
|
||||
|
||||
let rv = Services.prompt.confirmEx(window, title, message, buttonFlags,
|
||||
okButton, cancelButton, null, null, {});
|
||||
if (rv == 0) {
|
||||
ContextualIdentityService.closeAllContainerTabs();
|
||||
Services.prefs.setBoolPref("privacy.userContext.enabled", false);
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.checked = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets up the UI for the number of days of history to keep, and updates the
|
||||
* label of the "Clear Now..." button.
|
||||
|
|
@ -81,6 +136,7 @@ var gPrivacyPane = {
|
|||
this._initTrackingProtectionPBM();
|
||||
#endif
|
||||
this._initAutocomplete();
|
||||
this._initBrowserContainers();
|
||||
|
||||
setEventListener("privacy.sanitize.sanitizeOnShutdown", "change",
|
||||
gPrivacyPane._updateSanitizeSettingsButton);
|
||||
|
|
@ -128,6 +184,10 @@ var gPrivacyPane = {
|
|||
setEventListener("changeBlockListPBM", "command",
|
||||
gPrivacyPane.showBlockLists);
|
||||
#endif
|
||||
setEventListener("browserContainersCheckbox", "command",
|
||||
gPrivacyPane._checkBrowserContainers);
|
||||
setEventListener("browserContainersSettings", "command",
|
||||
gPrivacyPane.showContainerSettings);
|
||||
},
|
||||
|
||||
#ifdef MOZ_SAFE_BROWSING
|
||||
|
|
@ -429,6 +489,13 @@ var gPrivacyPane = {
|
|||
},
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Displays container panel for customising and adding containers.
|
||||
*/
|
||||
showContainerSettings() {
|
||||
gotoPref("containers");
|
||||
},
|
||||
|
||||
#ifdef MOZ_SAFE_BROWSING
|
||||
/**
|
||||
* Displays the available block lists for tracking protection.
|
||||
|
|
@ -635,4 +702,25 @@ var gPrivacyPane = {
|
|||
|
||||
settingsButton.disabled = !sanitizeOnShutdownPref.value;
|
||||
},
|
||||
|
||||
// CONTAINERS
|
||||
|
||||
/*
|
||||
* preferences:
|
||||
*
|
||||
* privacy.userContext.enabled
|
||||
* - true if containers is enabled
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enables/disables the Settings button used to configure containers
|
||||
*/
|
||||
readBrowserContainersCheckbox: function ()
|
||||
{
|
||||
var pref = document.getElementById("privacy.userContext.enabled");
|
||||
var settings = document.getElementById("browserContainersSettings");
|
||||
|
||||
settings.disabled = !pref.value;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -302,3 +302,28 @@
|
|||
&suggestionSettings.label;
|
||||
</label>
|
||||
</groupbox>
|
||||
|
||||
<!-- Containers -->
|
||||
<groupbox id="browserContainersGroup" data-category="panePrivacy" hidden="true">
|
||||
<vbox id="browserContainersbox" hidden="true">
|
||||
<caption><label>&browserContainersHeader.label;
|
||||
<label id="browserContainersLearnMore" class="text-link"
|
||||
value="&browserContainersLearnMore.label;"/>
|
||||
</label></caption>
|
||||
<hbox align="start">
|
||||
<vbox>
|
||||
<checkbox id="browserContainersCheckbox"
|
||||
label="&browserContainersEnabled.label;"
|
||||
accesskey="&browserContainersEnabled.accesskey;"
|
||||
preference="privacy.userContext.enabled"
|
||||
onsyncfrompreference="return gPrivacyPane.readBrowserContainersCheckbox();"/>
|
||||
</vbox>
|
||||
<spacer flex="1"/>
|
||||
<vbox>
|
||||
<button id="browserContainersSettings"
|
||||
label="&browserContainersSettings.label;"
|
||||
accesskey="&browserContainersSettings.accesskey;"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ browser.jar:
|
|||
* content/browser/preferences/languages.xul
|
||||
content/browser/preferences/languages.js
|
||||
content/browser/preferences/permissions.xul
|
||||
content/browser/preferences/containers.xul
|
||||
content/browser/preferences/containers.js
|
||||
content/browser/preferences/permissions.js
|
||||
content/browser/preferences/sanitize.xul
|
||||
content/browser/preferences/sanitize.js
|
||||
|
|
|
|||
|
|
@ -208,6 +208,10 @@ ContentRestoreInternal.prototype = {
|
|||
? Utils.deserializePrincipal(loadArguments.triggeringPrincipal)
|
||||
: null;
|
||||
|
||||
if (loadArguments.userContextId) {
|
||||
webNavigation.setOriginAttributesBeforeLoading({ userContextId: loadArguments.userContextId });
|
||||
}
|
||||
|
||||
webNavigation.loadURIWithOptions(loadArguments.uri, loadArguments.flags,
|
||||
referrer, referrerPolicy, postData,
|
||||
null, null, triggeringPrincipal);
|
||||
|
|
|
|||
|
|
@ -64,10 +64,11 @@ var SessionHistoryInternal = {
|
|||
* The docShell that owns the session history.
|
||||
*/
|
||||
collect: function (docShell) {
|
||||
let loadContext = docShell.QueryInterface(Ci.nsILoadContext);
|
||||
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
let history = webNavigation.sessionHistory.QueryInterface(Ci.nsISHistoryInternal);
|
||||
|
||||
let data = {entries: []};
|
||||
let data = {entries: [], userContextId: loadContext.originAttributes.userContextId };
|
||||
|
||||
if (history && history.count > 0) {
|
||||
// Loop over the transaction linked list directly so we can get the
|
||||
|
|
|
|||
|
|
@ -2204,9 +2204,10 @@ var SessionStoreInternal = {
|
|||
}
|
||||
|
||||
// Create a new tab.
|
||||
let userContextId = aTab.getAttribute("usercontextid");
|
||||
let newTab = aTab == aWindow.gBrowser.selectedTab ?
|
||||
aWindow.gBrowser.addTab(null, {relatedToCurrent: true, ownerTab: aTab}) :
|
||||
aWindow.gBrowser.addTab();
|
||||
aWindow.gBrowser.addTab(null, {relatedToCurrent: true, ownerTab: aTab, userContextId}) :
|
||||
aWindow.gBrowser.addTab(null, {userContextId});
|
||||
|
||||
// Set tab title to "Connecting..." and start the throbber to pretend we're
|
||||
// doing something while actually waiting for data from the frame script.
|
||||
|
|
@ -2295,7 +2296,7 @@ var SessionStoreInternal = {
|
|||
|
||||
// create a new tab
|
||||
let tabbrowser = aWindow.gBrowser;
|
||||
let tab = tabbrowser.selectedTab = tabbrowser.addTab();
|
||||
let tab = tabbrowser.selectedTab = tabbrowser.addTab(null, state);
|
||||
|
||||
// restore tab content
|
||||
this.restoreTab(tab, state);
|
||||
|
|
@ -3099,13 +3100,31 @@ var SessionStoreInternal = {
|
|||
let numVisibleTabs = 0;
|
||||
|
||||
for (var t = 0; t < newTabCount; t++) {
|
||||
tabs.push(t < openTabCount ?
|
||||
tabbrowser.tabs[t] :
|
||||
tabbrowser.addTab("about:blank", {
|
||||
skipAnimation: true,
|
||||
forceNotRemote: true,
|
||||
skipBackgroundNotify: true
|
||||
}));
|
||||
// When trying to restore into existing tab, we also take the userContextId
|
||||
// into account if present.
|
||||
let userContextId = winData.tabs[t].userContextId;
|
||||
let reuseExisting = t < openTabCount &&
|
||||
(tabbrowser.tabs[t].getAttribute("usercontextid") == (userContextId || ""));
|
||||
// If the tab is pinned, then we'll be loading it right away, and
|
||||
// there's no need to cause a remoteness flip by loading it initially
|
||||
// non-remote.
|
||||
let forceNotRemote = !winData.tabs[t].pinned;
|
||||
let tab = reuseExisting ? tabbrowser.tabs[t] :
|
||||
tabbrowser.addTab("about:blank",
|
||||
{skipAnimation: true,
|
||||
forceNotRemote,
|
||||
userContextId,
|
||||
skipBackgroundNotify: true});
|
||||
|
||||
// If we inserted a new tab because the userContextId didn't match with the
|
||||
// open tab, even though `t < openTabCount`, we need to remove that open tab
|
||||
// and put the newly added tab in its place.
|
||||
if (!reuseExisting && t < openTabCount) {
|
||||
tabbrowser.removeTab(tabbrowser.tabs[t]);
|
||||
tabbrowser.moveTabTo(tab, t);
|
||||
}
|
||||
|
||||
tabs.push(tab);
|
||||
|
||||
if (winData.tabs[t].pinned)
|
||||
tabbrowser.pinTab(tabs[t]);
|
||||
|
|
@ -3512,6 +3531,9 @@ var SessionStoreInternal = {
|
|||
let uri = activePageData ? activePageData.url || null : null;
|
||||
if (aLoadArguments) {
|
||||
uri = aLoadArguments.uri;
|
||||
if (aLoadArguments.userContextId) {
|
||||
browser.setAttribute("usercontextid", aLoadArguments.userContextId);
|
||||
}
|
||||
}
|
||||
|
||||
// We have to mark this tab as restoring first, otherwise
|
||||
|
|
|
|||
|
|
@ -181,6 +181,10 @@ var TabStateInternal = {
|
|||
if (key === "history") {
|
||||
tabData.entries = value.entries;
|
||||
|
||||
if (value.hasOwnProperty("userContextId")) {
|
||||
tabData.userContextId = value.userContextId;
|
||||
}
|
||||
|
||||
if (value.hasOwnProperty("index")) {
|
||||
tabData.index = value.index;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -638,6 +638,37 @@ e10s.accessibilityNotice.acceptButton.accesskey = O
|
|||
e10s.accessibilityNotice.enableAndRestart.label = Enable (Requires Restart)
|
||||
e10s.accessibilityNotice.enableAndRestart.accesskey = E
|
||||
|
||||
# LOCALIZATION NOTE (userContextPersonal.label,
|
||||
# userContextWork.label,
|
||||
# userContextShopping.label,
|
||||
# userContextBanking.label,
|
||||
# userContextNone.label):
|
||||
# These strings specify the four predefined contexts included in support of the
|
||||
# Contextual Identity / Containers project. Each context is meant to represent
|
||||
# the context that the user is in when interacting with the site. Different
|
||||
# contexts will store cookies and other information from those sites in
|
||||
# different, isolated locations. You can enable the feature by typing
|
||||
# about:config in the URL bar and changing privacy.userContext.enabled to true.
|
||||
# Once enabled, you can open a new tab in a specific context by clicking
|
||||
# File > New Container Tab > (1 of 4 contexts). Once opened, you will see these
|
||||
# strings on the right-hand side of the URL bar.
|
||||
userContextPersonal.label = Personal
|
||||
userContextWork.label = Work
|
||||
userContextBanking.label = Banking
|
||||
userContextShopping.label = Shopping
|
||||
userContextNone.label = No Container
|
||||
|
||||
userContextPersonal.accesskey = P
|
||||
userContextWork.accesskey = W
|
||||
userContextBanking.accesskey = B
|
||||
userContextShopping.accesskey = S
|
||||
userContextNone.accesskey = N
|
||||
|
||||
userContext.aboutPage.label = Manage containers
|
||||
userContext.aboutPage.accesskey = O
|
||||
|
||||
userContextOpenLink.label = Open Link in New %S Tab
|
||||
|
||||
muteTab.label = Mute Tab
|
||||
muteTab.accesskey = M
|
||||
unmuteTab.label = Unmute Tab
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY label.label "Name">
|
||||
<!ENTITY addButton.label "Add New Container">
|
||||
<!ENTITY addButton.accesskey "A">
|
||||
<!-- « is « however it's not defined in XML -->
|
||||
<!ENTITY backLink.label "« Go Back to Privacy">
|
||||
|
||||
<!ENTITY window.title "Add New Container">
|
||||
<!ENTITY window.width "45em">
|
||||
|
||||
<!ENTITY name.label "Name:">
|
||||
<!ENTITY name.accesskey "N">
|
||||
<!ENTITY icon.label "Icon:">
|
||||
<!ENTITY icon.accesskey "I">
|
||||
<!ENTITY color.label "Color:">
|
||||
<!ENTITY color.accesskey "o">
|
||||
<!ENTITY windowClose.key "w">
|
||||
|
||||
<!ENTITY button.ok.label "Done">
|
||||
<!ENTITY button.ok.accesskey "D">
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
containers.removeButton = Remove
|
||||
containers.preferencesButton = Preferences
|
||||
containers.colorHeading = Color:
|
||||
containers.labelMinWidth = 4rem
|
||||
containers.nameLabel = Name:
|
||||
containers.namePlaceholder = Enter a container name
|
||||
containers.submitButton = Done
|
||||
containers.iconHeading = Icon:
|
||||
containers.updateContainerTitle = %S Container Preferences
|
||||
|
||||
containers.blue.label = Blue
|
||||
containers.turquoise.label = Turquoise
|
||||
containers.green.label = Green
|
||||
containers.yellow.label = Yellow
|
||||
containers.orange.label = Orange
|
||||
containers.red.label = Red
|
||||
containers.pink.label = Pink
|
||||
containers.purple.label = Purple
|
||||
|
||||
containers.fingerprint.label = Fingerprint
|
||||
containers.briefcase.label = Briefcase
|
||||
# LOCALIZATION NOTE (containers.dollar.label)
|
||||
# String represents a money sign but currently uses a dollar sign so don't change to local currency
|
||||
# See Bug 1291672
|
||||
containers.dollar.label = Dollar sign
|
||||
containers.cart.label = Shopping cart
|
||||
containers.circle.label = Dot
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
<!ENTITY props.path.label "Path:">
|
||||
<!ENTITY props.secure.label "Send For:">
|
||||
<!ENTITY props.expires.label "Expires:">
|
||||
<!ENTITY props.container.label "Container:">
|
||||
|
||||
<!ENTITY window.title "Cookies">
|
||||
<!ENTITY windowClose.key "w">
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
<!ENTITY paneContent.title "Content">
|
||||
<!ENTITY paneApplications.title "Applications">
|
||||
<!ENTITY panePrivacy.title "Privacy">
|
||||
<!ENTITY paneContainers.title "Container Tabs">
|
||||
<!ENTITY paneSecurity.title "Security">
|
||||
<!ENTITY paneAdvanced.title "Advanced">
|
||||
|
||||
|
|
|
|||
|
|
@ -191,3 +191,17 @@ revertNoRestartButton=Revert
|
|||
|
||||
restartNow=Restart Now
|
||||
restartLater=Restart Later
|
||||
|
||||
disableContainersAlertTitle=Close All Container Tabs?
|
||||
|
||||
# LOCALIZATION NOTE (disableContainersMsg): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #S is the number of container tabs
|
||||
disableContainersMsg=If you disable Container Tabs now, #S container tab will be closed. Are you sure you want to disable Container Tabs?;If you disable Container Tabs now, #S container tabs will be closed. Are you sure you want to disable Container Tabs?
|
||||
|
||||
# LOCALIZATION NOTE (disableContainersOkButton): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #S is the number of container tabs
|
||||
disableContainersOkButton=Close #S Container Tab;Close #S Container Tabs
|
||||
|
||||
disableContainersButton2=Keep enabled
|
||||
|
|
|
|||
|
|
@ -110,3 +110,10 @@
|
|||
|
||||
<!ENTITY clearOnCloseSettings.label "Settings…">
|
||||
<!ENTITY clearOnCloseSettings.accesskey "t">
|
||||
|
||||
<!ENTITY browserContainersHeader.label "Container Tabs">
|
||||
<!ENTITY browserContainersLearnMore.label "Learn more">
|
||||
<!ENTITY browserContainersEnabled.label "Enable Container Tabs">
|
||||
<!ENTITY browserContainersEnabled.accesskey "n">
|
||||
<!ENTITY browserContainersSettings.label "Settings…">
|
||||
<!ENTITY browserContainersSettings.accesskey "i">
|
||||
|
|
|
|||
|
|
@ -79,8 +79,10 @@
|
|||
locale/browser/preferences/permissions.dtd (%chrome/browser/preferences/permissions.dtd)
|
||||
locale/browser/preferences/preferences.dtd (%chrome/browser/preferences/preferences.dtd)
|
||||
locale/browser/preferences/preferences.properties (%chrome/browser/preferences/preferences.properties)
|
||||
locale/browser/preferences/containers.properties (%chrome/browser/preferences/containers.properties)
|
||||
* locale/browser/preferences/privacy.dtd (%chrome/browser/preferences/privacy.dtd)
|
||||
locale/browser/preferences/security.dtd (%chrome/browser/preferences/security.dtd)
|
||||
locale/browser/preferences/containers.dtd (%chrome/browser/preferences/containers.dtd)
|
||||
locale/browser/preferences/sync.dtd (%chrome/browser/preferences/sync.dtd)
|
||||
locale/browser/preferences/tabs.dtd (%chrome/browser/preferences/tabs.dtd)
|
||||
locale/browser/preferences/search.dtd (%chrome/browser/preferences/search.dtd)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,11 @@ var ContentClick = {
|
|||
triggeringPrincipal: json.triggeringPrincipal,
|
||||
};
|
||||
|
||||
// The new tab/window must use the same userContextId.
|
||||
if (json.originAttributes.userContextId) {
|
||||
params.userContextId = json.originAttributes.userContextId;
|
||||
}
|
||||
|
||||
window.openLinkIn(json.href, where, params);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
/* Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
%include ../../../components/contextualidentity/content/usercontext.css
|
||||
|
||||
.container-header-links {
|
||||
margin-block-end: 15px;
|
||||
}
|
||||
|
||||
[data-identity-icon] {
|
||||
margin: 0;
|
||||
margin-inline-end: 16px;
|
||||
}
|
||||
|
||||
#containersView {
|
||||
border: 0 none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
#containersView richlistitem {
|
||||
margin: 0px;
|
||||
margin-inline-end: 8px;
|
||||
padding: 0;
|
||||
padding-block-end: 8px;
|
||||
border-block-end: 1px solid var(--in-content-header-border-color);
|
||||
}
|
||||
|
||||
#containersView richlistitem:last-of-type {
|
||||
border-block-end: 0 none;
|
||||
margin-block-end: 8px;
|
||||
}
|
||||
|
|
@ -237,7 +237,8 @@ treecol {
|
|||
/* Privacy pane */
|
||||
|
||||
#trackingProtectionPBMLearnMore,
|
||||
#trackingProtectionLearnMore {
|
||||
#trackingProtectionLearnMore,
|
||||
#browserContainersLearnMore {
|
||||
margin-inline-start: 1.5em !important;
|
||||
margin-top: 0;
|
||||
font-weight: normal;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@
|
|||
skin/classic/browser/preferences/in-content/favicon.ico (../shared/incontentprefs/favicon.ico)
|
||||
skin/classic/browser/preferences/in-content/icons.svg (../shared/incontentprefs/icons.svg)
|
||||
skin/classic/browser/preferences/in-content/search.css (../shared/incontentprefs/search.css)
|
||||
* skin/classic/browser/preferences/in-content/containers.css (../shared/incontentprefs/containers.css)
|
||||
* skin/classic/browser/preferences/containers.css (../shared/preferences/containers.css)
|
||||
skin/classic/browser/fxa/default-avatar.svg (../shared/fxa/default-avatar.svg)
|
||||
skin/classic/browser/fxa/logo.png (../shared/fxa/logo.png)
|
||||
skin/classic/browser/fxa/logo@2x.png (../shared/fxa/logo@2x.png)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
/* Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
%include ../../../components/contextualidentity/content/usercontext.css
|
||||
|
||||
:root {
|
||||
--preference-selected-color: #0996f8;
|
||||
--preference-unselected-color: #333;
|
||||
--preference-active-color: #858585;
|
||||
}
|
||||
|
||||
radiogroup {
|
||||
display: flex;
|
||||
margin-inline-start: 0.35rem;
|
||||
}
|
||||
|
||||
radio {
|
||||
flex: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
-moz-user-select: none;
|
||||
outline: 2px solid transparent;
|
||||
outline-offset: 4px;
|
||||
-moz-outline-radius: 100%;
|
||||
min-block-size: 24px;
|
||||
min-inline-size: 24px;
|
||||
border-radius: 50%;
|
||||
padding: 2px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.icon-buttons > radio > [data-identity-icon] {
|
||||
fill: #4d4d4d;
|
||||
}
|
||||
|
||||
radio > [data-identity-icon] {
|
||||
inline-size: 22px;
|
||||
block-size: 22px;
|
||||
}
|
||||
|
||||
radio[selected=true] {
|
||||
outline-color: var(--preference-unselected-color);
|
||||
}
|
||||
|
||||
radio[focused=true] {
|
||||
outline-color: var(--preference-selected-color);
|
||||
}
|
||||
|
||||
radio:hover:active {
|
||||
outline-color: var(--preference-active-color);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue