Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chrome/content/imglikeopera.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,6 @@ var ILO = {
}
};

window.addEventListener("load", function() ILO.onLoad(), false);
window.addEventListener("unload", function() ILO.unLoad(), false);
window.addEventListener("load", function(){ILO.onLoad();}, false);
window.addEventListener("unload", function(){ILO.unLoad();}, false);
window.addEventListener("delayLoadRefresher", ILO, false);
8 changes: 7 additions & 1 deletion chrome/content/preferences/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Filters = {
this.rButtons = document.getElementById("iloPermButtons").childNodes;
this.rPopup = document.getElementById("iloFiltersPopup").childNodes;

let policyPatternsData = (this.settings.policy_patterns || []).split(" ");
let policyPatternsData = (this.settings.policy_patterns || []).toString().split(" ");
for (let i = 0, len = policyPatternsData.length - 1; i < len; i++)
this.treeAddItem(policyPatternsData[i].split(" "));
},
Expand Down Expand Up @@ -449,3 +449,9 @@ const Filters = {
select[0]];
}
};

Object.defineProperty(this, "Filters", {
value: Filters,
enumerable: true,
writable: false
});
10 changes: 8 additions & 2 deletions chrome/content/preferences/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ const Preferences = {
let actualValue = typeof preference.value != "undefined" ? preference.value : preference.defaultValue;
let modesValue = (actualValue || "1,2,3,4")
.split(",")
.map(function(mode) parseInt(mode, 10))
.filter(function(mode) mode >= 1 && mode <= 4)
.map(function(mode) {parseInt(mode, 10)})
.filter(function(mode) {mode >= 1 && mode <= 4})
.sort();

if (!modesValue.length)
Expand Down Expand Up @@ -158,5 +158,11 @@ const Preferences = {
}
};

Object.defineProperty(this, "Preferences", {
value: Preferences,
enumerable: true,
writable: false
});

window.addEventListener("load", Preferences, false);
window.addEventListener("paneload", Preferences, false);
81 changes: 43 additions & 38 deletions components/nsImgLikeOpera.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const nsICacheEntryDescriptor = Ci.nsICacheEntryDescriptor;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

function makeURI(aURL, aOriginCharset, aBaseURI) {
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
return ioService.newURI(aURL, aOriginCharset, aBaseURI);
}


/************************************************************************
*
* Smthng...
Expand All @@ -47,27 +53,27 @@ Cu.import("resource://gre/modules/Services.jsm");
}

CacheListener.prototype = {
onCacheEntryAvailable: function CacheListener_onCacheEntryAvailable(descriptor, accessGranted, status) {
this.descriptor = descriptor;
onCacheEntryCheck: function (entry, appcache) {
return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
},
onCacheEntryAvailable: function (entry, isnew, appcache, status) {
this.descriptor = entry;
this.status = status;
this.done = true;
},

onCacheEntryDoomed: function CacheListener_onCacheEntryDoomed() {},

QueryInterface: function(iid) {
if (iid.equals(Ci.nsICacheListener))
if (iid.equals(Ci.nsISupports) || iid.equals(Ci.nsICacheEntryOpenCallback))
return this;
throw Cr.NS_NOINTERFACE;
}
};

const THREAD_MANAGER = Cc["@mozilla.org/thread-manager;1"].getService();

that.syncGetCacheEntry = function syncGetCacheEntry(aCacheSession, aKey, aAccessMode) {
that.syncGetCacheEntry = function syncGetCacheEntry(aCacheSession, aKey) {
let startTime = Date.now();
let listener = new CacheListener();
aCacheSession.asyncOpenCacheEntry(aKey, aAccessMode, listener, true);
aCacheSession.asyncOpenURI(makeURI(aKey), "", Ci.nsICacheStorage.OPEN_READONLY, listener);

while (!(listener.done || Math.abs(Date.now() - startTime) > 5000)) {
// if (Math.abs(Date.now() - startTime) > 5000)
Expand All @@ -86,15 +92,12 @@ function nsImgLikeOpera() {
this.wrappedJSObject = this;

// cache sessions
const CACHE_SERVICE = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService);
let {LoadContextInfo} = Cu.import(
"resource://gre/modules/LoadContextInfo.jsm", {});
const CACHE_SERVICE = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService);
let httpCacheSession = CACHE_SERVICE.diskCacheStorage(LoadContextInfo.default, false);

let httpCacheSession = CACHE_SERVICE.createSession("HTTP", nsICache.STORE_ANYWHERE, nsICache.STREAM_BASED);
httpCacheSession.doomEntriesIfExpired = false;

let imageCacheSession = CACHE_SERVICE.createSession("image", nsICache.STORE_ANYWHERE, nsICache.NOT_STREAM_BASED);
imageCacheSession.doomEntriesIfExpired = false;

this.cacheSessions = [httpCacheSession, imageCacheSession];
this.cacheSessions = [httpCacheSession];

Services.obs.addObserver(this, "profile-after-change", false);
Services.obs.addObserver(this, "profile-before-change", false);
Expand Down Expand Up @@ -128,7 +131,7 @@ nsImgLikeOpera.prototype = {
"Settings",
"DocumentData",
"FileUtils"
].forEach(function(moduleName) Cu.import("resource://imglikeopera-modules/" + moduleName + ".jsm"));
].forEach(function(moduleName) {Cu.import("resource://imglikeopera-modules/" + moduleName + ".jsm")});

// TODO: loader/unloader
AddonManager.startup();
Expand Down Expand Up @@ -284,8 +287,8 @@ nsImgLikeOpera.prototype = {
if (this._policySwitchModes === null) {
let modesValue = (this.settings.policy_switchModes || "1,2,3,4")
.split(",")
.map(function(mode) parseInt(mode, 10))
.filter(function(mode) mode >= 1 && mode <= 4);
.map(function(mode) {return parseInt(mode, 10);})
.filter(function(mode) {return mode >= 1 && mode <= 4;});

if (!modesValue.length)
modesValue = [1,2,3,4];
Expand Down Expand Up @@ -324,7 +327,7 @@ nsImgLikeOpera.prototype = {
cssFileContent = cssFileContent.replace(/\/\*font\*\//, fontSettings);

const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
let u = Services.io.newURI("data:text/css," + cssFileContent, null, null);
let u = Services.io.newURI("data:text/css," + encodeURIComponent(cssFileContent), null, null);

if (sss.sheetRegistered(u, sss.USER_SHEET))
sss.unregisterSheet(u, sss.USER_SHEET);
Expand Down Expand Up @@ -375,7 +378,7 @@ nsImgLikeOpera.prototype = {
return;

try {
this._sessionStoreService.setTabValue(aTab, "ilo-tab-policy", aPolicy);
this._sessionStoreService.setTabValue(aTab, "ilo-tab-policy", aPolicy.toString());
} catch(e) {}
},

Expand Down Expand Up @@ -420,7 +423,7 @@ nsImgLikeOpera.prototype = {
/**
* Policy (shouldProcess/shouldLoad)
*/
shouldProcess: function ILO_shouldProcess() ACCEPT,
shouldProcess: function ILO_shouldProcess() {return ACCEPT;},

/**
* So... should load?
Expand Down Expand Up @@ -545,7 +548,7 @@ nsImgLikeOpera.prototype = {
if (!wnd)
return;

wnd.setTimeout(function() aNode[aAction].apply(aNode, aActionArguments), 0);
wnd.setTimeout(function() {aNode[aAction].apply(aNode, aActionArguments)}, 0);
},

_getObjectWidthAndHeight: function ILO__getObjectWidthAndHeight(aObject) {
Expand Down Expand Up @@ -621,11 +624,15 @@ nsImgLikeOpera.prototype = {
removeCacheEntry: function ILO_removeCacheEntry(aURL) {
this.cacheSessions.forEach(function(aCacheSession) {
try {
let cacheEntryDescriptor = aCacheSession.openCacheEntry(aURL, nsICacheEntryDescriptor, false);
if (cacheEntryDescriptor) {
cacheEntryDescriptor.doom();
cacheEntryDescriptor.close();
aCacheSession.asyncOpenURI(makeURI(aURL), "", Ci.nsICacheStorage.OPEN_READONLY,
{
onCacheEntryCheck: function (entry, appcache) {
return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
},
onCacheEntryAvailable: function (entry, isnew, appcache, status) {
if (entry) entry.asyncDoom(null);
}
});
} catch(e) {}
});

Expand All @@ -646,31 +653,28 @@ nsImgLikeOpera.prototype = {
if (forcedExpTime > 0) {
for each (let cacheSession in this.cacheSessions) {
try {
cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url, nsICache.ACCESS_READ_WRITE).descriptor;
cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url).descriptor;
} catch(e) {}

if (cacheEntryDescriptor) {
if (cacheEntryDescriptor.lastModified) {
let expirationTime = cacheEntryDescriptor.lastModified + forcedExpTime;

if (expirationTime < timenow) { // || !cacheEntryDescriptor.dataSize(?)) {
cacheEntryDescriptor.doom();
cacheEntryDescriptor.asyncDoom(null);
} else {
expired = false;

if (cacheEntryDescriptor.expirationTime != expirationTime) {
cacheEntryDescriptor.setExpirationTime(expirationTime);
cacheEntryDescriptor.markValid();
}
}
}

cacheEntryDescriptor.close();

if (!expired) {
try {
// Need to call this after setExpirationTime for properly expiration time.
syncGetCacheEntry(cacheSession, url, nsICache.ACCESS_READ);
syncGetCacheEntry(cacheSession, url);
} catch(ex) {
expired = true;
}
Expand All @@ -683,14 +687,13 @@ nsImgLikeOpera.prototype = {
} else if (docpolicy == 3) {
for each (let cacheSession in this.cacheSessions) {
try {
cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url, nsICache.ACCESS_READ).descriptor;
cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url).descriptor;
} catch(e) {}

if (cacheEntryDescriptor) {
if (cacheEntryDescriptor.expirationTime > timenow)
expired = false;

cacheEntryDescriptor.close();

break; // for each
}
Expand Down Expand Up @@ -813,7 +816,9 @@ nsImgLikeOpera.prototype = {

var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsImgLikeOpera]);

this.__defineGetter__("gILO", function gILOGetter() {
delete this.gILO;
return this.gILO = Cc["@mozilla.org/imglikeopera;1"].getService().wrappedJSObject;
Object.defineProperty(this, "gILO", {
get: function gILOGetter() {
delete this.gILO;
return this.gILO = Cc["@mozilla.org/imglikeopera;1"].getService().wrappedJSObject;
}
});
12 changes: 11 additions & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>19.0</em:minVersion>
<em:minVersion>38.0</em:minVersion>
<em:maxVersion>56.*</em:maxVersion>
</Description>
</em:targetApplication>

<!-- PaleMoon -->
<em:targetApplication>
<Description>
<em:id>{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}</em:id>
<em:minVersion>26.0</em:minVersion>
<em:maxVersion>28.*</em:maxVersion>
</Description>
</em:targetApplication>

Expand Down
8 changes: 4 additions & 4 deletions modules/AddonManager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const AddonManager = {
// > 0 - curent > last
addonVersionState: 0,
// Is version changed?
get addonVersionChanged() this.addonVersionState != 0,
get addonVersionChanged() {return this.addonVersionState != 0;},
// ...up?
get addonUpgraded() this.addonVersionState > 0,
get addonUpgraded() {return this.addonVersionState > 0;},
// ...or down?
get addonDowngraded() this.addonVersionState < 0,
get addonDowngraded() {return this.addonVersionState < 0;},
// Previous version.
addonLastVersion: "0",
// true == "fresh" install.
get freshInstall() this.addonLastVersion === "0"
get freshInstall() {return this.addonLastVersion === "0";}
};

this._start();
Expand Down
2 changes: 1 addition & 1 deletion modules/DocumentData.jsm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

let EXPORTED_SYMBOLS = ["DocumentData"];
var EXPORTED_SYMBOLS = ["DocumentData"];

function DocumentData(aTab, aDelay) {
this.clearURLStatus();
Expand Down
2 changes: 1 addition & 1 deletion modules/FileUtils.jsm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

let EXPORTED_SYMBOLS = ["FileUtils"];
var EXPORTED_SYMBOLS = ["FileUtils"];

const {
classes: Cc,
Expand Down
Loading