OLD | NEW |
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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 var item = hooks.map(key, settings[key]); | 712 var item = hooks.map(key, settings[key]); |
713 | 713 |
714 if (item) | 714 if (item) |
715 { | 715 { |
716 delete settings[key]; | 716 delete settings[key]; |
717 settings[item.key] = item.value; | 717 settings[item.key] = item.value; |
718 } | 718 } |
719 } | 719 } |
720 | 720 |
721 hooks.done(); | 721 hooks.done(); |
| 722 }, |
| 723 |
| 724 // While moving away from the FileSystem API on Chrome the data structure |
| 725 // for files on Safari changed as well, in order to keep thing consistent. |
| 726 migrateFiles: function(callback) |
| 727 { |
| 728 var settings = safari.extension.settings; |
| 729 |
| 730 for (var key in settings) |
| 731 { |
| 732 var match = key.match(/^(.*)\/lastModified$/) |
| 733 |
| 734 if (match) |
| 735 { |
| 736 var filename = match[1]; |
| 737 var content = settings[filename]; |
| 738 |
| 739 if (typeof content == "string") |
| 740 { |
| 741 settings["file:" + filename] = { |
| 742 content: content.split(/[\r\n]+/), |
| 743 lastModified: settings[key] |
| 744 }; |
| 745 |
| 746 delete settings[key]; |
| 747 delete settings[filename]; |
| 748 } |
| 749 } |
| 750 } |
| 751 |
| 752 callback(); |
722 } | 753 } |
723 }; | 754 }; |
724 | 755 |
725 safari.extension.settings.addEventListener("change", function(event) | 756 safari.extension.settings.addEventListener("change", function(event) |
726 { | 757 { |
727 var changes = {}; | 758 var changes = {}; |
728 var change = changes[event.key] = {}; | 759 var change = changes[event.key] = {}; |
729 | 760 |
730 if (event.oldValue != null) | 761 if (event.oldValue != null) |
731 change.oldValue = event.oldValue; | 762 change.oldValue = event.oldValue; |
(...skipping 20 matching lines...) Expand all Loading... |
752 tab.activate(); | 783 tab.activate(); |
753 if (callback) | 784 if (callback) |
754 callback(page); | 785 callback(page); |
755 return; | 786 return; |
756 } | 787 } |
757 } | 788 } |
758 | 789 |
759 ext.pages.open(optionsUrl, callback); | 790 ext.pages.open(optionsUrl, callback); |
760 }; | 791 }; |
761 })(); | 792 })(); |
OLD | NEW |