fune/browser/components/preferences/applicationManager.js
Andrew McCreight 5dec0e0beb Bug 1432992, part 1 - Remove definitions of Ci, Cr, Cc, and Cu. r=florian
This patch was autogenerated by my decomponents.py

It covers almost every file with the extension js, jsm, html, py,
xhtml, or xul.

It removes blank lines after removed lines, when the removed lines are
preceded by either blank lines or the start of a new block. The "start
of a new block" is defined fairly hackily: either the line starts with
//, ends with */, ends with {, <![CDATA[, """ or '''. The first two
cover comments, the third one covers JS, the fourth covers JS embedded
in XUL, and the final two cover JS embedded in Python. This also
applies if the removed line was the first line of the file.

It covers the pattern matching cases like "var {classes: Cc,
interfaces: Ci, utils: Cu, results: Cr} = Components;". It'll remove
the entire thing if they are all either Ci, Cr, Cc or Cu, or it will
remove the appropriate ones and leave the residue behind. If there's
only one behind, then it will turn it into a normal, non-pattern
matching variable definition. (For instance, "const { classes: Cc,
Constructor: CC, interfaces: Ci, utils: Cu } = Components" becomes
"const CC = Components.Constructor".)

MozReview-Commit-ID: DeSHcClQ7cG

--HG--
extra : rebase_source : d9c41878036c1ef7766ef5e91a7005025bc1d72b
2018-02-06 09:36:57 -08:00

100 lines
3.5 KiB
JavaScript

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/* import-globals-from in-content/main.js */
var gAppManagerDialog = {
_removed: [],
init: function appManager_init() {
this.handlerInfo = window.arguments[0];
Services.scriptloader.loadSubScript("chrome://browser/content/preferences/in-content/main.js",
window);
var pane = gMainPane;
var bundle = document.getElementById("appManagerBundle");
var contentText;
if (this.handlerInfo.type == TYPE_MAYBE_FEED)
contentText = bundle.getString("handleWebFeeds");
else {
var description = pane._describeType(this.handlerInfo);
var key =
(this.handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) ? "handleFile"
: "handleProtocol";
contentText = bundle.getFormattedString(key, [description]);
}
contentText = bundle.getFormattedString("descriptionApplications", [contentText]);
document.getElementById("appDescription").textContent = contentText;
var list = document.getElementById("appList");
var apps = this.handlerInfo.possibleApplicationHandlers.enumerate();
while (apps.hasMoreElements()) {
let app = apps.getNext();
if (!pane.isValidHandlerApp(app))
continue;
app.QueryInterface(Ci.nsIHandlerApp);
var item = list.appendItem(app.name);
item.setAttribute("image", pane._getIconURLForHandlerApp(app));
item.className = "listitem-iconic";
item.app = app;
}
list.selectedIndex = 0;
},
onOK: function appManager_onOK() {
if (!this._removed.length) {
// return early to avoid calling the |store| method.
return;
}
for (var i = 0; i < this._removed.length; ++i)
this.handlerInfo.removePossibleApplicationHandler(this._removed[i]);
this.handlerInfo.store();
},
onCancel: function appManager_onCancel() {
// do nothing
},
remove: function appManager_remove() {
var list = document.getElementById("appList");
this._removed.push(list.selectedItem.app);
var index = list.selectedIndex;
list.removeItemAt(index);
if (list.getRowCount() == 0) {
// The list is now empty, make the bottom part disappear
document.getElementById("appDetails").hidden = true;
} else {
// Select the item at the same index, if we removed the last
// item of the list, select the previous item
if (index == list.getRowCount())
--index;
list.selectedIndex = index;
}
},
onSelect: function appManager_onSelect() {
var list = document.getElementById("appList");
if (!list.selectedItem) {
document.getElementById("remove").disabled = true;
return;
}
document.getElementById("remove").disabled = false;
var app = list.selectedItem.app;
var address = "";
if (app instanceof Ci.nsILocalHandlerApp)
address = app.executable.path;
else if (app instanceof Ci.nsIWebHandlerApp)
address = app.uriTemplate;
else if (app instanceof Ci.nsIWebContentHandlerInfo)
address = app.uri;
document.getElementById("appLocation").value = address;
var bundle = document.getElementById("appManagerBundle");
var appType = app instanceof Ci.nsILocalHandlerApp ? "descriptionLocalApp"
: "descriptionWebApp";
document.getElementById("appType").value = bundle.getString(appType);
}
};