applications.js
Go to the documentation of this file.
1 /*
2 # -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 #
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
10 #
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
15 #
16 # The Original Code is the Download Actions Manager.
17 #
18 # The Initial Developer of the Original Code is
19 # Ben Goodger.
20 # Portions created by the Initial Developer are Copyright (C) 2000
21 # the Initial Developer. All Rights Reserved.
22 #
23 # Contributor(s):
24 # Ben Goodger <ben@mozilla.org>
25 # Jeff Walden <jwalden+code@mit.edu>
26 # Asaf Romano <mozilla.mano@sent.com>
27 # Myk Melez <myk@mozilla.org>
28 # Florian Queze <florian@queze.net>
29 # Will Guaraldi <will.guaraldi@pculture.org>
30 #
31 # Alternatively, the contents of this file may be used under the terms of
32 # either the GNU General Public License Version 2 or later (the "GPL"), or
33 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34 # in which case the provisions of the GPL or the LGPL are applicable instead
35 # of those above. If you wish to allow use of your version of this file only
36 # under the terms of either the GPL or the LGPL, and not to allow others to
37 # use your version of this file under the terms of the MPL, indicate your
38 # decision by deleting the provisions above and replace them with the notice
39 # and other provisions required by the GPL or the LGPL. If you do not delete
40 # the provisions above, a recipient may use your version of this file under
41 # the terms of any one of the MPL, the GPL or the LGPL.
42 #
43 # ***** END LICENSE BLOCK *****
44  */
45 
46 //****************************************************************************//
47 // Constants & Enumeration Values
48 
49 /*
50 #ifndef XP_MACOSX
51 */
52 var Cc = Components.classes;
53 var Ci = Components.interfaces;
54 var Cr = Components.results;
55 /*
56 #endif
57 */
58 
59 const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
60 const TYPE_MAYBE_VIDEO_FEED = "application/vnd.mozilla.maybe.video.feed";
61 const TYPE_MAYBE_AUDIO_FEED = "application/vnd.mozilla.maybe.audio.feed";
62 
63 const PREF_DISABLED_PLUGIN_TYPES = "plugin.disable_full_page_plugin_for_types";
64 
65 // Preferences that affect which entries to show in the list.
66 const PREF_SHOW_PLUGINS_IN_LIST = "browser.download.show_plugins_in_list";
68  "browser.download.hide_plugins_without_extensions";
69 
70 /*
71  * Preferences where we store handling information about the feed type.
72  *
73  * browser.feeds.handler
74  * - "bookmarks", "reader" (clarified further using the .default preference),
75  * or "ask" -- indicates the default handler being used to process feeds;
76  * "bookmarks" is obsolete; to specify that the handler is bookmarks,
77  * set browser.feeds.handler.default to "bookmarks";
78  *
79  * browser.feeds.handler.default
80  * - "bookmarks", "client" or "web" -- indicates the chosen feed reader used
81  * to display feeds, either transiently (i.e., when the "use as default"
82  * checkbox is unchecked, corresponds to when browser.feeds.handler=="ask")
83  * or more permanently (i.e., the item displayed in the dropdown in Feeds
84  * preferences)
85  *
86  * browser.feeds.handler.webservice
87  * - the URL of the currently selected web service used to read feeds
88  *
89  * browser.feeds.handlers.application
90  * - nsILocalFile, stores the current client-side feed reading app if one has
91  * been chosen
92  */
93 const PREF_FEED_SELECTED_APP = "browser.feeds.handlers.application";
94 const PREF_FEED_SELECTED_WEB = "browser.feeds.handlers.webservice";
95 const PREF_FEED_SELECTED_ACTION = "browser.feeds.handler";
96 const PREF_FEED_SELECTED_READER = "browser.feeds.handler.default";
97 
98 const PREF_VIDEO_FEED_SELECTED_APP = "browser.videoFeeds.handlers.application";
99 const PREF_VIDEO_FEED_SELECTED_WEB = "browser.videoFeeds.handlers.webservice";
100 const PREF_VIDEO_FEED_SELECTED_ACTION = "browser.videoFeeds.handler";
101 const PREF_VIDEO_FEED_SELECTED_READER = "browser.videoFeeds.handler.default";
102 
103 const PREF_AUDIO_FEED_SELECTED_APP = "browser.audioFeeds.handlers.application";
104 const PREF_AUDIO_FEED_SELECTED_WEB = "browser.audioFeeds.handlers.webservice";
105 const PREF_AUDIO_FEED_SELECTED_ACTION = "browser.audioFeeds.handler";
106 const PREF_AUDIO_FEED_SELECTED_READER = "browser.audioFeeds.handler.default";
107 
108 // The nsHandlerInfoAction enumeration values in nsIHandlerInfo identify
109 // the actions the application can take with content of various types.
110 // But since nsIHandlerInfo doesn't support plugins, there's no value
111 // identifying the "use plugin" action, so we use this constant instead.
113 
114 /*
115 #ifdef MOZ_WIDGET_GTK2
116 */
117 const ICON_URL_APP = "moz-icon://dummy.exe?size=16";
118 /*
119 #else
120 */
121 const ICON_URL_APP = "chrome://browser/skin/preferences/application.png";
122 /*
123 #endif
124 */
125 
126 // For CSS. Can be one of "ask", "save", "plugin" or "feed". If absent, the icon URL
127 // was set by us to a custom handler icon and CSS should not try to override it.
128 const APP_ICON_ATTR_NAME = "appHandlerIcon";
129 
130 //****************************************************************************//
131 // Utilities
132 
133 function getDisplayNameForFile(aFile) {
134 /*
135 #ifdef XP_WIN
136 */
137  if (aFile instanceof Ci.nsILocalFileWin) {
138  try {
139  return aFile.getVersionInfoField("FileDescription");
140  }
141  catch(ex) {
142  // fall through to the file name
143  }
144  }
145 /*
146 #endif
147 #ifdef XP_MACOSX
148 */
149  if (aFile instanceof Ci.nsILocalFileMac) {
150  try {
151  return aFile.bundleDisplayName;
152  }
153  catch(ex) {
154  // fall through to the file name
155  }
156  }
157 /*
158 #endif
159 */
160 
161  return Cc["@mozilla.org/network/io-service;1"].
162  getService(Ci.nsIIOService).
163  newFileURI(aFile).
164  QueryInterface(Ci.nsIURL).
165  fileName;
166 }
167 
168 function getLocalHandlerApp(aFile) {
169  var localHandlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
170  createInstance(Ci.nsILocalHandlerApp);
171  localHandlerApp.name = getDisplayNameForFile(aFile);
172  localHandlerApp.executable = aFile;
173 
174  return localHandlerApp;
175 }
176 
184 function ArrayEnumerator(aItems) {
185  this._index = 0;
186  this._contents = aItems;
187 }
188 
189 ArrayEnumerator.prototype = {
190  _index: 0,
191 
192  hasMoreElements: function() {
193  return this._index < this._contents.length;
194  },
195 
196  getNext: function() {
197  return this._contents[this._index++];
198  }
199 };
200 
201 function isFeedType(t) {
203 }
204 
205 //****************************************************************************//
206 // HandlerInfoWrapper
207 
223 function HandlerInfoWrapper(aType, aHandlerInfo) {
224  this._type = aType;
225  this.wrappedHandlerInfo = aHandlerInfo;
226 }
227 
228 HandlerInfoWrapper.prototype = {
229  // The wrapped nsIHandlerInfo object. In general, this object is private,
230  // but there are a couple cases where callers access it directly for things
231  // we haven't (yet?) implemented, so we make it a public property.
232  wrappedHandlerInfo: null,
233 
234 
235  //**************************************************************************//
236  // Convenience Utils
237 
238  _handlerSvc: Cc["@mozilla.org/uriloader/handler-service;1"].
239  getService(Ci.nsIHandlerService),
240 
241  // Retrieve this as nsIPrefBranch and then immediately QI to nsIPrefBranch2
242  // so both interfaces are available to callers.
243  _prefSvc: Cc["@mozilla.org/preferences-service;1"].
244  getService(Ci.nsIPrefBranch).
245  QueryInterface(Ci.nsIPrefBranch2),
246 
247  _categoryMgr: Cc["@mozilla.org/categorymanager;1"].
248  getService(Ci.nsICategoryManager),
249 
250  element: function(aID) {
251  return document.getElementById(aID);
252  },
253 
254 
255  //**************************************************************************//
256  // nsIHandlerInfo
257 
258  // The MIME type or protocol scheme.
259  _type: null,
260  get type() {
261  return this._type;
262  },
263 
264  get description() {
265  if (this.wrappedHandlerInfo.description)
266  return this.wrappedHandlerInfo.description;
267 
268  if (this.primaryExtension) {
269  var extension = this.primaryExtension.toUpperCase();
270  return this.element("bundlePreferences").getFormattedString("fileEnding",
271  [extension]);
272  }
273 
274  return this.type;
275  },
276 
277  get preferredApplicationHandler() {
278  return this.wrappedHandlerInfo.preferredApplicationHandler;
279  },
280 
281  set preferredApplicationHandler(aNewValue) {
282  this.wrappedHandlerInfo.preferredApplicationHandler = aNewValue;
283 
284  // Make sure the preferred handler is in the set of possible handlers.
285  if (aNewValue)
286  this.addPossibleApplicationHandler(aNewValue)
287  },
288 
289  get possibleApplicationHandlers() {
290  return this.wrappedHandlerInfo.possibleApplicationHandlers;
291  },
292 
293  addPossibleApplicationHandler: function(aNewHandler) {
294  var possibleApps = this.possibleApplicationHandlers.enumerate();
295  while (possibleApps.hasMoreElements()) {
296  if (possibleApps.getNext().equals(aNewHandler))
297  return;
298  }
299  this.possibleApplicationHandlers.appendElement(aNewHandler, false);
300  },
301 
302  removePossibleApplicationHandler: function(aHandler) {
303  var defaultApp = this.preferredApplicationHandler;
304  if (defaultApp && aHandler.equals(defaultApp)) {
305  // If the app we remove was the default app, we must make sure
306  // it won't be used anymore
307  this.alwaysAskBeforeHandling = true;
308  this.preferredApplicationHandler = null;
309  }
310 
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);
316  break;
317  }
318  }
319  },
320 
321  get hasDefaultHandler() {
322  return this.wrappedHandlerInfo.hasDefaultHandler;
323  },
324 
325  get defaultDescription() {
326  return this.wrappedHandlerInfo.defaultDescription;
327  },
328 
329  // What to do with content of this type.
330  get preferredAction() {
331  // If we have an enabled plugin, then the action is to use that plugin.
332  if (this.plugin && !this.isDisabledPluginType)
333  return kActionUsePlugin;
334 
335  // If the action is to use a helper app, but we don't have a preferred
336  // handler app, then switch to using the system default, if any; otherwise
337  // fall back to saving to disk, which is the default action in nsMIMEInfo.
338  // Note: "save to disk" is an invalid value for protocol info objects,
339  // but the alwaysAskBeforeHandling getter will detect that situation
340  // and always return true in that case to override this invalid value.
341  if (this.wrappedHandlerInfo.preferredAction == Ci.nsIHandlerInfo.useHelperApp &&
342  !gApplicationsPane.isValidHandlerApp(this.preferredApplicationHandler)) {
343  if (this.wrappedHandlerInfo.hasDefaultHandler)
344  return Ci.nsIHandlerInfo.useSystemDefault;
345  else
346  return Ci.nsIHandlerInfo.saveToDisk;
347  }
348 
349  return this.wrappedHandlerInfo.preferredAction;
350  },
351 
352  set preferredAction(aNewValue) {
353  // We don't modify the preferred action if the new action is to use a plugin
354  // because handler info objects don't understand our custom "use plugin"
355  // value. Also, leaving it untouched means that we can automatically revert
356  // to the old setting if the user ever removes the plugin.
357 
358  if (aNewValue != kActionUsePlugin)
359  this.wrappedHandlerInfo.preferredAction = aNewValue;
360  },
361 
362  get alwaysAskBeforeHandling() {
363  // If this type is handled only by a plugin, we can't trust the value
364  // in the handler info object, since it'll be a default based on the absence
365  // of any user configuration, and the default in that case is to always ask,
366  // even though we never ask for content handled by a plugin, so special case
367  // plugin-handled types by returning false here.
368  if (this.plugin && this.handledOnlyByPlugin)
369  return false;
370 
371  // If this is a protocol type and the preferred action is "save to disk",
372  // which is invalid for such types, then return true here to override that
373  // action. This could happen when the preferred action is to use a helper
374  // app, but the preferredApplicationHandler is invalid, and there isn't
375  // a default handler, so the preferredAction getter returns save to disk
376  // instead.
377  if (!(this.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) &&
378  this.preferredAction == Ci.nsIHandlerInfo.saveToDisk)
379  return true;
380 
381  return this.wrappedHandlerInfo.alwaysAskBeforeHandling;
382  },
383 
384  set alwaysAskBeforeHandling(aNewValue) {
385  this.wrappedHandlerInfo.alwaysAskBeforeHandling = aNewValue;
386  },
387 
388 
389  //**************************************************************************//
390  // nsIMIMEInfo
391 
392  // The primary file extension associated with this type, if any.
393  //
394  // XXX Plugin objects contain an array of MimeType objects with "suffixes"
395  // properties; if this object has an associated plugin, shouldn't we check
396  // those properties for an extension?
397  get primaryExtension() {
398  try {
399  if (this.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo &&
400  this.wrappedHandlerInfo.primaryExtension)
401  return this.wrappedHandlerInfo.primaryExtension
402  } catch(ex) {}
403 
404  return null;
405  },
406 
407 
408  //**************************************************************************//
409  // Plugin Handling
410 
411  // A plugin that can handle this type, if any.
412  //
413  // Note: just because we have one doesn't mean it *will* handle the type.
414  // That depends on whether or not the type is in the list of types for which
415  // plugin handling is disabled.
416  plugin: null,
417 
418  // Whether or not this type is only handled by a plugin or is also handled
419  // by some user-configured action as specified in the handler info object.
420  //
421  // Note: we can't just check if there's a handler info object for this type,
422  // because OS and user configuration is mixed up in the handler info object,
423  // so we always need to retrieve it for the OS info and can't tell whether
424  // it represents only OS-default information or user-configured information.
425  //
426  // FIXME: once handler info records are broken up into OS-provided records
427  // and user-configured records, stop using this boolean flag and simply
428  // check for the presence of a user-configured record to determine whether
429  // or not this type is only handled by a plugin. Filed as bug 395142.
430  handledOnlyByPlugin: undefined,
431 
432  get isDisabledPluginType() {
433  return this._getDisabledPluginTypes().indexOf(this.type) != -1;
434  },
435 
436  _getDisabledPluginTypes: function() {
437  var types = "";
438 
439  if (this._prefSvc.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES))
440  types = this._prefSvc.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
441 
442  // Only split if the string isn't empty so we don't end up with an array
443  // containing a single empty string.
444  if (types != "")
445  return types.split(",");
446 
447  return [];
448  },
449 
450  disablePluginType: function() {
451  var disabledPluginTypes = this._getDisabledPluginTypes();
452 
453  if (disabledPluginTypes.indexOf(this.type) == -1)
454  disabledPluginTypes.push(this.type);
455 
456  this._prefSvc.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
457  disabledPluginTypes.join(","));
458 
459  // Update the category manager so existing browser windows update.
460  this._categoryMgr.deleteCategoryEntry("Gecko-Content-Viewers",
461  this.type,
462  false);
463  },
464 
465  enablePluginType: function() {
466  var disabledPluginTypes = this._getDisabledPluginTypes();
467 
468  var type = this.type;
469  disabledPluginTypes = disabledPluginTypes.filter(function(v) v != type);
470 
471  this._prefSvc.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
472  disabledPluginTypes.join(","));
473 
474  // Update the category manager so existing browser windows update.
475  this._categoryMgr.
476  addCategoryEntry("Gecko-Content-Viewers",
477  this.type,
478  "@mozilla.org/content/plugin/document-loader-factory;1",
479  false,
480  true);
481  },
482 
483 
484  //**************************************************************************//
485  // Storage
486 
487  store: function() {
488  this._handlerSvc.store(this.wrappedHandlerInfo);
489  },
490 
491 
492  //**************************************************************************//
493  // Icons
494 
495  get smallIcon() {
496  return this._getIcon(16);
497  },
498 
499  get largeIcon() {
500  return this._getIcon(32);
501  },
502 
503  _getIcon: function(aSize) {
504  if (this.primaryExtension)
505  return "moz-icon://goat." + this.primaryExtension + "?size=" + aSize;
506 
507  if (this.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo)
508  return "moz-icon://goat?size=" + aSize + "&contentType=" + this.type;
509 
510  // FIXME: consider returning some generic icon when we can't get a URL for
511  // one (for example in the case of protocol schemes). Filed as bug 395141.
512  return null;
513  }
514 
515 };
516 
517 
518 //****************************************************************************//
519 // Feed Handler Info
520 
535 function FeedHandlerInfo(aMIMEType) {
536  HandlerInfoWrapper.call(this, aMIMEType, null);
537 }
538 
539 FeedHandlerInfo.prototype = {
540  __proto__: HandlerInfoWrapper.prototype,
541 
542  //**************************************************************************//
543  // Convenience Utils
544 
545  _converterSvc:
546  Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
547  getService(Ci.nsIWebContentConverterService),
548 
549  _shellSvc:
550 #ifdef HAVE_SHELL_SERVICE
551  getShellService(),
552 #else
553  null,
554 #endif
555 
556 
557  //**************************************************************************//
558  // nsIHandlerInfo
559 
560  get description() {
561  return this.element("bundlePreferences").getString(this._appPrefLabel);
562  },
563 
564  get preferredApplicationHandler() {
565  switch (this.element(this._prefSelectedReader).value) {
566  case "client":
567  var file = this.element(this._prefSelectedApp).value;
568  if (file)
569  return getLocalHandlerApp(file);
570 
571  return null;
572 
573  case "web":
574  var uri = this.element(this._prefSelectedWeb).value;
575  if (!uri)
576  return null;
577  return this._converterSvc.getWebContentHandlerByURI(this.type, uri);
578 
579  case "bookmarks":
580  default:
581  // When the pref is set to bookmarks, we handle feeds internally,
582  // we don't forward them to a local or web handler app, so there is
583  // no preferred handler.
584  return null;
585  }
586  },
587 
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";
592  }
593  else if (aNewValue instanceof Ci.nsIWebContentHandlerInfo) {
594  this.element(this._prefSelectedWeb).value = aNewValue.uri;
595  this.element(this._prefSelectedReader).value = "web";
596  // Make the web handler be the new "auto handler" for feeds.
597  // Note: we don't have to unregister the auto handler when the user picks
598  // a non-web handler (local app, Live Bookmarks, etc.) because the service
599  // only uses the "auto handler" when the selected reader is a web handler.
600  // We also don't have to unregister it when the user turns on "always ask"
601  // (i.e. preview in browser), since that also overrides the auto handler.
602  this._converterSvc.setAutoHandler(this.type, aNewValue);
603  }
604  },
605 
606  _possibleApplicationHandlers: null,
607 
608  get possibleApplicationHandlers() {
609  if (this._possibleApplicationHandlers)
610  return this._possibleApplicationHandlers;
611 
612  // A minimal implementation of nsIMutableArray. It only supports the two
613  // methods its callers invoke, namely appendElement and nsIArray::enumerate.
614  this._possibleApplicationHandlers = {
615  _inner: [],
616  _removed: [],
617 
618  QueryInterface: function(aIID) {
619  if (aIID.equals(Ci.nsIMutableArray) ||
620  aIID.equals(Ci.nsIArray) ||
621  aIID.equals(Ci.nsISupports))
622  return this;
623 
624  throw Cr.NS_ERROR_NO_INTERFACE;
625  },
626 
627  get length() {
628  return this._inner.length;
629  },
630 
631  enumerate: function() {
632  return new ArrayEnumerator(this._inner);
633  },
634 
635  appendElement: function(aHandlerApp, aWeak) {
636  this._inner.push(aHandlerApp);
637  },
638 
639  removeElementAt: function(aIndex) {
640  this._removed.push(this._inner[aIndex]);
641  this._inner.splice(aIndex, 1);
642  },
643 
644  queryElementAt: function(aIndex, aInterface) {
645  return this._inner[aIndex].QueryInterface(aInterface);
646  }
647  };
648 
649  // Add the selected local app if it's different from the OS default handler.
650  // Unlike for other types, we can store only one local app at a time for the
651  // feed type, since we store it in a preference that historically stores
652  // only a single path. But we display all the local apps the user chooses
653  // while the prefpane is open, only dropping the list when the user closes
654  // the prefpane, for maximum usability and consistency with other types.
655  var preferredAppFile = this.element(this._prefSelectedApp).value;
656  if (preferredAppFile) {
657  let preferredApp = getLocalHandlerApp(preferredAppFile);
658  let defaultApp = this._defaultApplicationHandler;
659  if (!defaultApp || !defaultApp.equals(preferredApp))
660  this._possibleApplicationHandlers.appendElement(preferredApp, false);
661  }
662 
663  // Add the registered web handlers. There can be any number of these.
664  var webHandlers = this._converterSvc.getContentHandlers(this.type, {});
665  for each (let webHandler in webHandlers)
666  this._possibleApplicationHandlers.appendElement(webHandler, false);
667 
668  return this._possibleApplicationHandlers;
669  },
670 
671  __defaultApplicationHandler: undefined,
672  get _defaultApplicationHandler() {
673  if (typeof this.__defaultApplicationHandler != "undefined")
674  return this.__defaultApplicationHandler;
675 
676  var defaultFeedReader = null;
677 #ifdef HAVE_SHELL_SERVICE
678  try {
679  defaultFeedReader = this._shellSvc.defaultFeedReader;
680  }
681  catch(ex) {
682  // no default reader or _shellSvc is null
683  }
684 #endif
685 
686  if (defaultFeedReader) {
687  let handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
688  createInstance(Ci.nsIHandlerApp);
689  handlerApp.name = getDisplayNameForFile(defaultFeedReader);
690  handlerApp.QueryInterface(Ci.nsILocalHandlerApp);
691  handlerApp.executable = defaultFeedReader;
692 
693  this.__defaultApplicationHandler = handlerApp;
694  }
695  else {
696  this.__defaultApplicationHandler = null;
697  }
698 
699  return this.__defaultApplicationHandler;
700  },
701 
702  get hasDefaultHandler() {
703 #ifdef HAVE_SHELL_SERVICE
704  try {
705  if (this._shellSvc.defaultFeedReader)
706  return true;
707  }
708  catch(ex) {
709  // no default reader or _shellSvc is null
710  }
711 #endif
712 
713  return false;
714  },
715 
716  get defaultDescription() {
717  if (this.hasDefaultHandler)
718  return this._defaultApplicationHandler.name;
719 
720  // Should we instead return null?
721  return "";
722  },
723 
724  // What to do with content of this type.
725  get preferredAction() {
726  switch (this.element(this._prefSelectedAction).value) {
727 
728  case "bookmarks":
729  return Ci.nsIHandlerInfo.handleInternally;
730 
731  case "reader": {
732  let preferredApp = this.preferredApplicationHandler;
733  let defaultApp = this._defaultApplicationHandler;
734 
735  // If we have a valid preferred app, return useSystemDefault if it's
736  // the default app; otherwise return useHelperApp.
737  if (gApplicationsPane.isValidHandlerApp(preferredApp)) {
738  if (defaultApp && defaultApp.equals(preferredApp))
739  return Ci.nsIHandlerInfo.useSystemDefault;
740 
741  return Ci.nsIHandlerInfo.useHelperApp;
742  }
743 
744  // The pref is set to "reader", but we don't have a valid preferred app.
745  // What do we do now? Not sure this is the best option (perhaps we
746  // should direct the user to the default app, if any), but for now let's
747  // direct the user to live bookmarks.
748  return Ci.nsIHandlerInfo.handleInternally;
749  }
750 
751  // If the action is "ask", then alwaysAskBeforeHandling will override
752  // the action, so it doesn't matter what we say it is, it just has to be
753  // something that doesn't cause the controller to hide the type.
754  case "ask":
755  default:
756  return Ci.nsIHandlerInfo.handleInternally;
757  }
758  },
759 
760  set preferredAction(aNewValue) {
761  switch (aNewValue) {
762 
763  case Ci.nsIHandlerInfo.handleInternally:
764  this.element(this._prefSelectedReader).value = "bookmarks";
765  break;
766 
767  case Ci.nsIHandlerInfo.useHelperApp:
768  this.element(this._prefSelectedAction).value = "reader";
769  // The controller has already set preferredApplicationHandler
770  // to the new helper app.
771  break;
772 
773  case Ci.nsIHandlerInfo.useSystemDefault:
774  this.element(this._prefSelectedAction).value = "reader";
775  this.preferredApplicationHandler = this._defaultApplicationHandler;
776  break;
777  }
778  },
779 
780  get alwaysAskBeforeHandling() {
781  return this.element(this._prefSelectedAction).value == "ask";
782  },
783 
784  set alwaysAskBeforeHandling(aNewValue) {
785  if (aNewValue == true)
786  this.element(this._prefSelectedAction).value = "ask";
787  else
788  this.element(this._prefSelectedAction).value = "reader";
789  },
790 
791  // Whether or not we are currently storing the action selected by the user.
792  // We use this to suppress notification-triggered updates to the list when
793  // we make changes that may spawn such updates, specifically when we change
794  // the action for the feed type, which results in feed preference updates,
795  // which spawn "pref changed" notifications that would otherwise cause us
796  // to rebuild the view unnecessarily.
797  _storingAction: false,
798 
799 
800  //**************************************************************************//
801  // nsIMIMEInfo
802 
803  get primaryExtension() {
804  return "xml";
805  },
806 
807 
808  //**************************************************************************//
809  // Storage
810 
811  // Changes to the preferred action and handler take effect immediately
812  // (we write them out to the preferences right as they happen),
813  // so we when the controller calls store() after modifying the handlers,
814  // the only thing we need to store is the removal of possible handlers
815  // XXX Should we hold off on making the changes until this method gets called?
816  store: function() {
817  for each (let app in this._possibleApplicationHandlers._removed) {
818  if (app instanceof Ci.nsILocalHandlerApp) {
819  let pref = this.element(PREF_FEED_SELECTED_APP);
820  var preferredAppFile = pref.value;
821  if (preferredAppFile) {
822  let preferredApp = getLocalHandlerApp(preferredAppFile);
823  if (app.equals(preferredApp))
824  pref.reset();
825  }
826  }
827  else {
828  app.QueryInterface(Ci.nsIWebContentHandlerInfo);
829  this._converterSvc.removeContentHandler(app.contentType, app.uri);
830  }
831  }
832  this._possibleApplicationHandlers._removed = [];
833  },
834 
835 
836  //**************************************************************************//
837  // Icons
838 
839  get smallIcon() {
840  return this._smallIcon;
841  },
842 
843  get largeIcon() {
844  return this._largeIcon;
845  }
846 
847 };
848 
850  __proto__: new FeedHandlerInfo(TYPE_MAYBE_FEED),
851  _prefSelectedApp: PREF_FEED_SELECTED_APP,
852  _prefSelectedWeb: PREF_FEED_SELECTED_WEB,
853  _prefSelectedAction: PREF_FEED_SELECTED_ACTION,
854  _prefSelectedReader: PREF_FEED_SELECTED_READER,
855  _smallIcon: "chrome://browser/skin/feeds/feedIcon16.png",
856  _largeIcon: "chrome://browser/skin/feeds/feedIcon.png",
857  _appPrefLabel: "webFeed"
858 }
859 
860 var videoFeedHandlerInfo = {
861  __proto__: new FeedHandlerInfo(TYPE_MAYBE_VIDEO_FEED),
862  _prefSelectedApp: PREF_VIDEO_FEED_SELECTED_APP,
863  _prefSelectedWeb: PREF_VIDEO_FEED_SELECTED_WEB,
864  _prefSelectedAction: PREF_VIDEO_FEED_SELECTED_ACTION,
865  _prefSelectedReader: PREF_VIDEO_FEED_SELECTED_READER,
866  _smallIcon: "chrome://browser/skin/feeds/videoFeedIcon16.png",
867  _largeIcon: "chrome://browser/skin/feeds/videoFeedIcon.png",
868  _appPrefLabel: "videoPodcastFeed"
869 }
870 
871 var audioFeedHandlerInfo = {
872  __proto__: new FeedHandlerInfo(TYPE_MAYBE_AUDIO_FEED),
873  _prefSelectedApp: PREF_AUDIO_FEED_SELECTED_APP,
874  _prefSelectedWeb: PREF_AUDIO_FEED_SELECTED_WEB,
875  _prefSelectedAction: PREF_AUDIO_FEED_SELECTED_ACTION,
876  _prefSelectedReader: PREF_AUDIO_FEED_SELECTED_READER,
877  _smallIcon: "chrome://browser/skin/feeds/audioFeedIcon16.png",
878  _largeIcon: "chrome://browser/skin/feeds/audioFeedIcon.png",
879  _appPrefLabel: "audioPodcastFeed"
880 }
881 
882 
883 //****************************************************************************//
884 // Prefpane Controller
885 
886 var gApplicationsPane = {
887  // The set of types the app knows how to handle. A hash of HandlerInfoWrapper
888  // objects, indexed by type.
889  _handledTypes: {},
890 
891  // The list of types we can show, sorted by the sort column/direction.
892  // An array of HandlerInfoWrapper objects. We build this list when we first
893  // load the data and then rebuild it when users change a pref that affects
894  // what types we can show or change the sort column/direction.
895  // Note: this isn't necessarily the list of types we *will* show; if the user
896  // provides a filter string, we'll only show the subset of types in this list
897  // that match that string.
898  _visibleTypes: [],
899 
900  // A count of the number of times each visible type description appears.
901  // We use these counts to determine whether or not to annotate descriptions
902  // with their types to distinguish duplicate descriptions from each other.
903  // A hash of integer counts, indexed by string description.
904  _visibleTypeDescriptionCount: {},
905 
906 
907  //**************************************************************************//
908  // Convenience & Performance Shortcuts
909 
910  // These get defined by init().
911  _brandShortName : null,
912  _prefsBundle : null,
913  _list : null,
914  _filter : null,
915 
916  // Retrieve this as nsIPrefBranch and then immediately QI to nsIPrefBranch2
917  // so both interfaces are available to callers.
918  _prefSvc : Cc["@mozilla.org/preferences-service;1"].
919  getService(Ci.nsIPrefBranch).
920  QueryInterface(Ci.nsIPrefBranch2),
921 
922  _mimeSvc : Cc["@mozilla.org/mime;1"].
923  getService(Ci.nsIMIMEService),
924 
925  _helperAppSvc : Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
926  getService(Ci.nsIExternalHelperAppService),
927 
928  _handlerSvc : Cc["@mozilla.org/uriloader/handler-service;1"].
929  getService(Ci.nsIHandlerService),
930 
931  _ioSvc : Cc["@mozilla.org/network/io-service;1"].
932  getService(Ci.nsIIOService),
933 
934 
935  //**************************************************************************//
936  // Initialization & Destruction
937 
938  init: function() {
939  // Initialize shortcuts to some commonly accessed elements & values.
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");
945 
946  // Observe preferences that influence what we display so we can rebuild
947  // the view when they change.
948  this._prefSvc.addObserver(PREF_SHOW_PLUGINS_IN_LIST, this, false);
949  this._prefSvc.addObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this, false);
950  this._prefSvc.addObserver(PREF_FEED_SELECTED_APP, this, false);
951  this._prefSvc.addObserver(PREF_FEED_SELECTED_WEB, this, false);
952  this._prefSvc.addObserver(PREF_FEED_SELECTED_ACTION, this, false);
953  this._prefSvc.addObserver(PREF_FEED_SELECTED_READER, this, false);
954 
955  this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_APP, this, false);
956  this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_WEB, this, false);
957  this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this, false);
958  this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_READER, this, false);
959 
960  this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_APP, this, false);
961  this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_WEB, this, false);
962  this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this, false);
963  this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_READER, this, false);
964 
965 
966  // Listen for window unload so we can remove our preference observers.
967  window.addEventListener("unload", this, false);
968 
969  // Figure out how we should be sorting the list. We persist sort settings
970  // across sessions, so we can't assume the default sort column/direction.
971  // XXX should we be using the XUL sort service instead?
972  if (document.getElementById("actionColumn").hasAttribute("sortDirection")) {
973  this._sortColumn = document.getElementById("actionColumn");
974  // The typeColumn element always has a sortDirection attribute,
975  // either because it was persisted or because the default value
976  // from the xul file was used. If we are sorting on the other
977  // column, we should remove it.
978  document.getElementById("typeColumn").removeAttribute("sortDirection");
979  }
980  else
981  this._sortColumn = document.getElementById("typeColumn");
982 
983  // Load the data and build the list of handlers.
984  // By doing this in a timeout, we let the preferences dialog resize itself
985  // to an appropriate size before we add a bunch of items to the list.
986  // Otherwise, if there are many items, and the Applications prefpane
987  // is the one that gets displayed when the user first opens the dialog,
988  // the dialog might stretch too much in an attempt to fit them all in.
989  // XXX Shouldn't we perhaps just set a max-height on the richlistbox?
990  var _delayedPaneLoad = function(self) {
991  self._loadData();
992  self._rebuildVisibleTypes();
993  self._sortVisibleTypes();
994  self._rebuildView();
995 
996  // Notify observers that the UI is now ready
997  Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService).
998  notifyObservers(window, "app-handler-pane-loaded", null);
999  }
1000  setTimeout(_delayedPaneLoad, 0, this);
1001  },
1002 
1003  destroy: function() {
1004  window.removeEventListener("unload", this, false);
1005  this._prefSvc.removeObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
1006  this._prefSvc.removeObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
1007  this._prefSvc.removeObserver(PREF_FEED_SELECTED_APP, this);
1008  this._prefSvc.removeObserver(PREF_FEED_SELECTED_WEB, this);
1009  this._prefSvc.removeObserver(PREF_FEED_SELECTED_ACTION, this);
1010  this._prefSvc.removeObserver(PREF_FEED_SELECTED_READER, this);
1011 
1012  this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_APP, this);
1013  this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_WEB, this);
1014  this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
1015  this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
1016 
1017  this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
1018  this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
1019  this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
1020  this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
1021  },
1022 
1023 
1024  //**************************************************************************//
1025  // nsISupports
1026 
1027  QueryInterface: function(aIID) {
1028  if (aIID.equals(Ci.nsIObserver) ||
1029  aIID.equals(Ci.nsIDOMEventListener ||
1030  aIID.equals(Ci.nsISupports)))
1031  return this;
1032 
1033  throw Cr.NS_ERROR_NO_INTERFACE;
1034  },
1035 
1036 
1037  //**************************************************************************//
1038  // nsIObserver
1039 
1040  observe: function (aSubject, aTopic, aData) {
1041  // Rebuild the list when there are changes to preferences that influence
1042  // whether or not to show certain entries in the list.
1043  if (aTopic == "nsPref:changed" && !this._storingAction) {
1044  // These two prefs alter the list of visible types, so we have to rebuild
1045  // that list when they change.
1048  this._rebuildVisibleTypes();
1049  this._sortVisibleTypes();
1050  }
1051 
1052  // All the prefs we observe can affect what we display, so we rebuild
1053  // the view when any of them changes.
1054  this._rebuildView();
1055  }
1056  },
1057 
1058 
1059  //**************************************************************************//
1060  // nsIDOMEventListener
1061 
1062  handleEvent: function(aEvent) {
1063  if (aEvent.type == "unload") {
1064  this.destroy();
1065  }
1066  },
1067 
1068 
1069  //**************************************************************************//
1070  // Composed Model Construction
1071 
1072  _loadData: function() {
1073  this._loadFeedHandler();
1074  this._loadPluginHandlers();
1075  this._loadApplicationHandlers();
1076  },
1077 
1078  _loadFeedHandler: function() {
1079  this._handledTypes[TYPE_MAYBE_FEED] = feedHandlerInfo;
1080  feedHandlerInfo.handledOnlyByPlugin = false;
1081 
1082  this._handledTypes[TYPE_MAYBE_VIDEO_FEED] = videoFeedHandlerInfo;
1083  videoFeedHandlerInfo.handledOnlyByPlugin = false;
1084 
1085  this._handledTypes[TYPE_MAYBE_AUDIO_FEED] = audioFeedHandlerInfo;
1086  audioFeedHandlerInfo.handledOnlyByPlugin = false;
1087  },
1088 
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;
1114 
1115  let handlerInfoWrapper;
1116  if (type in this._handledTypes)
1117  handlerInfoWrapper = this._handledTypes[type];
1118  else {
1119  let wrappedHandlerInfo =
1120  this._mimeSvc.getFromTypeAndExtension(type, null);
1121  handlerInfoWrapper = new HandlerInfoWrapper(type, wrappedHandlerInfo);
1122  handlerInfoWrapper.handledOnlyByPlugin = true;
1123  this._handledTypes[type] = handlerInfoWrapper;
1124  }
1125 
1126  handlerInfoWrapper.plugin = plugin;
1127  }
1128  }
1129  },
1130 
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;
1140 
1141  let handlerInfoWrapper;
1142  if (type in this._handledTypes)
1143  handlerInfoWrapper = this._handledTypes[type];
1144  else {
1145  handlerInfoWrapper = new HandlerInfoWrapper(type, wrappedHandlerInfo);
1146  this._handledTypes[type] = handlerInfoWrapper;
1147  }
1148 
1149  handlerInfoWrapper.handledOnlyByPlugin = false;
1150  }
1151  },
1152 
1153 
1154  //**************************************************************************//
1155  // View Construction
1156 
1157  _rebuildVisibleTypes: function() {
1158  // Reset the list of visible types and the visible type description counts.
1159  this._visibleTypes = [];
1160  this._visibleTypeDescriptionCount = {};
1161 
1162  // Get the preferences that help determine what types to show.
1163  var showPlugins = this._prefSvc.getBoolPref(PREF_SHOW_PLUGINS_IN_LIST);
1164  var hidePluginsWithoutExtensions =
1165  this._prefSvc.getBoolPref(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS);
1166 
1167  for (let type in this._handledTypes) {
1168  let handlerInfo = this._handledTypes[type];
1169 
1170  // Hide plugins without associated extensions if so prefed so we don't
1171  // show a whole bunch of obscure types handled by plugins on Mac.
1172  // Note: though protocol types don't have extensions, we still show them;
1173  // the pref is only meant to be applied to MIME types, since plugins are
1174  // only associated with MIME types.
1175  // FIXME: should we also check the "suffixes" property of the plugin?
1176  // Filed as bug 395135.
1177  if (hidePluginsWithoutExtensions && handlerInfo.handledOnlyByPlugin &&
1178  handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo &&
1179  !handlerInfo.primaryExtension)
1180  continue;
1181 
1182  // Hide types handled only by plugins if so prefed.
1183  if (handlerInfo.handledOnlyByPlugin && !showPlugins)
1184  continue;
1185 
1186  // We couldn't find any reason to exclude the type, so include it.
1187  this._visibleTypes.push(handlerInfo);
1188 
1189  if (handlerInfo.description in this._visibleTypeDescriptionCount)
1190  this._visibleTypeDescriptionCount[handlerInfo.description]++;
1191  else
1192  this._visibleTypeDescriptionCount[handlerInfo.description] = 1;
1193  }
1194  },
1195 
1196  _rebuildView: function() {
1197  // Clear the list of entries.
1198  while (this._list.childNodes.length > 1)
1199  this._list.removeChild(this._list.lastChild);
1200 
1201  var visibleTypes = this._visibleTypes;
1202 
1203  // If the user is filtering the list, then only show matching types.
1204  if (this._filter.value)
1205  visibleTypes = visibleTypes.filter(this._matchesFilter, this);
1206 
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));
1215 
1216  if (!this._setIconClassForPreferredAction(visibleType, item)) {
1217  item.setAttribute("actionIcon",
1218  this._getIconURLForPreferredAction(visibleType));
1219  }
1220 
1221  this._list.appendChild(item);
1222  }
1223 
1224  this._selectLastSelectedType();
1225  },
1226 
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;
1231  },
1232 
1243  _describeType: function(aHandlerInfo) {
1244  if (this._visibleTypeDescriptionCount[aHandlerInfo.description] > 1)
1245  return this._prefsBundle.getFormattedString("typeDescriptionWithType",
1246  [aHandlerInfo.description,
1247  aHandlerInfo.type]);
1248 
1249  return aHandlerInfo.description;
1250  },
1251 
1264  _describePreferredAction: function(aHandlerInfo) {
1265  // alwaysAskBeforeHandling overrides the preferred action, so if that flag
1266  // is set, then describe that behavior instead. For most types, this is
1267  // the "alwaysAsk" string, but for the feed type we show something special.
1268  if (aHandlerInfo.alwaysAskBeforeHandling) {
1269  if (isFeedType(aHandlerInfo.type))
1270  return this._prefsBundle.getFormattedString("previewInApp",
1271  [this._brandShortName]);
1272  else
1273  return this._prefsBundle.getString("alwaysAsk");
1274  }
1275 
1276  switch (aHandlerInfo.preferredAction) {
1277  case Ci.nsIHandlerInfo.saveToDisk:
1278  return this._prefsBundle.getString("saveFile");
1279 
1280  case Ci.nsIHandlerInfo.useHelperApp:
1281  var preferredApp = aHandlerInfo.preferredApplicationHandler;
1282  var name;
1283  if (preferredApp instanceof Ci.nsILocalHandlerApp)
1284  name = getDisplayNameForFile(preferredApp.executable);
1285  else
1286  name = preferredApp.name;
1287  return this._prefsBundle.getFormattedString("useApp", [name]);
1288 
1289  case Ci.nsIHandlerInfo.handleInternally:
1290  // For the feed type, handleInternally means live bookmarks.
1291  if (isFeedType(aHandlerInfo.type))
1292  return this._prefsBundle.getFormattedString("addLiveBookmarksInApp",
1293  [this._brandShortName]);
1294 
1295  // For other types, handleInternally looks like either useHelperApp
1296  // or useSystemDefault depending on whether or not there's a preferred
1297  // handler app.
1298  if (this.isValidHandlerApp(aHandlerInfo.preferredApplicationHandler))
1299  return aHandlerInfo.preferredApplicationHandler.name;
1300 
1301  return aHandlerInfo.defaultDescription;
1302 
1303  // XXX Why don't we say the app will handle the type internally?
1304  // Is it because the app can't actually do that? But if that's true,
1305  // then why would a preferredAction ever get set to this value
1306  // in the first place?
1307 
1308  case Ci.nsIHandlerInfo.useSystemDefault:
1309  return this._prefsBundle.getFormattedString("useDefault",
1310  [aHandlerInfo.defaultDescription]);
1311 
1312  case kActionUsePlugin:
1313  return this._prefsBundle.getFormattedString("usePluginIn",
1314  [aHandlerInfo.plugin.name,
1315  this._brandShortName]);
1316  }
1317  },
1318 
1319  _selectLastSelectedType: function() {
1320  // If the list is disabled by the pref.downloads.disable_button.edit_actions
1321  // preference being locked, then don't select the type, as that would cause
1322  // it to appear selected, with a different background and an actions menu
1323  // that makes it seem like you can choose an action for the type.
1324  if (this._list.disabled)
1325  return;
1326 
1327  var lastSelectedType = this._list.getAttribute("lastSelectedType");
1328  if (!lastSelectedType)
1329  return;
1330 
1331  var item = this._list.getElementsByAttribute("type", lastSelectedType)[0];
1332  if (!item)
1333  return;
1334 
1335  this._list.selectedItem = item;
1336  },
1337 
1345  isValidHandlerApp: function(aHandlerApp) {
1346  if (!aHandlerApp)
1347  return false;
1348 
1349  if (aHandlerApp instanceof Ci.nsILocalHandlerApp)
1350  return this._isValidHandlerExecutable(aHandlerApp.executable);
1351 
1352  if (aHandlerApp instanceof Ci.nsIWebHandlerApp)
1353  return aHandlerApp.uriTemplate;
1354 
1355  if (aHandlerApp instanceof Ci.nsIWebContentHandlerInfo)
1356  return aHandlerApp.uri;
1357 
1358  return false;
1359  },
1360 
1361  _isValidHandlerExecutable: function(aExecutable) {
1362  return aExecutable &&
1363  aExecutable.exists() &&
1364  aExecutable.isExecutable() &&
1365 // XXXben - we need to compare this with the running instance executable
1366 // just don't know how to do that via script...
1367 // XXXmano TBD: can probably add this to nsIShellService
1368 #ifdef XP_WIN
1369 #expand aExecutable.leafName != "__MOZ_APP_NAME__.exe";
1370 #else
1371 #ifdef XP_MACOSX
1372 #expand aExecutable.leafName != "__MOZ_APP_DISPLAYNAME__.app";
1373 #else
1374 #expand aExecutable.leafName != "__MOZ_APP_NAME__-bin";
1375 #endif
1376 #endif
1377  },
1378 
1383  rebuildActionsMenu: function() {
1384  var typeItem = this._list.selectedItem;
1385  var handlerInfo = this._handledTypes[typeItem.type];
1386  var menu =
1387  document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
1388  var menuPopup = menu.menupopup;
1389 
1390  // Clear out existing items.
1391  while (menuPopup.hasChildNodes())
1392  menuPopup.removeChild(menuPopup.lastChild);
1393 
1394  {
1395  var askMenuItem = document.createElement("menuitem");
1396  askMenuItem.setAttribute("alwaysAsk", "true");
1397  let label;
1398  if (isFeedType(handlerInfo.type))
1399  label = this._prefsBundle.getFormattedString("previewInApp",
1400  [this._brandShortName]);
1401  else
1402  label = this._prefsBundle.getString("alwaysAsk");
1403  askMenuItem.setAttribute("label", label);
1404  askMenuItem.setAttribute("tooltiptext", label);
1405  askMenuItem.setAttribute(APP_ICON_ATTR_NAME, "ask");
1406  menuPopup.appendChild(askMenuItem);
1407  }
1408 
1409  // Create a menu item for saving to disk.
1410  // Note: this option isn't available to protocol types, since we don't know
1411  // what it means to save a URL having a certain scheme to disk, nor is it
1412  // available to feeds, since the feed code doesn't implement the capability.
1413  if ((handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) &&
1414  !isFeedType(handlerInfo.type)) {
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);
1420  saveMenuItem.setAttribute(APP_ICON_ATTR_NAME, "save");
1421  menuPopup.appendChild(saveMenuItem);
1422  }
1423 
1424  // If this is the feed type, add a Live Bookmarks item.
1425  if (isFeedType(handlerInfo.type)) {
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);
1432  internalMenuItem.setAttribute(APP_ICON_ATTR_NAME, "feed");
1433  menuPopup.appendChild(internalMenuItem);
1434  }
1435 
1436  // Add a separator to distinguish these items from the helper app items
1437  // that follow them.
1438  let menuItem = document.createElement("menuseparator");
1439  menuPopup.appendChild(menuItem);
1440 
1441  // Create a menu item for the OS default application, if any.
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));
1450 
1451  menuPopup.appendChild(defaultMenuItem);
1452  }
1453 
1454  // Create menu items for possible handlers.
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))
1461  continue;
1462 
1463  let menuItem = document.createElement("menuitem");
1464  menuItem.setAttribute("action", Ci.nsIHandlerInfo.useHelperApp);
1465  let label;
1466  if (possibleApp instanceof Ci.nsILocalHandlerApp)
1467  label = getDisplayNameForFile(possibleApp.executable);
1468  else
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));
1474 
1475  // Attach the handler app object to the menu item so we can use it
1476  // to make changes to the datastore when the user selects the item.
1477  menuItem.handlerApp = possibleApp;
1478 
1479  menuPopup.appendChild(menuItem);
1480  possibleAppMenuItems.push(menuItem);
1481  }
1482 
1483  // Create a menu item for the plugin.
1484  if (handlerInfo.plugin) {
1485  var pluginMenuItem = document.createElement("menuitem");
1486  pluginMenuItem.setAttribute("action", kActionUsePlugin);
1487  let label = this._prefsBundle.getFormattedString("usePluginIn",
1488  [handlerInfo.plugin.name,
1489  this._brandShortName]);
1490  pluginMenuItem.setAttribute("label", label);
1491  pluginMenuItem.setAttribute("tooltiptext", label);
1492  pluginMenuItem.setAttribute(APP_ICON_ATTR_NAME, "plugin");
1493  menuPopup.appendChild(pluginMenuItem);
1494  }
1495 
1496  // Create a menu item for selecting a local application.
1497 #ifdef XP_WIN
1498  // On Windows, selecting an application to open another application
1499  // would be meaningless so we special case executables.
1500  var executableType = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService)
1501  .getTypeFromExtension("exe");
1502  if (handlerInfo.type != executableType)
1503 #endif
1504  {
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);
1511  }
1512 
1513  // Create a menu item for managing applications.
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);
1521  }
1522 
1523  // Select the item corresponding to the preferred action. If the always
1524  // ask flag is set, it overrides the preferred action. Otherwise we pick
1525  // the item identified by the preferred action (when the preferred action
1526  // is to use a helper app, we have to pick the specific helper app item).
1527  if (handlerInfo.alwaysAskBeforeHandling)
1528  menu.selectedItem = askMenuItem;
1529  else switch (handlerInfo.preferredAction) {
1530  case Ci.nsIHandlerInfo.handleInternally:
1531  menu.selectedItem = internalMenuItem;
1532  break;
1533  case Ci.nsIHandlerInfo.useSystemDefault:
1534  menu.selectedItem = defaultMenuItem;
1535  break;
1536  case Ci.nsIHandlerInfo.useHelperApp:
1537  if (preferredApp)
1538  menu.selectedItem =
1539  possibleAppMenuItems.filter(function(v) v.handlerApp.equals(preferredApp))[0];
1540  break;
1541  case kActionUsePlugin:
1542  menu.selectedItem = pluginMenuItem;
1543  break;
1544  case Ci.nsIHandlerInfo.saveToDisk:
1545  menu.selectedItem = saveMenuItem;
1546  break;
1547  }
1548  },
1549 
1550 
1551  //**************************************************************************//
1552  // Sorting & Filtering
1553 
1554  _sortColumn: null,
1555 
1559  sort: function (event) {
1560  var column = event.target;
1561 
1562  // If the user clicked on a new sort column, remove the direction indicator
1563  // from the old column.
1564  if (this._sortColumn && this._sortColumn != column)
1565  this._sortColumn.removeAttribute("sortDirection");
1566 
1567  this._sortColumn = column;
1568 
1569  // Set (or switch) the sort direction indicator.
1570  if (column.getAttribute("sortDirection") == "ascending")
1571  column.setAttribute("sortDirection", "descending");
1572  else
1573  column.setAttribute("sortDirection", "ascending");
1574 
1575  this._sortVisibleTypes();
1576  this._rebuildView();
1577  },
1578 
1582  _sortVisibleTypes: function() {
1583  if (!this._sortColumn)
1584  return;
1585 
1586  var t = this;
1587 
1588  function sortByType(a, b) {
1589  return t._describeType(a).toLowerCase().
1590  localeCompare(t._describeType(b).toLowerCase());
1591  }
1592 
1593  function sortByAction(a, b) {
1594  return t._describePreferredAction(a).toLowerCase().
1595  localeCompare(t._describePreferredAction(b).toLowerCase());
1596  }
1597 
1598  switch (this._sortColumn.getAttribute("value")) {
1599  case "type":
1600  this._visibleTypes.sort(sortByType);
1601  break;
1602  case "action":
1603  this._visibleTypes.sort(sortByAction);
1604  break;
1605  }
1606 
1607  if (this._sortColumn.getAttribute("sortDirection") == "descending")
1608  this._visibleTypes.reverse();
1609  },
1610 
1614  filter: function() {
1615  this._rebuildView();
1616  },
1617 
1618  focusFilterBox: function() {
1619  this._filter.focus();
1620  this._filter.select();
1621  },
1622 
1623 
1624  //**************************************************************************//
1625  // Changes
1626 
1627  onSelectAction: function(aActionItem) {
1628  this._storingAction = true;
1629 
1630  try {
1631  this._storeAction(aActionItem);
1632  }
1633  finally {
1634  this._storingAction = false;
1635  }
1636  },
1637 
1638  _storeAction: function(aActionItem) {
1639  var typeItem = this._list.selectedItem;
1640  var handlerInfo = this._handledTypes[typeItem.type];
1641 
1642  if (aActionItem.hasAttribute("alwaysAsk")) {
1643  handlerInfo.alwaysAskBeforeHandling = true;
1644  }
1645  else if (aActionItem.hasAttribute("action")) {
1646  let action = parseInt(aActionItem.getAttribute("action"));
1647 
1648  // Set the plugin state if we're enabling or disabling a plugin.
1649  if (action == kActionUsePlugin)
1650  handlerInfo.enablePluginType();
1651  else if (handlerInfo.plugin && !handlerInfo.isDisabledPluginType)
1652  handlerInfo.disablePluginType();
1653 
1654  // Set the preferred application handler.
1655  // We leave the existing preferred app in the list when we set
1656  // the preferred action to something other than useHelperApp so that
1657  // legacy datastores that don't have the preferred app in the list
1658  // of possible apps still include the preferred app in the list of apps
1659  // the user can choose to handle the type.
1660  if (action == Ci.nsIHandlerInfo.useHelperApp)
1661  handlerInfo.preferredApplicationHandler = aActionItem.handlerApp;
1662 
1663  // Set the "always ask" flag.
1664  handlerInfo.alwaysAskBeforeHandling = false;
1665 
1666  // Set the preferred action.
1667  handlerInfo.preferredAction = action;
1668  }
1669 
1670  handlerInfo.store();
1671 
1672  // Make sure the handler info object is flagged to indicate that there is
1673  // now some user configuration for the type.
1674  handlerInfo.handledOnlyByPlugin = false;
1675 
1676  // Update the action label and image to reflect the new preferred action.
1677  typeItem.setAttribute("actionDescription",
1678  this._describePreferredAction(handlerInfo));
1679  if (!this._setIconClassForPreferredAction(handlerInfo, typeItem)) {
1680  typeItem.setAttribute("actionIcon",
1681  this._getIconURLForPreferredAction(handlerInfo));
1682  }
1683  },
1684 
1685  manageApp: function(aEvent) {
1686  // Don't let the normal "on select action" handler get this event,
1687  // as we handle it specially ourselves.
1688  aEvent.stopPropagation();
1689 
1690  var typeItem = this._list.selectedItem;
1691  var handlerInfo = this._handledTypes[typeItem.type];
1692 
1693  document.documentElement.openSubDialog("chrome://browser/content/preferences/applicationManager.xul",
1694  "", handlerInfo);
1695 
1696  // Rebuild the actions menu so that we revert to the previous selection,
1697  // or "Always ask" if the previous default application has been removed
1698  this.rebuildActionsMenu();
1699 
1700  // update the richlistitem too. Will be visible when selecting another row
1701  typeItem.setAttribute("actionDescription",
1702  this._describePreferredAction(handlerInfo));
1703  if (!this._setIconClassForPreferredAction(handlerInfo, typeItem)) {
1704  typeItem.setAttribute("actionIcon",
1705  this._getIconURLForPreferredAction(handlerInfo));
1706  }
1707  },
1708 
1709  chooseApp: function(aEvent) {
1710  // Don't let the normal "on select action" handler get this event,
1711  // as we handle it specially ourselves.
1712  aEvent.stopPropagation();
1713 
1714  var handlerApp;
1715 
1716 #ifdef XP_WIN
1717  var params = {};
1718  var handlerInfo = this._handledTypes[this._list.selectedItem.type];
1719 
1720  if (isFeedType(handlerInfo.type)) {
1721  // MIME info will be null, create a temp object.
1722  params.mimeInfo = this._mimeSvc.getFromTypeAndExtension(handlerInfo.type,
1723  handlerInfo.primaryExtension);
1724  } else {
1725  params.mimeInfo = handlerInfo.wrappedHandlerInfo;
1726  }
1727 
1728  params.title = this._prefsBundle.getString("fpTitleChooseApp");
1729  params.description = handlerInfo.description;
1730  params.filename = null;
1731  params.handlerApp = null;
1732 
1733  window.openDialog("chrome://global/content/appPicker.xul", null,
1734  "chrome,modal,centerscreen,titlebar,dialog=yes",
1735  params);
1736 
1737  if (params.handlerApp &&
1738  params.handlerApp.executable &&
1739  params.handlerApp.executable.isFile()) {
1740  handlerApp = params.handlerApp;
1741 
1742  // Add the app to the type's list of possible handlers.
1743  handlerInfo.addPossibleApplicationHandler(handlerApp);
1744  }
1745 #else
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);
1750 
1751  // Prompt the user to pick an app. If they pick one, and it's a valid
1752  // selection, then add it to the list of possible handlers.
1753  if (fp.show() == Ci.nsIFilePicker.returnOK && fp.file &&
1754  this._isValidHandlerExecutable(fp.file)) {
1755  handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
1756  createInstance(Ci.nsILocalHandlerApp);
1757  handlerApp.name = getDisplayNameForFile(fp.file);
1758  handlerApp.executable = fp.file;
1759 
1760  // Add the app to the type's list of possible handlers.
1761  let handlerInfo = this._handledTypes[this._list.selectedItem.type];
1762  handlerInfo.addPossibleApplicationHandler(handlerApp);
1763  }
1764 #endif
1765 
1766  // Rebuild the actions menu whether the user picked an app or canceled.
1767  // If they picked an app, we want to add the app to the menu and select it.
1768  // If they canceled, we want to go back to their previous selection.
1769  this.rebuildActionsMenu();
1770 
1771  // If the user picked a new app from the menu, select it.
1772  if (handlerApp) {
1773  let typeItem = this._list.selectedItem;
1774  let actionsMenu =
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);
1782  break;
1783  }
1784  }
1785  }
1786  },
1787 
1788  // Mark which item in the list was last selected so we can reselect it
1789  // when we rebuild the list or when the user returns to the prefpane.
1790  onSelectionChanged: function() {
1791  if (this._list.selectedItem)
1792  this._list.setAttribute("lastSelectedType",
1793  this._list.selectedItem.getAttribute("type"));
1794  },
1795 
1796  _setIconClassForPreferredAction: function(aHandlerInfo, aElement) {
1797  // If this returns true, the attribute that CSS sniffs for was set to something
1798  // so you shouldn't manually set an icon URI.
1799  // This removes the existing actionIcon attribute if any, even if returning false.
1800  aElement.removeAttribute("actionIcon");
1801 
1802  if (aHandlerInfo.alwaysAskBeforeHandling) {
1803  aElement.setAttribute(APP_ICON_ATTR_NAME, "ask");
1804  return true;
1805  }
1806 
1807  switch (aHandlerInfo.preferredAction) {
1808  case Ci.nsIHandlerInfo.saveToDisk:
1809  aElement.setAttribute(APP_ICON_ATTR_NAME, "save");
1810  return true;
1811 
1812  case Ci.nsIHandlerInfo.handleInternally:
1813  if (isFeedType(aHandlerInfo.type)) {
1814  aElement.setAttribute(APP_ICON_ATTR_NAME, "feed");
1815  return true;
1816  }
1817  break;
1818 
1819  case kActionUsePlugin:
1820  aElement.setAttribute(APP_ICON_ATTR_NAME, "plugin");
1821  return true;
1822  }
1823  aElement.removeAttribute(APP_ICON_ATTR_NAME);
1824  return false;
1825  },
1826 
1827  _getIconURLForPreferredAction: function(aHandlerInfo) {
1828  switch (aHandlerInfo.preferredAction) {
1829  case Ci.nsIHandlerInfo.useSystemDefault:
1830  return this._getIconURLForSystemDefault(aHandlerInfo);
1831 
1832  case Ci.nsIHandlerInfo.useHelperApp:
1833  let (preferredApp = aHandlerInfo.preferredApplicationHandler) {
1834  if (this.isValidHandlerApp(preferredApp))
1835  return this._getIconURLForHandlerApp(preferredApp);
1836  }
1837  break;
1838 
1839  // This should never happen, but if preferredAction is set to some weird
1840  // value, then fall back to the generic application icon.
1841  default:
1842  return ICON_URL_APP;
1843  }
1844  },
1845 
1846  _getIconURLForHandlerApp: function(aHandlerApp) {
1847  if (aHandlerApp instanceof Ci.nsILocalHandlerApp)
1848  return this._getIconURLForFile(aHandlerApp.executable);
1849 
1850  if (aHandlerApp instanceof Ci.nsIWebHandlerApp)
1851  return this._getIconURLForWebApp(aHandlerApp.uriTemplate);
1852 
1853  if (aHandlerApp instanceof Ci.nsIWebContentHandlerInfo)
1854  return this._getIconURLForWebApp(aHandlerApp.uri)
1855 
1856  // We know nothing about other kinds of handler apps.
1857  return "";
1858  },
1859 
1860  _getIconURLForFile: function(aFile) {
1861  var fph = this._ioSvc.getProtocolHandler("file").
1862  QueryInterface(Ci.nsIFileProtocolHandler);
1863  var urlSpec = fph.getURLSpecFromFile(aFile);
1864 
1865  return "moz-icon://" + urlSpec + "?size=16";
1866  },
1867 
1868  _getIconURLForWebApp: function(aWebAppURITemplate) {
1869  var uri = this._ioSvc.newURI(aWebAppURITemplate, null, null);
1870 
1871  // Unfortunately we can't use the favicon service to get the favicon,
1872  // because the service looks in the annotations table for a record with
1873  // the exact URL we give it, and users won't have such records for URLs
1874  // they don't visit, and users won't visit the web app's URL template,
1875  // they'll only visit URLs derived from that template (i.e. with %s
1876  // in the template replaced by the URL of the content being handled).
1877 
1878  if (/^https?/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
1879  return uri.prePath + "/favicon.ico";
1880 
1881  return "";
1882  },
1883 
1884  _getIconURLForSystemDefault: function(aHandlerInfo) {
1885  // Handler info objects for MIME types on some OSes implement a property bag
1886  // interface from which we can get an icon for the default app, so if we're
1887  // dealing with a MIME type on one of those OSes, then try to get the icon.
1888  if ("wrappedHandlerInfo" in aHandlerInfo) {
1889  let wrappedHandlerInfo = aHandlerInfo.wrappedHandlerInfo;
1890 
1891  if (wrappedHandlerInfo instanceof Ci.nsIMIMEInfo &&
1892  wrappedHandlerInfo instanceof Ci.nsIPropertyBag) {
1893  try {
1894  let url = wrappedHandlerInfo.getProperty("defaultApplicationIconURL");
1895  if (url)
1896  return url + "?size=16";
1897  }
1898  catch(ex) {}
1899  }
1900  }
1901 
1902  // If this isn't a MIME type object on an OS that supports retrieving
1903  // the icon, or if we couldn't retrieve the icon for some other reason,
1904  // then use a generic icon.
1905  return ICON_URL_APP;
1906  }
1907 
1908 };
const PREF_VIDEO_FEED_SELECTED_APP
Definition: applications.js:98
function isFeedType(t)
const ICON_URL_APP
const TYPE_MAYBE_VIDEO_FEED
Definition: applications.js:60
const TYPE_MAYBE_AUDIO_FEED
Definition: applications.js:61
function getDisplayNameForFile(aFile)
var menuItem
Definition: FeedWriter.js:970
function ArrayEnumerator(aItems)
Wraps a js array in an nsISimpleEnumerator.
var pref
Definition: openLocation.js:44
const PREF_FEED_SELECTED_WEB
Definition: applications.js:94
var event
function getLocalHandlerApp(aFile)
function enumerate(enumerator, func)
var menu
const PREF_FEED_SELECTED_READER
Definition: applications.js:96
sidebarFactory createInstance
Definition: nsSidebar.js:351
sbOSDControlService prototype QueryInterface
var handlers
Definition: FeedWriter.js:1044
const char * types
const PREF_FEED_SELECTED_APP
Definition: applications.js:93
getService(Ci.sbIFaceplateManager)
const PREF_FEED_SELECTED_ACTION
Definition: applications.js:95
let window
const PREF_AUDIO_FEED_SELECTED_APP
var Ci
Definition: applications.js:53
function FeedHandlerInfo(aMIMEType)
_window init
Definition: FeedWriter.js:1144
this _contentSandbox label
Definition: FeedWriter.js:814
const kActionUsePlugin
var t
function HandlerInfoWrapper(aType, aHandlerInfo)
var feedHandlerInfo
const PREF_VIDEO_FEED_SELECTED_WEB
Definition: applications.js:99
const PREF_AUDIO_FEED_SELECTED_WEB
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
const PREF_DISABLED_PLUGIN_TYPES
Definition: applications.js:63
function newFileURI(file)
var Cc
Definition: applications.js:52
const APP_ICON_ATTR_NAME
return null
Definition: FeedWriter.js:1143
const PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS
Definition: applications.js:67
SimpleArrayEnumerator prototype hasMoreElements
return
Definition: FeedWriter.js:850
const PREF_AUDIO_FEED_SELECTED_READER
function url(spec)
var uri
Definition: FeedWriter.js:1135
countRef value
Definition: FeedWriter.js:1423
var Cr
Definition: applications.js:54
const PREF_AUDIO_FEED_SELECTED_ACTION
const PREF_SHOW_PLUGINS_IN_LIST
Definition: applications.js:66
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
GstMessage gpointer data sbGStreamerMessageHandler * handler
const TYPE_MAYBE_FEED
Definition: applications.js:59
const PREF_VIDEO_FEED_SELECTED_READER
_updateTextAndScrollDataForFrame aData
var file
sbDeviceFirmwareAutoCheckForUpdate prototype observe