| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 { | 526 { |
| 527 var item = hooks.map(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 hooks.done(); |
| 535 }); | 535 }); |
| 536 }, |
| 537 |
| 538 // Migrate FileSystem API to chrome.storage.local. For simplicity |
| 539 // only patterns.ini is considered. Backups are left behind. |
| 540 migrateFiles: function(callback) |
| 541 { |
| 542 if ("webkitRequestFileSystem" in window) |
| 543 { |
| 544 webkitRequestFileSystem(PERSISTENT, 0, function(fs) |
| 545 { |
| 546 fs.root.getFile("patterns.ini", {}, function(entry) |
| 547 { |
| 548 entry.getMetadata(function(metadata) |
| 549 { |
| 550 entry.file(function(file) |
| 551 { |
| 552 var reader = new FileReader(); |
| 553 reader.onloadend = function() |
| 554 { |
| 555 if (!reader.error) |
| 556 { |
| 557 chrome.storage.local.set( |
| 558 { |
| 559 "file:patterns.ini": { |
| 560 content: reader.result.split(/[\r\n]+/), |
| 561 lastModified: metadata.modificationTime.getTime() |
| 562 } |
| 563 }, |
| 564 function() |
| 565 { |
| 566 fs.root.removeRecursively(callback, callback); |
| 567 } |
| 568 ); |
| 569 } |
| 570 else |
| 571 { |
| 572 callback(); |
| 573 } |
| 574 }; |
| 575 reader.readAsText(file); |
| 576 }, callback); |
| 577 }, callback); |
| 578 }, callback); |
| 579 }, callback); |
| 580 } |
| 581 else |
| 582 { |
| 583 callback(); |
| 584 } |
| 536 } | 585 } |
| 537 }; | 586 }; |
| 538 | 587 |
| 539 /* Options */ | 588 /* Options */ |
| 540 | 589 |
| 541 ext.showOptions = function(callback) | 590 ext.showOptions = function(callback) |
| 542 { | 591 { |
| 543 chrome.windows.getLastFocused(function(win) | 592 chrome.windows.getLastFocused(function(win) |
| 544 { | 593 { |
| 545 var optionsUrl = chrome.extension.getURL("options.html"); | 594 var optionsUrl = chrome.extension.getURL("options.html"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 564 callback(new Page(tab)); | 613 callback(new Page(tab)); |
| 565 } | 614 } |
| 566 else | 615 else |
| 567 { | 616 { |
| 568 ext.pages.open(optionsUrl, callback); | 617 ext.pages.open(optionsUrl, callback); |
| 569 } | 618 } |
| 570 }); | 619 }); |
| 571 }); | 620 }); |
| 572 }; | 621 }; |
| 573 })(); | 622 })(); |
| OLD | NEW |