Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/ext/background.js

Issue 5768064935133184: Issue 2021 - Replaced FileSystem API with chrome.storage.local (Closed)
Patch Set: Rebased Created March 20, 2015, 1:24 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/filesystem/io.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/background.js
===================================================================
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -533,6 +533,55 @@
localStorage.clear();
hooks.done();
});
+ },
+
+ // Migrate FileSystem API to chrome.storage.local. For simplicity
+ // only patterns.ini is considered. Backups are left behind.
+ migrateFiles: function(callback)
+ {
+ if ("webkitRequestFileSystem" in window)
+ {
+ webkitRequestFileSystem(PERSISTENT, 0, function(fs)
+ {
+ fs.root.getFile("patterns.ini", {}, function(entry)
+ {
+ entry.getMetadata(function(metadata)
+ {
+ entry.file(function(file)
+ {
+ var reader = new FileReader();
+ reader.onloadend = function()
+ {
+ if (!reader.error)
+ {
+ chrome.storage.local.set(
+ {
+ "file:patterns.ini": {
+ content: reader.result.split(/[\r\n]+/),
+ lastModified: metadata.modificationTime.getTime()
+ }
+ },
+ function()
+ {
+ fs.root.removeRecursively(callback, callback);
+ }
+ );
+ }
+ else
+ {
+ callback();
+ }
+ };
+ reader.readAsText(file);
+ }, callback);
+ }, callback);
+ }, callback);
+ }, callback);
+ }
+ else
+ {
+ callback();
+ }
}
};
« no previous file with comments | « no previous file | lib/filesystem/io.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld