fix to ensure PSL is available when binding tabs

pull/2/head 0.8.0.0-alpha.8
gorhill 10 years ago
parent abdbbd55dd
commit 8cb0619687

@ -116,18 +116,6 @@ chrome.webNavigation.onBeforeNavigate.addListener(onBeforeNavigateCallback);
/******************************************************************************/
// Initialize internal state with maybe already existing tabs
chrome.tabs.query({ url: '<all_urls>' }, function(tabs) {
var i = tabs.length;
// console.debug('HTTP Switchboard > preparing to bind %d tabs', i);
while ( i-- ) {
µMatrix.bindTabToPageStats(tabs[i].id, tabs[i].url);
}
});
/******************************************************************************/
// Browser data jobs
(function() {
@ -175,7 +163,24 @@ chrome.tabs.query({ url: '<all_urls>' }, function(tabs) {
// Load everything
µMatrix.load();
µMatrix.webRequest.start();
(function() {
var µm = µMatrix;
// This needs to be done when the PSL is loaded
var bindTabs = function(tabs) {
var i = tabs.length;
// console.debug('start.js > binding %d tabs', i);
while ( i-- ) {
µm.bindTabToPageStats(tabs[i].id, tabs[i].url);
}
µm.webRequest.start();
};
var queryTabs = function() {
chrome.tabs.query({ url: '<all_urls>' }, bindTabs);
};
µm.load(queryTabs);
})();
/******************************************************************************/

@ -362,13 +362,18 @@
// Load updatable assets
µMatrix.loadUpdatableAssets = function(forceUpdate) {
µMatrix.loadUpdatableAssets = function(forceUpdate, callback) {
if ( typeof callback !== 'function' ) {
callback = this.noopFunc;
}
this.assets.autoUpdate = forceUpdate === true;
this.assets.autoUpdateDelay = this.updateAssetsEvery;
if ( forceUpdate ) {
this.updater.restart();
}
this.loadPublicSuffixList();
this.loadPublicSuffixList(callback);
this.loadHostsFiles();
};
@ -376,13 +381,17 @@
// Load all
µMatrix.load = function() {
µMatrix.load = function(callback) {
if ( typeof callback !== 'function' ) {
callback = this.noopFunc;
}
var µm = this;
// User settings are in memory
var onUserSettingsReady = function(settings) {
// Never auto-update at boot time
µm.loadUpdatableAssets(false);
µm.loadUpdatableAssets(false, callback);
// Setup auto-updater, earlier if auto-upate is enabled, later if not
if ( settings.autoUpdate ) {

Loading…
Cancel
Save