Bug 1567423 - Combine all synchronous messages sent at startup of about:logins. r=MattN

Differential Revision: https://phabricator.services.mozilla.com/D45739

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jared Wein 2019-09-17 15:01:02 +00:00
Родитель a0762fda35
Коммит 9e6039ee22
5 изменённых файлов: 161 добавлений и 152 удалений

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

@ -140,12 +140,12 @@ let LEGACY_ACTORS = {
},
messages: [
"AboutLogins:AllLogins",
"AboutLogins:LocalizeBadges",
"AboutLogins:LoginAdded",
"AboutLogins:LoginModified",
"AboutLogins:LoginRemoved",
"AboutLogins:MasterPasswordResponse",
"AboutLogins:SendFavicons",
"AboutLogins:Setup",
"AboutLogins:ShowLoginItemError",
"AboutLogins:SyncState",
"AboutLogins:UpdateBreaches",

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

@ -177,9 +177,6 @@ class AboutLoginsChild extends ActorChild {
case "AboutLogins:AllLogins":
this.sendToContent("AllLogins", message.data);
break;
case "AboutLogins:LocalizeBadges":
this.sendToContent("LocalizeBadges", message.data);
break;
case "AboutLogins:LoginAdded":
this.sendToContent("LoginAdded", message.data);
break;
@ -197,6 +194,9 @@ class AboutLoginsChild extends ActorChild {
case "AboutLogins:SendFavicons":
this.sendToContent("SendFavicons", message.data);
break;
case "AboutLogins:Setup":
this.sendToContent("Setup", message.data);
break;
case "AboutLogins:ShowLoginItemError":
this.sendToContent("ShowLoginItemError", message.data);
break;

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

@ -46,6 +46,123 @@ const HIDE_MOBILE_FOOTER_PREF = "signon.management.page.hideMobileFooter";
// even if it is disabled for other consumers such as about:newtab.
const EXPECTED_ABOUTLOGINS_REMOTE_TYPE = E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE;
// App store badges sourced from https://developer.apple.com/app-store/marketing/guidelines/#section-badges.
// This array mirrors the file names from the App store directory (./content/third-party/app-store)
const APP_STORE_LOCALES = [
"az",
"ar",
"bg",
"cs",
"da",
"de",
"el",
"en",
"es-mx",
"es",
"et",
"fi",
"fr",
"he",
"hu",
"id",
"it",
"ja",
"ko",
"lt",
"lv",
"my",
"nb",
"nl",
"nn",
"pl",
"pt-br",
"pt-pt",
"ro",
"ru",
"si",
"sk",
"sv",
"th",
"tl",
"tr",
"vi",
"zh-hans",
"zh-hant",
];
// Google play badges sourced from https://play.google.com/intl/en_us/badges/
// This array mirrors the file names from the play store directory (./content/third-party/play-store)
const PLAY_STORE_LOCALES = [
"af",
"ar",
"az",
"be",
"bg",
"bn",
"bs",
"ca",
"cs",
"da",
"de",
"el",
"en",
"es",
"et",
"eu",
"fa",
"fr",
"gl",
"gu",
"he",
"hi",
"hr",
"hu",
"hy",
"id",
"is",
"it",
"ja",
"ka",
"kk",
"km",
"kn",
"ko",
"lo",
"lt",
"lv",
"mk",
"mr",
"ms",
"my",
"nb",
"ne",
"nl",
"nn",
"pa",
"pl",
"pt-br",
"pt",
"ro",
"ru",
"si",
"sk",
"sl",
"sq",
"sr",
"sv",
"ta",
"te",
"th",
"tl",
"tr",
"uk",
"ur",
"uz",
"vi",
"zh-cn",
"zh-tw",
];
const convertSubjectToLogin = subject => {
subject.QueryInterface(Ci.nsILoginMetaInfo).QueryInterface(Ci.nsILoginInfo);
const login = LoginHelper.loginToVanillaObject(subject);
@ -265,154 +382,36 @@ var AboutLoginsParent = {
const logins = await this.getAllLogins();
try {
messageManager.sendAsyncMessage("AboutLogins:AllLogins", logins);
let syncState;
if (FXA_ENABLED) {
let syncState = this.getSyncState();
messageManager.sendAsyncMessage("AboutLogins:SyncState", syncState);
syncState = this.getSyncState();
this.updatePasswordSyncNotificationState();
}
// App store badges sourced from https://developer.apple.com/app-store/marketing/guidelines/#section-badges.
// This array mirrors the file names from the App store directory (./content/third-party/app-store)
const appStoreLocales = [
"az",
"ar",
"bg",
"cs",
"da",
"de",
"el",
"en",
"es-mx",
"es",
"et",
"fi",
"fr",
"he",
"hu",
"id",
"it",
"ja",
"ko",
"lt",
"lv",
"my",
"nb",
"nl",
"nn",
"pl",
"pt-br",
"pt-pt",
"ro",
"ru",
"si",
"sk",
"sv",
"th",
"tl",
"tr",
"vi",
"zh-hans",
"zh-hant",
];
// Google play badges sourced from https://play.google.com/intl/en_us/badges/
// This array mirrors the file names from the play store directory (./content/third-party/play-store)
const playStoreLocales = [
"af",
"ar",
"az",
"be",
"bg",
"bn",
"bs",
"ca",
"cs",
"da",
"de",
"el",
"en",
"es",
"et",
"eu",
"fa",
"fr",
"gl",
"gu",
"he",
"hi",
"hr",
"hu",
"hy",
"id",
"is",
"it",
"ja",
"ka",
"kk",
"km",
"kn",
"ko",
"lo",
"lt",
"lv",
"mk",
"mr",
"ms",
"my",
"nb",
"ne",
"nl",
"nn",
"pa",
"pl",
"pt-br",
"pt",
"ro",
"ru",
"si",
"sk",
"sl",
"sq",
"sr",
"sv",
"ta",
"te",
"th",
"tl",
"tr",
"uk",
"ur",
"uz",
"vi",
"zh-cn",
"zh-tw",
];
const playStoreBadgeLanguage = Services.locale.negotiateLanguages(
Services.locale.appLocalesAsBCP47,
playStoreLocales,
"en-US",
PLAY_STORE_LOCALES,
"en-us",
Services.locale.langNegStrategyLookup
);
)[0];
const appStoreBadgeLanguage = Services.locale.negotiateLanguages(
Services.locale.appLocalesAsBCP47,
appStoreLocales,
"en-US",
APP_STORE_LOCALES,
"en-us",
Services.locale.langNegStrategyLookup
);
)[0];
const selectedBadgeLanguages = {
appStoreBadge: appStoreBadgeLanguage,
playStoreBadge: playStoreBadgeLanguage,
appStoreBadgeLanguage,
playStoreBadgeLanguage,
};
messageManager.sendAsyncMessage(
"AboutLogins:LocalizeBadges",
selectedBadgeLanguages
);
messageManager.sendAsyncMessage("AboutLogins:Setup", {
logins,
syncState,
selectedBadgeLanguages,
});
if (BREACH_ALERTS_ENABLED) {
const breachesByLoginGUID = await LoginBreaches.getPotentialBreachesByLoginGUID(

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

@ -31,16 +31,21 @@ function updateNoLogins() {
gElements.loginItem.classList.toggle("no-logins", numberOfLogins == 0);
}
function handleAllLogins(logins) {
gElements.loginList.setLogins(logins);
numberOfLogins = logins.length;
updateNoLogins();
}
function handleSyncState(syncState) {
gElements.fxAccountsButton.updateState(syncState);
gElements.loginFooter.hidden = syncState.hideMobileFooter;
}
window.addEventListener("AboutLoginsChromeToContent", event => {
switch (event.detail.messageType) {
case "AllLogins": {
gElements.loginList.setLogins(event.detail.value);
numberOfLogins = event.detail.value.length;
updateNoLogins();
break;
}
case "LocalizeBadges": {
gElements.loginFooter.showStoreIconsForLocales(event.detail.value);
handleAllLogins(event.detail.value);
break;
}
case "LoginAdded": {
@ -66,13 +71,20 @@ window.addEventListener("AboutLoginsChromeToContent", event => {
gElements.loginList.addFavicons(event.detail.value);
break;
}
case "Setup": {
handleAllLogins(event.detail.value.logins);
gElements.loginFooter.showStoreIconsForLocales(
event.detail.value.selectedBadgeLanguages
);
handleSyncState(event.detail.value.syncState);
break;
}
case "ShowLoginItemError": {
gElements.loginItem.showLoginItemError(event.detail.value);
break;
}
case "SyncState": {
gElements.fxAccountsButton.updateState(event.detail.value);
gElements.loginFooter.hidden = event.detail.value.hideMobileFooter;
handleSyncState(event.detail.value);
break;
}
case "UpdateBreaches": {

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

@ -52,26 +52,24 @@ export default class LoginFooter extends HTMLElement {
}
_setAppStoreImage(lang) {
const currLang = lang.toLowerCase();
let appStoreLink =
"chrome://browser/content/aboutlogins/third-party/app-store/app_" +
currLang +
lang +
".png";
this._imageAppStore.setAttribute("src", appStoreLink);
}
_setPlayStoreImage(lang) {
const currLang = lang.toLowerCase();
let playStoreLink =
"chrome://browser/content/aboutlogins/third-party/play-store/play_" +
currLang +
lang +
".png";
this._imagePlayStore.setAttribute("src", playStoreLink);
}
showStoreIconsForLocales(appLocales) {
this._setAppStoreImage(appLocales.appStoreBadge[0]);
this._setPlayStoreImage(appLocales.playStoreBadge[0]);
this._setAppStoreImage(appLocales.appStoreBadgeLanguage);
this._setPlayStoreImage(appLocales.playStoreBadgeLanguage);
}
}
customElements.define("login-footer", LoginFooter);