browser/components/preferences/applicationManager.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4
michael@0 5 #ifdef XP_MACOSX
michael@0 6 var Cc = Components.classes;
michael@0 7 var Ci = Components.interfaces;
michael@0 8 #endif
michael@0 9
michael@0 10 var gAppManagerDialog = {
michael@0 11 _removed: [],
michael@0 12
michael@0 13 init: function appManager_init() {
michael@0 14 this.handlerInfo = window.arguments[0];
michael@0 15
michael@0 16 var bundle = document.getElementById("appManagerBundle");
michael@0 17 var contentText;
michael@0 18 if (this.handlerInfo.type == TYPE_MAYBE_FEED)
michael@0 19 contentText = bundle.getString("handleWebFeeds");
michael@0 20 else {
michael@0 21 var description = gApplicationsPane._describeType(this.handlerInfo);
michael@0 22 var key =
michael@0 23 (this.handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) ? "handleFile"
michael@0 24 : "handleProtocol";
michael@0 25 contentText = bundle.getFormattedString(key, [description]);
michael@0 26 }
michael@0 27 contentText = bundle.getFormattedString("descriptionApplications", [contentText]);
michael@0 28 document.getElementById("appDescription").textContent = contentText;
michael@0 29
michael@0 30 var list = document.getElementById("appList");
michael@0 31 var apps = this.handlerInfo.possibleApplicationHandlers.enumerate();
michael@0 32 while (apps.hasMoreElements()) {
michael@0 33 let app = apps.getNext();
michael@0 34 if (!gApplicationsPane.isValidHandlerApp(app))
michael@0 35 continue;
michael@0 36
michael@0 37 app.QueryInterface(Ci.nsIHandlerApp);
michael@0 38 var item = list.appendItem(app.name);
michael@0 39 item.setAttribute("image", gApplicationsPane._getIconURLForHandlerApp(app));
michael@0 40 item.className = "listitem-iconic";
michael@0 41 item.app = app;
michael@0 42 }
michael@0 43
michael@0 44 list.selectedIndex = 0;
michael@0 45 },
michael@0 46
michael@0 47 onOK: function appManager_onOK() {
michael@0 48 if (!this._removed.length) {
michael@0 49 // return early to avoid calling the |store| method.
michael@0 50 return;
michael@0 51 }
michael@0 52
michael@0 53 for (var i = 0; i < this._removed.length; ++i)
michael@0 54 this.handlerInfo.removePossibleApplicationHandler(this._removed[i]);
michael@0 55
michael@0 56 this.handlerInfo.store();
michael@0 57 },
michael@0 58
michael@0 59 onCancel: function appManager_onCancel() {
michael@0 60 // do nothing
michael@0 61 },
michael@0 62
michael@0 63 remove: function appManager_remove() {
michael@0 64 var list = document.getElementById("appList");
michael@0 65 this._removed.push(list.selectedItem.app);
michael@0 66 var index = list.selectedIndex;
michael@0 67 list.removeItemAt(index);
michael@0 68 if (list.getRowCount() == 0) {
michael@0 69 // The list is now empty, make the bottom part disappear
michael@0 70 document.getElementById("appDetails").hidden = true;
michael@0 71 }
michael@0 72 else {
michael@0 73 // Select the item at the same index, if we removed the last
michael@0 74 // item of the list, select the previous item
michael@0 75 if (index == list.getRowCount())
michael@0 76 --index;
michael@0 77 list.selectedIndex = index;
michael@0 78 }
michael@0 79 },
michael@0 80
michael@0 81 onSelect: function appManager_onSelect() {
michael@0 82 var list = document.getElementById("appList");
michael@0 83 if (!list.selectedItem) {
michael@0 84 document.getElementById("remove").disabled = true;
michael@0 85 return;
michael@0 86 }
michael@0 87 document.getElementById("remove").disabled = false;
michael@0 88 var app = list.selectedItem.app;
michael@0 89 var address = "";
michael@0 90 if (app instanceof Ci.nsILocalHandlerApp)
michael@0 91 address = app.executable.path;
michael@0 92 else if (app instanceof Ci.nsIWebHandlerApp)
michael@0 93 address = app.uriTemplate;
michael@0 94 else if (app instanceof Ci.nsIWebContentHandlerInfo)
michael@0 95 address = app.uri;
michael@0 96 document.getElementById("appLocation").value = address;
michael@0 97 var bundle = document.getElementById("appManagerBundle");
michael@0 98 var appType = app instanceof Ci.nsILocalHandlerApp ? "descriptionLocalApp"
michael@0 99 : "descriptionWebApp";
michael@0 100 document.getElementById("appType").value = bundle.getString(appType);
michael@0 101 }
michael@0 102 };

mercurial