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: Display an alert when trying to save to full localStorage Created July 27, 2016, 9:30 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 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 entry = localStorage.getItem(key); 363 var entry = localStorage.getItem(key);
kzar 2016/07/27 10:08:14 You missed the `var`.
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)
380 { 392 {
381 // QuotaExceededError can happen. Notify the user and ignore 393 // QuotaExceededError can happen. Notify the user and ignore
382 alert("Subscription storage is full. Please remove some subscriptions and try again."); 394 var errorMessage = "Subscription storage is full. " +
kzar 2016/07/27 10:08:15 Nit: These lines are too long.
383 callback(new Error("Subscription storage is full. Please remove some subsc riptions and try again.")); 395 "Please remove some subscriptions and try again.";
kzar 2016/07/27 10:08:14 Mind putting the message in a variable instead of
shoniko 2016/07/27 10:46:51 If we are going to push this we should do it ASAP.
396 alert(errorMessage);
397 callback(new Error(errorMessage));
384 return; 398 return;
385 } 399 }
386 callback(); 400 callback();
387 } 401 }
388 exports.IO = { 402 exports.IO = {
389 resolveFilePath: function(path) 403 resolveFilePath: function(path)
390 { 404 {
391 return new FakeFile(path); 405 return new FakeFile(path);
392 }, 406 },
393 readFromFile: function(file, listener, callback) 407 readFromFile: function(file, listener, callback)
(...skipping 6146 matching lines...) Expand 10 before | Expand all | Expand 10 after
6540 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); 6554 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount));
6541 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc h.join("&")); 6555 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + searc h.join("&"));
6542 } 6556 }
6543 if ("setUninstallURL" in chrome.runtime) 6557 if ("setUninstallURL" in chrome.runtime)
6544 { 6558 {
6545 Prefs.untilLoaded.then(setUninstallURL); 6559 Prefs.untilLoaded.then(setUninstallURL);
6546 Prefs.on("notificationdata", setUninstallURL); 6560 Prefs.on("notificationdata", setUninstallURL);
6547 } 6561 }
6548 return exports; 6562 return exports;
6549 })(); 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