Bug 921804 - Show checkboxes at the bottom of prompts. r=mfinkle

This commit is contained in:
Wes Johnston 2013-12-17 10:15:14 -08:00
Родитель 16b03a57c8
Коммит 5e48596dff
1 изменённых файлов: 17 добавлений и 20 удалений

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

@ -10,18 +10,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Prompt.jsm");
// Whitelist of methods we remote - to check against malicious data.
// For example, it would be dangerous to allow content to show auth prompts.
const REMOTABLE_METHODS = {
alert: { outParams: [] },
alertCheck: { outParams: [4] },
confirm: { outParams: [] },
prompt: { outParams: [3, 5] },
confirmEx: { outParams: [8] },
confirmCheck: { outParams: [4] },
select: { outParams: [5] }
};
var gPromptService = null;
function PromptService() {
@ -134,18 +122,21 @@ InternalPrompt.prototype = {
PromptUtils.getLocaleString("Cancel")
]
});
return p;
},
addCheckbox: function addCheckbox(aPrompt, aCheckMsg, aCheckState) {
// Don't bother to check for aCheckSate. For nsIPomptService interfaces, aCheckState is an
// out param and is required to be defined. If we've gotten here without it, something
// has probably gone wrong and we should fail
if (aCheckMsg) {
p.addCheckbox({
aPrompt.addCheckbox({
label: PromptUtils.cleanUpLabel(aCheckMsg),
checked: aCheckState.value
});
}
return p;
return aPrompt;
},
/* Shows a native prompt, and then spins the event loop for this thread while we wait
@ -223,7 +214,8 @@ InternalPrompt.prototype = {
},
alertCheck: function alertCheck(aTitle, aText, aCheckMsg, aCheckState) {
let p = this._getPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], aCheckMsg, aCheckState);
let p = this._getPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ]);
this.addCheckbox(p, aCheckMsg, aCheckState);
let data = this.showPrompt(p);
if (aCheckState && data.button > -1)
aCheckState.value = data.checkbox0 == "true";
@ -237,7 +229,8 @@ InternalPrompt.prototype = {
},
confirmCheck: function confirmCheck(aTitle, aText, aCheckMsg, aCheckState) {
let p = this._getPrompt(aTitle, aText, null, aCheckMsg, aCheckState);
let p = this._getPrompt(aTitle, aText, null);
this.addCheckbox(p, aCheckMsg, aCheckState);
let data = this.showPrompt(p);
let ok = data.button == 0;
if (aCheckState && data.button > -1)
@ -284,7 +277,8 @@ InternalPrompt.prototype = {
aButtonFlags >>= 8;
}
let p = this._getPrompt(aTitle, aText, buttons, aCheckMsg, aCheckState);
let p = this._getPrompt(aTitle, aText, buttons);
this.addCheckbox(p, aCheckMsg, aCheckState);
let data = this.showPrompt(p);
if (aCheckState && data.button > -1)
aCheckState.value = data.checkbox0 == "true";
@ -298,6 +292,7 @@ InternalPrompt.prototype = {
value: aValue.value,
autofocus: true
});
this.addCheckbox(p, aCheckMsg, aCheckState);
let data = this.showPrompt(p);
let ok = data.button == 0;
@ -310,12 +305,13 @@ InternalPrompt.prototype = {
nsIPrompt_promptPassword: function nsIPrompt_promptPassword(
aTitle, aText, aPassword, aCheckMsg, aCheckState) {
let p = this._getPrompt(aTitle, aText, null, aCheckMsg, aCheckState);
let p = this._getPrompt(aTitle, aText, null);
p.addPassword({
value: aPassword.value || "",
autofocus: true,
hint: PromptUtils.getLocaleString("password", "passwdmgr")
});
this.addCheckbox(p, aCheckMsg, aCheckState);
let data = this.showPrompt(p);
let ok = data.button == 0;
@ -328,7 +324,7 @@ InternalPrompt.prototype = {
nsIPrompt_promptUsernameAndPassword: function nsIPrompt_promptUsernameAndPassword(
aTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState) {
let p = this._getPrompt(aTitle, aText, null, aCheckMsg, aCheckState);
let p = this._getPrompt(aTitle, aText, null);
p.addTextbox({
value: aUsername.value,
autofocus: true,
@ -337,6 +333,7 @@ InternalPrompt.prototype = {
value: aPassword.value,
hint: PromptUtils.getLocaleString("password", "passwdmgr")
});
this.addCheckbox(p, aCheckMsg, aCheckState);
let data = this.showPrompt(p);
let ok = data.button == 0;
@ -350,7 +347,7 @@ InternalPrompt.prototype = {
},
select: function select(aTitle, aText, aCount, aSelectList, aOutSelection) {
let p = this._getPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], "", { value: false });
let p = this._getPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ]);
p.addMenulist({ values: aSelectList });
let data = this.showPrompt(p);