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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 { | 378 { |
379 resolve(entry); | 379 resolve(entry); |
380 } | 380 } |
381 else | 381 else |
382 { | 382 { |
383 reject(new Error("File doesn't exist")); | 383 reject(new Error("File doesn't exist")); |
384 } | 384 } |
385 }); | 385 }); |
386 }.bind(this)); | 386 }.bind(this)); |
387 } | 387 } |
388 | |
389 function saveFile(file, data, callback) | 388 function saveFile(file, data, callback) |
390 { | 389 { |
391 var entry = {}; | 390 var entry = {}; |
392 var key = fileToKey(file); | 391 var key = fileToKey(file); |
393 | 392 |
394 if (typeof browser == "undefined") | 393 if (typeof browser == "undefined") |
395 { | 394 { |
396 entry[key] = { | 395 entry[key] = { |
397 lastModified: Date.now(), | 396 lastModified: Date.now(), |
398 content: data | 397 content: data |
399 }; | 398 }; |
400 ext.storage.set(entry, callback); | 399 ext.storage.set(entry, callback); |
401 } | 400 } |
402 else | 401 else |
403 { | 402 { |
404 var processedData = LZString.compressToUTF16(JSON.stringify(data)); | 403 var processedData = LZString.compressToUTF16(JSON.stringify(data)); |
405 ext.storage.remove(key); | 404 ext.storage.remove(key); |
406 entry[key] = { | 405 entry[key] = { |
407 lastModified: Date.now(), | 406 lastModified: Date.now(), |
408 content: processedData, | 407 content: processedData, |
409 compressed: true | 408 compressed: true |
410 }; | 409 }; |
411 window.localStorage.setItem(key, JSON.stringify(entry[key])); | 410 window.localStorage.setItem(key, JSON.stringify(entry[key])); |
412 setTimeout(callback, 0); | 411 setTimeout(callback, 0); |
413 } | 412 } |
| 413 callback(); |
414 } | 414 } |
415 exports.IO = { | 415 exports.IO = { |
416 resolveFilePath: function(path) | 416 resolveFilePath: function(path) |
417 { | 417 { |
418 return new FakeFile(path); | 418 return new FakeFile(path); |
419 }, | 419 }, |
420 readFromFile: function(file, listener, callback) | 420 readFromFile: function(file, listener, callback) |
421 { | 421 { |
422 function onLoaded(entry) | 422 function onLoaded(entry) |
423 { | 423 { |
424 if ("content" in entry) | 424 if ("content" in entry) |
425 { | 425 { |
426 if ("compressed" in entry) | 426 if (entry["compressed"]) |
427 { | 427 { |
428 entry.content = JSON.parse(LZString.decompressFromUTF16(entry.conten
t)); | 428 entry.content = JSON.parse(LZString.decompressFromUTF16(entry.conten
t)); |
429 } | 429 } |
430 for (var _loopIndex15 = 0; _loopIndex15 < entry.content.length; ++_loo
pIndex15) | 430 for (var _loopIndex15 = 0; _loopIndex15 < entry.content.length; ++_loo
pIndex15) |
431 { | 431 { |
432 var line = entry.content[_loopIndex15]; | 432 var line = entry.content[_loopIndex15]; |
433 listener.process(line); | 433 listener.process(line); |
434 } | 434 } |
435 } | 435 } |
436 callback(null); | 436 callback(null); |
(...skipping 6136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6573 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); | 6573 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); |
6574 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc
h.join("&")); | 6574 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc
h.join("&")); |
6575 } | 6575 } |
6576 if ("setUninstallURL" in chrome.runtime) | 6576 if ("setUninstallURL" in chrome.runtime) |
6577 { | 6577 { |
6578 Prefs.untilLoaded.then(setUninstallURL); | 6578 Prefs.untilLoaded.then(setUninstallURL); |
6579 Prefs.on("notificationdata", setUninstallURL); | 6579 Prefs.on("notificationdata", setUninstallURL); |
6580 } | 6580 } |
6581 return exports; | 6581 return exports; |
6582 })(); | 6582 })(); |
LEFT | RIGHT |