1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6#include "nsISupports.idl" 7 8interface nsIHelperAppLauncher; 9interface nsIFile; 10interface nsIInterfaceRequestor; 11 12/** 13 * This interface is used to display a confirmation dialog before 14 * launching a "helper app" to handle content not handled by 15 * Mozilla. 16 * 17 * Usage: Clients (of which there is one: the nsIExternalHelperAppService 18 * implementation in mozilla/uriloader/exthandler) create an instance of 19 * this interface (using the contract ID) and then call the show() method. 20 * 21 * The dialog is shown non-modally. The implementation of the dialog 22 * will access methods of the nsIHelperAppLauncher passed in to show() 23 * in order to cause a "save to disk" or "open using" action. 24 */ 25[scriptable, uuid(bfc739f3-8d75-4034-a6f8-1039a5996bad)] 26interface nsIHelperAppLauncherDialog : nsISupports { 27 /** 28 * This request is passed to the helper app dialog because Gecko can not 29 * handle content of this type. 30 */ 31 const unsigned long REASON_CANTHANDLE = 0; 32 33 /** 34 * The server requested external handling. 35 */ 36 const unsigned long REASON_SERVERREQUEST = 1; 37 38 /** 39 * Gecko detected that the type sent by the server (e.g. text/plain) does 40 * not match the actual type. 41 */ 42 const unsigned long REASON_TYPESNIFFED = 2; 43 44 /** 45 * Show confirmation dialog for launching application (or "save to 46 * disk") for content specified by aLauncher. 47 * 48 * @param aLauncher 49 * A nsIHelperAppLauncher to be invoked when a file is selected. 50 * @param aWindowContext 51 * Window associated with action. 52 * @param aReason 53 * One of the constants from above. It indicates why the dialog is 54 * shown. Implementors should treat unknown reasons like 55 * REASON_CANTHANDLE. 56 */ 57 void show(in nsIHelperAppLauncher aLauncher, 58 in nsIInterfaceRequestor aWindowContext, 59 in unsigned long aReason); 60 61 /** 62 * Async invoke a save-to-file dialog instead of the full fledged helper app 63 * dialog. When the file is chosen (or the dialog is closed), the callback 64 * in aLauncher (aLauncher.saveDestinationAvailable) is called with the 65 * selected file. 66 * 67 * @param aLauncher 68 * A nsIHelperAppLauncher to be invoked when a file is selected. 69 * @param aWindowContext 70 * Window associated with action. 71 * @param aDefaultFileName 72 * Default file name to provide (can be null) 73 * @param aSuggestedFileExtension 74 * Sugested file extension 75 * @param aForcePrompt 76 * Set to true to force prompting the user for thet file 77 * name/location, otherwise perferences may control if the user is 78 * prompted. 79 */ 80 void promptForSaveToFileAsync(in nsIHelperAppLauncher aLauncher, 81 in nsIInterfaceRequestor aWindowContext, 82 in wstring aDefaultFileName, 83 in wstring aSuggestedFileExtension, 84 in boolean aForcePrompt); 85}; 86 87 88%{C++ 89#define NS_HELPERAPPLAUNCHERDLG_CONTRACTID "@mozilla.org/helperapplauncherdialog;1" 90%} 91