зеркало из https://github.com/mozilla/gecko-dev.git
Bug #44176 --> support a ShowProgress method to launch a standalone
progress dialog. r=law, sr=alecf
This commit is contained in:
Родитель
709c18bab1
Коммит
22c6882ac0
|
@ -43,6 +43,8 @@ interface nsIHelperAppLauncherDialog : nsISupports {
|
||||||
// aSuggestedFileExtension --> sugested file extension
|
// aSuggestedFileExtension --> sugested file extension
|
||||||
// aFileLocation --> return value for the file location
|
// aFileLocation --> return value for the file location
|
||||||
void promptForSaveToFile(in nsISupports aWindowContext, in wstring aDefaultFile, in wstring aSuggestedFileExtension, out nsILocalFile aFileLocation);
|
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" );
|
document.getElementById( "alwaysAskMe" ).setAttribute( "disabled", "true" );
|
||||||
|
|
||||||
// Pre-select the choice the user made last time.
|
// 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.
|
// Run app.
|
||||||
document.getElementById( "runApp" ).checked = true;
|
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;
|
|
||||||
} else {
|
} else {
|
||||||
// Save to disk.
|
// Save to disk.
|
||||||
document.getElementById( "saveToDisk" ).checked = true;
|
document.getElementById( "saveToDisk" ).checked = true;
|
||||||
|
@ -70,6 +63,15 @@ nsHelperAppLauncherDialog.prototype= {
|
||||||
document.getElementById( "chooseApp" ).setAttribute( "disabled", "true" );
|
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.
|
// Put content type into dialog text.
|
||||||
var html = document.getElementById( "intro" );
|
var html = document.getElementById( "intro" );
|
||||||
if ( html && html.childNodes && html.childNodes.length ) {
|
if ( html && html.childNodes && html.childNodes.length ) {
|
||||||
|
@ -109,7 +111,10 @@ nsHelperAppLauncherDialog.prototype= {
|
||||||
this.appLauncher.launchWithApplication( this.chosenApp, dontAskNextTime );
|
this.appLauncher.launchWithApplication( this.chosenApp, dontAskNextTime );
|
||||||
} else {
|
} else {
|
||||||
this.appLauncher.MIMEInfo.preferredAction = this.nsIHelperAppLauncher.saveToDisk;
|
this.appLauncher.MIMEInfo.preferredAction = this.nsIHelperAppLauncher.saveToDisk;
|
||||||
this.appLauncher.saveToDisk( null, dontAskNextTime );
|
try {
|
||||||
|
this.appLauncher.saveToDisk( null, dontAskNextTime );
|
||||||
|
} catch (exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.close();
|
window.close();
|
||||||
|
|
|
@ -182,6 +182,46 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIChannel *aChannel,
|
||||||
return rv;
|
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.
|
// Show the helper app launch confirmation dialog as instructed.
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher, nsISupports *aContext ) {
|
nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher, nsISupports *aContext ) {
|
||||||
|
@ -206,7 +246,7 @@ nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher, nsISupports
|
||||||
"sss%ip",
|
"sss%ip",
|
||||||
"chrome://global/content/helperAppLauncher.xul",
|
"chrome://global/content/helperAppLauncher.xul",
|
||||||
"_blank",
|
"_blank",
|
||||||
"chrome",
|
"chrome,titlebar",
|
||||||
(const nsIID*)(&NS_GET_IID(nsIHelperAppLauncher)),
|
(const nsIID*)(&NS_GET_IID(nsIHelperAppLauncher)),
|
||||||
(nsISupports*)aLauncher );
|
(nsISupports*)aLauncher );
|
||||||
if ( argv ) {
|
if ( argv ) {
|
||||||
|
@ -244,7 +284,13 @@ nsUnknownContentTypeHandler::PromptForSaveToFile(nsISupports * aWindowContext, c
|
||||||
nsCOMPtr<nsIDOMWindowInternal> parent( do_GetInterface( aWindowContext ) );
|
nsCOMPtr<nsIDOMWindowInternal> parent( do_GetInterface( aWindowContext ) );
|
||||||
filePicker->Init(parent, windowTitle, nsIFilePicker::modeSave);
|
filePicker->Init(parent, windowTitle, nsIFilePicker::modeSave);
|
||||||
filePicker->SetDefaultString(aDefaultFile);
|
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);
|
filePicker->AppendFilters(nsIFilePicker::filterAll);
|
||||||
|
|
||||||
PRInt16 dialogResult;
|
PRInt16 dialogResult;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче