LEFT | RIGHT |
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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 chrome.storage.local.set(items, callback); | 511 chrome.storage.local.set(items, callback); |
512 }, | 512 }, |
513 remove: function(key, callback) | 513 remove: function(key, callback) |
514 { | 514 { |
515 chrome.storage.local.remove(key, callback); | 515 chrome.storage.local.remove(key, callback); |
516 }, | 516 }, |
517 onChanged: chrome.storage.onChanged, | 517 onChanged: chrome.storage.onChanged, |
518 | 518 |
519 // Migrate localStorage to chrome.storage.local, | 519 // Migrate localStorage to chrome.storage.local, |
520 // ignoring unkown and inavlid preferences. | 520 // ignoring unkown and inavlid preferences. |
521 migratePrefs: function(mapFunc) | 521 migratePrefs: function(hooks) |
522 { | 522 { |
523 var items = {}; | 523 var items = {}; |
524 | 524 |
525 for (let key in localStorage) | 525 for (let key in localStorage) |
526 { | 526 { |
527 var item = mapFunc(key, localStorage[key]); | 527 var item = hooks.map(key, localStorage[key]); |
528 if (item) | 528 if (item) |
529 items[item.key] = item.value; | 529 items[item.key] = item.value; |
530 } | 530 } |
531 | 531 |
532 chrome.storage.local.set(items, function() { | 532 chrome.storage.local.set(items, function() { |
533 localStorage.clear(); | 533 localStorage.clear(); |
| 534 hooks.done(); |
534 }); | 535 }); |
535 }, | 536 }, |
536 | 537 |
537 // Migrate FileSystem API to chrome.storage.local. For simplicity | 538 // Migrate FileSystem API to chrome.storage.local. For simplicity |
538 // only patterns.ini is considered. Backups are left behind. | 539 // only patterns.ini is considered. Backups are left behind. |
539 migrateFiles: function(callback) | 540 migrateFiles: function(callback) |
540 { | 541 { |
541 if ("webkitRequestFileSystem" in window) | 542 if ("webkitRequestFileSystem" in window) |
542 { | 543 { |
543 webkitRequestFileSystem(PERSISTENT, 0, function(fs) | 544 webkitRequestFileSystem(PERSISTENT, 0, function(fs) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 callback(new Page(tab)); | 613 callback(new Page(tab)); |
613 } | 614 } |
614 else | 615 else |
615 { | 616 { |
616 ext.pages.open(optionsUrl, callback); | 617 ext.pages.open(optionsUrl, callback); |
617 } | 618 } |
618 }); | 619 }); |
619 }); | 620 }); |
620 }; | 621 }; |
621 })(); | 622 })(); |
LEFT | RIGHT |