1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-01 18:10:17 +12:00

Firefox: different kind of vAPI.localStorage

This commit is contained in:
Deathamns 2015-03-16 08:09:34 +01:00 committed by gorhill
parent 10f364c153
commit aff7501596

View file

@ -120,21 +120,34 @@ vAPI.closePopup = function() {
// This storage is optional, but it is nice to have, for a more polished user
// experience.
Object.defineProperty(vAPI, 'localStorage', {
get: function() {
if ( this._localStorage ) {
return this._localStorage;
vAPI.localStorage = {
PB: Services.prefs.getBranch('extensions.' + location.host + '.'),
str: Components.classes['@mozilla.org/supports-string;1']
.createInstance(Components.interfaces.nsISupportsString),
getItem: function(key) {
try {
return this.PB.getComplexValue(
key, Components.interfaces.nsISupportsString
).data;
} catch (ex) {
return null;
}
this._localStorage = Services.domStorageManager.getLocalStorageForPrincipal(
Services.scriptSecurityManager.getCodebasePrincipal(
Services.io.newURI('http://ublock.raymondhill.net/', null, null)
),
''
},
setItem: function(key, value) {
this.str.data = value;
this.PB.setComplexValue(
key,
Components.interfaces.nsISupportsString,
this.str
);
return this._localStorage;
},
removeItem: function(key) {
this.PB.clearUserPref(key);
},
clear: function() {
this.PB.deleteBranch('');
}
});
};
/******************************************************************************/