Index: lib/adblockplus.js |
=================================================================== |
--- a/lib/adblockplus.js |
+++ b/lib/adblockplus.js |
@@ -360,27 +360,28 @@ |
function loadFile(file, successCallback, errorCallback) |
{ |
var key = fileToKey(file); |
- ext.storage.get([key], function(items) |
- { |
- var entry = items[key]; |
- if (entry) |
- { |
- successCallback(entry); |
- } |
- else |
- { |
- errorCallback(new Error("File doesn't exist")); |
- } |
- }); |
+ dataInJson = localStorage.getItem(key); |
+ if (dataInJson != null) |
kzar
2016/07/27 08:44:21
Perhaps just check if dataInJson is truthy like th
|
+ successCallback(JSON.parse(dataInJson)); |
+ else |
+ errorCallback(new Error("File doesn't exist")); |
} |
function saveFile(file, data, callback) |
{ |
- ext.storage.set(fileToKey(file), |
- { |
- content: data, |
- lastModified: Date.now() |
- }, callback); |
+ try |
+ { |
+ localStorage.setItem(fileToKey(file), JSON.stringify({ |
kzar
2016/07/27 08:44:21
Nit: The indentation here looks kind of weird. How
|
+ content: data, |
+ lastModified: Date.now() |
+ } |
+ )); |
+ } |
+ catch(error) |
+ { |
+ // QuotaExceededError can happen. Ignore silently |
kzar
2016/07/27 08:44:21
Maybe we should display an alert that asks the use
|
+ } |
+ callback(); |
} |
exports.IO = { |
resolveFilePath: function(path) |