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

Delta Between Two Patch Sets: lib/prefs.js

Issue 29317074: Issue 2693 - Update adblockplus dependency (Closed)
Left Patch Set: Created June 18, 2015, 3:31 p.m.
Right Patch Set: rebase Created July 2, 2015, 1:37 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 | « lib/notificationShowRegistration.js ('k') | libadblockplus.gyp » ('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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 24 matching lines...) Expand all
35 documentation_link: "https://adblockplus.org/redirect?link=%LINK%&lang=%LANG%" , 35 documentation_link: "https://adblockplus.org/redirect?link=%LINK%&lang=%LANG%" ,
36 update_url_release: "https://update.adblockplus.org/%NAME%/update.json?type=%T YPE%", 36 update_url_release: "https://update.adblockplus.org/%NAME%/update.json?type=%T YPE%",
37 update_url_devbuild: "https://adblockplus.org/devbuilds/%NAME%/update.json?typ e=%TYPE%", 37 update_url_devbuild: "https://adblockplus.org/devbuilds/%NAME%/update.json?typ e=%TYPE%",
38 update_last_check: 0, 38 update_last_check: 0,
39 update_last_error: 0, 39 update_last_error: 0,
40 update_soft_expiration: 0, 40 update_soft_expiration: 0,
41 update_hard_expiration: 0, 41 update_hard_expiration: 0,
42 currentVersion: "0.0", 42 currentVersion: "0.0",
43 notificationdata: {}, 43 notificationdata: {},
44 notificationurl: "https://notification.adblockplus.org/notification.json", 44 notificationurl: "https://notification.adblockplus.org/notification.json",
45 suppress_first_run_page: false,
46 disable_auto_updates: false,
45 notifications_ignoredcategories: [], 47 notifications_ignoredcategories: [],
46 }; 48 };
47 49
48 let values = Object.create(defaults); 50 let preconfigurable = ["suppress_first_run_page", "disable_auto_updates"];
51
52 let values;
49 let path = _fileSystem.resolve("prefs.json"); 53 let path = _fileSystem.resolve("prefs.json");
50 let listeners = []; 54 let listeners = [];
51 let isDirty = false; 55 let isDirty = false;
52 let isSaving = false; 56 let isSaving = false;
53 57
54 function defineProperty(key) 58 function defineProperty(key)
55 { 59 {
56 Object.defineProperty(Prefs, key, 60 Object.defineProperty(Prefs, key,
57 { 61 {
58 get: () => values[key], 62 get: () => values[key],
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 }, 129 },
126 130
127 removeListener: function(listener) 131 removeListener: function(listener)
128 { 132 {
129 let index = listeners.indexOf(listener); 133 let index = listeners.indexOf(listener);
130 if (index >= 0) 134 if (index >= 0)
131 listeners.splice(index, 1); 135 listeners.splice(index, 1);
132 }, 136 },
133 }; 137 };
134 138
139 // Update the default prefs with what was preconfigured
140 for (let key in _preconfiguredPrefs)
141 if (preconfigurable.indexOf(key) != -1)
142 defaults[key] = _preconfiguredPrefs[key];
143
144 // Define defaults
135 for (let key in defaults) 145 for (let key in defaults)
136 defineProperty(key); 146 defineProperty(key);
137 147
148 // Set values of prefs based on defaults
149 values = Object.create(defaults);
150
138 load(); 151 load();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld