diff --git a/xpfe/components/ucth/public/nsIHelperAppLauncherDialog.idl b/xpfe/components/ucth/public/nsIHelperAppLauncherDialog.idl index 0d28043520d0..e10b963a905c 100644 --- a/xpfe/components/ucth/public/nsIHelperAppLauncherDialog.idl +++ b/xpfe/components/ucth/public/nsIHelperAppLauncherDialog.idl @@ -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); }; diff --git a/xpfe/components/ucth/resources/helperAppLauncher.js b/xpfe/components/ucth/resources/helperAppLauncher.js index 88c43f0ddf88..a884187e4261 100644 --- a/xpfe/components/ucth/resources/helperAppLauncher.js +++ b/xpfe/components/ucth/resources/helperAppLauncher.js @@ -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(); diff --git a/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp b/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp index fef205836c72..1336a0d5ab23 100644 --- a/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp +++ b/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp @@ -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 parent( do_GetInterface( aContext ) ); + if ( parent ) { + // Get JS context from parent window. + nsCOMPtr sgo = do_QueryInterface( parent, &rv ); + if ( NS_SUCCEEDED( rv ) && sgo ) { + nsCOMPtr 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 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 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;