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

Side by Side Diff: chrome/ext/background.js

Issue 5768064935133184: Issue 2021 - Replaced FileSystem API with chrome.storage.local (Closed)
Patch Set: Created Feb. 26, 2015, 12:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/filesystem/io.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 } 517 }
518 else if (key == "currentVersion") 518 else if (key == "currentVersion")
519 { 519 {
520 items[key] = value; 520 items[key] = value;
521 } 521 }
522 } 522 }
523 523
524 chrome.storage.local.set(items, function() { 524 chrome.storage.local.set(items, function() {
525 localStorage.clear(); 525 localStorage.clear();
526 }); 526 });
527 },
528
529 // Migrate FileSystem API to chrome.storage.local. For simplicity
530 // only patterns.ini is considered. Backups are left behind.
531 migrateFiles: function(callback)
532 {
533 if ("webkitRequestFileSystem" in window)
534 {
535 webkitRequestFileSystem(PERSISTENT, 0, function(fs)
536 {
537 fs.root.getFile("patterns.ini", {}, function(entry)
538 {
539 entry.getMetadata(function(metadata)
540 {
541 entry.file(function(file)
542 {
543 var reader = new FileReader();
544 reader.onloadend = function()
545 {
546 if (!reader.error)
547 {
548 chrome.storage.local.set(
549 {
550 "file:patterns.ini": {
551 content: reader.result.split(/[\r\n]+/),
552 lastModified: metadata.modificationTime.getTime()
553 }
554 },
555 function()
556 {
557 fs.root.removeRecursively(callback, callback);
558 }
559 );
560 }
561 else
562 {
563 callback();
564 }
565 };
566 reader.readAsText(file);
567 }, callback);
568 }, callback);
569 }, callback);
570 }, callback);
571 }
572 else
573 {
574 callback();
575 }
527 } 576 }
528 }; 577 };
529 578
530 /* Options */ 579 /* Options */
531 580
532 ext.showOptions = function(callback) 581 ext.showOptions = function(callback)
533 { 582 {
534 chrome.windows.getLastFocused(function(win) 583 chrome.windows.getLastFocused(function(win)
535 { 584 {
536 var optionsUrl = chrome.extension.getURL("options.html"); 585 var optionsUrl = chrome.extension.getURL("options.html");
(...skipping 24 matching lines...) Expand all
561 callback(new Page(tab)); 610 callback(new Page(tab));
562 } 611 }
563 else 612 else
564 { 613 {
565 ext.pages.open(optionsUrl, callback); 614 ext.pages.open(optionsUrl, callback);
566 } 615 }
567 }); 616 });
568 }); 617 });
569 }; 618 };
570 })(); 619 })();
OLDNEW
« 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