Index: lib/prefs.js |
=================================================================== |
--- a/lib/prefs.js |
+++ b/lib/prefs.js |
@@ -40,6 +40,7 @@ |
defaults.show_statsinpopup = true; |
defaults.shouldShowBlockElementMenu = true; |
defaults.hidePlaceholders = true; |
+defaults.suppress_first_run_page = false; |
let Prefs = exports.Prefs = { |
onChanged: new ext._EventTarget(), |
@@ -93,6 +94,35 @@ |
let prefs = Object.keys(defaults); |
prefs.forEach(addPreference); |
+ let localLoaded = false; |
+ let managedLoaded = false; |
+ |
+ let onProgress = 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
|
+ { |
+ if (!localLoaded || !managedLoaded) |
+ return; |
+ |
+ ext.storage.onChanged.addListener(function(changes) |
+ { |
+ for (let key in changes) |
+ { |
+ let pref = keyToPref(key); |
+ if (pref && pref in defaults) |
+ { |
+ let change = changes[key]; |
+ if ("newValue" in change && change.newValue != defaults[pref]) |
+ overrides[pref] = change.newValue; |
+ else |
+ delete overrides[pref]; |
+ |
+ Prefs.onChanged._dispatch(pref); |
+ } |
+ } |
+ }); |
+ |
+ Prefs.onLoaded._dispatch(); |
+ }; |
+ |
// Migrate preferences for users updating from old versions. |
// TODO: Remove the migration code after a few releases. |
ext.storage.migratePrefs({ |
@@ -125,28 +155,28 @@ |
for (let key in items) |
overrides[keyToPref(key)] = items[key]; |
- ext.storage.onChanged.addListener(function(changes) |
- { |
- for (let key in changes) |
- { |
- let pref = keyToPref(key); |
- if (pref && pref in defaults) |
- { |
- let change = changes[key]; |
- if ("newValue" in change && change.newValue != defaults[pref]) |
- overrides[pref] = change.newValue; |
- else |
- delete overrides[pref]; |
- |
- Prefs.onChanged._dispatch(pref); |
- } |
- } |
- }); |
- |
- Prefs.onLoaded._dispatch(); |
+ localLoaded = true; |
+ onProgress(); |
}); |
} |
}); |
+ |
+ if (require("info").platform == "chromium" && "managed" in chrome.storage) |
+ { |
+ chrome.storage.managed.get(null, function(items) |
+ { |
+ for (let key in items) |
+ defaults[key] = items[key]; |
+ |
+ managedLoaded = true; |
+ onProgress(); |
+ }); |
+ } |
+ else |
+ { |
+ managedLoaded = true; |
+ onProgress(); |
+ } |
} |
init(); |