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: Fallback to chrome.storage.local to read initialization data Created July 27, 2016, 4:11 p.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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 var keyPrefix = "file:"; 353 var keyPrefix = "file:";
354 354
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 fileDoesNotExistMessage = "File doesn't exist"; 363 var entry = localStorage.getItem(key);
Sebastian Noack 2016/07/27 16:18:16 Any reason to put this text into a variable rather
kzar 2016/07/27 16:22:03 Nit: Don't see the purpose of this variable.
364 entry = localStorage.getItem(key);
Sebastian Noack 2016/07/27 16:18:16 Did you forget the var statement here?
kzar 2016/07/27 16:22:03 You've missed the `var` again.
365 if (entry) 364 if (entry)
365 {
366 successCallback(JSON.parse(entry)); 366 successCallback(JSON.parse(entry));
kzar 2016/07/27 16:22:02 Nit: Mind adding the { } braces for the if clause
367 }
367 else 368 else
368 { 369 {
369 // Also check the chrome.storage.local 370 // Also check the chrome.storage.local
Sebastian Noack 2016/07/27 16:18:16 Just to clarify, so this is for when migrating fro
Oleksandr 2016/07/27 16:33:30 No, this is for the first run when there is no pat
Sebastian Noack 2016/07/27 16:45:43 Then I don't understand what this workaround does.
Oleksandr 2016/07/27 18:23:40 I misdiagnosed it, you are right. It is only neede
Sebastian Noack 2016/07/27 18:29:43 Well, using setTimeout() would be much simpler. Al
Sebastian Noack 2016/07/27 21:33:16 (Not quite) LGTM but since the code as-is already
370 // We may have a init data there 371 // We may have a init data there
371 ext.storage.get([key], function(items) 372 ext.storage.get([key], function(items)
372 { 373 {
373 var entry = items[key]; 374 var entry = items[key];
374 if (entry) 375 if (entry)
375 { 376 successCallback(entry);
Sebastian Noack 2016/07/27 16:18:16 Nit: The inner braces can be omitted.
kzar 2016/07/27 16:22:02 Nit: Mind removing the braces for the if + else he
376 successCallback(entry);
377 }
378 else 377 else
379 { 378 errorCallback(new Error("File doesn't exist"));
380 errorCallback(new Error(fileDoesNotExistMessage));
381 }
382 }); 379 });
383 } 380 }
384 } 381 }
385 function saveFile(file, data, callback) 382 function saveFile(file, data, callback)
386 { 383 {
387 try 384 try
388 { 385 {
389 localStorage.setItem(fileToKey(file), JSON.stringify({ 386 localStorage.setItem(fileToKey(file), JSON.stringify({
390 content: data, 387 content: data,
391 lastModified: Date.now() 388 lastModified: Date.now()
(...skipping 6165 matching lines...) Expand 10 before | Expand all | Expand 10 after
6557 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); 6554 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount));
6558 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc h.join("&")); 6555 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc h.join("&"));
6559 } 6556 }
6560 if ("setUninstallURL" in chrome.runtime) 6557 if ("setUninstallURL" in chrome.runtime)
6561 { 6558 {
6562 Prefs.untilLoaded.then(setUninstallURL); 6559 Prefs.untilLoaded.then(setUninstallURL);
6563 Prefs.on("notificationdata", setUninstallURL); 6560 Prefs.on("notificationdata", setUninstallURL);
6564 } 6561 }
6565 return exports; 6562 return exports;
6566 })(); 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