AboutWelcomeDefaults.sys.mjs (34773B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 // We use importESModule here instead of static import so that 6 // the Karma test environment won't choke on this module. This 7 // is because the Karma test environment already stubs out 8 // AppConstants, and overrides importESModule to be a no-op (which 9 // can't be done for a static import statement). 10 11 // eslint-disable-next-line mozilla/use-static-import 12 const { AppConstants } = ChromeUtils.importESModule( 13 "resource://gre/modules/AppConstants.sys.mjs" 14 ); 15 16 const lazy = {}; 17 18 ChromeUtils.defineESModuleGetters(lazy, { 19 AddonRepository: "resource://gre/modules/addons/AddonRepository.sys.mjs", 20 AttributionCode: 21 "moz-src:///browser/components/attribution/AttributionCode.sys.mjs", 22 AWScreenUtils: "resource:///modules/aboutwelcome/AWScreenUtils.sys.mjs", 23 BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs", 24 }); 25 26 const isMSIX = 27 AppConstants.platform === "win" && 28 Services.sysinfo.getProperty("hasWinPackageId", false); 29 30 // Message to be updated based on finalized MR designs 31 const MR_ABOUT_WELCOME_DEFAULT = { 32 id: "MR_WELCOME_DEFAULT", 33 template: "multistage", 34 // Allow tests to easily disable transitions. 35 transitions: Services.prefs.getBoolPref( 36 "browser.aboutwelcome.transitions", 37 true 38 ), 39 backdrop: 40 "var(--mr-welcome-background-color) var(--mr-welcome-background-gradient)", 41 screens: [ 42 { 43 id: "AW_BACKUP_RESTORE_EMBEDDED_BACKUP_FOUND", 44 targeting: 45 "backupRestoreEnabled && (backupsInfo.found || backupsInfo.multipleBackupsFound)", 46 content: { 47 fullscreen: true, 48 logo: {}, 49 title: { 50 string_id: "restore-from-backup-title", 51 }, 52 subtitle: { 53 string_id: "restore-from-backup-subtitle", 54 }, 55 tiles: { 56 type: "backup_restore", 57 }, 58 position: "split", 59 split_narrow_bkg_position: "-42px", 60 background: 61 "url('chrome://activity-stream/content/data/content/assets/fox-doodle-backup-restore.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 62 progress_bar: true, 63 hide_secondary_section: "responsive", 64 backup_show_filepicker: { 65 action: {}, 66 }, 67 skip_button: { 68 label: { 69 string_id: "restore-from-backup-secondary-button", 70 }, 71 action: { 72 navigate: true, 73 }, 74 }, 75 }, 76 }, 77 { 78 id: "AW_WELCOME_BACK", 79 targeting: "isDeviceMigration", 80 content: { 81 fullscreen: true, 82 position: "split", 83 split_narrow_bkg_position: "-100px", 84 image_alt_text: { 85 string_id: "onboarding-device-migration-image-alt", 86 }, 87 background: 88 "url('chrome://activity-stream/content/data/content/assets/device-migration.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 89 progress_bar: true, 90 logo: {}, 91 title: { 92 string_id: "onboarding-device-migration-title", 93 }, 94 subtitle: { 95 string_id: "onboarding-device-migration-subtitle2", 96 }, 97 primary_button: { 98 label: { 99 string_id: "onboarding-device-migration-primary-button-label", 100 }, 101 action: { 102 type: "FXA_SIGNIN_FLOW", 103 needsAwait: true, 104 navigate: "actionResult", 105 data: { 106 entrypoint: "fx-device-migration-onboarding", 107 extraParams: { 108 utm_content: "migration-onboarding", 109 utm_source: "fx-new-device-sync", 110 utm_medium: "firefox-desktop", 111 utm_campaign: "migration", 112 }, 113 }, 114 }, 115 }, 116 secondary_button: { 117 label: { 118 string_id: "mr2022-onboarding-secondary-skip-button-label", 119 }, 120 action: { 121 navigate: true, 122 }, 123 has_arrow_icon: true, 124 }, 125 }, 126 }, 127 { 128 id: "RETURN_TO_AMO", 129 targeting: "isRTAMO", 130 content: { 131 fullscreen: true, 132 position: "split", 133 title: { string_id: "mr1-return-to-amo-subtitle" }, 134 isRtamo: true, 135 subtitle: { 136 string_id: "mr1-return-to-amo-addon-title", 137 }, 138 backdrop: 139 "var(--mr-welcome-background-color) var(--mr-welcome-background-gradient)", 140 background: 141 "url('chrome://activity-stream/content/data/content/assets/mr-rtamo-background-image.svg') center center / cover no-repeat", 142 progress_bar: true, 143 primary_button: { 144 label: { string_id: "mr1-return-to-amo-add-extension-label" }, 145 action: { 146 type: "INSTALL_ADDON_FROM_URL", 147 data: { url: null, telemetrySource: "rtamo" }, 148 }, 149 }, 150 secondary_button: { 151 label: { 152 string_id: "mr2022-onboarding-secondary-skip-button-label", 153 }, 154 action: { 155 navigate: true, 156 }, 157 has_arrow_icon: true, 158 }, 159 secondary_button_top: { 160 label: { 161 string_id: "mr1-onboarding-sign-in-button-label", 162 }, 163 action: { 164 data: { 165 entrypoint: "activity-stream-firstrun", 166 where: "tab", 167 }, 168 type: "SHOW_FIREFOX_ACCOUNTS", 169 addFlowParams: true, 170 }, 171 targeting: "!isFxASignedIn", 172 }, 173 }, 174 }, 175 { 176 id: "AW_EASY_SETUP_NEEDS_DEFAULT_AND_PIN", 177 targeting: 178 "doesAppNeedPin && (unhandledCampaignAction != 'SET_DEFAULT_BROWSER') && (unhandledCampaignAction != 'PIN_FIREFOX_TO_TASKBAR') && (unhandledCampaignAction != 'PIN_AND_DEFAULT') && 'browser.shell.checkDefaultBrowser'|preferenceValue && !isDefaultBrowser", 179 content: { 180 fullscreen: true, 181 position: "split", 182 split_narrow_bkg_position: "-60px", 183 image_alt_text: { 184 string_id: "mr2022-onboarding-default-image-alt", 185 }, 186 background: 187 "url('chrome://activity-stream/content/data/content/assets/mr-settodefault.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 188 progress_bar: true, 189 hide_secondary_section: "responsive", 190 logo: {}, 191 title: { 192 string_id: "onboarding-easy-setup-security-and-privacy-title", 193 }, 194 subtitle: { 195 string_id: "onboarding-easy-setup-security-and-privacy-subtitle", 196 }, 197 tiles: { 198 type: "multiselect", 199 data: [ 200 { 201 id: "checkbox-1", 202 defaultValue: true, 203 label: { 204 string_id: isMSIX 205 ? "mr2022-onboarding-pin-primary-button-label-msix" 206 : "mr2022-onboarding-pin-primary-button-label", 207 }, 208 action: { 209 type: "MULTI_ACTION", 210 data: { 211 actions: [ 212 { 213 type: "PIN_FIREFOX_TO_TASKBAR", 214 }, 215 { 216 type: "PIN_FIREFOX_TO_START_MENU", 217 }, 218 ], 219 }, 220 }, 221 }, 222 { 223 id: "checkbox-2", 224 defaultValue: true, 225 label: { 226 string_id: 227 "mr2022-onboarding-easy-setup-set-default-checkbox-label", 228 }, 229 action: { 230 type: "SET_DEFAULT_BROWSER", 231 }, 232 }, 233 { 234 id: "checkbox-3", 235 defaultValue: true, 236 label: { 237 string_id: "mr2022-onboarding-easy-setup-import-checkbox-label", 238 }, 239 uncheckedAction: { 240 type: "MULTI_ACTION", 241 data: { 242 actions: [ 243 { 244 type: "SET_PREF", 245 data: { 246 pref: { 247 name: "showEmbeddedImport", 248 }, 249 }, 250 }, 251 ], 252 }, 253 }, 254 checkedAction: { 255 type: "MULTI_ACTION", 256 data: { 257 actions: [ 258 { 259 type: "SET_PREF", 260 data: { 261 pref: { 262 name: "showEmbeddedImport", 263 value: true, 264 }, 265 }, 266 }, 267 ], 268 }, 269 }, 270 }, 271 ], 272 }, 273 primary_button: { 274 label: { 275 string_id: "mr2022-onboarding-easy-setup-primary-button-label", 276 }, 277 action: { 278 type: "MULTI_ACTION", 279 collectSelect: true, 280 navigate: true, 281 data: { 282 actions: [], 283 }, 284 }, 285 }, 286 secondary_button: { 287 label: { 288 string_id: "mr2022-onboarding-secondary-skip-button-label", 289 }, 290 action: { 291 navigate: true, 292 }, 293 has_arrow_icon: true, 294 }, 295 secondary_button_top: [ 296 { 297 label: { string_id: "mr1-onboarding-sign-in-button-label" }, 298 action: { 299 data: { entrypoint: "activity-stream-firstrun", where: "tab" }, 300 type: "SHOW_FIREFOX_ACCOUNTS", 301 addFlowParams: true, 302 }, 303 targeting: "!isFxASignedIn", 304 }, 305 { 306 label: { string_id: "restore-from-backup-secondary-top-button" }, 307 action: { 308 type: "SET_PREF", 309 data: { 310 pref: { name: "showRestoreFromBackup", value: true }, 311 }, 312 navigate: true, 313 }, 314 targeting: "backupRestoreEnabled", 315 }, 316 ], 317 }, 318 }, 319 { 320 id: "AW_EASY_SETUP_NEEDS_DEFAULT", 321 targeting: 322 "!doesAppNeedPin && (unhandledCampaignAction != 'SET_DEFAULT_BROWSER') && (unhandledCampaignAction != 'PIN_AND_DEFAULT') && 'browser.shell.checkDefaultBrowser'|preferenceValue && !isDefaultBrowser", 323 content: { 324 fullscreen: true, 325 position: "split", 326 split_narrow_bkg_position: "-60px", 327 image_alt_text: { 328 string_id: "mr2022-onboarding-default-image-alt", 329 }, 330 background: 331 "url('chrome://activity-stream/content/data/content/assets/mr-settodefault.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 332 progress_bar: true, 333 logo: {}, 334 title: { 335 string_id: "onboarding-easy-setup-security-and-privacy-title", 336 }, 337 subtitle: { 338 string_id: "onboarding-easy-setup-security-and-privacy-subtitle", 339 }, 340 tiles: { 341 type: "multiselect", 342 data: [ 343 { 344 id: "checkbox-1", 345 defaultValue: true, 346 label: { 347 string_id: 348 "mr2022-onboarding-easy-setup-set-default-checkbox-label", 349 }, 350 action: { 351 type: "SET_DEFAULT_BROWSER", 352 }, 353 }, 354 { 355 id: "checkbox-2", 356 defaultValue: true, 357 label: { 358 string_id: "mr2022-onboarding-easy-setup-import-checkbox-label", 359 }, 360 uncheckedAction: { 361 type: "MULTI_ACTION", 362 data: { 363 actions: [ 364 { 365 type: "SET_PREF", 366 data: { 367 pref: { 368 name: "showEmbeddedImport", 369 }, 370 }, 371 }, 372 ], 373 }, 374 }, 375 checkedAction: { 376 type: "MULTI_ACTION", 377 data: { 378 actions: [ 379 { 380 type: "SET_PREF", 381 data: { 382 pref: { 383 name: "showEmbeddedImport", 384 value: true, 385 }, 386 }, 387 }, 388 ], 389 }, 390 }, 391 }, 392 ], 393 }, 394 primary_button: { 395 label: { 396 string_id: "mr2022-onboarding-easy-setup-primary-button-label", 397 }, 398 action: { 399 type: "MULTI_ACTION", 400 collectSelect: true, 401 navigate: true, 402 data: { 403 actions: [], 404 }, 405 }, 406 }, 407 secondary_button: { 408 label: { 409 string_id: "mr2022-onboarding-secondary-skip-button-label", 410 }, 411 action: { 412 navigate: true, 413 }, 414 has_arrow_icon: true, 415 }, 416 secondary_button_top: [ 417 { 418 label: { string_id: "mr1-onboarding-sign-in-button-label" }, 419 action: { 420 data: { entrypoint: "activity-stream-firstrun", where: "tab" }, 421 type: "SHOW_FIREFOX_ACCOUNTS", 422 addFlowParams: true, 423 }, 424 targeting: "!isFxASignedIn", 425 }, 426 { 427 label: { string_id: "restore-from-backup-secondary-top-button" }, 428 action: { 429 type: "SET_PREF", 430 data: { 431 pref: { name: "showRestoreFromBackup", value: true }, 432 }, 433 navigate: true, 434 }, 435 targeting: "backupRestoreEnabled", 436 }, 437 ], 438 }, 439 }, 440 { 441 id: "AW_EASY_SETUP_NEEDS_PIN", 442 targeting: 443 "(unhandledCampaignAction != 'PIN_FIREFOX_TO_TASKBAR') && (unhandledCampaignAction != 'PIN_AND_DEFAULT') && doesAppNeedPin && (!'browser.shell.checkDefaultBrowser'|preferenceValue || isDefaultBrowser || (unhandledCampaignAction == 'SET_DEFAULT_BROWSER'))", 444 content: { 445 fullscreen: true, 446 position: "split", 447 split_narrow_bkg_position: "-60px", 448 image_alt_text: { 449 string_id: "mr2022-onboarding-default-image-alt", 450 }, 451 background: 452 "url('chrome://activity-stream/content/data/content/assets/mr-settodefault.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 453 progress_bar: true, 454 logo: {}, 455 title: { 456 string_id: "onboarding-easy-setup-security-and-privacy-title", 457 }, 458 subtitle: { 459 string_id: "onboarding-easy-setup-security-and-privacy-subtitle", 460 }, 461 tiles: { 462 type: "multiselect", 463 data: [ 464 { 465 id: "checkbox-1", 466 defaultValue: true, 467 label: { 468 string_id: isMSIX 469 ? "mr2022-onboarding-pin-primary-button-label-msix" 470 : "mr2022-onboarding-pin-primary-button-label", 471 }, 472 action: { 473 type: "MULTI_ACTION", 474 data: { 475 actions: [ 476 { 477 type: "PIN_FIREFOX_TO_TASKBAR", 478 }, 479 { 480 type: "PIN_FIREFOX_TO_START_MENU", 481 }, 482 ], 483 }, 484 }, 485 }, 486 { 487 id: "checkbox-2", 488 defaultValue: true, 489 label: { 490 string_id: "mr2022-onboarding-easy-setup-import-checkbox-label", 491 }, 492 uncheckedAction: { 493 type: "MULTI_ACTION", 494 data: { 495 actions: [ 496 { 497 type: "SET_PREF", 498 data: { 499 pref: { 500 name: "showEmbeddedImport", 501 }, 502 }, 503 }, 504 ], 505 }, 506 }, 507 checkedAction: { 508 type: "MULTI_ACTION", 509 data: { 510 actions: [ 511 { 512 type: "SET_PREF", 513 data: { 514 pref: { 515 name: "showEmbeddedImport", 516 value: true, 517 }, 518 }, 519 }, 520 ], 521 }, 522 }, 523 }, 524 ], 525 }, 526 primary_button: { 527 label: { 528 string_id: "mr2022-onboarding-easy-setup-primary-button-label", 529 }, 530 action: { 531 type: "MULTI_ACTION", 532 collectSelect: true, 533 navigate: true, 534 data: { 535 actions: [], 536 }, 537 }, 538 }, 539 secondary_button: { 540 label: { 541 string_id: "mr2022-onboarding-secondary-skip-button-label", 542 }, 543 action: { 544 navigate: true, 545 }, 546 has_arrow_icon: true, 547 }, 548 secondary_button_top: [ 549 { 550 label: { string_id: "mr1-onboarding-sign-in-button-label" }, 551 action: { 552 data: { entrypoint: "activity-stream-firstrun", where: "tab" }, 553 type: "SHOW_FIREFOX_ACCOUNTS", 554 addFlowParams: true, 555 }, 556 targeting: "!isFxASignedIn", 557 }, 558 { 559 label: { string_id: "restore-from-backup-secondary-top-button" }, 560 action: { 561 type: "SET_PREF", 562 data: { 563 pref: { name: "showRestoreFromBackup", value: true }, 564 }, 565 navigate: true, 566 }, 567 targeting: "backupRestoreEnabled", 568 }, 569 ], 570 }, 571 }, 572 { 573 id: "AW_EASY_SETUP_ONLY_IMPORT", 574 targeting: 575 "(!doesAppNeedPin || (unhandledCampaignAction == 'PIN_FIREFOX_TO_TASKBAR') || (unhandledCampaignAction == 'PIN_AND_DEFAULT')) && (!'browser.shell.checkDefaultBrowser'|preferenceValue || isDefaultBrowser || (unhandledCampaignAction == 'SET_DEFAULT_BROWSER') || (unhandledCampaignAction == 'PIN_AND_DEFAULT'))", 576 content: { 577 fullscreen: true, 578 position: "split", 579 split_narrow_bkg_position: "-60px", 580 image_alt_text: { 581 string_id: "mr2022-onboarding-default-image-alt", 582 }, 583 background: 584 "url('chrome://activity-stream/content/data/content/assets/mr-settodefault.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 585 progress_bar: true, 586 logo: {}, 587 title: { 588 string_id: "onboarding-easy-setup-security-and-privacy-title", 589 }, 590 subtitle: { 591 string_id: "onboarding-easy-setup-security-and-privacy-subtitle", 592 }, 593 tiles: { 594 type: "multiselect", 595 data: [ 596 { 597 id: "checkbox-1", 598 defaultValue: true, 599 label: { 600 string_id: "mr2022-onboarding-easy-setup-import-checkbox-label", 601 }, 602 uncheckedAction: { 603 type: "MULTI_ACTION", 604 data: { 605 actions: [ 606 { 607 type: "SET_PREF", 608 data: { 609 pref: { 610 name: "showEmbeddedImport", 611 }, 612 }, 613 }, 614 ], 615 }, 616 }, 617 checkedAction: { 618 type: "MULTI_ACTION", 619 data: { 620 actions: [ 621 { 622 type: "SET_PREF", 623 data: { 624 pref: { 625 name: "showEmbeddedImport", 626 value: true, 627 }, 628 }, 629 }, 630 ], 631 }, 632 }, 633 }, 634 ], 635 }, 636 primary_button: { 637 label: { 638 string_id: "mr2022-onboarding-easy-setup-primary-button-label", 639 }, 640 action: { 641 type: "MULTI_ACTION", 642 collectSelect: true, 643 navigate: true, 644 data: { 645 actions: [], 646 }, 647 }, 648 }, 649 secondary_button: { 650 label: { 651 string_id: "mr2022-onboarding-secondary-skip-button-label", 652 }, 653 action: { 654 navigate: true, 655 }, 656 has_arrow_icon: true, 657 }, 658 secondary_button_top: [ 659 { 660 label: { string_id: "mr1-onboarding-sign-in-button-label" }, 661 action: { 662 data: { entrypoint: "activity-stream-firstrun", where: "tab" }, 663 type: "SHOW_FIREFOX_ACCOUNTS", 664 addFlowParams: true, 665 }, 666 targeting: "!isFxASignedIn", 667 }, 668 { 669 label: { string_id: "restore-from-backup-secondary-top-button" }, 670 action: { 671 type: "SET_PREF", 672 data: { 673 pref: { name: "showRestoreFromBackup", value: true }, 674 }, 675 navigate: true, 676 }, 677 targeting: "backupRestoreEnabled", 678 }, 679 ], 680 }, 681 }, 682 { 683 id: "AW_BACKUP_RESTORE_EMBEDDED_NO_BACKUP_FOUND", 684 targeting: 685 "backupRestoreEnabled && 'messaging-system-action.showRestoreFromBackup' |preferenceValue == true", 686 content: { 687 fullscreen: true, 688 logo: {}, 689 title: { 690 string_id: "restore-from-backup-title", 691 }, 692 subtitle: { 693 string_id: "restore-from-backup-subtitle", 694 }, 695 tiles: { 696 type: "backup_restore", 697 }, 698 position: "split", 699 split_narrow_bkg_position: "-42px", 700 background: 701 "url('chrome://activity-stream/content/data/content/assets/fox-doodle-backup-restore.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 702 progress_bar: true, 703 hide_secondary_section: "responsive", 704 backup_show_filepicker: { 705 action: {}, 706 }, 707 skip_button: { 708 label: { 709 string_id: "restore-from-backup-secondary-button", 710 }, 711 has_arrow_icon: true, 712 action: { 713 type: "SET_PREF", 714 data: { 715 pref: { name: "showRestoreFromBackup", value: false }, 716 }, 717 goBack: true, 718 navigate: true, 719 }, 720 }, 721 }, 722 }, 723 { 724 id: "AW_LANGUAGE_MISMATCH", 725 content: { 726 fullscreen: true, 727 position: "split", 728 background: "var(--mr-screen-background-color)", 729 progress_bar: true, 730 logo: {}, 731 title: { 732 string_id: "mr2022-onboarding-live-language-text", 733 }, 734 subtitle: { 735 string_id: "mr2022-language-mismatch-subtitle", 736 }, 737 hero_text: { 738 string_id: "mr2022-onboarding-live-language-text", 739 useLangPack: true, 740 }, 741 languageSwitcher: { 742 downloading: { 743 string_id: "onboarding-live-language-button-label-downloading", 744 }, 745 cancel: { 746 string_id: "onboarding-live-language-secondary-cancel-download", 747 }, 748 waiting: { string_id: "onboarding-live-language-waiting-button" }, 749 skip: { string_id: "mr2022-onboarding-secondary-skip-button-label" }, 750 action: { 751 navigate: true, 752 }, 753 switch: { 754 string_id: "mr2022-onboarding-live-language-switch-to", 755 useLangPack: true, 756 }, 757 continue: { 758 string_id: "mr2022-onboarding-live-language-continue-in", 759 }, 760 }, 761 }, 762 }, 763 { 764 id: "AW_IMPORT_SETTINGS_EMBEDDED", 765 targeting: `("messaging-system-action.showEmbeddedImport" |preferenceValue == true) && useEmbeddedMigrationWizard`, 766 content: { 767 fullscreen: true, 768 tiles: { type: "migration-wizard" }, 769 position: "split", 770 split_narrow_bkg_position: "-42px", 771 image_alt_text: { 772 string_id: "mr2022-onboarding-import-image-alt", 773 }, 774 background: 775 "url('chrome://activity-stream/content/data/content/assets/mr-import.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 776 progress_bar: true, 777 hide_secondary_section: "responsive", 778 migrate_start: { 779 action: {}, 780 }, 781 migrate_close: { 782 action: { 783 navigate: true, 784 }, 785 }, 786 secondary_button: { 787 label: { 788 string_id: "mr2022-onboarding-secondary-skip-button-label", 789 }, 790 action: { 791 navigate: true, 792 }, 793 has_arrow_icon: true, 794 }, 795 }, 796 }, 797 { 798 id: "AW_AMO_INTRODUCE", 799 targeting: "localeLanguageCode == 'en'", 800 content: { 801 position: "split", 802 fullscreen: true, 803 split_narrow_bkg_position: "-58px", 804 background: 805 "url('chrome://activity-stream/content/data/content/assets/mr-amo-collection.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 806 progress_bar: true, 807 logo: {}, 808 title: { 809 string_id: "amo-screen-title", 810 }, 811 subtitle: { 812 raw: "Extensions are tiny apps that let you customize Firefox. They can boost your privacy, enhance productivity, improve media, change the way Firefox looks, and so much more.", 813 }, 814 primary_button: { 815 label: { 816 raw: "Explore staff recommended extensions", 817 }, 818 action: { 819 type: "OPEN_URL", 820 data: { 821 args: "https://addons.mozilla.org/en-US/firefox/collections/4757633/b4d5649fb087446aa05add5f0258c3/?page=1&collection_sort=-popularity", 822 where: "tabshifted", 823 }, 824 navigate: true, 825 }, 826 }, 827 secondary_button: { 828 label: { 829 string_id: "mr2022-onboarding-secondary-skip-button-label", 830 }, 831 action: { 832 navigate: true, 833 }, 834 has_arrow_icon: true, 835 }, 836 }, 837 }, 838 { 839 id: "AW_GRATITUDE", 840 content: { 841 fullscreen: true, 842 position: "split", 843 split_narrow_bkg_position: "-228px", 844 image_alt_text: { 845 string_id: "mr2022-onboarding-gratitude-image-alt", 846 }, 847 background: 848 "url('chrome://activity-stream/content/data/content/assets/mr-gratitude.svg') var(--mr-secondary-position) no-repeat var(--mr-screen-background-color)", 849 progress_bar: true, 850 logo: {}, 851 title: { 852 string_id: "onboarding-gratitude-security-and-privacy-title", 853 }, 854 subtitle: { 855 string_id: "onboarding-gratitude-security-and-privacy-subtitle", 856 }, 857 primary_button: { 858 label: { 859 string_id: "mr2-onboarding-start-browsing-button-label", 860 }, 861 action: { 862 navigate: true, 863 }, 864 }, 865 }, 866 targeting: "isFxASignedIn", 867 }, 868 { 869 id: "AW_ACCOUNT_LOGIN", 870 content: { 871 fullscreen: true, 872 position: "split", 873 split_narrow_bkg_position: "-228px", 874 image_alt_text: { 875 string_id: "mr2022-onboarding-gratitude-image-alt", 876 }, 877 background: 878 "url('chrome://activity-stream/content/data/content/assets/fox-doodle-waving-laptop.svg') center center / 80% no-repeat var(--mr-screen-background-color)", 879 progress_bar: true, 880 logo: {}, 881 title: { 882 string_id: "onboarding-sign-up-title", 883 }, 884 subtitle: { 885 string_id: "onboarding-sign-up-description", 886 }, 887 secondary_button: { 888 label: { 889 string_id: "mr2-onboarding-start-browsing-button-label", 890 }, 891 style: "secondary", 892 action: { 893 navigate: true, 894 }, 895 }, 896 primary_button: { 897 label: { 898 string_id: "onboarding-sign-up-button", 899 }, 900 action: { 901 data: { 902 entrypoint: "newuser-onboarding-desktop", 903 }, 904 type: "FXA_SIGNIN_FLOW", 905 navigate: true, 906 }, 907 }, 908 }, 909 targeting: "!isFxASignedIn", 910 }, 911 ], 912 }; 913 914 async function getAddonFromRepository(data) { 915 const [addonInfo] = await lazy.AddonRepository.getAddonsByIDs([data]); 916 if (addonInfo.sourceURI.scheme !== "https") { 917 return null; 918 } 919 920 return { 921 addonId: addonInfo.id, 922 name: addonInfo.name, 923 url: addonInfo.sourceURI.spec, 924 iconURL: addonInfo.icons["64"] || addonInfo.icons["32"], 925 type: addonInfo.type, 926 screenshots: addonInfo.screenshots, 927 }; 928 } 929 930 async function getAddonInfo(attrbObj) { 931 let { content, source } = attrbObj; 932 try { 933 if (!content || source !== "addons.mozilla.org") { 934 return null; 935 } 936 // Attribution data can be double encoded 937 while (content.includes("%")) { 938 try { 939 const result = decodeURIComponent(content); 940 if (result === content) { 941 break; 942 } 943 content = result; 944 } catch (e) { 945 break; 946 } 947 } 948 // return_to_amo embeds the addon id in the content 949 // param, prefixed with "rta:". Translating that 950 // happens in AddonRepository, however we can avoid 951 // an API call if we check up front here. 952 if (content.startsWith("rta:")) { 953 return await getAddonFromRepository(content); 954 } 955 } catch (e) { 956 console.error("Failed to get the latest add-on version for Return to AMO"); 957 } 958 return null; 959 } 960 961 async function getAttributionContent() { 962 let attribution = await lazy.AttributionCode.getAttrDataAsync(); 963 if (attribution?.source === "addons.mozilla.org") { 964 let addonInfo = await getAddonInfo(attribution); 965 if (addonInfo) { 966 return { 967 ...addonInfo, 968 ua: decodeURIComponent(attribution.ua), 969 template: "return_to_amo", 970 }; 971 } 972 } 973 if (attribution?.ua) { 974 return { 975 ua: decodeURIComponent(attribution.ua), 976 }; 977 } 978 return null; 979 } 980 981 // Return default multistage welcome content 982 function getDefaults() { 983 return Cu.cloneInto(MR_ABOUT_WELCOME_DEFAULT, {}); 984 } 985 986 let gSourceL10n = null; 987 988 // Localize Firefox download source from user agent attribution to show inside 989 // import primary button label such as 'Import from <localized browser name>'. 990 // no firefox as import wizard doesn't show it 991 const allowedUAs = ["chrome", "edge", "ie"]; 992 function getLocalizedUA(ua) { 993 if (!gSourceL10n) { 994 gSourceL10n = new Localization(["browser/migrationWizard.ftl"]); 995 } 996 if (allowedUAs.includes(ua)) { 997 const messageIDs = { 998 chrome: "migration-source-name-chrome", 999 edge: "migration-source-name-edge", 1000 ie: "migration-source-name-ie", 1001 }; 1002 return gSourceL10n.formatValue(messageIDs[ua]); 1003 } 1004 return null; 1005 } 1006 1007 function prepareMobileDownload(content) { 1008 let mobileContent = content?.screens?.find( 1009 screen => screen.id === "AW_MOBILE_DOWNLOAD" 1010 )?.content; 1011 1012 if (!mobileContent) { 1013 return content; 1014 } 1015 if (!lazy.BrowserUtils.sendToDeviceEmailsSupported()) { 1016 // If send to device emails are not supported for a user's locale, 1017 // remove the send to device link and update the screen text 1018 delete mobileContent.cta_paragraph.action; 1019 mobileContent.cta_paragraph.text = { 1020 string_id: "mr2022-onboarding-no-mobile-download-cta-text", 1021 }; 1022 } 1023 // Update CN specific QRCode url 1024 if (lazy.BrowserUtils.isChinaRepack()) { 1025 mobileContent.hero_image.url = `${mobileContent.hero_image.url.slice( 1026 0, 1027 mobileContent.hero_image.url.indexOf(".svg") 1028 )}-cn.svg`; 1029 } 1030 1031 return content; 1032 } 1033 1034 async function prepareContentForReact(content) { 1035 if (!content.screens) { 1036 return content; 1037 } 1038 1039 const { screens } = content; 1040 1041 if (content?.template === "return_to_amo") { 1042 return content; 1043 } 1044 1045 // Set the primary import button source based on attribution. 1046 if (content?.ua) { 1047 // If available, add the browser source to action data 1048 // and localized browser string args to primary button label 1049 const { label, action } = 1050 content?.screens?.find( 1051 screen => 1052 screen?.content?.primary_button?.action?.type === 1053 "SHOW_MIGRATION_WIZARD" 1054 )?.content?.primary_button ?? {}; 1055 1056 if (action) { 1057 action.data = { ...action.data, source: content.ua }; 1058 } 1059 1060 let browserStr = await getLocalizedUA(content.ua); 1061 1062 if (label?.string_id) { 1063 label.string_id = browserStr 1064 ? "mr1-onboarding-import-primary-button-label-attribution" 1065 : "mr2022-onboarding-import-primary-button-label-no-attribution"; 1066 1067 label.args = browserStr ? { previous: browserStr } : {}; 1068 } 1069 } 1070 1071 // Remove Firefox Accounts related UI and prevent related metrics. 1072 if (!Services.prefs.getBoolPref("identity.fxaccounts.enabled", false)) { 1073 delete content.screens?.find( 1074 screen => 1075 screen.content?.secondary_button_top?.action?.type === 1076 "SHOW_FIREFOX_ACCOUNTS" 1077 )?.content.secondary_button_top; 1078 content.skipFxA = true; 1079 } 1080 1081 let shouldRemoveLanguageMismatchScreen = true; 1082 if (content.languageMismatchEnabled) { 1083 const screen = content?.screens?.find(s => s.id === "AW_LANGUAGE_MISMATCH"); 1084 if (screen && content.appAndSystemLocaleInfo.canLiveReload) { 1085 // Add the display names for the OS and Firefox languages, like "American English". 1086 function addMessageArgs(obj) { 1087 for (const value of Object.values(obj)) { 1088 if (value?.string_id) { 1089 value.args = content.appAndSystemLocaleInfo.displayNames; 1090 } 1091 } 1092 } 1093 1094 addMessageArgs(screen.content.languageSwitcher); 1095 addMessageArgs(screen.content); 1096 shouldRemoveLanguageMismatchScreen = false; 1097 } 1098 } 1099 1100 if (shouldRemoveLanguageMismatchScreen) { 1101 await lazy.AWScreenUtils.removeScreens( 1102 screens, 1103 screen => screen.id === "AW_LANGUAGE_MISMATCH" 1104 ); 1105 } 1106 1107 return prepareMobileDownload(content); 1108 } 1109 1110 export const AboutWelcomeDefaults = { 1111 prepareContentForReact, 1112 getDefaults, 1113 getAttributionContent, 1114 };