Bug 1191455 - Add URL bar decoration signifying which user context the tab is in. r=paolo

This commit is contained in:
Steven Englehardt 2015-09-04 17:11:00 +02:00
Родитель 8a514ecd12
Коммит 8d3a102b33
5 изменённых файлов: 115 добавлений и 0 удалений

Просмотреть файл

@ -84,6 +84,10 @@ function pktUIGetter(prop) {
Object.defineProperty(window, "pktUI", pktUIGetter("pktUI"));
Object.defineProperty(window, "pktUIMessaging", pktUIGetter("pktUIMessaging"));
XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() {
return Services.strings.createBundle('chrome://browser/locale/browser.properties');
});
const nsIWebNavigation = Ci.nsIWebNavigation;
var gLastBrowserCharset = null;
@ -4033,6 +4037,41 @@ function updateUserContextUIVisibility()
document.getElementById("menu_newUserContext").hidden = !userContextEnabled;
}
/**
* Updates the User Context UI indicators if the browser is in a non-default context
*/
function updateUserContextUIIndicator(browser)
{
let hbox = document.getElementById("userContext-icons");
if (!browser.hasAttribute("usercontextid")) {
hbox.removeAttribute("usercontextid");
return;
}
let label = document.getElementById("userContext-label");
let userContextId = browser.getAttribute("usercontextid");
hbox.setAttribute("usercontextid", userContextId);
switch (userContextId) {
case "1":
label.value = gBrowserBundle.GetStringFromName("usercontext.personal.label");
break;
case "2":
label.value = gBrowserBundle.GetStringFromName("usercontext.work.label");
break;
case "3":
label.value = gBrowserBundle.GetStringFromName("usercontext.banking.label");
break;
case "4":
label.value = gBrowserBundle.GetStringFromName("usercontext.shopping.label");
break;
// Display the context IDs for values outside the pre-defined range.
// Used for debugging, no localization necessary.
default:
label.value = "Context " + userContextId;
}
}
/**
* Makes the Character Encoding menu enabled or disabled as appropriate.
* To be called when the View menu or the app menu is opened.

Просмотреть файл

@ -768,6 +768,10 @@
hidden="true"
onclick="ReaderParent.buttonClick(event);"/>
</hbox>
<hbox id="userContext-icons">
<label id="userContext-label"/>
<image id="userContext-indicator"/>
</hbox>
<toolbarbutton id="urlbar-go-button"
class="chromeclass-toolbar-additional"
onclick="gURLBar.handleCommand(event);"

Просмотреть файл

@ -1236,6 +1236,8 @@
this._adjustFocusAfterTabSwitch(this.mCurrentTab);
}
updateUserContextUIIndicator(gBrowser.selectedBrowser);
this.tabContainer._setPositionalAttributes();
if (!gMultiProcessBrowser) {

Просмотреть файл

@ -776,6 +776,24 @@ e10s.accessibilityNotice.disableAndRestart.accesskey = R
e10s.accessibilityNotice.dontDisable.label = Don't Disable
e10s.accessibilityNotice.dontDisable.accesskey = D
# LOCALIZATION NOTE (usercontext.personal.label,
# usercontext.work.label,
# usercontext.shopping.label,
# usercontext.banking.label):
# These strings specify the four default 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.
usercontext.personal.label = Personal
usercontext.work.label = Work
usercontext.shopping.label = Shopping
usercontext.banking.label = Banking
muteTab.label = Mute Tab
muteTab.accesskey = M
unmuteTab.label = Unmute Tab

Просмотреть файл

@ -15,3 +15,55 @@
#menu_newUserContextTabShopping {
list-style-image: url("chrome://browser/skin/usercontext/shopping.svg");
}
/* URL Bar Decoration */
#userContext-indicator {
height: 16px;
width: 16px;
}
#userContext-label {
margin-inline-end: 3px;
color: #909090;
}
#userContext-icons:not([usercontextid]) {
display: none;
}
#userContext-icons {
-moz-box-align: center;
}
/* Personal User Context */
#userContext-icons[usercontextid="1"] > #userContext-label {
color: #00a7e0;
}
#userContext-icons[usercontextid="1"] > #userContext-indicator {
list-style-image: url("chrome://browser/skin/usercontext/personal.svg");
}
/* Work User Context */
#userContext-icons[usercontextid="2"] > #userContext-label {
color: #f89c24;
}
#userContext-icons[usercontextid="2"] > #userContext-indicator {
list-style-image: url("chrome://browser/skin/usercontext/work.svg");
}
/* Banking User Context */
#userContext-icons[usercontextid="3"] > #userContext-label {
color: #7dc14c;
}
#userContext-icons[usercontextid="3"] > #userContext-indicator {
list-style-image: url("chrome://browser/skin/usercontext/banking.svg");
}
/* Shopping User Context */
#userContext-icons[usercontextid="4"] > #userContext-label {
color: #ee5195;
}
#userContext-icons[usercontextid="4"] > #userContext-indicator {
list-style-image: url("chrome://browser/skin/usercontext/shopping.svg");
}