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

Delta Between Two Patch Sets: background.js

Issue 5923900886089728: Use FileSystem API to store data in Opera (Closed)
Left Patch Set: Better approach to prevent first-run page from appearing Created Nov. 26, 2013, 12:35 p.m.
Right Patch Set: Fixed remaining comment Created Nov. 27, 2013, 3:45 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 | no next file » | 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 23 matching lines...) Expand all
34 var Synchronizer = require("synchronizer").Synchronizer; 34 var Synchronizer = require("synchronizer").Synchronizer;
35 var Utils = require("utils").Utils; 35 var Utils = require("utils").Utils;
36 var Notification = require("notification").Notification; 36 var Notification = require("notification").Notification;
37 37
38 // Some types cannot be distinguished 38 // Some types cannot be distinguished
39 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; 39 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
40 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT HER; 40 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT HER;
41 41
42 var isFirstRun = false; 42 var isFirstRun = false;
43 var seenDataCorruption = false; 43 var seenDataCorruption = false;
44 var importingOldData = false;
45 require("filterNotifier").FilterNotifier.addListener(function(action) 44 require("filterNotifier").FilterNotifier.addListener(function(action)
46 { 45 {
47 if (action == "load") 46 if (action == "load")
48 { 47 {
49 importOldData(); 48 var importingOldData = importOldData();
50 49
51 var addonVersion = require("info").addonVersion; 50 var addonVersion = require("info").addonVersion;
52 var prevVersion = localStorage.currentVersion; 51 var prevVersion = localStorage.currentVersion;
53 if (prevVersion != addonVersion) 52 if (prevVersion != addonVersion)
54 { 53 {
55 isFirstRun = !prevVersion; 54 isFirstRun = !prevVersion;
56 localStorage.currentVersion = addonVersion; 55 localStorage.currentVersion = addonVersion;
57 if (!importingOldData) 56 if (!importingOldData)
Thomas Greiner 2013/11/26 13:40:13 You're only using this variable for this check her
Wladimir Palant 2013/11/27 15:46:21 Done.
58 addSubscription(prevVersion); 57 addSubscription(prevVersion);
59 } 58 }
60 } 59 }
61 }); 60 });
62 61
63 // Special-case domains for which we cannot use style-based hiding rules. 62 // Special-case domains for which we cannot use style-based hiding rules.
64 // See http://crbug.com/68705. 63 // See http://crbug.com/68705.
65 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; 64 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"];
66 65
67 function removeDeprecatedOptions() 66 function removeDeprecatedOptions()
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Set context menu status according to whether current tab has whitelisted domain 143 // Set context menu status according to whether current tab has whitelisted domain
145 if (excluded) 144 if (excluded)
146 chrome.contextMenus.removeAll(); 145 chrome.contextMenus.removeAll();
147 else 146 else
148 showContextMenu(); 147 showContextMenu();
149 } 148 }
150 149
151 /** 150 /**
152 * Old versions for Opera stored patterns.ini in the localStorage object, this 151 * Old versions for Opera stored patterns.ini in the localStorage object, this
153 * will import it into FilterStorage properly. 152 * will import it into FilterStorage properly.
153 * @return {Boolean} true if data import is in progress
154 */ 154 */
155 function importOldData() 155 function importOldData()
156 { 156 {
157 if ("patterns.ini" in localStorage) 157 if ("patterns.ini" in localStorage)
158 { 158 {
159 importingOldData = true;
160 FilterStorage.loadFromDisk(localStorage["patterns.ini"]); 159 FilterStorage.loadFromDisk(localStorage["patterns.ini"]);
161 160
162 var remove = []; 161 var remove = [];
163 for (var key in localStorage) 162 for (var key in localStorage)
164 if (key.indexOf("patterns.ini") == 0 || key.indexOf("patterns-backup") == 0) 163 if (key.indexOf("patterns.ini") == 0 || key.indexOf("patterns-backup") == 0)
165 remove.push(key); 164 remove.push(key);
166 for (var i = 0; i < remove.length; i++) 165 for (var i = 0; i < remove.length; i++)
167 delete localStorage[remove[i]]; 166 delete localStorage[remove[i]];
168 } 167
168 return true;
169 }
170 else
171 return false;
169 } 172 }
170 173
171 /** 174 /**
172 * This function is called on an extension update. It will add the default 175 * This function is called on an extension update. It will add the default
173 * filter subscription if necessary. 176 * filter subscription if necessary.
174 */ 177 */
175 function addSubscription(prevVersion) 178 function addSubscription(prevVersion)
176 { 179 {
177 // Make sure to remove "Recommended filters", no longer necessary 180 // Make sure to remove "Recommended filters", no longer necessary
178 var toRemove = "https://easylist-downloads.adblockplus.org/chrome_supplement.t xt"; 181 var toRemove = "https://easylist-downloads.adblockplus.org/chrome_supplement.t xt";
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 tab.sendMessage({type: "clickhide-deactivate"}); 461 tab.sendMessage({type: "clickhide-deactivate"});
459 refreshIconAndContextMenu(tab); 462 refreshIconAndContextMenu(tab);
460 }); 463 });
461 464
462 setTimeout(function() 465 setTimeout(function()
463 { 466 {
464 var notificationToShow = Notification.getNextToShow(); 467 var notificationToShow = Notification.getNextToShow();
465 if (notificationToShow) 468 if (notificationToShow)
466 showNotification(notificationToShow); 469 showNotification(notificationToShow);
467 }, 3 * 60 * 1000); 470 }, 3 * 60 * 1000);
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld