Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/adblockplus.js

Issue 29348698: NoIssue - Use localStorage for storing filters in current Windows Store version of ABP for Edge (Closed)
Left Patch Set: Address the nits Created July 27, 2016, 10:14 a.m.
Right Patch Set: Address the comments Created July 27, 2016, 4:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | manifest.json » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 function fileToKey(file) 355 function fileToKey(file)
356 { 356 {
357 return keyPrefix + (file instanceof FakeFile ? file.path : file.spec); 357 return keyPrefix + (file instanceof FakeFile ? file.path : file.spec);
358 } 358 }
359 359
360 function loadFile(file, successCallback, errorCallback) 360 function loadFile(file, successCallback, errorCallback)
361 { 361 {
362 var key = fileToKey(file); 362 var key = fileToKey(file);
363 var entry = localStorage.getItem(key); 363 var entry = localStorage.getItem(key);
364 if (entry) 364 if (entry)
365 {
365 successCallback(JSON.parse(entry)); 366 successCallback(JSON.parse(entry));
367 }
366 else 368 else
367 errorCallback(new Error("File doesn't exist")); 369 {
368 } 370 // Also check the chrome.storage.local
369 371 // We may have a init data there
372 ext.storage.get([key], function(items)
373 {
374 var entry = items[key];
375 if (entry)
376 successCallback(entry);
377 else
378 errorCallback(new Error("File doesn't exist"));
379 });
380 }
381 }
370 function saveFile(file, data, callback) 382 function saveFile(file, data, callback)
371 { 383 {
372 try 384 try
373 { 385 {
374 localStorage.setItem(fileToKey(file), JSON.stringify({ 386 localStorage.setItem(fileToKey(file), JSON.stringify({
375 content: data, 387 content: data,
376 lastModified: Date.now() 388 lastModified: Date.now()
377 })); 389 }));
378 } 390 }
379 catch(error) 391 catch(error)
(...skipping 6162 matching lines...) Expand 10 before | Expand all | Expand 10 after
6542 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); 6554 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount));
6543 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc h.join("&")); 6555 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc h.join("&"));
6544 } 6556 }
6545 if ("setUninstallURL" in chrome.runtime) 6557 if ("setUninstallURL" in chrome.runtime)
6546 { 6558 {
6547 Prefs.untilLoaded.then(setUninstallURL); 6559 Prefs.untilLoaded.then(setUninstallURL);
6548 Prefs.on("notificationdata", setUninstallURL); 6560 Prefs.on("notificationdata", setUninstallURL);
6549 } 6561 }
6550 return exports; 6562 return exports;
6551 })(); 6563 })();
LEFTRIGHT
« no previous file | manifest.json » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld