Bug 746756 - On feature activation, Download Panel should limit reported downloads. r=mak.

This commit is contained in:
Mike Conley 2012-10-24 10:02:29 -04:00
parent 7f0db6cc58
commit 6c55267d1c
2 changed files with 42 additions and 4 deletions

View File

@ -329,6 +329,10 @@ pref("browser.download.useToolkitUI", false);
// This controls retention behavior in the Downloads Panel only.
pref("browser.download.panel.removeFinishedDownloads", false);
// This records whether or not at least one session with the Downloads Panel
// enabled has been completed already.
pref("browser.download.panel.firstSessionCompleted", false);
// search engines URL
pref("browser.search.searchEnginesURL", "https://addons.mozilla.org/%LOCALE%/firefox/search-engines/");

View File

@ -98,7 +98,7 @@ DownloadsStartup.prototype = {
// database to see if there are completed downloads to recover and show
// in the panel, in addition to in-progress downloads.
if (gSessionStartup.sessionType != Ci.nsISessionStartup.NO_SESSION) {
this._recoverAllDownloads = true;
this._restoringSession = true;
}
this._ensureDataLoaded();
break;
@ -188,6 +188,14 @@ DownloadsStartup.prototype = {
if (this._cleanupOnShutdown) {
Services.downloads.cleanUp();
}
if (!DownloadsCommon.useToolkitUI) {
// If we got this far, that means that we finished our first session
// with the Downloads Panel without crashing. This means that we don't
// have to force displaying only active downloads on the next startup
// now.
this._firstSessionCompleted = true;
}
break;
}
},
@ -196,10 +204,11 @@ DownloadsStartup.prototype = {
//// Private
/**
* Indicates whether we should load all downloads from the previous session,
* including completed items as well as active downloads.
* Indicates whether we're restoring a previous session. This is used by
* _recoverAllDownloads to determine whether or not we should load and
* display all downloads data, or restrict it to only the active downloads.
*/
_recoverAllDownloads: false,
_restoringSession: false,
/**
* Indicates whether the Download Manager service has been initialized. This
@ -219,6 +228,31 @@ DownloadsStartup.prototype = {
*/
_cleanupOnShutdown: false,
/**
* True if we should display all downloads, as opposed to just active
* downloads. We decide to display all downloads if we're restoring a session,
* or if we're using the Downloads Panel anytime after the first session with
* it has completed.
*/
get _recoverAllDownloads() {
return this._restoringSession ||
(!DownloadsCommon.useToolkitUI && this._firstSessionCompleted);
},
/**
* True if we've ever completed a session with the Downloads Panel enabled.
*/
get _firstSessionCompleted() {
return Services.prefs
.getBoolPref("browser.download.panel.firstSessionCompleted");
},
set _firstSessionCompleted(aValue) {
Services.prefs.setBoolPref("browser.download.panel.firstSessionCompleted",
aValue);
return aValue;
},
/**
* Ensures that persistent download data is reloaded at the appropriate time.
*/