Bug #44176 --> support a ShowProgress method to launch a standalone

progress dialog.
r=law, sr=alecf
This commit is contained in:
mscott%netscape.com 2000-10-04 06:53:08 +00:00
Родитель 709c18bab1
Коммит 22c6882ac0
3 изменённых файлов: 66 добавлений и 13 удалений

Просмотреть файл

@ -43,6 +43,8 @@ interface nsIHelperAppLauncherDialog : nsISupports {
// aSuggestedFileExtension --> sugested file extension
// aFileLocation --> return value for the file location
void promptForSaveToFile(in nsISupports aWindowContext, in wstring aDefaultFile, in wstring aSuggestedFileExtension, out nsILocalFile aFileLocation);
void showProgressDialog(in nsIHelperAppLauncher aLauncher, in nsISupports aContext);
};

Просмотреть файл

@ -52,17 +52,10 @@ nsHelperAppLauncherDialog.prototype= {
document.getElementById( "alwaysAskMe" ).setAttribute( "disabled", "true" );
// Pre-select the choice the user made last time.
if ( this.appLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.saveToDisk ) {
this.chosenApp = this.appLauncher.MIMEInfo.preferredApplicationHandler;
if ( this.chosenApp && this.appLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.saveToDisk ) {
// Run app.
document.getElementById( "runApp" ).checked = true;
this.chosenApp = this.appLauncher.MIMEInfo.preferredApplicationHandler;
var applicationDescription = this.appLauncher.MIMEInfo.applicationDescription;
if (applicationDescription != "")
document.getElementById( "appName" ).value = applicationDescription;
else
// If a user-chosen application, show its path.
document.getElementById( "appName" ).value = this.chosenApp.unicodePath;
document.getElementById( "runApp" ).checked = true;
} else {
// Save to disk.
document.getElementById( "saveToDisk" ).checked = true;
@ -70,6 +63,15 @@ nsHelperAppLauncherDialog.prototype= {
document.getElementById( "chooseApp" ).setAttribute( "disabled", "true" );
}
var applicationDescription = this.appLauncher.MIMEInfo.applicationDescription;
if (applicationDescription != "")
document.getElementById( "appName" ).value = applicationDescription;
else if (this.chosenApp)
{
// If a user-chosen application, show its path.
document.getElementById( "appName" ).value = this.chosenApp.unicodePath;
}
// Put content type into dialog text.
var html = document.getElementById( "intro" );
if ( html && html.childNodes && html.childNodes.length ) {
@ -109,7 +111,10 @@ nsHelperAppLauncherDialog.prototype= {
this.appLauncher.launchWithApplication( this.chosenApp, dontAskNextTime );
} else {
this.appLauncher.MIMEInfo.preferredAction = this.nsIHelperAppLauncher.saveToDisk;
this.appLauncher.saveToDisk( null, dontAskNextTime );
try {
this.appLauncher.saveToDisk( null, dontAskNextTime );
} catch (exception) {
}
}
window.close();

Просмотреть файл

@ -182,6 +182,46 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIChannel *aChannel,
return rv;
}
NS_IMETHODIMP
nsUnknownContentTypeHandler::ShowProgressDialog(nsIHelperAppLauncher *aLauncher, nsISupports *aContext ) {
nsresult rv = NS_ERROR_FAILURE;
// Get parent window (from context).
nsCOMPtr<nsIDOMWindowInternal> parent( do_GetInterface( aContext ) );
if ( parent ) {
// Get JS context from parent window.
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface( parent, &rv );
if ( NS_SUCCEEDED( rv ) && sgo ) {
nsCOMPtr<nsIScriptContext> context;
sgo->GetContext( getter_AddRefs( context ) );
if ( context ) {
// Get native context.
JSContext *jsContext = (JSContext*)context->GetNativeContext();
if ( jsContext ) {
// Set up window.arguments[0]...
void *stackPtr;
jsval *argv = JS_PushArguments( jsContext,
&stackPtr,
"sss%ip",
"chrome://global/content/helperAppDldProgress.xul",
"_blank",
"chrome,titlebar",
(const nsIID*)(&NS_GET_IID(nsIHelperAppLauncher)),
(nsISupports*)aLauncher );
if ( argv ) {
// Open the dialog.
nsCOMPtr<nsIDOMWindowInternal> dialog;
rv = parent->OpenDialog( jsContext, argv, 4, getter_AddRefs( dialog ) );
// Pop arguments.
JS_PopArguments( jsContext, stackPtr );
}
}
}
}
}
return rv;
}
// Show the helper app launch confirmation dialog as instructed.
NS_IMETHODIMP
nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher, nsISupports *aContext ) {
@ -206,7 +246,7 @@ nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher, nsISupports
"sss%ip",
"chrome://global/content/helperAppLauncher.xul",
"_blank",
"chrome",
"chrome,titlebar",
(const nsIID*)(&NS_GET_IID(nsIHelperAppLauncher)),
(nsISupports*)aLauncher );
if ( argv ) {
@ -244,7 +284,13 @@ nsUnknownContentTypeHandler::PromptForSaveToFile(nsISupports * aWindowContext, c
nsCOMPtr<nsIDOMWindowInternal> parent( do_GetInterface( aWindowContext ) );
filePicker->Init(parent, windowTitle, nsIFilePicker::modeSave);
filePicker->SetDefaultString(aDefaultFile);
filePicker->AppendFilter(aSuggestedFileExtension, aSuggestedFileExtension);
nsAutoString wildCardExtension (NS_LITERAL_STRING("*").get());
if (aSuggestedFileExtension)
wildCardExtension.Append(aSuggestedFileExtension);
else
wildCardExtension.Append(NS_LITERAL_STRING(".*").get());
filePicker->AppendFilter(wildCardExtension.GetUnicode(), wildCardExtension.GetUnicode());
filePicker->AppendFilters(nsIFilePicker::filterAll);
PRInt16 dialogResult;