Bug 1689079 - allow account provisioning to use provider email and displayname, and fix some bugs. r=aleca

Provider can send back
 - x-thunderbird-account-name specifying the chosen display name
 - x-thunderbird-account-email specifying the chosen email

Other bug fixes:

 - only check main language, so if the provider supports "en", it will be shown to "en-US" users.
 - close the provider window after selecting an account - onload doesn't happen on trunk, and I don't see why we need to wait for the load to finish
 - tabmail: gStatusBar is an <hbox> - and sometimes not there. removing pointless setting of value
 - MsgAccountManager: needed in the provisioner success message, but wasn't included in accountProvisioner.xhtml
This commit is contained in:
Magnus Melin 2021-02-04 12:45:40 +02:00
Родитель fbc6de20c0
Коммит dcc568361a
4 изменённых файлов: 35 добавлений и 35 удалений

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

@ -1805,10 +1805,8 @@
if (typeof aThinkingState == "string") {
statusFeedback.showStatusString(aThinkingState);
}
gStatusBar.removeAttribute("value");
} else {
statusFeedback.showProgress(0);
gStatusBar.value = 0;
}
}

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

@ -115,10 +115,10 @@ var EmailAccountProvisioner = {
},
/**
* Returns the language that the user currently accepts.
* Returns the language tag of the language that the user currently accepts.
*/
get userLanguage() {
return Services.locale.requestedLocale;
return Services.locale.requestedLocale.split("-")[0];
},
/**
@ -585,19 +585,11 @@ var EmailAccountProvisioner = {
realName: (firstName + " " + lastName).trim(),
email,
searchEngine: provider.search_engine,
onLoad(aEvent, aBrowser) {
window.close();
},
});
// Wait for the handler to close us.
EmailAccountProvisioner.spinning(true);
EmailAccountProvisioner.searchEnabled(false);
for (let node of document.querySelectorAll(
"#notifications > :not(.spinner)"
)) {
node.style.display = "none";
}
// The user has made a selection. Close the provisioner window and let
// the provider setup process take place in the tab.
window.close();
},
/**
@ -611,8 +603,6 @@ var EmailAccountProvisioner = {
return;
}
gLog.info("Trying to populate provider list...");
// If there's a timeout ID for waking the account provisioner, clear it.
if (this._loadProviderRetryId) {
window.clearTimeout(this._loadProviderRetryId);
@ -626,6 +616,8 @@ var EmailAccountProvisioner = {
"mail.provider.providerList"
);
gLog.info(`Trying to populate provider list from ${providerListUrl}...`);
let request = new XMLHttpRequest();
request.open("GET", providerListUrl);
request.onload = function() {
@ -713,7 +705,7 @@ var EmailAccountProvisioner = {
EmailAccountProvisioner.providers = {};
data.forEach(function(provider) {
for (let provider of data) {
if (!EmailAccountProvisioner.providerHasCorrectFields(provider)) {
gLog.error("A provider had incorrect fields, and has been skipped");
return;
@ -721,13 +713,6 @@ var EmailAccountProvisioner = {
EmailAccountProvisioner.providers[provider.id] = provider;
// Let's go through the array of languages for this provider, and
// check to see if at least one of them matches the user's language.
// If so, we'll show / select this provider by default.
let supportsSomeUserLang = provider.languages.some(function(x) {
return x == "*" || x == EmailAccountProvisioner.userLanguage;
});
let checkboxId = provider.id + "-check";
let providerCheckbox = document.createElement("input");
@ -762,7 +747,11 @@ var EmailAccountProvisioner = {
EmailAccountProvisioner.populateTermsAndPrivacyLinks
);
if (supportsSomeUserLang) {
// Let's go through the array of languages for this provider, and
// check to see if at least one of them matches the user's language.
// If so, we'll show / select this provider by default.
let ul = EmailAccountProvisioner.userLanguage;
if (provider.languages.some(l => l == "*" || l == ul)) {
providerCheckbox.setAttribute("checked", "true");
providerEntry.style.display = "inline-block";
providerList.appendChild(providerEntry);
@ -770,7 +759,7 @@ var EmailAccountProvisioner = {
providerEntry.classList.add("otherLanguage");
otherLangProviders.push(providerEntry);
}
});
}
if (otherLangProviders.length) {
for (let provider of otherLangProviders) {

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

@ -36,6 +36,7 @@
</script>
<script src="chrome://messenger/content/newmailaccount/accountProvisioner.js">
</script>
<script src="chrome://messenger/content/accountUtils.js"></script>
</head>
<body dir="&locale.dir;">
<div id="window" class="vbox">

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

@ -53,18 +53,30 @@ httpRequestObserver.prototype = {
);
return;
}
// Helper function to get header values.
let getHttpHeader = (httpChannel, header) => {
// getResponseHeader throws when header is not set.
try {
return httpChannel.getResponseHeader(header);
} catch (e) {
return null;
}
};
let contentType = "";
try {
contentType = aSubject.getResponseHeader("Content-Type");
} catch (e) {
// If we couldn't get the response header, which can happen,
// just swallow the exception and return.
let contentType = getHttpHeader(aSubject, "Content-Type");
if (!contentType.toLowerCase().startsWith("text/xml")) {
return;
}
if (!contentType.toLowerCase().startsWith("text/xml")) {
return;
// It's possible the account information changed during the setup at the
// provider. Check some headers and set them if needed.
let name = getHttpHeader(aSubject, "x-thunderbird-account-name");
if (name) {
this.params.realName = name;
}
let email = getHttpHeader(aSubject, "x-thunderbird-account-email");
if (email) {
this.params.email = email;
}
let requestWindow = this._getWindowForRequest(aSubject);