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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 } | 538 } |
539 else if (key == "currentVersion") | 539 else if (key == "currentVersion") |
540 { | 540 { |
541 items[key] = value; | 541 items[key] = value; |
542 } | 542 } |
543 } | 543 } |
544 | 544 |
545 chrome.storage.local.set(items, function() { | 545 chrome.storage.local.set(items, function() { |
546 localStorage.clear(); | 546 localStorage.clear(); |
547 }); | 547 }); |
| 548 }, |
| 549 |
| 550 // Migrate FileSystem API to chrome.storage.local. For simplicity |
| 551 // only patterns.ini is considered. Backups are left behind. |
| 552 migrateFiles: function(callback) |
| 553 { |
| 554 if ("webkitRequestFileSystem" in window) |
| 555 { |
| 556 webkitRequestFileSystem(PERSISTENT, 0, function(fs) |
| 557 { |
| 558 fs.root.getFile("patterns.ini", {}, function(entry) |
| 559 { |
| 560 entry.getMetadata(function(metadata) |
| 561 { |
| 562 entry.file(function(file) |
| 563 { |
| 564 var reader = new FileReader(); |
| 565 reader.onloadend = function() |
| 566 { |
| 567 if (!reader.error) |
| 568 { |
| 569 chrome.storage.local.set( |
| 570 { |
| 571 "file:patterns.ini": { |
| 572 content: reader.result.split(/[\r\n]+/), |
| 573 lastModified: metadata.modificationTime.getTime() |
| 574 } |
| 575 }, |
| 576 function() |
| 577 { |
| 578 fs.root.removeRecursively(callback, callback); |
| 579 } |
| 580 ); |
| 581 } |
| 582 else |
| 583 { |
| 584 callback(); |
| 585 } |
| 586 }; |
| 587 reader.readAsText(file); |
| 588 }, callback); |
| 589 }, callback); |
| 590 }, callback); |
| 591 }, callback); |
| 592 } |
| 593 else |
| 594 { |
| 595 callback(); |
| 596 } |
548 } | 597 } |
549 }; | 598 }; |
550 | 599 |
551 /* Options */ | 600 /* Options */ |
552 | 601 |
553 ext.showOptions = function(callback) | 602 ext.showOptions = function(callback) |
554 { | 603 { |
555 chrome.windows.getLastFocused(function(win) | 604 chrome.windows.getLastFocused(function(win) |
556 { | 605 { |
557 var optionsUrl = chrome.extension.getURL("options.html"); | 606 var optionsUrl = chrome.extension.getURL("options.html"); |
(...skipping 18 matching lines...) Expand all Loading... |
576 callback(new Page(tab)); | 625 callback(new Page(tab)); |
577 } | 626 } |
578 else | 627 else |
579 { | 628 { |
580 ext.pages.open(optionsUrl, callback); | 629 ext.pages.open(optionsUrl, callback); |
581 } | 630 } |
582 }); | 631 }); |
583 }); | 632 }); |
584 }; | 633 }; |
585 })(); | 634 })(); |
OLD | NEW |