michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIHelperAppLauncher; michael@0: interface nsIFile; michael@0: michael@0: /** michael@0: * This interface is used to display a confirmation dialog before michael@0: * launching a "helper app" to handle content not handled by michael@0: * Mozilla. michael@0: * michael@0: * Usage: Clients (of which there is one: the nsIExternalHelperAppService michael@0: * implementation in mozilla/uriloader/exthandler) create an instance of michael@0: * this interface (using the contract ID) and then call the show() method. michael@0: * michael@0: * The dialog is shown non-modally. The implementation of the dialog michael@0: * will access methods of the nsIHelperAppLauncher passed in to show() michael@0: * in order to cause a "save to disk" or "open using" action. michael@0: */ michael@0: [scriptable, uuid(3ae4dca8-ac91-4891-adcf-3fbebed6170e)] michael@0: interface nsIHelperAppLauncherDialog : nsISupports { michael@0: /** michael@0: * This request is passed to the helper app dialog because Gecko can not michael@0: * handle content of this type. michael@0: */ michael@0: const unsigned long REASON_CANTHANDLE = 0; michael@0: michael@0: /** michael@0: * The server requested external handling. michael@0: */ michael@0: const unsigned long REASON_SERVERREQUEST = 1; michael@0: michael@0: /** michael@0: * Gecko detected that the type sent by the server (e.g. text/plain) does michael@0: * not match the actual type. michael@0: */ michael@0: const unsigned long REASON_TYPESNIFFED = 2; michael@0: michael@0: /** michael@0: * Show confirmation dialog for launching application (or "save to michael@0: * disk") for content specified by aLauncher. michael@0: * michael@0: * @param aLauncher michael@0: * A nsIHelperAppLauncher to be invoked when a file is selected. michael@0: * @param aWindowContext michael@0: * Window associated with action. michael@0: * @param aReason michael@0: * One of the constants from above. It indicates why the dialog is michael@0: * shown. Implementors should treat unknown reasons like michael@0: * REASON_CANTHANDLE. michael@0: */ michael@0: void show(in nsIHelperAppLauncher aLauncher, michael@0: in nsISupports aWindowContext, michael@0: in unsigned long aReason); michael@0: michael@0: /** michael@0: * Invoke a save-to-file dialog instead of the full fledged helper app dialog. michael@0: * Returns the a nsIFile for the file name/location selected. michael@0: * michael@0: * @param aLauncher michael@0: * A nsIHelperAppLauncher to be invoked when a file is selected. michael@0: * @param aWindowContext michael@0: * Window associated with action. michael@0: * @param aDefaultFileName michael@0: * Default file name to provide (can be null) michael@0: * @param aSuggestedFileExtension michael@0: * Sugested file extension michael@0: * @param aForcePrompt michael@0: * Set to true to force prompting the user for thet file michael@0: * name/location, otherwise perferences may control if the user is michael@0: * prompted. michael@0: * michael@0: * @throws NS_ERROR_NOT_AVAILABLE if the async version of this function michael@0: * should be used. michael@0: */ michael@0: nsIFile promptForSaveToFile(in nsIHelperAppLauncher aLauncher, michael@0: in nsISupports aWindowContext, michael@0: in wstring aDefaultFileName, michael@0: in wstring aSuggestedFileExtension, michael@0: in boolean aForcePrompt); michael@0: michael@0: /** michael@0: * Async invoke a save-to-file dialog instead of the full fledged helper app michael@0: * dialog. When the file is chosen (or the dialog is closed), the callback michael@0: * in aLauncher (aLauncher.saveDestinationAvailable) is called with the michael@0: * selected file. michael@0: * michael@0: * @param aLauncher michael@0: * A nsIHelperAppLauncher to be invoked when a file is selected. michael@0: * @param aWindowContext michael@0: * Window associated with action. michael@0: * @param aDefaultFileName michael@0: * Default file name to provide (can be null) michael@0: * @param aSuggestedFileExtension michael@0: * Sugested file extension michael@0: * @param aForcePrompt michael@0: * Set to true to force prompting the user for thet file michael@0: * name/location, otherwise perferences may control if the user is michael@0: * prompted. michael@0: */ michael@0: void promptForSaveToFileAsync(in nsIHelperAppLauncher aLauncher, michael@0: in nsISupports aWindowContext, michael@0: in wstring aDefaultFileName, michael@0: in wstring aSuggestedFileExtension, michael@0: in boolean aForcePrompt); michael@0: }; michael@0: michael@0: michael@0: %{C++ michael@0: #define NS_HELPERAPPLAUNCHERDLG_CONTRACTID "@mozilla.org/helperapplauncherdialog;1" michael@0: %}