52 var
Cc = Components.classes;
53 var
Ci = Components.interfaces;
54 var
Cr = Components.results;
68 "browser.download.hide_plugins_without_extensions";
121 const ICON_URL_APP =
"chrome://browser/skin/preferences/application.png";
137 if (aFile instanceof
Ci.nsILocalFileWin) {
139 return aFile.getVersionInfoField(
"FileDescription");
149 if (aFile instanceof
Ci.nsILocalFileMac) {
151 return aFile.bundleDisplayName;
161 return Cc[
"@mozilla.org/network/io-service;1"].
169 var localHandlerApp =
Cc[
"@mozilla.org/uriloader/local-handler-app;1"].
172 localHandlerApp.executable = aFile;
174 return localHandlerApp;
186 this._contents = aItems;
193 return this._index < this._contents.length;
196 getNext:
function() {
197 return this._contents[this._index++];
225 this.wrappedHandlerInfo = aHandlerInfo;
232 wrappedHandlerInfo:
null,
238 _handlerSvc:
Cc[
"@mozilla.org/uriloader/handler-service;1"].
243 _prefSvc:
Cc[
"@mozilla.org/preferences-service;1"].
247 _categoryMgr:
Cc[
"@mozilla.org/categorymanager;1"].
251 return document.getElementById(aID);
265 if (this.wrappedHandlerInfo.description)
266 return this.wrappedHandlerInfo.description;
268 if (this.primaryExtension) {
269 var extension = this.primaryExtension.toUpperCase();
270 return this.
element(
"bundlePreferences").getFormattedString(
"fileEnding",
277 get preferredApplicationHandler() {
278 return this.wrappedHandlerInfo.preferredApplicationHandler;
281 set preferredApplicationHandler(aNewValue) {
282 this.wrappedHandlerInfo.preferredApplicationHandler = aNewValue;
286 this.addPossibleApplicationHandler(aNewValue)
289 get possibleApplicationHandlers() {
290 return this.wrappedHandlerInfo.possibleApplicationHandlers;
293 addPossibleApplicationHandler:
function(aNewHandler) {
294 var possibleApps = this.possibleApplicationHandlers.enumerate();
295 while (possibleApps.hasMoreElements()) {
296 if (possibleApps.getNext().equals(aNewHandler))
299 this.possibleApplicationHandlers.appendElement(aNewHandler,
false);
302 removePossibleApplicationHandler:
function(aHandler) {
303 var defaultApp = this.preferredApplicationHandler;
304 if (defaultApp && aHandler.equals(defaultApp)) {
307 this.alwaysAskBeforeHandling =
true;
308 this.preferredApplicationHandler =
null;
311 var
handlers = this.possibleApplicationHandlers;
312 for (var
i = 0;
i < handlers.length; ++
i) {
313 var
handler = handlers.queryElementAt(
i,
Ci.nsIHandlerApp);
314 if (handler.equals(aHandler)) {
315 handlers.removeElementAt(
i);
321 get hasDefaultHandler() {
322 return this.wrappedHandlerInfo.hasDefaultHandler;
325 get defaultDescription() {
326 return this.wrappedHandlerInfo.defaultDescription;
330 get preferredAction() {
332 if (this.plugin && !this.isDisabledPluginType)
341 if (this.wrappedHandlerInfo.preferredAction ==
Ci.nsIHandlerInfo.useHelperApp &&
342 !gApplicationsPane.isValidHandlerApp(
this.preferredApplicationHandler)) {
343 if (this.wrappedHandlerInfo.hasDefaultHandler)
344 return Ci.nsIHandlerInfo.useSystemDefault;
346 return Ci.nsIHandlerInfo.saveToDisk;
349 return this.wrappedHandlerInfo.preferredAction;
352 set preferredAction(aNewValue) {
359 this.wrappedHandlerInfo.preferredAction = aNewValue;
362 get alwaysAskBeforeHandling() {
368 if (this.plugin && this.handledOnlyByPlugin)
377 if (!(this.wrappedHandlerInfo instanceof
Ci.nsIMIMEInfo) &&
378 this.preferredAction ==
Ci.nsIHandlerInfo.saveToDisk)
381 return this.wrappedHandlerInfo.alwaysAskBeforeHandling;
384 set alwaysAskBeforeHandling(aNewValue) {
385 this.wrappedHandlerInfo.alwaysAskBeforeHandling = aNewValue;
397 get primaryExtension() {
399 if (this.wrappedHandlerInfo instanceof
Ci.nsIMIMEInfo &&
400 this.wrappedHandlerInfo.primaryExtension)
401 return this.wrappedHandlerInfo.primaryExtension
430 handledOnlyByPlugin: undefined,
432 get isDisabledPluginType() {
433 return this._getDisabledPluginTypes().indexOf(this.type) != -1;
436 _getDisabledPluginTypes:
function() {
445 return types.split(
",");
450 disablePluginType:
function() {
451 var disabledPluginTypes = this._getDisabledPluginTypes();
453 if (disabledPluginTypes.indexOf(
this.type) == -1)
454 disabledPluginTypes.push(
this.type);
457 disabledPluginTypes.join(
","));
460 this._categoryMgr.deleteCategoryEntry(
"Gecko-Content-Viewers",
465 enablePluginType:
function() {
466 var disabledPluginTypes = this._getDisabledPluginTypes();
468 var type = this.type;
469 disabledPluginTypes = disabledPluginTypes.filter(
function(v) v != type);
472 disabledPluginTypes.join(
","));
476 addCategoryEntry(
"Gecko-Content-Viewers",
478 "@mozilla.org/content/plugin/document-loader-factory;1",
488 this._handlerSvc.store(this.wrappedHandlerInfo);
496 return this._getIcon(16);
500 return this._getIcon(32);
503 _getIcon:
function(aSize) {
504 if (this.primaryExtension)
505 return "moz-icon://goat." + this.primaryExtension +
"?size=" + aSize;
507 if (this.wrappedHandlerInfo instanceof
Ci.nsIMIMEInfo)
508 return "moz-icon://goat?size=" + aSize +
"&contentType=" + this.type;
546 Cc[
"@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
550 #ifdef HAVE_SHELL_SERVICE
561 return this.
element(
"bundlePreferences").getString(this._appPrefLabel);
564 get preferredApplicationHandler() {
567 var
file = this.
element(this._prefSelectedApp).value;
574 var
uri = this.
element(this._prefSelectedWeb).value;
577 return this._converterSvc.getWebContentHandlerByURI(this.type, uri);
588 set preferredApplicationHandler(aNewValue) {
589 if (aNewValue instanceof
Ci.nsILocalHandlerApp) {
590 this.
element(this._prefSelectedApp).value = aNewValue.executable;
591 this.
element(this._prefSelectedReader).value =
"client";
593 else if (aNewValue instanceof
Ci.nsIWebContentHandlerInfo) {
594 this.
element(this._prefSelectedWeb).value = aNewValue.uri;
595 this.
element(this._prefSelectedReader).value =
"web";
602 this._converterSvc.setAutoHandler(this.type, aNewValue);
606 _possibleApplicationHandlers:
null,
608 get possibleApplicationHandlers() {
609 if (this._possibleApplicationHandlers)
610 return this._possibleApplicationHandlers;
614 this._possibleApplicationHandlers = {
619 if (aIID.equals(
Ci.nsIMutableArray) ||
620 aIID.equals(
Ci.nsIArray) ||
621 aIID.equals(
Ci.nsISupports))
624 throw Cr.NS_ERROR_NO_INTERFACE;
628 return this._inner.length;
635 appendElement:
function(aHandlerApp, aWeak) {
636 this._inner.push(aHandlerApp);
639 removeElementAt:
function(aIndex) {
640 this._removed.push(this._inner[aIndex]);
641 this._inner.splice(aIndex, 1);
644 queryElementAt:
function(aIndex, aInterface) {
645 return this._inner[aIndex].QueryInterface(aInterface);
655 var preferredAppFile = this.
element(this._prefSelectedApp).value;
656 if (preferredAppFile) {
658 let defaultApp = this._defaultApplicationHandler;
659 if (!defaultApp || !defaultApp.equals(preferredApp))
660 this._possibleApplicationHandlers.appendElement(preferredApp,
false);
664 var webHandlers = this._converterSvc.getContentHandlers(this.type, {});
665 for each (let webHandler
in webHandlers)
666 this._possibleApplicationHandlers.appendElement(webHandler,
false);
668 return this._possibleApplicationHandlers;
671 __defaultApplicationHandler: undefined,
672 get _defaultApplicationHandler() {
673 if (typeof this.__defaultApplicationHandler !=
"undefined")
674 return this.__defaultApplicationHandler;
676 var defaultFeedReader =
null;
677 #ifdef HAVE_SHELL_SERVICE
679 defaultFeedReader = this._shellSvc.defaultFeedReader;
686 if (defaultFeedReader) {
687 let handlerApp =
Cc[
"@mozilla.org/uriloader/local-handler-app;1"].
690 handlerApp.QueryInterface(
Ci.nsILocalHandlerApp);
691 handlerApp.executable = defaultFeedReader;
693 this.__defaultApplicationHandler = handlerApp;
696 this.__defaultApplicationHandler =
null;
699 return this.__defaultApplicationHandler;
702 get hasDefaultHandler() {
703 #ifdef HAVE_SHELL_SERVICE
705 if (this._shellSvc.defaultFeedReader)
716 get defaultDescription() {
717 if (this.hasDefaultHandler)
718 return this._defaultApplicationHandler.name;
725 get preferredAction() {
726 switch (this.
element(this._prefSelectedAction).value) {
729 return Ci.nsIHandlerInfo.handleInternally;
732 let preferredApp = this.preferredApplicationHandler;
733 let defaultApp = this._defaultApplicationHandler;
737 if (gApplicationsPane.isValidHandlerApp(preferredApp)) {
738 if (defaultApp && defaultApp.equals(preferredApp))
739 return Ci.nsIHandlerInfo.useSystemDefault;
741 return Ci.nsIHandlerInfo.useHelperApp;
748 return Ci.nsIHandlerInfo.handleInternally;
756 return Ci.nsIHandlerInfo.handleInternally;
760 set preferredAction(aNewValue) {
763 case Ci.nsIHandlerInfo.handleInternally:
764 this.
element(this._prefSelectedReader).value =
"bookmarks";
767 case Ci.nsIHandlerInfo.useHelperApp:
768 this.
element(this._prefSelectedAction).value =
"reader";
773 case Ci.nsIHandlerInfo.useSystemDefault:
774 this.
element(this._prefSelectedAction).value =
"reader";
775 this.preferredApplicationHandler = this._defaultApplicationHandler;
780 get alwaysAskBeforeHandling() {
781 return this.
element(this._prefSelectedAction).value ==
"ask";
784 set alwaysAskBeforeHandling(aNewValue) {
785 if (aNewValue ==
true)
786 this.
element(this._prefSelectedAction).value =
"ask";
788 this.
element(this._prefSelectedAction).value =
"reader";
797 _storingAction:
false,
803 get primaryExtension() {
817 for each (let app
in this._possibleApplicationHandlers._removed) {
818 if (app instanceof
Ci.nsILocalHandlerApp) {
820 var preferredAppFile = pref.value;
821 if (preferredAppFile) {
823 if (app.equals(preferredApp))
828 app.QueryInterface(
Ci.nsIWebContentHandlerInfo);
829 this._converterSvc.removeContentHandler(app.contentType, app.uri);
832 this._possibleApplicationHandlers._removed = [];
840 return this._smallIcon;
844 return this._largeIcon;
855 _smallIcon:
"chrome://browser/skin/feeds/feedIcon16.png",
856 _largeIcon:
"chrome://browser/skin/feeds/feedIcon.png",
857 _appPrefLabel:
"webFeed"
860 var videoFeedHandlerInfo = {
866 _smallIcon:
"chrome://browser/skin/feeds/videoFeedIcon16.png",
867 _largeIcon:
"chrome://browser/skin/feeds/videoFeedIcon.png",
868 _appPrefLabel:
"videoPodcastFeed"
871 var audioFeedHandlerInfo = {
877 _smallIcon:
"chrome://browser/skin/feeds/audioFeedIcon16.png",
878 _largeIcon:
"chrome://browser/skin/feeds/audioFeedIcon.png",
879 _appPrefLabel:
"audioPodcastFeed"
886 var gApplicationsPane = {
904 _visibleTypeDescriptionCount: {},
911 _brandShortName :
null,
918 _prefSvc :
Cc[
"@mozilla.org/preferences-service;1"].
922 _mimeSvc :
Cc[
"@mozilla.org/mime;1"].
925 _helperAppSvc :
Cc[
"@mozilla.org/uriloader/external-helper-app-service;1"].
928 _handlerSvc :
Cc[
"@mozilla.org/uriloader/handler-service;1"].
931 _ioSvc :
Cc[
"@mozilla.org/network/io-service;1"].
940 this._brandShortName =
941 document.getElementById(
"bundleBrand").getString(
"brandShortName");
942 this._prefsBundle = document.getElementById(
"bundlePreferences");
943 this._list = document.getElementById(
"handlersView");
944 this._filter = document.getElementById(
"filter");
967 window.addEventListener(
"unload",
this,
false);
972 if (document.getElementById(
"actionColumn").hasAttribute(
"sortDirection")) {
973 this._sortColumn = document.getElementById(
"actionColumn");
978 document.getElementById(
"typeColumn").removeAttribute(
"sortDirection");
981 this._sortColumn = document.getElementById(
"typeColumn");
990 var _delayedPaneLoad =
function(
self) {
992 self._rebuildVisibleTypes();
993 self._sortVisibleTypes();
997 Cc[
"@mozilla.org/observer-service;1"].getService(
Ci.nsIObserverService).
1003 destroy:
function() {
1004 window.removeEventListener(
"unload",
this,
false);
1028 if (aIID.equals(
Ci.nsIObserver) ||
1029 aIID.equals(
Ci.nsIDOMEventListener ||
1030 aIID.equals(
Ci.nsISupports)))
1033 throw Cr.NS_ERROR_NO_INTERFACE;
1043 if (aTopic ==
"nsPref:changed" && !this._storingAction) {
1048 this._rebuildVisibleTypes();
1049 this._sortVisibleTypes();
1054 this._rebuildView();
1062 handleEvent:
function(aEvent) {
1063 if (aEvent.type ==
"unload") {
1072 _loadData:
function() {
1073 this._loadFeedHandler();
1074 this._loadPluginHandlers();
1075 this._loadApplicationHandlers();
1078 _loadFeedHandler:
function() {
1080 feedHandlerInfo.handledOnlyByPlugin =
false;
1083 videoFeedHandlerInfo.handledOnlyByPlugin =
false;
1086 audioFeedHandlerInfo.handledOnlyByPlugin =
false;
1109 _loadPluginHandlers:
function() {
1110 for (let
i = 0;
i < navigator.plugins.length; ++
i) {
1111 let plugin = navigator.plugins[
i];
1112 for (let j = 0; j < plugin.length; ++j) {
1113 let type = plugin[j].type;
1115 let handlerInfoWrapper;
1116 if (type in this._handledTypes)
1117 handlerInfoWrapper = this._handledTypes[type];
1119 let wrappedHandlerInfo =
1120 this._mimeSvc.getFromTypeAndExtension(type,
null);
1122 handlerInfoWrapper.handledOnlyByPlugin =
true;
1123 this._handledTypes[type] = handlerInfoWrapper;
1126 handlerInfoWrapper.plugin = plugin;
1134 _loadApplicationHandlers:
function() {
1135 var wrappedHandlerInfos = this._handlerSvc.enumerate();
1136 while (wrappedHandlerInfos.hasMoreElements()) {
1137 let wrappedHandlerInfo =
1138 wrappedHandlerInfos.getNext().QueryInterface(
Ci.nsIHandlerInfo);
1139 let type = wrappedHandlerInfo.type;
1141 let handlerInfoWrapper;
1142 if (type in this._handledTypes)
1143 handlerInfoWrapper = this._handledTypes[type];
1146 this._handledTypes[type] = handlerInfoWrapper;
1149 handlerInfoWrapper.handledOnlyByPlugin =
false;
1157 _rebuildVisibleTypes:
function() {
1159 this._visibleTypes = [];
1160 this._visibleTypeDescriptionCount = {};
1164 var hidePluginsWithoutExtensions =
1167 for (let type in this._handledTypes) {
1168 let handlerInfo = this._handledTypes[type];
1177 if (hidePluginsWithoutExtensions && handlerInfo.handledOnlyByPlugin &&
1178 handlerInfo.wrappedHandlerInfo instanceof
Ci.nsIMIMEInfo &&
1179 !handlerInfo.primaryExtension)
1183 if (handlerInfo.handledOnlyByPlugin && !showPlugins)
1187 this._visibleTypes.push(handlerInfo);
1189 if (handlerInfo.description in
this._visibleTypeDescriptionCount)
1190 this._visibleTypeDescriptionCount[handlerInfo.description]++;
1192 this._visibleTypeDescriptionCount[handlerInfo.description] = 1;
1196 _rebuildView:
function() {
1198 while (this._list.childNodes.length > 1)
1199 this._list.removeChild(this._list.lastChild);
1201 var visibleTypes = this._visibleTypes;
1204 if (this._filter.value)
1205 visibleTypes = visibleTypes.filter(this._matchesFilter,
this);
1207 for each (let visibleType
in visibleTypes) {
1208 let item = document.createElement(
"richlistitem");
1209 item.setAttribute(
"type", visibleType.type);
1210 item.setAttribute(
"typeDescription", this._describeType(visibleType));
1211 if (visibleType.smallIcon)
1212 item.setAttribute(
"typeIcon", visibleType.smallIcon);
1213 item.setAttribute(
"actionDescription",
1214 this._describePreferredAction(visibleType));
1216 if (!this._setIconClassForPreferredAction(visibleType, item)) {
1217 item.setAttribute(
"actionIcon",
1218 this._getIconURLForPreferredAction(visibleType));
1221 this._list.appendChild(item);
1224 this._selectLastSelectedType();
1227 _matchesFilter:
function(aType) {
1228 var filterValue = this._filter.value.toLowerCase();
1229 return this._describeType(aType).toLowerCase().indexOf(filterValue) != -1 ||
1230 this._describePreferredAction(aType).toLowerCase().indexOf(filterValue) != -1;
1243 _describeType:
function(aHandlerInfo) {
1244 if (this._visibleTypeDescriptionCount[aHandlerInfo.description] > 1)
1245 return this._prefsBundle.getFormattedString(
"typeDescriptionWithType",
1246 [aHandlerInfo.description,
1247 aHandlerInfo.type]);
1249 return aHandlerInfo.description;
1264 _describePreferredAction:
function(aHandlerInfo) {
1268 if (aHandlerInfo.alwaysAskBeforeHandling) {
1270 return this._prefsBundle.getFormattedString(
"previewInApp",
1271 [
this._brandShortName]);
1273 return this._prefsBundle.getString(
"alwaysAsk");
1276 switch (aHandlerInfo.preferredAction) {
1277 case Ci.nsIHandlerInfo.saveToDisk:
1278 return this._prefsBundle.getString(
"saveFile");
1280 case Ci.nsIHandlerInfo.useHelperApp:
1281 var preferredApp = aHandlerInfo.preferredApplicationHandler;
1283 if (preferredApp instanceof
Ci.nsILocalHandlerApp)
1286 name = preferredApp.name;
1287 return this._prefsBundle.getFormattedString(
"useApp", [name]);
1289 case Ci.nsIHandlerInfo.handleInternally:
1292 return this._prefsBundle.getFormattedString(
"addLiveBookmarksInApp",
1293 [this._brandShortName]);
1298 if (this.isValidHandlerApp(aHandlerInfo.preferredApplicationHandler))
1299 return aHandlerInfo.preferredApplicationHandler.name;
1301 return aHandlerInfo.defaultDescription;
1308 case Ci.nsIHandlerInfo.useSystemDefault:
1309 return this._prefsBundle.getFormattedString(
"useDefault",
1310 [aHandlerInfo.defaultDescription]);
1313 return this._prefsBundle.getFormattedString(
"usePluginIn",
1314 [aHandlerInfo.plugin.name,
1315 this._brandShortName]);
1319 _selectLastSelectedType:
function() {
1324 if (this._list.disabled)
1327 var lastSelectedType = this._list.getAttribute(
"lastSelectedType");
1328 if (!lastSelectedType)
1331 var item = this._list.getElementsByAttribute(
"type", lastSelectedType)[0];
1335 this._list.selectedItem = item;
1345 isValidHandlerApp:
function(aHandlerApp) {
1349 if (aHandlerApp instanceof
Ci.nsILocalHandlerApp)
1350 return this._isValidHandlerExecutable(aHandlerApp.executable);
1352 if (aHandlerApp instanceof
Ci.nsIWebHandlerApp)
1353 return aHandlerApp.uriTemplate;
1355 if (aHandlerApp instanceof
Ci.nsIWebContentHandlerInfo)
1356 return aHandlerApp.uri;
1361 _isValidHandlerExecutable:
function(aExecutable) {
1362 return aExecutable &&
1363 aExecutable.exists() &&
1364 aExecutable.isExecutable() &&
1369 #expand aExecutable.leafName != "__MOZ_APP_NAME__.exe";
1372 #expand aExecutable.leafName != "__MOZ_APP_DISPLAYNAME__.app";
1374 #expand aExecutable.leafName != "__MOZ_APP_NAME__-bin";
1383 rebuildActionsMenu:
function() {
1384 var typeItem = this._list.selectedItem;
1385 var handlerInfo = this._handledTypes[typeItem.type];
1387 document.getAnonymousElementByAttribute(typeItem,
"class",
"actionsMenu");
1388 var menuPopup = menu.menupopup;
1391 while (menuPopup.hasChildNodes())
1392 menuPopup.removeChild(menuPopup.lastChild);
1395 var askMenuItem = document.createElement(
"menuitem");
1396 askMenuItem.setAttribute(
"alwaysAsk",
"true");
1399 label = this._prefsBundle.getFormattedString(
"previewInApp",
1400 [this._brandShortName]);
1402 label = this._prefsBundle.getString(
"alwaysAsk");
1403 askMenuItem.setAttribute(
"label", label);
1404 askMenuItem.setAttribute(
"tooltiptext", label);
1406 menuPopup.appendChild(askMenuItem);
1413 if ((handlerInfo.wrappedHandlerInfo instanceof
Ci.nsIMIMEInfo) &&
1415 var saveMenuItem = document.createElement(
"menuitem");
1416 saveMenuItem.setAttribute(
"action",
Ci.nsIHandlerInfo.saveToDisk);
1417 let label = this._prefsBundle.getString(
"saveFile");
1418 saveMenuItem.setAttribute(
"label", label);
1419 saveMenuItem.setAttribute(
"tooltiptext", label);
1421 menuPopup.appendChild(saveMenuItem);
1426 var internalMenuItem = document.createElement(
"menuitem");
1427 internalMenuItem.setAttribute(
"action",
Ci.nsIHandlerInfo.handleInternally);
1428 let label = this._prefsBundle.getFormattedString(
"addLiveBookmarksInApp",
1429 [this._brandShortName]);
1430 internalMenuItem.setAttribute(
"label", label);
1431 internalMenuItem.setAttribute(
"tooltiptext", label);
1433 menuPopup.appendChild(internalMenuItem);
1438 let
menuItem = document.createElement(
"menuseparator");
1439 menuPopup.appendChild(menuItem);
1442 if (handlerInfo.hasDefaultHandler) {
1443 var defaultMenuItem = document.createElement(
"menuitem");
1444 defaultMenuItem.setAttribute(
"action",
Ci.nsIHandlerInfo.useSystemDefault);
1445 let label = this._prefsBundle.getFormattedString(
"useDefault",
1446 [handlerInfo.defaultDescription]);
1447 defaultMenuItem.setAttribute(
"label", label);
1448 defaultMenuItem.setAttribute(
"tooltiptext", handlerInfo.defaultDescription);
1449 defaultMenuItem.setAttribute(
"image", this._getIconURLForSystemDefault(handlerInfo));
1451 menuPopup.appendChild(defaultMenuItem);
1455 let preferredApp = handlerInfo.preferredApplicationHandler;
1456 let possibleApps = handlerInfo.possibleApplicationHandlers.enumerate();
1457 var possibleAppMenuItems = [];
1458 while (possibleApps.hasMoreElements()) {
1459 let possibleApp = possibleApps.getNext();
1460 if (!this.isValidHandlerApp(possibleApp))
1463 let menuItem = document.createElement(
"menuitem");
1464 menuItem.setAttribute(
"action",
Ci.nsIHandlerInfo.useHelperApp);
1466 if (possibleApp instanceof
Ci.nsILocalHandlerApp)
1469 label = possibleApp.name;
1470 label = this._prefsBundle.getFormattedString(
"useApp", [label]);
1471 menuItem.setAttribute(
"label", label);
1472 menuItem.setAttribute(
"tooltiptext", label);
1473 menuItem.setAttribute(
"image", this._getIconURLForHandlerApp(possibleApp));
1477 menuItem.handlerApp = possibleApp;
1479 menuPopup.appendChild(menuItem);
1480 possibleAppMenuItems.push(menuItem);
1484 if (handlerInfo.plugin) {
1485 var pluginMenuItem = document.createElement(
"menuitem");
1487 let label = this._prefsBundle.getFormattedString(
"usePluginIn",
1488 [handlerInfo.plugin.name,
1489 this._brandShortName]);
1490 pluginMenuItem.setAttribute(
"label", label);
1491 pluginMenuItem.setAttribute(
"tooltiptext", label);
1493 menuPopup.appendChild(pluginMenuItem);
1500 var executableType =
Cc[
"@mozilla.org/mime;1"].getService(
Ci.nsIMIMEService)
1501 .getTypeFromExtension(
"exe");
1502 if (handlerInfo.type != executableType)
1505 let menuItem = document.createElement(
"menuitem");
1506 menuItem.setAttribute(
"oncommand",
"gApplicationsPane.chooseApp(event)");
1507 let label = this._prefsBundle.getString(
"useOtherApp");
1508 menuItem.setAttribute(
"label", label);
1509 menuItem.setAttribute(
"tooltiptext", label);
1510 menuPopup.appendChild(menuItem);
1514 if (possibleAppMenuItems.length) {
1515 let menuItem = document.createElement(
"menuseparator");
1516 menuPopup.appendChild(menuItem);
1517 menuItem = document.createElement(
"menuitem");
1518 menuItem.setAttribute(
"oncommand",
"gApplicationsPane.manageApp(event)");
1519 menuItem.setAttribute(
"label", this._prefsBundle.getString(
"manageApp"));
1520 menuPopup.appendChild(menuItem);
1527 if (handlerInfo.alwaysAskBeforeHandling)
1528 menu.selectedItem = askMenuItem;
1529 else switch (handlerInfo.preferredAction) {
1530 case Ci.nsIHandlerInfo.handleInternally:
1531 menu.selectedItem = internalMenuItem;
1533 case Ci.nsIHandlerInfo.useSystemDefault:
1534 menu.selectedItem = defaultMenuItem;
1536 case Ci.nsIHandlerInfo.useHelperApp:
1539 possibleAppMenuItems.filter(
function(v) v.handlerApp.equals(preferredApp))[0];
1542 menu.selectedItem = pluginMenuItem;
1544 case Ci.nsIHandlerInfo.saveToDisk:
1545 menu.selectedItem = saveMenuItem;
1559 sort:
function (
event) {
1560 var column =
event.target;
1564 if (this._sortColumn && this._sortColumn != column)
1565 this._sortColumn.removeAttribute(
"sortDirection");
1567 this._sortColumn = column;
1570 if (column.getAttribute(
"sortDirection") ==
"ascending")
1571 column.setAttribute(
"sortDirection",
"descending");
1573 column.setAttribute(
"sortDirection",
"ascending");
1575 this._sortVisibleTypes();
1576 this._rebuildView();
1582 _sortVisibleTypes:
function() {
1583 if (!this._sortColumn)
1588 function sortByType(a, b) {
1589 return t._describeType(a).toLowerCase().
1590 localeCompare(t._describeType(b).toLowerCase());
1593 function sortByAction(a, b) {
1594 return t._describePreferredAction(a).toLowerCase().
1595 localeCompare(t._describePreferredAction(b).toLowerCase());
1598 switch (this._sortColumn.getAttribute(
"value")) {
1600 this._visibleTypes.sort(sortByType);
1603 this._visibleTypes.sort(sortByAction);
1607 if (this._sortColumn.getAttribute(
"sortDirection") ==
"descending")
1608 this._visibleTypes.reverse();
1615 this._rebuildView();
1618 focusFilterBox:
function() {
1619 this._filter.focus();
1620 this._filter.select();
1627 onSelectAction:
function(aActionItem) {
1628 this._storingAction =
true;
1631 this._storeAction(aActionItem);
1634 this._storingAction =
false;
1638 _storeAction:
function(aActionItem) {
1639 var typeItem = this._list.selectedItem;
1640 var handlerInfo = this._handledTypes[typeItem.type];
1642 if (aActionItem.hasAttribute(
"alwaysAsk")) {
1643 handlerInfo.alwaysAskBeforeHandling =
true;
1645 else if (aActionItem.hasAttribute(
"action")) {
1646 let action = parseInt(aActionItem.getAttribute(
"action"));
1650 handlerInfo.enablePluginType();
1651 else if (handlerInfo.plugin && !handlerInfo.isDisabledPluginType)
1652 handlerInfo.disablePluginType();
1660 if (action ==
Ci.nsIHandlerInfo.useHelperApp)
1661 handlerInfo.preferredApplicationHandler = aActionItem.handlerApp;
1664 handlerInfo.alwaysAskBeforeHandling =
false;
1667 handlerInfo.preferredAction = action;
1670 handlerInfo.store();
1674 handlerInfo.handledOnlyByPlugin =
false;
1677 typeItem.setAttribute(
"actionDescription",
1678 this._describePreferredAction(handlerInfo));
1679 if (!this._setIconClassForPreferredAction(handlerInfo, typeItem)) {
1680 typeItem.setAttribute(
"actionIcon",
1681 this._getIconURLForPreferredAction(handlerInfo));
1685 manageApp:
function(aEvent) {
1688 aEvent.stopPropagation();
1690 var typeItem = this._list.selectedItem;
1691 var handlerInfo = this._handledTypes[typeItem.type];
1693 document.documentElement.openSubDialog(
"chrome://browser/content/preferences/applicationManager.xul",
1698 this.rebuildActionsMenu();
1701 typeItem.setAttribute(
"actionDescription",
1702 this._describePreferredAction(handlerInfo));
1703 if (!this._setIconClassForPreferredAction(handlerInfo, typeItem)) {
1704 typeItem.setAttribute(
"actionIcon",
1705 this._getIconURLForPreferredAction(handlerInfo));
1709 chooseApp:
function(aEvent) {
1712 aEvent.stopPropagation();
1718 var handlerInfo = this._handledTypes[this._list.selectedItem.type];
1722 params.mimeInfo = this._mimeSvc.getFromTypeAndExtension(handlerInfo.type,
1723 handlerInfo.primaryExtension);
1725 params.mimeInfo = handlerInfo.wrappedHandlerInfo;
1728 params.title = this._prefsBundle.getString(
"fpTitleChooseApp");
1729 params.description = handlerInfo.description;
1730 params.filename =
null;
1731 params.handlerApp =
null;
1733 window.openDialog(
"chrome://global/content/appPicker.xul",
null,
1734 "chrome,modal,centerscreen,titlebar,dialog=yes",
1737 if (params.handlerApp &&
1738 params.handlerApp.executable &&
1739 params.handlerApp.executable.isFile()) {
1740 handlerApp = params.handlerApp;
1743 handlerInfo.addPossibleApplicationHandler(handlerApp);
1746 var fp =
Cc[
"@mozilla.org/filepicker;1"].createInstance(
Ci.nsIFilePicker);
1747 var winTitle = this._prefsBundle.getString(
"fpTitleChooseApp");
1748 fp.init(
window, winTitle,
Ci.nsIFilePicker.modeOpen);
1749 fp.appendFilters(
Ci.nsIFilePicker.filterApps);
1753 if (fp.show() ==
Ci.nsIFilePicker.returnOK && fp.file &&
1754 this._isValidHandlerExecutable(fp.file)) {
1755 handlerApp =
Cc[
"@mozilla.org/uriloader/local-handler-app;1"].
1758 handlerApp.executable = fp.file;
1761 let handlerInfo = this._handledTypes[this._list.selectedItem.type];
1762 handlerInfo.addPossibleApplicationHandler(handlerApp);
1769 this.rebuildActionsMenu();
1773 let typeItem = this._list.selectedItem;
1775 document.getAnonymousElementByAttribute(typeItem,
"class",
"actionsMenu");
1776 let menuItems = actionsMenu.menupopup.childNodes;
1777 for (let
i = 0;
i < menuItems.length;
i++) {
1778 let menuItem = menuItems[
i];
1779 if (menuItem.handlerApp && menuItem.handlerApp.equals(handlerApp)) {
1780 actionsMenu.selectedIndex =
i;
1781 this.onSelectAction(menuItem);
1790 onSelectionChanged:
function() {
1791 if (this._list.selectedItem)
1792 this._list.setAttribute(
"lastSelectedType",
1793 this._list.selectedItem.getAttribute(
"type"));
1796 _setIconClassForPreferredAction:
function(aHandlerInfo, aElement) {
1800 aElement.removeAttribute(
"actionIcon");
1802 if (aHandlerInfo.alwaysAskBeforeHandling) {
1807 switch (aHandlerInfo.preferredAction) {
1808 case Ci.nsIHandlerInfo.saveToDisk:
1812 case Ci.nsIHandlerInfo.handleInternally:
1827 _getIconURLForPreferredAction:
function(aHandlerInfo) {
1828 switch (aHandlerInfo.preferredAction) {
1829 case Ci.nsIHandlerInfo.useSystemDefault:
1830 return this._getIconURLForSystemDefault(aHandlerInfo);
1832 case Ci.nsIHandlerInfo.useHelperApp:
1833 let (preferredApp = aHandlerInfo.preferredApplicationHandler) {
1834 if (this.isValidHandlerApp(preferredApp))
1835 return this._getIconURLForHandlerApp(preferredApp);
1846 _getIconURLForHandlerApp:
function(aHandlerApp) {
1847 if (aHandlerApp instanceof
Ci.nsILocalHandlerApp)
1848 return this._getIconURLForFile(aHandlerApp.executable);
1850 if (aHandlerApp instanceof
Ci.nsIWebHandlerApp)
1851 return this._getIconURLForWebApp(aHandlerApp.uriTemplate);
1853 if (aHandlerApp instanceof
Ci.nsIWebContentHandlerInfo)
1854 return this._getIconURLForWebApp(aHandlerApp.uri)
1860 _getIconURLForFile: function(aFile) {
1861 var fph = this._ioSvc.getProtocolHandler(
"file").
1863 var urlSpec = fph.getURLSpecFromFile(aFile);
1865 return "moz-icon://" + urlSpec +
"?size=16";
1868 _getIconURLForWebApp:
function(aWebAppURITemplate) {
1869 var uri = this._ioSvc.newURI(aWebAppURITemplate,
null,
null);
1878 if (/^https?/.
test(uri.scheme) &&
this._prefSvc.getBoolPref(
"browser.chrome.favicons"))
1879 return uri.prePath +
"/favicon.ico";
1884 _getIconURLForSystemDefault:
function(aHandlerInfo) {
1888 if (
"wrappedHandlerInfo" in aHandlerInfo) {
1889 let wrappedHandlerInfo = aHandlerInfo.wrappedHandlerInfo;
1891 if (wrappedHandlerInfo instanceof
Ci.nsIMIMEInfo &&
1892 wrappedHandlerInfo instanceof
Ci.nsIPropertyBag) {
1894 let
url = wrappedHandlerInfo.getProperty(
"defaultApplicationIconURL");
1896 return url +
"?size=16";
const PREF_VIDEO_FEED_SELECTED_APP
const TYPE_MAYBE_VIDEO_FEED
const TYPE_MAYBE_AUDIO_FEED
function getDisplayNameForFile(aFile)
function ArrayEnumerator(aItems)
Wraps a js array in an nsISimpleEnumerator.
const PREF_FEED_SELECTED_WEB
function getLocalHandlerApp(aFile)
function enumerate(enumerator, func)
const PREF_FEED_SELECTED_READER
sbOSDControlService prototype QueryInterface
const PREF_FEED_SELECTED_APP
getService(Ci.sbIFaceplateManager)
const PREF_FEED_SELECTED_ACTION
const PREF_AUDIO_FEED_SELECTED_APP
function FeedHandlerInfo(aMIMEType)
this _contentSandbox label
function HandlerInfoWrapper(aType, aHandlerInfo)
const PREF_VIDEO_FEED_SELECTED_WEB
const PREF_AUDIO_FEED_SELECTED_WEB
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
const PREF_DISABLED_PLUGIN_TYPES
function newFileURI(file)
const PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS
SimpleArrayEnumerator prototype hasMoreElements
const PREF_AUDIO_FEED_SELECTED_READER
const PREF_AUDIO_FEED_SELECTED_ACTION
const PREF_SHOW_PLUGINS_IN_LIST
function getShellService()
const PREF_VIDEO_FEED_SELECTED_ACTION
os notifyObservers(null,"quit-application-granted", null)
_getSelectedPageStyle s i
Array filter(tab.attributes, function(aAttr){return(_this.xulAttributes.indexOf(aAttr.name) >-1);}).forEach(tab.removeAttribute
const PREF_VIDEO_FEED_SELECTED_READER
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe