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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 { | 701 { |
702 settings["pref:" + key] = JSON.parse(settings[key]); | 702 settings["pref:" + key] = JSON.parse(settings[key]); |
703 } | 703 } |
704 catch (e) | 704 catch (e) |
705 { | 705 { |
706 } | 706 } |
707 | 707 |
708 delete settings[key]; | 708 delete settings[key]; |
709 } | 709 } |
710 } | 710 } |
| 711 }, |
| 712 |
| 713 // While moving away from the FileSystem API on Chrome the data structure |
| 714 // for files on Safari changed as well, in order to keep thing consistent. |
| 715 migrateFiles: function(callback) |
| 716 { |
| 717 var settings = safari.extension.settings; |
| 718 |
| 719 for (var key in settings) |
| 720 { |
| 721 var match = key.match(/^(.*)\/lastModified$/) |
| 722 |
| 723 if (match) |
| 724 { |
| 725 var filename = match[1]; |
| 726 var content = settings[filename]; |
| 727 |
| 728 if (typeof content == "string") |
| 729 { |
| 730 settings["file:" + filename] = { |
| 731 content: content.split(/[\r\n]+/), |
| 732 lastModified: settings[key] |
| 733 }; |
| 734 |
| 735 delete settings[key]; |
| 736 delete settings[filename]; |
| 737 } |
| 738 } |
| 739 } |
| 740 |
| 741 callback(); |
711 } | 742 } |
712 }; | 743 }; |
713 | 744 |
714 safari.extension.settings.addEventListener("change", function(event) | 745 safari.extension.settings.addEventListener("change", function(event) |
715 { | 746 { |
716 var changes = {}; | 747 var changes = {}; |
717 var change = changes[event.key] = {}; | 748 var change = changes[event.key] = {}; |
718 | 749 |
719 if (event.oldValue != null) | 750 if (event.oldValue != null) |
720 change.oldValue = event.oldValue; | 751 change.oldValue = event.oldValue; |
(...skipping 20 matching lines...) Expand all Loading... |
741 tab.activate(); | 772 tab.activate(); |
742 if (callback) | 773 if (callback) |
743 callback(page); | 774 callback(page); |
744 return; | 775 return; |
745 } | 776 } |
746 } | 777 } |
747 | 778 |
748 ext.pages.open(optionsUrl, callback); | 779 ext.pages.open(optionsUrl, callback); |
749 }; | 780 }; |
750 })(); | 781 })(); |
OLD | NEW |