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

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

Issue 5768064935133184: Issue 2021 - Replaced FileSystem API with chrome.storage.local (Closed)
Patch Set: Rebased Created April 10, 2015, 6:54 a.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 | « metadata.safari ('k') | no next file » | 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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 var item = hooks.map(key, settings[key]); 735 var item = hooks.map(key, settings[key]);
736 736
737 if (item) 737 if (item)
738 { 738 {
739 delete settings[key]; 739 delete settings[key];
740 settings[item.key] = item.value; 740 settings[item.key] = item.value;
741 } 741 }
742 } 742 }
743 743
744 hooks.done(); 744 hooks.done();
745 },
746
747 // While moving away from the FileSystem API on Chrome the data structure
748 // for files on Safari changed as well, in order to keep thing consistent.
749 migrateFiles: function(callback)
750 {
751 var settings = safari.extension.settings;
752
753 for (var key in settings)
754 {
755 var match = key.match(/^(.*)\/lastModified$/)
756
757 if (match)
758 {
759 var filename = match[1];
760 var content = settings[filename];
761
762 if (typeof content == "string")
763 {
764 settings["file:" + filename] = {
765 content: content.split(/[\r\n]+/),
766 lastModified: settings[key]
767 };
768
769 delete settings[key];
770 delete settings[filename];
771 }
772 }
773 }
774
775 callback();
745 } 776 }
746 }; 777 };
747 778
748 safari.extension.settings.addEventListener("change", function(event) 779 safari.extension.settings.addEventListener("change", function(event)
749 { 780 {
750 var changes = {}; 781 var changes = {};
751 var change = changes[event.key] = {}; 782 var change = changes[event.key] = {};
752 783
753 if (event.oldValue != null) 784 if (event.oldValue != null)
754 change.oldValue = event.oldValue; 785 change.oldValue = event.oldValue;
(...skipping 20 matching lines...) Expand all
775 tab.activate(); 806 tab.activate();
776 if (callback) 807 if (callback)
777 callback(page); 808 callback(page);
778 return; 809 return;
779 } 810 }
780 } 811 }
781 812
782 ext.pages.open(optionsUrl, callback); 813 ext.pages.open(optionsUrl, callback);
783 }; 814 };
784 })(); 815 })();
OLDNEW
« no previous file with comments | « metadata.safari ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld