mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1173523 - Part 6: Update translation to use new API for nsIPermission, r=florian
This commit is contained in:
parent
792acf7107
commit
d45471bc71
@ -9,6 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gLangBundle", () =>
|
||||
Services.strings.createBundle("chrome://global/locale/languageNames.properties"));
|
||||
@ -83,7 +84,7 @@ let gTranslationExceptions = {
|
||||
|
||||
if (perm.type == kPermissionType &&
|
||||
perm.capability == Services.perms.DENY_ACTION) {
|
||||
this._sites.push(perm.host);
|
||||
this._sites.push(perm.principal.origin);
|
||||
}
|
||||
}
|
||||
Services.obs.addObserver(this, "perm-changed", false);
|
||||
@ -126,14 +127,14 @@ let gTranslationExceptions = {
|
||||
if (aData == "added") {
|
||||
if (perm.capability != Services.perms.DENY_ACTION)
|
||||
return;
|
||||
this._sites.push(perm.host);
|
||||
this._sites.push(perm.principal.origin);
|
||||
this._sites.sort();
|
||||
let boxObject = this._siteTree.boxObject;
|
||||
boxObject.rowCountChanged(0, 1);
|
||||
boxObject.invalidate();
|
||||
}
|
||||
else if (aData == "deleted") {
|
||||
let index = this._sites.indexOf(perm.host);
|
||||
let index = this._sites.indexOf(perm.principal.origin);
|
||||
if (index == -1)
|
||||
return;
|
||||
this._sites.splice(index, 1);
|
||||
@ -188,9 +189,9 @@ let gTranslationExceptions = {
|
||||
|
||||
onSiteDeleted: function() {
|
||||
let removedSites = this._siteTree.getSelectedItems();
|
||||
for (let host of removedSites) {
|
||||
let uri = Services.io.newURI("http://" + host, null, null);
|
||||
Services.perms.remove(uri, kPermissionType);
|
||||
for (let origin of removedSites) {
|
||||
let principal = BrowserUtils.principalFromOrigin(origin);
|
||||
Services.perms.removeFromPrincipal(principal, kPermissionType);
|
||||
}
|
||||
},
|
||||
|
||||
@ -201,9 +202,9 @@ let gTranslationExceptions = {
|
||||
let removedSites = this._sites.splice(0, this._sites.length);
|
||||
this._siteTree.boxObject.rowCountChanged(0, -removedSites.length);
|
||||
|
||||
for (let host of removedSites) {
|
||||
let uri = Services.io.newURI("http://" + host, null, null);
|
||||
Services.perms.remove(uri, kPermissionType);
|
||||
for (let origin of removedSites) {
|
||||
let principal = BrowserUtils.principalFromOrigin(origin);
|
||||
Services.perms.removeFromPrincipal(principal, kPermissionType);
|
||||
}
|
||||
|
||||
this.onSiteSelected();
|
||||
|
@ -51,7 +51,7 @@ function getDomainExceptions() {
|
||||
|
||||
if (perm.type == "translate" &&
|
||||
perm.capability == Services.perms.DENY_ACTION)
|
||||
results.push(perm.host);
|
||||
results.push(perm.principal);
|
||||
}
|
||||
|
||||
return results;
|
||||
@ -181,7 +181,7 @@ let gTests = [
|
||||
// Check this has been saved to the exceptions list.
|
||||
let sites = getDomainExceptions();
|
||||
is(sites.length, 1, "one site in the exception list");
|
||||
is(sites[0], "example.com", "correct site in the exception list");
|
||||
is(sites[0].origin, "http://example.com", "correct site in the exception list");
|
||||
ok(!ui.shouldShowInfoBar(uri, "fr"),
|
||||
"the infobar wouldn't be shown anymore");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user