Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
fix to ensure PSL is available when binding tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 26, 2014
1 parent abdbbd5 commit 8cb0619
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
33 changes: 19 additions & 14 deletions src/js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
})();

/******************************************************************************/
17 changes: 13 additions & 4 deletions src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,27 +362,36 @@

// 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();
};

/******************************************************************************/

// 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 ) {
Expand Down

0 comments on commit 8cb0619

Please sign in to comment.