Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue 5888: Improve logic for when to open first-run page

  • Loading branch information...
commit d349c955b3a29e8b21a305b894c55c39a1e07a7c 1 parent df657ef
@janodvarko janodvarko authored
View
2  extension/bootstrap.js
@@ -66,7 +66,7 @@ function startup(params, reason)
// Load Firebug into all existing browser windows.
var enumerator = Services.wm.getEnumerator("navigator:browser");
while (enumerator.hasMoreElements())
- FirebugLoader.loadIntoWindow(enumerator.getNext());
+ FirebugLoader.loadIntoWindow(enumerator.getNext(), reason);
// Listen for new windows, Firebug must be loaded into them too.
Services.ww.registerNotification(windowWatcher);
View
97 extension/content/firebug/firefox/browserOverlay.js
@@ -509,13 +509,6 @@ Firebug.GlobalUI =
});
},
- openFirstRunPage: function()
- {
- var version = Firebug.GlobalUI.getVersion();
- url = firstRunPage + version;
- gBrowser.selectedTab = gBrowser.addTab(url, null, null, null);
- },
-
setPosition: function(newPosition)
{
// todo
@@ -606,7 +599,64 @@ Firebug.GlobalUI =
win.nsContextMenu.prototype.setTarget = this.setTargetOriginal;
win.nsContextMenu.prototype.initItems = this.initItemsOriginal;
- }
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // First Run Page
+
+ loadFirstRunPage: function(win, reason)
+ {
+ if (checkFirebugVersion(PrefLoader.getPref("currentVersion")) <= 0)
+ return;
+
+ // Do not show the first run page when Firebug is being updated. It'll be displayed
+ // the next time the browser is restarted
+ // # ADDON_UPGRADE == 7
+ if (reason == 7)
+ return;
+
+ // Open the page in the top most window, so the user can see it immediately.
+ var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
+ if (wm.getMostRecentWindow("navigator:browser") == win.top)
+ {
+ // Update the preference to make sure the page is not displayed again.
+ // To avoid being annoying when Firefox crashes, forcibly save it, too.
+ var version = Firebug.GlobalUI.getVersion();
+ PrefLoader.setPref("currentVersion", version);
+
+ if (PrefLoader.getPref("showFirstRunPage"))
+ {
+ var timeout = setTimeout(function()
+ {
+ if (window.closed)
+ return;
+
+ Firebug.GlobalUI.openFirstRunPage();
+ }, 1000);
+
+ window.addEventListener("unload", function()
+ {
+ clearTimeout(timeout);
+ }, false);
+ }
+ }
+ },
+
+ openFirstRunPage: function()
+ {
+ var version = Firebug.GlobalUI.getVersion();
+ url = firstRunPage + version;
+
+ // Open the firstRunPage in background
+ /*gBrowser.selectedTab = */gBrowser.addTab(url, null, null, null);
+
+ // Make sure prefs are stored, otherwise the firstRunPage would be displayed
+ // again if Firefox crashes.
+ setTimeout(function()
+ {
+ PrefLoader.forceSave();
+ }, 400);
+ },
}
// ********************************************************************************************* //
@@ -1273,9 +1323,7 @@ var elements = cloneArray(document.getElementsByClassName("fbInternational"));
Locale.internationalizeElements(document, elements, ["label", "tooltiptext", "aria-label"]);
// ********************************************************************************************* //
-// First Run Page
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
+// Version Checker
function checkFirebugVersion(currentVersion)
{
@@ -1290,33 +1338,6 @@ function checkFirebugVersion(currentVersion)
return versionChecker.compare(version, currentVersion);
}
-if (checkFirebugVersion(PrefLoader.getPref("currentVersion")) > 0)
-{
- // Open the page in the top most window, so the user can see it immediately.
- if (wm.getMostRecentWindow("navigator:browser") == window.top)
- {
- // Don't forget to update the preference, so the page is not displayed again
- var version = Firebug.GlobalUI.getVersion();
- PrefLoader.setPref("currentVersion", version);
-
- if (PrefLoader.getPref("showFirstRunPage"))
- {
- var timeout = setTimeout(function()
- {
- if (window.closed)
- return;
-
- Firebug.GlobalUI.openFirstRunPage();
- }, 1000);
-
- window.addEventListener("unload", function()
- {
- clearTimeout(timeout);
- }, false);
- }
- }
-}
-
// ********************************************************************************************* //
// All Pages Activation" is on
View
3  extension/modules/loader.js
@@ -132,7 +132,7 @@ var FirebugLoader =
delete win.FBL;
},
- loadIntoWindow: function(win)
+ loadIntoWindow: function(win, reason)
{
// This is the place where the global Firebug object is created. This object represents
// the entire application and all consequently created namespaces and variables should be
@@ -144,6 +144,7 @@ var FirebugLoader =
loadSubscript("chrome://firebug/content/firefox/browserOverlay.js", win);
win.Firebug.GlobalUI.loadContextMenuOverlay(win);
+ win.Firebug.GlobalUI.loadFirstRunPage(win, reason);
// Firebug extensions should initialize here.
this.dispatchToScopes("topWindowLoad", [win]);
View
6 extension/modules/prefLoader.js
@@ -144,6 +144,11 @@ function setPref(name, value)
return value;
}
+function forceSave()
+{
+ Services.prefs.savePrefFile(null);
+}
+
// ********************************************************************************************* //
// Registration
@@ -151,5 +156,6 @@ PrefLoader.loadDefaultPrefs = loadDefaultPrefs;
PrefLoader.clearDefaultPrefs = clearDefaultPrefs;
PrefLoader.getPref = getPref;
PrefLoader.setPref = setPref;
+PrefLoader.forceSave = forceSave;
// ********************************************************************************************* //
Please sign in to comment.
Something went wrong with that request. Please try again.