Bug 570156 - Convert download dialog to a nsIPromptService prompt [r=mbrubeck]

This commit is contained in:
Mark Finkle 2010-06-07 15:46:54 -04:00
Родитель c7f993e35f
Коммит 1da6992c36
6 изменённых файлов: 59 добавлений и 61 удалений

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

@ -2718,45 +2718,6 @@ var AlertsHelper = {
}
};
var HelperAppDialog = {
_launcher: null,
_container: null,
show: function had_show(aLauncher) {
this._launcher = aLauncher;
document.getElementById("helperapp-target").value = this._launcher.suggestedFileName;
if (!this._launcher.MIMEInfo.hasDefaultHandler)
document.getElementById("helperapp-open").disabled = true;
this._container = document.getElementById("helperapp-container");
this._container.hidden = false;
let rect = this._container.getBoundingClientRect();
this._container.top = (window.innerHeight - rect.height) / 2;
this._container.left = (window.innerWidth - rect.width) / 2;
BrowserUI.pushPopup(this, this._container);
},
save: function had_save() {
this._launcher.saveToDisk(null, false);
this.hide();
},
open: function had_open() {
this._launcher.launchWithApplication(null, false);
this.hide();
},
hide: function had_hide() {
document.getElementById("helperapp-target").value = "";
this._container.hidden = true;
BrowserUI.popPopup();
}
};
function ProgressController(tab) {
this._tab = tab;

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

@ -497,18 +497,6 @@
<placelist id="bookmark-items" type="bookmarks" flex="1" onopen="BookmarkList.openBookmark();" autoedit="true"/>
</vbox>
<!-- save/open dialog -->
<vbox id="helperapp-container" class="dialog-dark" hidden="true" align="center" top="0" left="0">
<label id="helperapp-prompt" value="&helperApp.prompt;"/>
<label id="helperapp-target" value="" crop="center"/>
<separator/>
<hbox pack="center">
<button id="helperapp-open" class="button-dark" label="&helperApp.open;" oncommand="HelperAppDialog.open();"/>
<button id="helperapp-save" class="button-dark" label="&helperApp.save;" oncommand="HelperAppDialog.save();"/>
<button id="helperapp-nothing" class="button-dark" label="&helperApp.nothing;" oncommand="HelperAppDialog.hide();"/>
</hbox>
</vbox>
<vbox id="context-popup" hidden="true" class="dialog-dark" top="0" left="0">
<hbox id="context-header">
<label id="context-hint" crop="center" flex="1"/>

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

@ -54,12 +54,57 @@ HelperAppLauncherDialog.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIHelperAppLauncherDialog]),
show: function hald_show(aLauncher, aContext, aReason) {
this._launcher = aLauncher;
this._context = aContext;
let window = aContext.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowInternal);
let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
let browser = wm.getMostRecentWindow("navigator:browser");
browser.HelperAppDialog.show(aLauncher);
let sbs = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
let bundle = sbs.createBundle("chrome://browser/locale/browser.properties");
let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
let flags = Ci.nsIPrompt.BUTTON_POS_1_DEFAULT +
(Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_0) +
(Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_1);
let title = bundle.GetStringFromName("helperApp.title");
let message = bundle.GetStringFromName("helperApp.prompt");
message += "\n " + aLauncher.suggestedFileName;
let type = aLauncher.MIMEInfo.description;
if (type == "") {
try {
type = aLauncher.MIMEInfo.primaryExtension.toUpperCase();
} catch (e) {
type = aLauncher.MIMEInfo.MIMEType;
}
}
message += "\n " + type;
let open = bundle.GetStringFromName("helperApp.open");
let save = bundle.GetStringFromName("helperApp.save");
let nothing = bundle.GetStringFromName("helperApp.nothing");
// Check to see if we can open this file or not
if (aLauncher.MIMEInfo.hasDefaultHandler) {
flags += (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_2);
let choice = prompter.confirmEx(window,
title, message,
flags, save, open, nothing,
null, {});
if (choice == 0)
aLauncher.saveToDisk(null, false);
else if (choice == 1)
aLauncher.launchWithApplication(null, false);
} else {
let choice = prompter.confirmEx(window,
title, message,
flags, save, nothing, null,
null, {});
if (choice == 0)
aLauncher.saveToDisk(null, false);
}
},
promptForSaveToFile: function hald_promptForSaveToFile(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) {

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

@ -27,11 +27,6 @@
<!ENTITY editBookmarkDone.label "Done">
<!ENTITY editBookmarkTags.label "Add tags here">
<!ENTITY helperApp.prompt "What would you like to do with">
<!ENTITY helperApp.open "Open">
<!ENTITY helperApp.save "Save">
<!ENTITY helperApp.nothing "Nothing">
<!ENTITY formHelper.previous "Previous">
<!ENTITY formHelper.next "Next">
<!ENTITY formHelper.done "Done">

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

@ -149,3 +149,11 @@ pageactions.geo=Location
pageactions.popup=Popups
pageactions.offline-app=Offline Storage
pageactions.password=Password
# Helper App Dialog (Save/Open)
helperApp.title=Opening File
helperApp.prompt=What would you like to do with:
helperApp.open=Open
helperApp.save=Save
helperApp.nothing=Nothing

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

@ -160,6 +160,7 @@ dialog .prompt-title {
dialog .prompt-message {
margin-top: 8px;
white-space: pre-wrap;
}
dialog .button-checkbox {