Improve external protocol handling dialog UE (bug 402771), ui-r=beltzner, r=gavin, a=blocking-1.9+

This commit is contained in:
dmose@mozilla.org 2007-12-02 17:55:12 -08:00
Родитель 694cfd8995
Коммит 7f9ec488f7
2 изменённых файлов: 23 добавлений и 3 удалений

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

@ -21,6 +21,7 @@
# Contributor(s):
# Ben Goodger <beng@google.com>
# Asaf Romano <mano@mozilla.com>
# Dan Mosedale <dmose@mozilla.org>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -447,6 +448,12 @@ WebContentConverterRegistrar.prototype = {
var handlerInfo = eps.getProtocolHandlerInfo(protocol);
handlerInfo.possibleApplicationHandlers.appendElement(handler, false);
// Since the user has agreed to add a new handler, chances are good
// that the next time they see a handler of this type, they're going
// to want to use it. Reset the handlerInfo to ask before the next
// use.
handlerInfo.alwaysAskBeforeHandling = true;
var hs = Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService);
hs.store(handlerInfo);

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

@ -123,7 +123,9 @@ var dialog = {
*/
populateList: function populateList()
{
var items = document.getElementById("items");
var possibleHandlers = this._handlerInfo.possibleApplicationHandlers;
var preferredHandler = this._handlerInfo.preferredApplicationHandler;
for (let i = possibleHandlers.length - 1; i >= 0; --i) {
let app = possibleHandlers.queryElementAt(i, Ci.nsIHandlerApp);
let elm = document.createElement("richlistitem");
@ -142,7 +144,9 @@ var dialog = {
}
elm.obj = app;
document.getElementById("items").insertBefore(elm, this._itemChoose);
items.insertBefore(elm, this._itemChoose);
if (preferredHandler && app == preferredHandler)
this.selectedItem = elm;
}
if (this._handlerInfo.hasDefaultHandler) {
@ -151,8 +155,12 @@ var dialog = {
elm.id = "os-default-handler";
elm.setAttribute("name", this._handlerInfo.defaultDescription);
document.getElementById("items").insertBefore(elm, this._itemChoose);
items.insertBefore(elm, items.firstChild);
if (this._handlerInfo.preferredAction ==
Ci.nsIHandlerInfo.useSystemDefault)
this.selectedItem = elm;
}
items.ensureSelectedElementIsVisible();
},
/**
@ -259,10 +267,15 @@ var dialog = {
//// Getters / Setters
/**
* Returns the selected element in the richlistbox
* Returns/sets the selected element in the richlistbox
*/
get selectedItem()
{
return document.getElementById("items").selectedItem;
},
set selectedItem(aItem)
{
return document.getElementById("items").selectedItem = aItem;
}
};