зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
a0762fda35
Коммит
9e6039ee22
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче