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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 { | 692 { |
693 settings["pref:" + key] = JSON.parse(settings[key]); | 693 settings["pref:" + key] = JSON.parse(settings[key]); |
694 } | 694 } |
695 catch (e) | 695 catch (e) |
696 { | 696 { |
697 } | 697 } |
698 | 698 |
699 delete settings[key]; | 699 delete settings[key]; |
700 } | 700 } |
701 } | 701 } |
| 702 }, |
| 703 |
| 704 // While moving away from the FileSystem API on Chrome the data structure |
| 705 // for files on Safari changed as well, in order to keep thing consistent. |
| 706 migrateFiles: function(callback) |
| 707 { |
| 708 var settings = safari.extension.settings; |
| 709 |
| 710 for (var key in settings) |
| 711 { |
| 712 var match = key.match(/^(.*)\/lastModified$/) |
| 713 |
| 714 if (match) |
| 715 { |
| 716 var filename = match[1]; |
| 717 var content = settings[filename]; |
| 718 |
| 719 if (typeof content == "string") |
| 720 { |
| 721 settings["file:" + filename] = { |
| 722 content: content.split(/[\r\n]+/), |
| 723 lastModified: settings[key] |
| 724 }; |
| 725 |
| 726 delete settings[key]; |
| 727 delete settings[filename]; |
| 728 } |
| 729 } |
| 730 } |
| 731 |
| 732 callback(); |
702 } | 733 } |
703 }; | 734 }; |
704 | 735 |
705 safari.extension.settings.addEventListener("change", function(event) | 736 safari.extension.settings.addEventListener("change", function(event) |
706 { | 737 { |
707 var changes = {}; | 738 var changes = {}; |
708 var change = changes[event.key] = {}; | 739 var change = changes[event.key] = {}; |
709 | 740 |
710 if (event.oldValue != null) | 741 if (event.oldValue != null) |
711 change.oldValue = event.oldValue; | 742 change.oldValue = event.oldValue; |
(...skipping 20 matching lines...) Expand all Loading... |
732 tab.activate(); | 763 tab.activate(); |
733 if (callback) | 764 if (callback) |
734 callback(page); | 765 callback(page); |
735 return; | 766 return; |
736 } | 767 } |
737 } | 768 } |
738 | 769 |
739 ext.pages.open(optionsUrl, callback); | 770 ext.pages.open(optionsUrl, callback); |
740 }; | 771 }; |
741 })(); | 772 })(); |
OLD | NEW |