mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-05 16:22:53 +00:00
bug 354410 move auth prompt strings out of necko. also, use the correct
strings for prompting without a realm and for prompting only for a password. r=darin
This commit is contained in:
parent
d65cf45412
commit
9a381e7875
@ -29,3 +29,4 @@
|
||||
locale/@AB_CD@/global-platform/mac/accessible.properties (%chrome/accessibility/mac/accessible.properties)
|
||||
locale/@AB_CD@/global-platform/unix/accessible.properties (%chrome/accessibility/unix/accessible.properties)
|
||||
locale/@AB_CD@/global/storage.properties (%chrome/storage.properties)
|
||||
locale/@AB_CD@/global/prompts.properties (%chrome/prompts.properties)
|
||||
|
@ -582,7 +582,7 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = bundleSvc->CreateBundle("chrome://necko/locale/necko.properties",
|
||||
rv = bundleSvc->CreateBundle("chrome://global/locale/prompts.properties",
|
||||
getter_AddRefs(bundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -600,6 +600,9 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
|
||||
nsCAutoString scheme;
|
||||
uri->GetScheme(scheme);
|
||||
|
||||
nsAutoString username;
|
||||
aAuthInfo->GetUsername(username);
|
||||
|
||||
PRUint32 flags;
|
||||
aAuthInfo->GetFlags(&flags);
|
||||
PRBool proxyAuth = (flags & nsIAuthInformation::AUTH_PROXY) != 0;
|
||||
@ -615,6 +618,8 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
|
||||
|
||||
NS_NAMED_LITERAL_STRING(proxyText, "EnterUserPasswordForProxy");
|
||||
NS_NAMED_LITERAL_STRING(originText, "EnterUserPasswordForRealm");
|
||||
NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor");
|
||||
NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor");
|
||||
|
||||
const PRUnichar *text;
|
||||
if (proxyAuth) {
|
||||
@ -630,8 +635,18 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
|
||||
}
|
||||
|
||||
const PRUnichar *strings[] = { realm.get(), displayHost.get() };
|
||||
PRUint32 count = NS_ARRAY_LENGTH(strings);
|
||||
|
||||
rv = bundle->FormatStringFromName(text, strings, 2, getter_Copies(message));
|
||||
if (flags & nsIAuthInformation::ONLY_PASSWORD) {
|
||||
text = passwordText.get();
|
||||
strings[0] = username.get();
|
||||
} else if (!proxyAuth && realm.IsEmpty()) {
|
||||
text = noRealmText.get();
|
||||
count--;
|
||||
strings[0] = strings[1];
|
||||
}
|
||||
|
||||
rv = bundle->FormatStringFromName(text, strings, count, getter_Copies(message));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,6 @@ extern "C" {
|
||||
#include "nsINetUtil.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsError.h"
|
||||
#include "netCore.h"
|
||||
#include "prlog.h"
|
||||
#include "prtime.h"
|
||||
#include "prprf.h"
|
||||
@ -243,7 +242,8 @@ ProxiedAuthCallback(gconstpointer in,
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
bundleSvc->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
|
||||
bundleSvc->CreateBundle("chrome://global/locale/prompts.properties",
|
||||
getter_AddRefs(bundle));
|
||||
if (!bundle)
|
||||
return;
|
||||
|
||||
|
@ -54,6 +54,14 @@ public:
|
||||
const nsString& User() const { return mUser; }
|
||||
const nsString& Password() const { return mPassword; }
|
||||
const nsString& Domain() const { return mDomain; }
|
||||
|
||||
/**
|
||||
* This method can be used to initialize the username when the
|
||||
* ONLY_PASSWORD flag is set.
|
||||
*/
|
||||
void SetUserInternal(const nsString& aUsername) {
|
||||
mUser = aUsername;
|
||||
}
|
||||
private:
|
||||
nsString mUser;
|
||||
nsString mPassword;
|
||||
|
@ -52,10 +52,6 @@
|
||||
27=Beginning FTP transaction...
|
||||
28=Finished FTP transaction
|
||||
|
||||
EnterUserPasswordForRealm=Enter username and password for "%1$S" at %2$S
|
||||
EnterUserPasswordForProxy=Enter username and password for proxy "%1$S" at %2$S
|
||||
EnterUserPasswordFor=Enter username and password for %1$S
|
||||
EnterPasswordFor=Enter password for %1$S on %2$S
|
||||
UnsupportedFTPServer=The FTP server %1$S is currently unsupported.
|
||||
RepostFormData=This web page is being redirected to a new location. Would you like to resend the form data you have typed to the new location?
|
||||
|
||||
|
@ -762,6 +762,8 @@ nsFtpState::S_pass() {
|
||||
EmptyString(),
|
||||
EmptyCString());
|
||||
|
||||
info->SetUserInternal(mUsername);
|
||||
|
||||
PRBool retval;
|
||||
rv = prompter->PromptAuth(mChannel, nsIAuthPrompt2::LEVEL_NONE,
|
||||
info, &retval);
|
||||
|
@ -84,12 +84,20 @@ function run_test() {
|
||||
do_check_eq(this.scheme + "://" + host, realm);
|
||||
|
||||
do_check_neq(text.indexOf(host), -1);
|
||||
// Only HTTP has realms
|
||||
if (this.scheme == "http")
|
||||
do_check_neq(text.indexOf(info.realm), -1);
|
||||
// No explicit port in the URL; message should not contain -1
|
||||
// for those cases
|
||||
do_check_eq(text.indexOf("-1"), -1);
|
||||
if (info.flags & nsIAuthInformation.ONLY_PASSWORD) {
|
||||
// Should have the username in the text
|
||||
do_check_neq(text.indexOf(info.username), -1);
|
||||
} else {
|
||||
// Make sure that we show the realm if we have one and that we don't
|
||||
// show "" otherwise
|
||||
if (info.realm != "")
|
||||
do_check_neq(text.indexOf(info.realm), -1);
|
||||
else
|
||||
do_check_eq(text.indexOf('""'), -1);
|
||||
// No explicit port in the URL; message should not contain -1
|
||||
// for those cases
|
||||
do_check_eq(text.indexOf("-1"), -1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -127,6 +135,9 @@ function run_test() {
|
||||
prompt1.rv = expectedRV;
|
||||
info.flags |= nsIAuthInformation.ONLY_PASSWORD;
|
||||
|
||||
// Initialize the username so that the prompt can show it
|
||||
info.username = prompt1.user;
|
||||
|
||||
wrapper = adapter.createAdapter(prompt1);
|
||||
rv = wrapper.promptAuth(chan, 0, info);
|
||||
do_check_eq(rv, prompt1.rv);
|
||||
@ -134,7 +145,7 @@ function run_test() {
|
||||
|
||||
if (rv) {
|
||||
do_check_eq(info.domain, "");
|
||||
do_check_eq(info.username, "");
|
||||
do_check_eq(info.username, prompt1.user); // we initialized this
|
||||
do_check_eq(info.password, prompt1.pw);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user