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

Delta Between Two Patch Sets: lib/prefs.js

Issue 5251132066627584: Issue 1488 - Add pre-configurable preference to suppress first run page (Closed)
Left Patch Set: Don't dispatch onChanged before loading is complete Created March 20, 2015, 4:13 p.m.
Right Patch Set: Rebased and renamed onProgress() to checkLoaded() Created April 8, 2015, 3:09 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 | « chrome/managed-storage-schema.json ('k') | metadata.chrome » ('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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 91
92 function init() 92 function init()
93 { 93 {
94 let prefs = Object.keys(defaults); 94 let prefs = Object.keys(defaults);
95 prefs.forEach(addPreference); 95 prefs.forEach(addPreference);
96 96
97 let localLoaded = false; 97 let localLoaded = false;
98 let managedLoaded = false; 98 let managedLoaded = false;
99 99
100 let onProgress = function() 100 let checkLoaded = function()
kzar 2015/04/08 13:55:45 I found this function name a little confusing when
Sebastian Noack 2015/04/08 15:11:20 Renamed it to checkLoaded, as well for the code in
101 { 101 {
102 if (!localLoaded || !managedLoaded) 102 if (!localLoaded || !managedLoaded)
103 return; 103 return;
104 104
105 ext.storage.onChanged.addListener(function(changes) 105 ext.storage.onChanged.addListener(function(changes)
106 { 106 {
107 for (let key in changes) 107 for (let key in changes)
108 { 108 {
109 let pref = keyToPref(key); 109 let pref = keyToPref(key);
110 if (pref && pref in defaults) 110 if (pref && pref in defaults)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 }, 149 },
150 150
151 done: function() 151 done: function()
152 { 152 {
153 ext.storage.get(prefs.map(prefToKey), function(items) 153 ext.storage.get(prefs.map(prefToKey), function(items)
154 { 154 {
155 for (let key in items) 155 for (let key in items)
156 overrides[keyToPref(key)] = items[key]; 156 overrides[keyToPref(key)] = items[key];
157 157
158 localLoaded = true; 158 localLoaded = true;
159 onProgress(); 159 checkLoaded();
160 }); 160 });
161 } 161 }
162 }); 162 });
163 163
164 if (require("info").platform == "chromium" && "managed" in chrome.storage) 164 if (require("info").platform == "chromium" && "managed" in chrome.storage)
165 { 165 {
166 chrome.storage.managed.get(null, function(items) 166 chrome.storage.managed.get(null, function(items)
167 { 167 {
168 for (let key in items) 168 for (let key in items)
169 defaults[key] = items[key]; 169 defaults[key] = items[key];
170 170
171 managedLoaded = true; 171 managedLoaded = true;
172 onProgress(); 172 checkLoaded();
173 }); 173 });
174 } 174 }
175 else 175 else
176 { 176 {
177 managedLoaded = true; 177 managedLoaded = true;
178 onProgress(); 178 checkLoaded();
179 } 179 }
180 } 180 }
181 181
182 init(); 182 init();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld