Bug 1280485 - Don't sort permission list to improve tab load performance. r=Gijs
MozReview-Commit-ID: CIOY5G1v44u
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -28,17 +28,17 @@ this.SitePermissions = {
* - label: the translated label of that state
*/
getPermissionsByURI: function (aURI) {
if (!this.isSupportedURI(aURI)) {
return [];
}
let permissions = [];
- for (let permission of this.listPermissions()) {
+ for (let permission of kPermissionIDs) {
let state = this.get(aURI, permission);
if (state === this.UNKNOWN) {
continue;
}
let availableStates = this.getAvailableStates(permission).map( state => {
return { id: state, label: this.getStateLabel(permission, state) };
});
@@ -59,17 +59,17 @@ this.SitePermissions = {
* (meaning allowed or session-allowed) permissions for the given URI.
* Will return false for invalid URIs (such as file:// URLs).
*/
hasGrantedPermissions: function (aURI) {
if (!this.isSupportedURI(aURI)) {
return false;
}
- for (let permission of this.listPermissions()) {
+ for (let permission of kPermissionIDs) {
let state = this.get(aURI, permission);
if (state === this.ALLOW || state === this.SESSION) {
return true;
}
}
return false;
},
@@ -79,21 +79,17 @@ this.SitePermissions = {
*/
isSupportedURI: function (aURI) {
return aURI.schemeIs("http") || aURI.schemeIs("https");
},
/* Returns an array of all permission IDs.
*/
listPermissions: function () {
- let array = Object.keys(gPermissionObject);
- array.sort((a, b) => {
- return this.getPermissionLabel(a).localeCompare(this.getPermissionLabel(b));
- });
- return array;
+ return kPermissionIDs;
},
/* Returns an array of permission states to be exposed to the user for a
* permission with the given ID.
*/
getAvailableStates: function (aPermissionID) {
if (aPermissionID in gPermissionObject &&
gPermissionObject[aPermissionID].states)
@@ -250,8 +246,11 @@ var gPermissionObject = {
},
"indexedDB": {},
"pointerLock": {
exactHostMatch: true
}
};
+
+const kPermissionIDs = Object.keys(gPermissionObject);
+