Bug 244273 - improve current HTTP authentication prompt. r=neil,bsmedberg ui-r=johnath, a=blocking-1.9+, a-latel10n=damons

This commit is contained in:
dolske%mozilla.com 2008-01-29 19:33:26 +00:00
Родитель 1dcaad2e40
Коммит fc103dbaff
7 изменённых файлов: 81 добавлений и 44 удалений

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

@ -34,8 +34,13 @@
# #
# ***** END LICENSE BLOCK ***** # ***** END LICENSE BLOCK *****
EnterUserPasswordForRealm=Enter username and password for "%1$S" at %2$S # Localizer note: %1 is an untrusted string provided by a remote server. It
EnterUserPasswordForProxy=Enter username and password for proxy "%1$S" at %2$S # could try to take advantage of sentence structure in order to mislead the
# user (see bug 244273). It should be integrated into the these property
# strings as little as possible.
EnterLoginForRealm=A username and password are being requested by %2$S. The site says: "%1$S"
EnterLoginForProxy=The proxy %2$S is requesting a username and password. The site says: "%1$S"
EnterUserPasswordFor=Enter username and password for %1$S EnterUserPasswordFor=Enter username and password for %1$S
EnterPasswordFor=Enter password for %1$S on %2$S EnterPasswordFor=Enter password for %1$S on %2$S

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

@ -55,6 +55,9 @@
#include "nsIIDNService.h" #include "nsIIDNService.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsPromptUtils.h" #include "nsPromptUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
nsresult nsresult
NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent) NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent)
@ -418,6 +421,26 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
nsAutoString realm; nsAutoString realm;
aAuthInfo->GetRealm(realm); aAuthInfo->GetRealm(realm);
// Trim obnoxiously long realms.
if (realm.Length() > 150) {
realm.Truncate(150);
// Append "..." (or localized equivalent). Yay complexity.
nsAutoString ellipsis;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
nsCOMPtr<nsIPrefLocalizedString> prefString;
rv = prefs->GetComplexValue("intl.ellipsis",
NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(prefString));
if (prefString)
prefString->ToString(getter_Copies(ellipsis));
}
if (ellipsis.IsEmpty())
ellipsis.AssignLiteral("...");
realm.Append(ellipsis);
}
// Append the port if it was specified // Append the port if it was specified
if (port != -1) { if (port != -1) {
@ -425,8 +448,8 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
displayHost.AppendInt(port); displayHost.AppendInt(port);
} }
NS_NAMED_LITERAL_STRING(proxyText, "EnterUserPasswordForProxy"); NS_NAMED_LITERAL_STRING(proxyText, "EnterLoginForProxy");
NS_NAMED_LITERAL_STRING(originText, "EnterUserPasswordForRealm"); NS_NAMED_LITERAL_STRING(originText, "EnterLoginForRealm");
NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor"); NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor");
NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor"); NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor");

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

@ -37,9 +37,18 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */ @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */
#info\.box > description { #infoContainer {
max-width: 45em;
}
#info\.body {
-moz-user-focus: normal; -moz-user-focus: normal;
-moz-user-select: text; -moz-user-select: text;
cursor: text !important; cursor: text !important;
white-space: -moz-pre-wrap; white-space: -moz-pre-wrap;
} }
#loginLabel, #password1Label, #password2Label {
text-align: right;
}

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

@ -124,9 +124,9 @@ function commonDialogOnLoad()
} }
// display the main text // display the main text
var messageParent = document.getElementById("info.box").getElementsByTagName('description')[0];
// XXX the substr(0, 10000) part is a workaround for bug 317334 // XXX the substr(0, 10000) part is a workaround for bug 317334
messageParent.textContent = gCommonDialogParam.GetString(0).substr(0, 10000); var croppedMessage = gCommonDialogParam.GetString(0).substr(0, 10000);
setElementText("info.body", croppedMessage, true);
setElementText("info.header", gCommonDialogParam.GetString(3), true); setElementText("info.header", gCommonDialogParam.GetString(3), true);
@ -262,9 +262,7 @@ function setElementText(aElementID, aValue, aChildNodeFlag)
function setCheckbox(aChkMsg, aChkValue) function setCheckbox(aChkMsg, aChkValue)
{ {
if (aChkMsg) { if (aChkMsg) {
// XXX Would love to use hidden instead of collapsed, but the checkbox unHideElementById("checkboxContainer");
// fails to size itself properly when I do this.
document.getElementById("checkboxContainer").removeAttribute("collapsed");
var checkboxElement = document.getElementById("checkbox"); var checkboxElement = document.getElementById("checkbox");
setLabelForNode(checkboxElement, aChkMsg); setLabelForNode(checkboxElement, aChkMsg);

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

@ -38,46 +38,46 @@
</popup> </popup>
</popupset> </popupset>
<hbox flex="1">
<hbox align="start">
<image id="info.icon" class="spaced"/>
</hbox>
<vbox flex="1" style="max-width: 45em;">
#ifdef XP_MACOSX
# On mac, we're exposing the dialog title inside the dialog
<!-- Dialog title -->
<description id="info.title" class="dialogTitle"/>
#endif
<!-- text -->
<description id="info.header" class="header"/>
<vbox id="info.box">
<description context="contentAreaContextMenu" tabindex="-1"/>
</vbox>
<!-- textboxes --> <grid>
<vbox id="loginContainer" hidden="true"> <columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<hbox align="start">
<image id="info.icon" class="spaced"/>
</hbox>
<vbox id="infoContainer">
#ifdef XP_MACOSX
<!-- Dialog title is inside dialog for OS X -->
<description id="info.title" class="dialogTitle"/>
#endif
<description id="info.header" class="header"/>
<description id="info.body" context="contentAreaContextMenu" tabindex="-1"/>
</vbox>
</row>
<row id="loginContainer" hidden="true" align="center">
<label id="loginLabel" value="&editfield0.label;" control="loginTextbox"/> <label id="loginLabel" value="&editfield0.label;" control="loginTextbox"/>
<textbox id="loginTextbox"/> <textbox id="loginTextbox"/>
<separator class="thin"/> </row>
</vbox> <row id ="password1Container" hidden="true" align="center">
<vbox id ="password1Container" hidden="true">
<label id="password1Label" value="&editfield1.label;" control="password1Textbox"/> <label id="password1Label" value="&editfield1.label;" control="password1Textbox"/>
<textbox type="password" id="password1Textbox"/> <textbox type="password" id="password1Textbox"/>
<separator class="thin"/> </row>
</vbox> <row id="password2Container" hidden="true" align="center">
<vbox id="password2Container" hidden="true">
<label id="password2Label" value="&editfield2.label;" control="password2Textbox"/> <label id="password2Label" value="&editfield2.label;" control="password2Textbox"/>
<textbox type="password" id="password2Textbox"/> <textbox type="password" id="password2Textbox"/>
<separator class="thin"/> </row>
</vbox> <row id="checkboxContainer" hidden="true">
<spacer/>
<!-- checkbox -->
<vbox id="checkboxContainer" align="start" collapsed="true">
<checkbox id="checkbox" oncommand="onCheckboxClick(this);"/> <checkbox id="checkbox" oncommand="onCheckboxClick(this);"/>
</vbox> </row>
</vbox> </rows>
</hbox> </grid>
<!-- This method is called inline because it may unset hidden="true" on the <!-- This method is called inline because it may unset hidden="true" on the
above boxes, causing their frames to be build and bindings to load. above boxes, causing their frames to be build and bindings to load.

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

@ -189,7 +189,9 @@
margin: 0px 2px 0px 1px !important; margin: 0px 2px 0px 1px !important;
} }
#commonDialog > hbox > vbox > description, #commonDialog > hbox > vbox > vbox > description { #commonDialog #info\.title,
#commonDialog #info\.header,
#commonDialog #info\.body {
font: menu; font: menu;
line-height: 16px; line-height: 16px;
margin-bottom: 6px; margin-bottom: 6px;

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

@ -186,7 +186,7 @@ statusbarpanel {
line-height: 13px; line-height: 13px;
} }
#commonDialog > hbox > vbox { #commonDialog #infoContainer {
max-width: 33em !important; max-width: 33em !important;
} }