зеркало из https://github.com/mozilla/gecko-dev.git
Improve external protocol handling dialog UE (bug 402771), ui-r=beltzner, r=gavin, a=blocking-1.9+
This commit is contained in:
Родитель
e74132557d
Коммит
5953cabe8c
|
@ -21,6 +21,7 @@
|
||||||
# Contributor(s):
|
# Contributor(s):
|
||||||
# Ben Goodger <beng@google.com>
|
# Ben Goodger <beng@google.com>
|
||||||
# Asaf Romano <mano@mozilla.com>
|
# Asaf Romano <mano@mozilla.com>
|
||||||
|
# Dan Mosedale <dmose@mozilla.org>
|
||||||
#
|
#
|
||||||
# Alternatively, the contents of this file may be used under the terms of
|
# 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
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
@ -447,6 +448,12 @@ WebContentConverterRegistrar.prototype = {
|
||||||
var handlerInfo = eps.getProtocolHandlerInfo(protocol);
|
var handlerInfo = eps.getProtocolHandlerInfo(protocol);
|
||||||
handlerInfo.possibleApplicationHandlers.appendElement(handler, false);
|
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"].
|
var hs = Cc["@mozilla.org/uriloader/handler-service;1"].
|
||||||
getService(Ci.nsIHandlerService);
|
getService(Ci.nsIHandlerService);
|
||||||
hs.store(handlerInfo);
|
hs.store(handlerInfo);
|
||||||
|
|
|
@ -123,7 +123,9 @@ var dialog = {
|
||||||
*/
|
*/
|
||||||
populateList: function populateList()
|
populateList: function populateList()
|
||||||
{
|
{
|
||||||
|
var items = document.getElementById("items");
|
||||||
var possibleHandlers = this._handlerInfo.possibleApplicationHandlers;
|
var possibleHandlers = this._handlerInfo.possibleApplicationHandlers;
|
||||||
|
var preferredHandler = this._handlerInfo.preferredApplicationHandler;
|
||||||
for (let i = possibleHandlers.length - 1; i >= 0; --i) {
|
for (let i = possibleHandlers.length - 1; i >= 0; --i) {
|
||||||
let app = possibleHandlers.queryElementAt(i, Ci.nsIHandlerApp);
|
let app = possibleHandlers.queryElementAt(i, Ci.nsIHandlerApp);
|
||||||
let elm = document.createElement("richlistitem");
|
let elm = document.createElement("richlistitem");
|
||||||
|
@ -142,7 +144,9 @@ var dialog = {
|
||||||
}
|
}
|
||||||
elm.obj = app;
|
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) {
|
if (this._handlerInfo.hasDefaultHandler) {
|
||||||
|
@ -151,8 +155,12 @@ var dialog = {
|
||||||
elm.id = "os-default-handler";
|
elm.id = "os-default-handler";
|
||||||
elm.setAttribute("name", this._handlerInfo.defaultDescription);
|
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
|
//// Getters / Setters
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the selected element in the richlistbox
|
* Returns/sets the selected element in the richlistbox
|
||||||
*/
|
*/
|
||||||
get selectedItem()
|
get selectedItem()
|
||||||
{
|
{
|
||||||
return document.getElementById("items").selectedItem;
|
return document.getElementById("items").selectedItem;
|
||||||
|
},
|
||||||
|
set selectedItem(aItem)
|
||||||
|
{
|
||||||
|
return document.getElementById("items").selectedItem = aItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче