Bug 825060 - Enable the new Library Downloads view by default when the panel is enabled.

r=mconley
This commit is contained in:
Marco Bonardo 2012-12-28 00:54:48 +01:00
Родитель 04f0f28be1
Коммит a87f0db724
5 изменённых файлов: 53 добавлений и 62 удалений

Просмотреть файл

@ -600,6 +600,7 @@ function DownloadsPlacesView(aRichListBox) {
// Make sure to unregister the view if the window is closed.
window.addEventListener("unload", function() {
this._richlistbox.controllers.removeController(this);
downloadsData.removeView(this);
this.result = null;
}.bind(this), true);
@ -770,6 +771,7 @@ DownloadsPlacesView.prototype = {
// sibling first, if any.
if (aElement.nextSibling &&
this._richlistbox.selectedItems &&
this._richlistbox.selectedItems.length > 0 &&
this._richlistbox.selectedItems[0] == aElement) {
this._richlistbox.selectItem(aElement.nextSibling);
}

Просмотреть файл

@ -107,28 +107,11 @@ DownloadsUI.prototype = {
},
/**
* Helper function that opens the right download manager UI. Either the
* new Downloads View in Places, or the toolkit download window if the
* Places Downloads View is not enabled.
* Helper function that opens the download manager UI.
*/
_showDownloadManagerUI:
function DUI_showDownloadManagerUI(aWindowContext, aID, aReason)
{
// First, determine if the Places Downloads view is preffed on.
let usePlacesView = false;
try {
usePlacesView =
Services.prefs.getBoolPref("browser.library.useNewDownloadsView");
} catch(e) {}
if (!usePlacesView) {
// If we got here, then the browser.library.useNewDownloadsView pref
// either didn't exist or was false, so just show the toolkit downloads
// manager.
this._toolkitUI.show(aWindowContext, aID, aReason);
return;
}
let organizer = Services.wm.getMostRecentWindow("Places:Organizer");
if (!organizer) {
let parentWindow = aWindowContext;

Просмотреть файл

@ -8,21 +8,13 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"><![CDATA[
let useNewView = false;
try {
useNewView = Services.prefs.getBoolPref("browser.library.useNewDownloadsView");
}
catch(ex) { }
const DOWNLOADS_QUERY = "place:transition=" +
Components.interfaces.nsINavHistoryService.TRANSITION_DOWNLOAD +
"&sort=" +
Components.interfaces.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING;
if (useNewView) {
const DOWNLOADS_QUERY = "place:transition=" +
Components.interfaces.nsINavHistoryService.TRANSITION_DOWNLOAD +
"&sort=" +
Components.interfaces.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING;
ContentArea.setContentViewForQueryString(DOWNLOADS_QUERY,
function() new DownloadsPlacesView(document.getElementById("downloadsRichListBox")));
}
ContentArea.setContentViewForQueryString(DOWNLOADS_QUERY,
function() new DownloadsPlacesView(document.getElementById("downloadsRichListBox")));
]]></script>
<window id="places">

Просмотреть файл

@ -82,7 +82,7 @@ var PlacesOrganizer = {
// Select the first item in the content area view.
let view = ContentArea.currentView;
let root = view.result ? view.result.root : null;
if (root && root.containerOpen && root.childCount >= 0)
if (root && root.containerOpen && root.childCount > 0)
view.selectNode(root.getChild(0));
ContentArea.focus();
},

Просмотреть файл

@ -15,42 +15,56 @@ let now = Date.now();
function test() {
waitForExplicitFinish();
function onLibraryReady(win) {
let onLibraryReady = function(win) {
// Add visits to compare contents with.
fastAddVisit("http://mozilla.com",
PlacesUtils.history.TRANSITION_TYPED);
fastAddVisit("http://google.com",
PlacesUtils.history.TRANSITION_DOWNLOAD);
fastAddVisit("http://en.wikipedia.org",
PlacesUtils.history.TRANSITION_TYPED);
fastAddVisit("http://ubuntu.org",
PlacesUtils.history.TRANSITION_DOWNLOAD);
let places = [
{ uri: NetUtil.newURI("http://mozilla.com"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_TYPED) ]
},
{ uri: NetUtil.newURI("http://google.com"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_DOWNLOAD) ]
},
{ uri: NetUtil.newURI("http://en.wikipedia.org"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_TYPED) ]
},
{ uri: NetUtil.newURI("http://ubuntu.org"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_DOWNLOAD) ]
},
]
PlacesUtils.asyncHistory.updatePlaces(places, {
handleResult: function () {},
handleError: function () {
ok(false, "gHistory.updatePlaces() failed");
},
handleCompletion: function () {
// Make sure Downloads is present.
isnot(win.PlacesOrganizer._places.selectedNode, null,
"Downloads is present and selected");
// Make sure Downloads is present.
isnot(win.PlacesOrganizer._places.selectedNode, null,
"Downloads is present and selected");
// Make sure content in right pane exists.
let tree = win.document.getElementById("placeContent");
isnot(tree, null, "placeContent tree exists");
// Check results.
let contentRoot = win.ContentArea.currentView.result.root;
let len = contentRoot.childCount;
const TEST_URIS = ["http://ubuntu.org/", "http://google.com/"];
for (let i = 0; i < len; i++) {
is(contentRoot.getChild(i).uri, TEST_URIS[i],
"Comparing downloads shown at index " + i);
}
// Check results.
var contentRoot = tree.result.root;
var len = contentRoot.childCount;
var testUris = ["http://ubuntu.org/", "http://google.com/"];
for (var i = 0; i < len; i++) {
is(contentRoot.getChild(i).uri, testUris[i],
"Comparing downloads shown at index " + i);
}
win.close();
waitForClearHistory(finish);
win.close();
waitForClearHistory(finish);
}
})
}
openLibrary(onLibraryReady, "Downloads");
}
function fastAddVisit(uri, transition) {
PlacesUtils.history.addVisit(PlacesUtils._uri(uri), now++ * 1000,
null, transition, false, 0);
function VisitInfo(aTransitionType)
{
this.transitionType =
aTransitionType === undefined ?
PlacesUtils.history.TRANSITION_LINK : aTransitionType;
this.visitDate = now++ * 1000;
}
VisitInfo.prototype = {}