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

Side by Side Diff: lib/prefs.js

Issue 29452181: Noissue - Merge current tip to Edge bookmark (Closed)
Patch Set: Created May 30, 2017, 3:49 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/popupBlocker.js ('k') | lib/publicSuffixList.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2017 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 * @type {string} 109 * @type {string}
110 */ 110 */
111 defaults.notificationurl = "https://notification.adblockplus.org/notification.js on"; 111 defaults.notificationurl = "https://notification.adblockplus.org/notification.js on";
112 /** 112 /**
113 * The total number of requests blocked by the extension. 113 * The total number of requests blocked by the extension.
114 * 114 *
115 * @type {number} 115 * @type {number}
116 */ 116 */
117 defaults.blocked_total = 0; 117 defaults.blocked_total = 0;
118 /** 118 /**
119 * Whether to show a badge in the toolbar icon indicating the number of blocked ads. 119 * Whether to show a badge in the toolbar icon indicating the number
120 * of blocked ads.
120 * 121 *
121 * @type {boolean} 122 * @type {boolean}
122 */ 123 */
123 defaults.show_statsinicon = true; 124 defaults.show_statsinicon = true;
124 /** 125 /**
125 * Whether to show the number of blocked ads in the popup. 126 * Whether to show the number of blocked ads in the popup.
126 * 127 *
127 * @type {boolean} 128 * @type {boolean}
128 */ 129 */
129 defaults.show_statsinpopup = true; 130 defaults.show_statsinpopup = true;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 }, 254 },
254 enumerable: true 255 enumerable: true
255 }); 256 });
256 } 257 }
257 258
258 function init() 259 function init()
259 { 260 {
260 let prefs = Object.keys(defaults); 261 let prefs = Object.keys(defaults);
261 prefs.forEach(addPreference); 262 prefs.forEach(addPreference);
262 263
263 let localLoaded = new Promise(resolve => { 264 let localLoaded = new Promise(resolve =>
265 {
264 ext.storage.get(prefs.map(prefToKey), items => 266 ext.storage.get(prefs.map(prefToKey), items =>
265 { 267 {
266 for (let key in items) 268 for (let key in items)
267 overrides[keyToPref(key)] = items[key]; 269 overrides[keyToPref(key)] = items[key];
268 270
269 resolve(); 271 resolve();
270 }); 272 });
271 }); 273 });
272 274
273 let managedLoaded = new Promise(resolve => { 275 let managedLoaded = new Promise(resolve =>
274 if (typeof chrome == "object" && "managed" in chrome.storage) 276 {
277 if (require("info").platform == "chromium" && "managed" in chrome.storage)
275 { 278 {
276 chrome.storage.managed.get(null, items => 279 chrome.storage.managed.get(null, items =>
277 { 280 {
278 // Opera doesn't support chrome.storage.managed, but instead simply 281 // Opera doesn't support chrome.storage.managed, but instead simply
279 // removing the API, Opera sets chrome.runtime.lastError when using it. 282 // removing the API, Opera sets chrome.runtime.lastError when using it.
280 // So we have to retrieve that error, to prevent it from showing up 283 // So we have to retrieve that error, to prevent it from showing up
281 // in the console. 284 // in the console.
282 chrome.runtime.lastError; 285 chrome.runtime.lastError;
283 286
284 for (let key in items) 287 for (let key in items)
(...skipping 26 matching lines...) Expand all
311 eventEmitter.emit(pref); 314 eventEmitter.emit(pref);
312 } 315 }
313 } 316 }
314 }); 317 });
315 } 318 }
316 319
317 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded); 320 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded);
318 } 321 }
319 322
320 init(); 323 init();
OLDNEW
« no previous file with comments | « lib/popupBlocker.js ('k') | lib/publicSuffixList.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld