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 11:33:26 -08:00
parent 0d3c713dd0
commit a714da4a56
7 changed files with 81 additions and 44 deletions

View File

@ -34,8 +34,13 @@
#
# ***** END LICENSE BLOCK *****
EnterUserPasswordForRealm=Enter username and password for "%1$S" at %2$S
EnterUserPasswordForProxy=Enter username and password for proxy "%1$S" at %2$S
# Localizer note: %1 is an untrusted string provided by a remote server. It
# 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
EnterPasswordFor=Enter password for %1$S on %2$S

View File

@ -55,6 +55,9 @@
#include "nsIIDNService.h"
#include "nsNetUtil.h"
#include "nsPromptUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
nsresult
NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent)
@ -418,6 +421,26 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
nsAutoString 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
if (port != -1) {
@ -425,8 +448,8 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
displayHost.AppendInt(port);
}
NS_NAMED_LITERAL_STRING(proxyText, "EnterUserPasswordForProxy");
NS_NAMED_LITERAL_STRING(originText, "EnterUserPasswordForRealm");
NS_NAMED_LITERAL_STRING(proxyText, "EnterLoginForProxy");
NS_NAMED_LITERAL_STRING(originText, "EnterLoginForRealm");
NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor");
NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor");

View File

@ -37,9 +37,18 @@
@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-select: text;
cursor: text !important;
white-space: -moz-pre-wrap;
}
#loginLabel, #password1Label, #password2Label {
text-align: right;
}

View File

@ -124,9 +124,9 @@ function commonDialogOnLoad()
}
// 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
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);
@ -262,9 +262,7 @@ function setElementText(aElementID, aValue, aChildNodeFlag)
function setCheckbox(aChkMsg, aChkValue)
{
if (aChkMsg) {
// XXX Would love to use hidden instead of collapsed, but the checkbox
// fails to size itself properly when I do this.
document.getElementById("checkboxContainer").removeAttribute("collapsed");
unHideElementById("checkboxContainer");
var checkboxElement = document.getElementById("checkbox");
setLabelForNode(checkboxElement, aChkMsg);

View File

@ -38,46 +38,46 @@
</popup>
</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 -->
<vbox id="loginContainer" hidden="true">
<grid>
<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"/>
<textbox id="loginTextbox"/>
<separator class="thin"/>
</vbox>
<vbox id ="password1Container" hidden="true">
</row>
<row id ="password1Container" hidden="true" align="center">
<label id="password1Label" value="&editfield1.label;" control="password1Textbox"/>
<textbox type="password" id="password1Textbox"/>
<separator class="thin"/>
</vbox>
<vbox id="password2Container" hidden="true">
</row>
<row id="password2Container" hidden="true" align="center">
<label id="password2Label" value="&editfield2.label;" control="password2Textbox"/>
<textbox type="password" id="password2Textbox"/>
<separator class="thin"/>
</vbox>
<!-- checkbox -->
<vbox id="checkboxContainer" align="start" collapsed="true">
</row>
<row id="checkboxContainer" hidden="true">
<spacer/>
<checkbox id="checkbox" oncommand="onCheckboxClick(this);"/>
</vbox>
</vbox>
</hbox>
</row>
</rows>
</grid>
<!-- 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.

View File

@ -189,7 +189,9 @@
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;
line-height: 16px;
margin-bottom: 6px;

View File

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