nsHelperAppDlg - @line

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* [email protected] 45 "e:\builds\moz2_slave\win32_build\build\toolkit\mozapps\downloads\src\nsHelperAppDl g.js.in" */ /////////////////////////////////////////////////////////////////////////////// //// Helper Functions /** * Determines if a given directory is able to be used to download to. * * @param aDirectory * The directory to check. * @returns true if we can use the directory, false otherwise. */ function isUsableDirectory(aDirectory) { return aDirectory.exists() && aDirectory.isDirectory() && aDirectory.isWritable(); } /////////////////////////////////////////////////////////////////////////////// //// nsUnkownContentTypeDialog /* This file implements the nsIHelperAppLauncherDialog interface. * * The implementation consists of a JavaScript "class" named nsUnknownContentTypeDialog, * comprised of: * - a JS constructor function * - a prototype providing all the interface methods and implementation stuff * * In addition, this file implements an nsIModule object that registers the * nsUnknownContentTypeDialog component. */ const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir"; const nsITimer = Components.interfaces.nsITimer; Components.utils.import("resource://gre/modules/DownloadLastDir.jsm"); /* ctor */ function nsUnknownContentTypeDialog() { // Initialize data properties. this.mLauncher = null; this.mContext = null; this.mSourcePath = null; this.chosenApp = null; this.givenDefaultApp = false; this.updateSelf = true; this.mTitle = ""; } nsUnknownContentTypeDialog.prototype = { nsIMIMEInfo : Components.interfaces.nsIMIMEInfo, QueryInterface: function (iid) { if (!iid.equals(Components.interfaces.nsIHelperAppLauncherDialog) && !iid.equals(Components.interfaces.nsITimerCallback) && !iid.equals(Components.interfaces.nsISupports)) { throw Components.results.NS_ERROR_NO_INTERFACE; } return this; }, // ---------- nsIHelperAppLauncherDialog methods ---------- // show: Open XUL dialog using window watcher. Since the dialog is not // modal, it needs to be a top level window and the way to open // one of those is via that route). show: function(aLauncher, aContext, aReason) { this.mLauncher = aLauncher; this.mContext = aContext; const nsITimer = Components.interfaces.nsITimer; this._showTimer = Components.classes["@mozilla.org/timer;1"] .createInstance(nsITimer); this._showTimer.initWithCallback(this, 0, nsITimer.TYPE_ONE_SHOT); }, // When opening from new tab, if tab closes while dialog is opening, // (which is a race condition on the XUL file being cached and the timer // in nsExternalHelperAppService), the dialog gets a blur and doesn't // activate the OK button. So we wait a bit before doing opening it. reallyShow: function() { try { var ir = this.mContext.QueryInterface(Components.interfaces.nsIInterfaceRequestor); var dwi = ir.getInterface(Components.interfaces.nsIDOMWindowInternal); var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] .getService(Components.interfaces.nsIWindowWatcher); this.mDialog = ww.openWindow(dwi, "chrome://mozapps/content/downloads/unknownC...
View Full Document

This note was uploaded on 03/11/2010 for the course ISD 125 taught by Professor 3ant during the Spring '10 term at École Normale Supérieure.

Page1 / 21

nsHelperAppDlg - @line

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online