Merge branch 'master' into edit-ui-55
This commit is contained in:
commit
297dccb4e8
1 changed files with 63 additions and 4 deletions
67
index.js
67
index.js
|
@ -43,7 +43,10 @@ let ContainerService = {
|
||||||
"openTab",
|
"openTab",
|
||||||
"moveTabsToWindow",
|
"moveTabsToWindow",
|
||||||
"queryIdentities",
|
"queryIdentities",
|
||||||
"getIdentity"
|
"getIdentity",
|
||||||
|
"createIdentity",
|
||||||
|
"removeIdentity",
|
||||||
|
"updateIdentity",
|
||||||
];
|
];
|
||||||
|
|
||||||
// Map of identities.
|
// Map of identities.
|
||||||
|
@ -164,10 +167,14 @@ let ContainerService = {
|
||||||
// Tabs management
|
// Tabs management
|
||||||
|
|
||||||
hideTabs(args) {
|
hideTabs(args) {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!("userContextId" in args)) {
|
||||||
|
reject("hideTabs must be called with userContextId argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const tab of tabs) {
|
for (const tab of tabs) {
|
||||||
const userContextId = this._getUserContextIdFromTab(tab);
|
if (args.userContextId !== this._getUserContextIdFromTab(tab)) {
|
||||||
if ("userContextId" in args && args.userContextId !== userContextId) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +187,11 @@ let ContainerService = {
|
||||||
},
|
},
|
||||||
|
|
||||||
showTabs(args) {
|
showTabs(args) {
|
||||||
|
if (!("userContextId" in args)) {
|
||||||
|
Promise.reject("showTabs must be called with userContextId argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let promises = [];
|
let promises = [];
|
||||||
|
|
||||||
for (let url of this._identitiesState[args.userContextId].hiddenTabUrls) {
|
for (let url of this._identitiesState[args.userContextId].hiddenTabUrls) {
|
||||||
|
@ -367,10 +379,57 @@ let ContainerService = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getIdentity(args) {
|
getIdentity(args) {
|
||||||
|
if (!("userContextId" in args)) {
|
||||||
|
Promise.reject("getIdentity must be called with userContextId argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let identity = ContextualIdentityService.getIdentityFromId(args.userContextId);
|
let identity = ContextualIdentityService.getIdentityFromId(args.userContextId);
|
||||||
return Promise.resolve(identity ? this._convert(identity) : null);
|
return Promise.resolve(identity ? this._convert(identity) : null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createIdentity(args) {
|
||||||
|
for (const arg of [ "name", "color", "icon"]) {
|
||||||
|
if (!(arg in args)) {
|
||||||
|
Promise.reject("createIdentity must be called with " + arg + " argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: icon and color conversion based on FF version.
|
||||||
|
const identity = ContextualIdentityService.create(args.name, args.icon, args.color);
|
||||||
|
return Promise.resolve(this._convert(identity));
|
||||||
|
},
|
||||||
|
|
||||||
|
updateIdentity(args) {
|
||||||
|
if (!("userContextId" in args)) {
|
||||||
|
Promise.reject("updateIdentity must be called with userContextId argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let identity = ContextualIdentityService.getIdentityFromId(args.userContextId);
|
||||||
|
for (const arg of [ "name", "color", "icon"]) {
|
||||||
|
if ((arg in args)) {
|
||||||
|
identity[arg] = args[arg];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: icon and color conversion based on FF version.
|
||||||
|
// FIXME: color/name update propagation
|
||||||
|
return Promise.resolve(ContextualIdentityService.update(args.userContextId,
|
||||||
|
identity.name,
|
||||||
|
identity.icon,
|
||||||
|
identity.color));
|
||||||
|
},
|
||||||
|
|
||||||
|
removeIdentity(args) {
|
||||||
|
if (!("userContextId" in args)) {
|
||||||
|
Promise.reject("removeIdentity must be called with userContextId argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return Promise.resolve(ContextualIdentityService.remove(args.userContextId));
|
||||||
|
},
|
||||||
|
|
||||||
// Styling the window
|
// Styling the window
|
||||||
|
|
||||||
configureWindow(window) {
|
configureWindow(window) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue