Bug 753448 - Part 2 - Integrate the new tab preloader; r=jaws

This commit is contained in:
Tim Taubert
2012-08-13 09:34:10 -07:00
parent 83fb595f23
commit b24eb4f102
2 changed files with 22 additions and 0 deletions

View File

@@ -151,6 +151,12 @@ XPCOMUtils.defineLazyGetter(this, "SafeBrowsing", function() {
});
#endif
XPCOMUtils.defineLazyGetter(this, "gBrowserNewTabPreloader", function () {
let tmp = {};
Cu.import("resource://gre/modules/BrowserNewTabPreloader.jsm", tmp);
return new tmp.BrowserNewTabPreloader();
});
let gInitialPages = [
"about:blank",
"about:newtab",
@@ -1401,6 +1407,12 @@ var gBrowserInit = {
gSyncUI.init();
#endif
// Don't preload new tab pages when the toolbar is hidden
// (i.e. when the current window is a popup window).
if (window.toolbar.visible) {
gBrowserNewTabPreloader.init(window);
}
gBrowserThumbnails.init();
TabView.init();
@@ -1557,6 +1569,10 @@ var gBrowserInit = {
Services.obs.removeObserver(gPluginHandler.pluginCrashed, "plugin-crashed");
if (!__lookupGetter__("gBrowserNewTabPreloader")) {
gBrowserNewTabPreloader.uninit();
}
try {
gBrowser.removeProgressListener(window.XULBrowserWindow);
gBrowser.removeTabsProgressListener(window.TabsProgressListener);

View File

@@ -1383,6 +1383,12 @@
// activeness in the tab switcher.
b.docShellIsActive = false;
// If we just created a new tab that loads the default
// newtab url, swap in a preloaded page if possible.
if (aURI == BROWSER_NEW_TAB_URL) {
gBrowserNewTabPreloader.newTab(t);
}
// Check if we're opening a tab related to the current tab and
// move it to after the current tab.
// aReferrerURI is null or undefined if the tab is opened from