Index: lib/adblockplus.js |
=================================================================== |
--- a/lib/adblockplus.js |
+++ b/lib/adblockplus.js |
@@ -360,27 +360,44 @@ |
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")); |
- } |
- }); |
+ var entry = localStorage.getItem(key); |
+ if (entry) |
+ { |
+ successCallback(JSON.parse(entry)); |
+ } |
+ else |
+ { |
+ // Also check the chrome.storage.local |
+ // We may have a init data there |
+ ext.storage.get([key], function(items) |
+ { |
+ var entry = items[key]; |
+ if (entry) |
+ successCallback(entry); |
+ 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({ |
+ content: data, |
+ lastModified: Date.now() |
+ })); |
+ } |
+ catch(error) |
+ { |
+ // QuotaExceededError can happen. Notify the user and ignore |
+ var errorMessage = "Subscription storage is full. " + |
+ "Please remove some subscriptions and try again."; |
+ alert(errorMessage); |
+ callback(new Error(errorMessage)); |
+ return; |
+ } |
+ callback(); |
} |
exports.IO = { |
resolveFilePath: function(path) |