1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/preferences/applicationManager.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +#ifdef XP_MACOSX 1.9 +var Cc = Components.classes; 1.10 +var Ci = Components.interfaces; 1.11 +#endif 1.12 + 1.13 +var gAppManagerDialog = { 1.14 + _removed: [], 1.15 + 1.16 + init: function appManager_init() { 1.17 + this.handlerInfo = window.arguments[0]; 1.18 + 1.19 + var bundle = document.getElementById("appManagerBundle"); 1.20 + var contentText; 1.21 + if (this.handlerInfo.type == TYPE_MAYBE_FEED) 1.22 + contentText = bundle.getString("handleWebFeeds"); 1.23 + else { 1.24 + var description = gApplicationsPane._describeType(this.handlerInfo); 1.25 + var key = 1.26 + (this.handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) ? "handleFile" 1.27 + : "handleProtocol"; 1.28 + contentText = bundle.getFormattedString(key, [description]); 1.29 + } 1.30 + contentText = bundle.getFormattedString("descriptionApplications", [contentText]); 1.31 + document.getElementById("appDescription").textContent = contentText; 1.32 + 1.33 + var list = document.getElementById("appList"); 1.34 + var apps = this.handlerInfo.possibleApplicationHandlers.enumerate(); 1.35 + while (apps.hasMoreElements()) { 1.36 + let app = apps.getNext(); 1.37 + if (!gApplicationsPane.isValidHandlerApp(app)) 1.38 + continue; 1.39 + 1.40 + app.QueryInterface(Ci.nsIHandlerApp); 1.41 + var item = list.appendItem(app.name); 1.42 + item.setAttribute("image", gApplicationsPane._getIconURLForHandlerApp(app)); 1.43 + item.className = "listitem-iconic"; 1.44 + item.app = app; 1.45 + } 1.46 + 1.47 + list.selectedIndex = 0; 1.48 + }, 1.49 + 1.50 + onOK: function appManager_onOK() { 1.51 + if (!this._removed.length) { 1.52 + // return early to avoid calling the |store| method. 1.53 + return; 1.54 + } 1.55 + 1.56 + for (var i = 0; i < this._removed.length; ++i) 1.57 + this.handlerInfo.removePossibleApplicationHandler(this._removed[i]); 1.58 + 1.59 + this.handlerInfo.store(); 1.60 + }, 1.61 + 1.62 + onCancel: function appManager_onCancel() { 1.63 + // do nothing 1.64 + }, 1.65 + 1.66 + remove: function appManager_remove() { 1.67 + var list = document.getElementById("appList"); 1.68 + this._removed.push(list.selectedItem.app); 1.69 + var index = list.selectedIndex; 1.70 + list.removeItemAt(index); 1.71 + if (list.getRowCount() == 0) { 1.72 + // The list is now empty, make the bottom part disappear 1.73 + document.getElementById("appDetails").hidden = true; 1.74 + } 1.75 + else { 1.76 + // Select the item at the same index, if we removed the last 1.77 + // item of the list, select the previous item 1.78 + if (index == list.getRowCount()) 1.79 + --index; 1.80 + list.selectedIndex = index; 1.81 + } 1.82 + }, 1.83 + 1.84 + onSelect: function appManager_onSelect() { 1.85 + var list = document.getElementById("appList"); 1.86 + if (!list.selectedItem) { 1.87 + document.getElementById("remove").disabled = true; 1.88 + return; 1.89 + } 1.90 + document.getElementById("remove").disabled = false; 1.91 + var app = list.selectedItem.app; 1.92 + var address = ""; 1.93 + if (app instanceof Ci.nsILocalHandlerApp) 1.94 + address = app.executable.path; 1.95 + else if (app instanceof Ci.nsIWebHandlerApp) 1.96 + address = app.uriTemplate; 1.97 + else if (app instanceof Ci.nsIWebContentHandlerInfo) 1.98 + address = app.uri; 1.99 + document.getElementById("appLocation").value = address; 1.100 + var bundle = document.getElementById("appManagerBundle"); 1.101 + var appType = app instanceof Ci.nsILocalHandlerApp ? "descriptionLocalApp" 1.102 + : "descriptionWebApp"; 1.103 + document.getElementById("appType").value = bundle.getString(appType); 1.104 + } 1.105 +};