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

Side by Side Diff: lib/prefs.js

Issue 5251132066627584: Issue 1488 - Add pre-configurable preference to suppress first run page (Closed)
Patch Set: Rebased and addressed comments Created March 20, 2015, 1:25 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 | « chrome/managed-storage-schema.json ('k') | metadata.chrome » ('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-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 22 matching lines...) Expand all
33 defaults.subscriptions_exceptionsurl = "https://easylist-downloads.adblockplus.o rg/exceptionrules.txt"; 33 defaults.subscriptions_exceptionsurl = "https://easylist-downloads.adblockplus.o rg/exceptionrules.txt";
34 defaults.subscriptions_antiadblockurl = "https://easylist-downloads.adblockplus. org/antiadblockfilters.txt"; 34 defaults.subscriptions_antiadblockurl = "https://easylist-downloads.adblockplus. org/antiadblockfilters.txt";
35 defaults.documentation_link = "https://adblockplus.org/redirect?link=%LINK%&lang =%LANG%"; 35 defaults.documentation_link = "https://adblockplus.org/redirect?link=%LINK%&lang =%LANG%";
36 defaults.notificationdata = {}; 36 defaults.notificationdata = {};
37 defaults.notificationurl = "https://notification.adblockplus.org/notification.js on"; 37 defaults.notificationurl = "https://notification.adblockplus.org/notification.js on";
38 defaults.stats_total = {}; 38 defaults.stats_total = {};
39 defaults.show_statsinicon = true; 39 defaults.show_statsinicon = true;
40 defaults.show_statsinpopup = true; 40 defaults.show_statsinpopup = true;
41 defaults.shouldShowBlockElementMenu = true; 41 defaults.shouldShowBlockElementMenu = true;
42 defaults.hidePlaceholders = true; 42 defaults.hidePlaceholders = true;
43 defaults.suppress_first_run_page = false;
43 44
44 let Prefs = exports.Prefs = { 45 let Prefs = exports.Prefs = {
45 onChanged: new ext._EventTarget(), 46 onChanged: new ext._EventTarget(),
46 onLoaded: new ext._EventTarget() 47 onLoaded: new ext._EventTarget()
47 }; 48 };
48 49
49 function keyToPref(key) 50 function keyToPref(key)
50 { 51 {
51 if (key.indexOf(keyPrefix) != 0) 52 if (key.indexOf(keyPrefix) != 0)
52 return null; 53 return null;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }, 87 },
87 enumerable: true 88 enumerable: true
88 }); 89 });
89 } 90 }
90 91
91 function init() 92 function init()
92 { 93 {
93 let prefs = Object.keys(defaults); 94 let prefs = Object.keys(defaults);
94 prefs.forEach(addPreference); 95 prefs.forEach(addPreference);
95 96
97 let localLoaded = false;
98 let managedLoaded = false;
99
96 // Migrate preferences for users updating from old versions. 100 // Migrate preferences for users updating from old versions.
97 // TODO: Remove the migration code after a few releases. 101 // TODO: Remove the migration code after a few releases.
98 ext.storage.migratePrefs({ 102 ext.storage.migratePrefs({
99 map: function(key, value) 103 map: function(key, value)
100 { 104 {
101 if (key in defaults) 105 if (key in defaults)
102 { 106 {
103 if (key != "currentVersion") 107 if (key != "currentVersion")
104 { 108 {
105 try 109 try
(...skipping 30 matching lines...) Expand all
136 if ("newValue" in change && change.newValue != defaults[pref]) 140 if ("newValue" in change && change.newValue != defaults[pref])
137 overrides[pref] = change.newValue; 141 overrides[pref] = change.newValue;
138 else 142 else
139 delete overrides[pref]; 143 delete overrides[pref];
140 144
141 Prefs.onChanged._dispatch(pref); 145 Prefs.onChanged._dispatch(pref);
142 } 146 }
143 } 147 }
144 }); 148 });
145 149
146 Prefs.onLoaded._dispatch(); 150 localLoaded = true;
151 if (localLoaded && managedLoaded)
152 Prefs.onLoaded._dispatch();
147 }); 153 });
148 } 154 }
149 }); 155 });
156
157 if (require("info").platform == "chromium" && "managed" in chrome.storage)
158 {
159 chrome.storage.managed.get(null, function(items)
160 {
161 for (let key in items)
162 defaults[key] = items[key];
163
164 managedLoaded = true;
165 if (localLoaded && managedLoaded)
166 Prefs.onLoaded._dispatch();
167 });
168 }
169 else
170 {
171 managedLoaded = true;
172 }
150 } 173 }
151 174
152 init(); 175 init();
OLDNEW
« no previous file with comments | « chrome/managed-storage-schema.json ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld