tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CFRMessageProvider.sys.mjs (27984B)


      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 // eslint-disable-next-line mozilla/use-static-import
      6 const { PlacesUtils } = ChromeUtils.importESModule(
      7  "resource://gre/modules/PlacesUtils.sys.mjs"
      8 );
      9 
     10 // 30 days ago, 60 visits, bookmarked.
     11 const MIN_FRECENCY_THRESHOLD = PlacesUtils.history.pageFrecencyThreshold(
     12  30,
     13  60,
     14  true
     15 );
     16 
     17 const FACEBOOK_CONTAINER_PARAMS = {
     18  existing_addons: [
     19    "@contain-facebook",
     20    "{bb1b80be-e6b3-40a1-9b6e-9d4073343f0b}",
     21    "{a50d61ca-d27b-437a-8b52-5fd801a0a88b}",
     22  ],
     23  open_urls: ["www.facebook.com", "facebook.com"],
     24  sumo_path: "extensionrecommendations",
     25  min_frecency: MIN_FRECENCY_THRESHOLD,
     26 };
     27 const GOOGLE_TRANSLATE_PARAMS = {
     28  existing_addons: [
     29    "jid1-93WyvpgvxzGATw@jetpack",
     30    "{087ef4e1-4286-4be6-9aa3-8d6c420ee1db}",
     31    "{4170faaa-ee87-4a0e-b57a-1aec49282887}",
     32    "jid1-TMndP6cdKgxLcQ@jetpack",
     33    "s3google@translator",
     34    "{9c63d15c-b4d9-43bd-b223-37f0a1f22e2a}",
     35    "translator@zoli.bod",
     36    "{8cda9ce6-7893-4f47-ac70-a65215cec288}",
     37    "simple-translate@sienori",
     38    "@translatenow",
     39    "{a79fafce-8da6-4685-923f-7ba1015b8748})",
     40    "{8a802b5a-eeab-11e2-a41d-b0096288709b}",
     41    "jid0-fbHwsGfb6kJyq2hj65KnbGte3yT@jetpack",
     42    "storetranslate.plugin@gmail.com",
     43    "jid1-r2tWDbSkq8AZK1@jetpack",
     44    "{b384b75c-c978-4c4d-b3cf-62a82d8f8f12}",
     45    "jid1-f7dnBeTj8ElpWQ@jetpack",
     46    "{dac8a935-4775-4918-9205-5c0600087dc4}",
     47    "gtranslation2@slam.com",
     48    "{e20e0de5-1667-4df4-bd69-705720e37391}",
     49    "{09e26ae9-e9c1-477c-80a6-99934212f2fe}",
     50    "mgxtranslator@magemagix.com",
     51    "gtranslatewins@mozilla.org",
     52  ],
     53  open_urls: ["translate.google.com"],
     54  sumo_path: "extensionrecommendations",
     55  min_frecency: MIN_FRECENCY_THRESHOLD,
     56 };
     57 const YOUTUBE_ENHANCE_PARAMS = {
     58  existing_addons: [
     59    "enhancerforyoutube@maximerf.addons.mozilla.org",
     60    "{dc8f61ab-5e98-4027-98ef-bb2ff6060d71}",
     61    "{7b1bf0b6-a1b9-42b0-b75d-252036438bdc}",
     62    "jid0-UVAeBCfd34Kk5usS8A1CBiobvM8@jetpack",
     63    "iridium@particlecore.github.io",
     64    "jid1-ss6kLNCbNz6u0g@jetpack",
     65    "{1cf918d2-f4ea-4b4f-b34e-455283fef19f}",
     66  ],
     67  open_urls: ["www.youtube.com", "youtube.com"],
     68  sumo_path: "extensionrecommendations",
     69  min_frecency: MIN_FRECENCY_THRESHOLD,
     70 };
     71 const WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS = {
     72  existing_addons: [
     73    "@wikipediacontextmenusearch",
     74    "{ebf47fc8-01d8-4dba-aa04-2118402f4b20}",
     75    "{5737a280-b359-4e26-95b0-adec5915a854}",
     76    "olivier.debroqueville@gmail.com",
     77    "{3923146e-98cb-472b-9c13-f6849d34d6b8}",
     78  ],
     79  open_urls: ["www.wikipedia.org", "wikipedia.org"],
     80  sumo_path: "extensionrecommendations",
     81  min_frecency: MIN_FRECENCY_THRESHOLD,
     82 };
     83 const REDDIT_ENHANCEMENT_PARAMS = {
     84  existing_addons: ["jid1-xUfzOsOFlzSOXg@jetpack"],
     85  open_urls: ["www.reddit.com", "reddit.com"],
     86  sumo_path: "extensionrecommendations",
     87  min_frecency: MIN_FRECENCY_THRESHOLD,
     88 };
     89 
     90 const CFR_MESSAGES = [
     91  {
     92    id: "FACEBOOK_CONTAINER_3",
     93    template: "cfr_doorhanger",
     94    groups: ["cfr-message-provider"],
     95    content: {
     96      layout: "addon_recommendation",
     97      category: "cfrAddons",
     98      bucket_id: "CFR_M1",
     99      notification_text: {
    100        string_id: "cfr-doorhanger-extension-notification2",
    101      },
    102      heading_text: { string_id: "cfr-doorhanger-extension-heading" },
    103      info_icon: {
    104        label: { string_id: "cfr-doorhanger-extension-sumo-link" },
    105        sumo_path: FACEBOOK_CONTAINER_PARAMS.sumo_path,
    106      },
    107      addon: {
    108        id: "954390",
    109        title: "Facebook Container",
    110        icon: "chrome://browser/skin/addons/addon-install-downloading.svg",
    111        rating: "4.6",
    112        users: "299019",
    113        author: "Mozilla",
    114        amo_url: "https://addons.mozilla.org/firefox/addon/facebook-container/",
    115      },
    116      text: "Stop Facebook from tracking your activity across the web. Use Facebook the way you normally do without annoying ads following you around.",
    117      buttons: {
    118        primary: {
    119          label: { string_id: "cfr-doorhanger-extension-ok-button" },
    120          action: {
    121            type: "INSTALL_ADDON_FROM_URL",
    122            data: { url: "https://example.com", telemetrySource: "amo" },
    123          },
    124        },
    125        secondary: [
    126          {
    127            label: { string_id: "cfr-doorhanger-extension-cancel-button" },
    128            action: { type: "CANCEL" },
    129          },
    130          {
    131            label: {
    132              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    133            },
    134          },
    135          {
    136            label: {
    137              string_id: "cfr-doorhanger-extension-manage-settings-button",
    138            },
    139            action: {
    140              type: "OPEN_PREFERENCES_PAGE",
    141              data: { category: "general-cfraddons" },
    142            },
    143          },
    144        ],
    145      },
    146    },
    147    frequency: { lifetime: 3 },
    148    targeting: `
    149      localeLanguageCode == "en" &&
    150      (xpinstallEnabled == true) &&
    151      (${JSON.stringify(
    152        FACEBOOK_CONTAINER_PARAMS.existing_addons
    153      )} intersect addonsInfo.addons|keys)|length == 0 &&
    154      (${JSON.stringify(
    155        FACEBOOK_CONTAINER_PARAMS.open_urls
    156      )} intersect topFrecentSites[.frecency >= ${
    157        FACEBOOK_CONTAINER_PARAMS.min_frecency
    158      }]|mapToProperty('host'))|length > 0`,
    159    trigger: { id: "openURL", params: FACEBOOK_CONTAINER_PARAMS.open_urls },
    160  },
    161  {
    162    id: "GOOGLE_TRANSLATE_3",
    163    groups: ["cfr-message-provider"],
    164    template: "cfr_doorhanger",
    165    content: {
    166      layout: "addon_recommendation",
    167      category: "cfrAddons",
    168      bucket_id: "CFR_M1",
    169      notification_text: {
    170        string_id: "cfr-doorhanger-extension-notification2",
    171      },
    172      heading_text: { string_id: "cfr-doorhanger-extension-heading" },
    173      info_icon: {
    174        label: { string_id: "cfr-doorhanger-extension-sumo-link" },
    175        sumo_path: GOOGLE_TRANSLATE_PARAMS.sumo_path,
    176      },
    177      addon: {
    178        id: "445852",
    179        title: "To Google Translate",
    180        icon: "chrome://browser/skin/addons/addon-install-downloading.svg",
    181        rating: "4.1",
    182        users: "313474",
    183        author: "Juan Escobar",
    184        amo_url:
    185          "https://addons.mozilla.org/firefox/addon/to-google-translate/",
    186      },
    187      text: "Instantly translate any webpage text. Simply highlight the text, right-click to open the context menu, and choose a text or aural translation.",
    188      buttons: {
    189        primary: {
    190          label: { string_id: "cfr-doorhanger-extension-ok-button" },
    191          action: {
    192            type: "INSTALL_ADDON_FROM_URL",
    193            data: { url: "https://example.com", telemetrySource: "amo" },
    194          },
    195        },
    196        secondary: [
    197          {
    198            label: { string_id: "cfr-doorhanger-extension-cancel-button" },
    199            action: { type: "CANCEL" },
    200          },
    201          {
    202            label: {
    203              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    204            },
    205          },
    206          {
    207            label: {
    208              string_id: "cfr-doorhanger-extension-manage-settings-button",
    209            },
    210            action: {
    211              type: "OPEN_PREFERENCES_PAGE",
    212              data: { category: "general-cfraddons" },
    213            },
    214          },
    215        ],
    216      },
    217    },
    218    frequency: { lifetime: 3 },
    219    targeting: `
    220      localeLanguageCode == "en" &&
    221      (xpinstallEnabled == true) &&
    222      (${JSON.stringify(
    223        GOOGLE_TRANSLATE_PARAMS.existing_addons
    224      )} intersect addonsInfo.addons|keys)|length == 0 &&
    225      (${JSON.stringify(
    226        GOOGLE_TRANSLATE_PARAMS.open_urls
    227      )} intersect topFrecentSites[.frecency >= ${
    228        GOOGLE_TRANSLATE_PARAMS.min_frecency
    229      }]|mapToProperty('host'))|length > 0`,
    230    trigger: { id: "openURL", params: GOOGLE_TRANSLATE_PARAMS.open_urls },
    231  },
    232  {
    233    id: "YOUTUBE_ENHANCE_3",
    234    groups: ["cfr-message-provider"],
    235    template: "cfr_doorhanger",
    236    content: {
    237      layout: "addon_recommendation",
    238      category: "cfrAddons",
    239      bucket_id: "CFR_M1",
    240      notification_text: {
    241        string_id: "cfr-doorhanger-extension-notification2",
    242      },
    243      heading_text: { string_id: "cfr-doorhanger-extension-heading" },
    244      info_icon: {
    245        label: { string_id: "cfr-doorhanger-extension-sumo-link" },
    246        sumo_path: YOUTUBE_ENHANCE_PARAMS.sumo_path,
    247      },
    248      addon: {
    249        id: "700308",
    250        title: "Enhancer for YouTube\u2122",
    251        icon: "chrome://browser/skin/addons/addon-install-downloading.svg",
    252        rating: "4.8",
    253        users: "357328",
    254        author: "Maxime RF",
    255        amo_url:
    256          "https://addons.mozilla.org/firefox/addon/enhancer-for-youtube/",
    257      },
    258      text: "Take control of your YouTube experience. Automatically block annoying ads, set playback speed and volume, remove annotations, and more.",
    259      buttons: {
    260        primary: {
    261          label: { string_id: "cfr-doorhanger-extension-ok-button" },
    262          action: {
    263            type: "INSTALL_ADDON_FROM_URL",
    264            data: { url: "https://example.com", telemetrySource: "amo" },
    265          },
    266        },
    267        secondary: [
    268          {
    269            label: { string_id: "cfr-doorhanger-extension-cancel-button" },
    270            action: { type: "CANCEL" },
    271          },
    272          {
    273            label: {
    274              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    275            },
    276          },
    277          {
    278            label: {
    279              string_id: "cfr-doorhanger-extension-manage-settings-button",
    280            },
    281            action: {
    282              type: "OPEN_PREFERENCES_PAGE",
    283              data: { category: "general-cfraddons" },
    284            },
    285          },
    286        ],
    287      },
    288    },
    289    frequency: { lifetime: 3 },
    290    targeting: `
    291      localeLanguageCode == "en" &&
    292      (xpinstallEnabled == true) &&
    293      (${JSON.stringify(
    294        YOUTUBE_ENHANCE_PARAMS.existing_addons
    295      )} intersect addonsInfo.addons|keys)|length == 0 &&
    296      (${JSON.stringify(
    297        YOUTUBE_ENHANCE_PARAMS.open_urls
    298      )} intersect topFrecentSites[.frecency >= ${
    299        YOUTUBE_ENHANCE_PARAMS.min_frecency
    300      }]|mapToProperty('host'))|length > 0`,
    301    trigger: { id: "openURL", params: YOUTUBE_ENHANCE_PARAMS.open_urls },
    302  },
    303  {
    304    id: "WIKIPEDIA_CONTEXT_MENU_SEARCH_3",
    305    groups: ["cfr-message-provider"],
    306    template: "cfr_doorhanger",
    307    exclude: true,
    308    content: {
    309      layout: "addon_recommendation",
    310      category: "cfrAddons",
    311      bucket_id: "CFR_M1",
    312      notification_text: {
    313        string_id: "cfr-doorhanger-extension-notification2",
    314      },
    315      heading_text: { string_id: "cfr-doorhanger-extension-heading" },
    316      info_icon: {
    317        label: { string_id: "cfr-doorhanger-extension-sumo-link" },
    318        sumo_path: WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.sumo_path,
    319      },
    320      addon: {
    321        id: "659026",
    322        title: "Wikipedia Context Menu Search",
    323        icon: "chrome://browser/skin/addons/addon-install-downloading.svg",
    324        rating: "4.9",
    325        users: "3095",
    326        author: "Nick Diedrich",
    327        amo_url:
    328          "https://addons.mozilla.org/firefox/addon/wikipedia-context-menu-search/",
    329      },
    330      text: "Get to a Wikipedia page fast, from anywhere on the web. Just highlight any webpage text and right-click to open the context menu to start a Wikipedia search.",
    331      buttons: {
    332        primary: {
    333          label: { string_id: "cfr-doorhanger-extension-ok-button" },
    334          action: {
    335            type: "INSTALL_ADDON_FROM_URL",
    336            data: { url: "https://example.com", telemetrySource: "amo" },
    337          },
    338        },
    339        secondary: [
    340          {
    341            label: { string_id: "cfr-doorhanger-extension-cancel-button" },
    342            action: { type: "CANCEL" },
    343          },
    344          {
    345            label: {
    346              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    347            },
    348          },
    349          {
    350            label: {
    351              string_id: "cfr-doorhanger-extension-manage-settings-button",
    352            },
    353            action: {
    354              type: "OPEN_PREFERENCES_PAGE",
    355              data: { category: "general-cfraddons" },
    356            },
    357          },
    358        ],
    359      },
    360    },
    361    frequency: { lifetime: 3 },
    362    targeting: `
    363      localeLanguageCode == "en" &&
    364      (xpinstallEnabled == true) &&
    365      (${JSON.stringify(
    366        WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.existing_addons
    367      )} intersect addonsInfo.addons|keys)|length == 0 &&
    368      (${JSON.stringify(
    369        WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls
    370      )} intersect topFrecentSites[.frecency >= ${
    371        WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.min_frecency
    372      }]|mapToProperty('host'))|length > 0`,
    373    trigger: {
    374      id: "openURL",
    375      params: WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls,
    376    },
    377  },
    378  {
    379    id: "REDDIT_ENHANCEMENT_3",
    380    groups: ["cfr-message-provider"],
    381    template: "cfr_doorhanger",
    382    exclude: true,
    383    content: {
    384      layout: "addon_recommendation",
    385      category: "cfrAddons",
    386      bucket_id: "CFR_M1",
    387      notification_text: {
    388        string_id: "cfr-doorhanger-extension-notification2",
    389      },
    390      heading_text: { string_id: "cfr-doorhanger-extension-heading" },
    391      info_icon: {
    392        label: { string_id: "cfr-doorhanger-extension-sumo-link" },
    393        sumo_path: REDDIT_ENHANCEMENT_PARAMS.sumo_path,
    394      },
    395      addon: {
    396        id: "387429",
    397        title: "Reddit Enhancement Suite",
    398        icon: "chrome://browser/skin/addons/addon-install-downloading.svg",
    399        rating: "4.6",
    400        users: "258129",
    401        author: "honestbleeps",
    402        amo_url:
    403          "https://addons.mozilla.org/firefox/addon/reddit-enhancement-suite/",
    404      },
    405      text: "New features include Inline Image Viewer, Never Ending Reddit (never click 'next page' again), Keyboard Navigation, Account Switcher, and User Tagger.",
    406      buttons: {
    407        primary: {
    408          label: { string_id: "cfr-doorhanger-extension-ok-button" },
    409          action: {
    410            type: "INSTALL_ADDON_FROM_URL",
    411            data: { url: "https://example.com", telemetrySource: "amo" },
    412          },
    413        },
    414        secondary: [
    415          {
    416            label: { string_id: "cfr-doorhanger-extension-cancel-button" },
    417            action: { type: "CANCEL" },
    418          },
    419          {
    420            label: {
    421              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    422            },
    423          },
    424          {
    425            label: {
    426              string_id: "cfr-doorhanger-extension-manage-settings-button",
    427            },
    428            action: {
    429              type: "OPEN_PREFERENCES_PAGE",
    430              data: { category: "general-cfraddons" },
    431            },
    432          },
    433        ],
    434      },
    435    },
    436    frequency: { lifetime: 3 },
    437    targeting: `
    438      localeLanguageCode == "en" &&
    439      (xpinstallEnabled == true) &&
    440      (${JSON.stringify(
    441        REDDIT_ENHANCEMENT_PARAMS.existing_addons
    442      )} intersect addonsInfo.addons|keys)|length == 0 &&
    443      (${JSON.stringify(
    444        REDDIT_ENHANCEMENT_PARAMS.open_urls
    445      )} intersect topFrecentSites[.frecency >= ${
    446        REDDIT_ENHANCEMENT_PARAMS.min_frecency
    447      }]|mapToProperty('host'))|length > 0`,
    448    trigger: { id: "openURL", params: REDDIT_ENHANCEMENT_PARAMS.open_urls },
    449  },
    450  {
    451    id: "DOH_ROLLOUT_CONFIRMATION",
    452    groups: ["cfr-message-provider"],
    453    targeting: `
    454      "doh-rollout.enabled"|preferenceValue &&
    455      !"doh-rollout.disable-heuristics"|preferenceValue &&
    456      !"doh-rollout.skipHeuristicsCheck"|preferenceValue &&
    457      !"doh-rollout.doorhanger-decision"|preferenceValue
    458    `,
    459    template: "cfr_doorhanger",
    460    content: {
    461      skip_address_bar_notifier: true,
    462      persistent_doorhanger: true,
    463      anchor_id: "PanelUI-menu-button",
    464      layout: "icon_and_message",
    465      text: { string_id: "cfr-doorhanger-doh-body" },
    466      icon: "chrome://global/skin/icons/security.svg",
    467      buttons: {
    468        secondary: [
    469          {
    470            label: { string_id: "cfr-doorhanger-doh-secondary-button" },
    471            action: {
    472              type: "DISABLE_DOH",
    473            },
    474          },
    475        ],
    476        primary: {
    477          label: { string_id: "cfr-doorhanger-doh-primary-button-2" },
    478          action: {
    479            type: "ACCEPT_DOH",
    480          },
    481        },
    482      },
    483      bucket_id: "DOH_ROLLOUT_CONFIRMATION",
    484      heading_text: { string_id: "cfr-doorhanger-doh-header" },
    485      info_icon: {
    486        label: {
    487          string_id: "cfr-doorhanger-extension-sumo-link",
    488        },
    489        sumo_path: "extensionrecommendations",
    490      },
    491      notification_text: "Message from Firefox",
    492      category: "cfrFeatures",
    493    },
    494    trigger: {
    495      id: "openURL",
    496      patterns: ["*://*/*"],
    497    },
    498  },
    499  {
    500    id: "SAVE_LOGIN",
    501    groups: ["cfr-message-provider"],
    502    frequency: {
    503      lifetime: 3,
    504    },
    505    targeting:
    506      "(!type || type == 'save') && isFxAEnabled == true && usesFirefoxSync == false",
    507    template: "cfr_doorhanger",
    508    content: {
    509      layout: "icon_and_message",
    510      text: "Securely store and sync your passwords to all your devices.",
    511      icon: "chrome://browser/content/aboutlogins/icons/intro-illustration.svg",
    512      icon_class: "cfr-doorhanger-large-icon",
    513      buttons: {
    514        secondary: [
    515          {
    516            label: {
    517              string_id: "cfr-doorhanger-extension-cancel-button",
    518            },
    519            action: {
    520              type: "CANCEL",
    521            },
    522          },
    523          {
    524            label: {
    525              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    526            },
    527          },
    528          {
    529            label: {
    530              string_id: "cfr-doorhanger-extension-manage-settings-button",
    531            },
    532            action: {
    533              type: "OPEN_PREFERENCES_PAGE",
    534              data: {
    535                category: "general-cfrfeatures",
    536              },
    537            },
    538          },
    539        ],
    540        primary: {
    541          label: {
    542            value: "Turn on Sync",
    543            attributes: { accesskey: "T" },
    544          },
    545          action: {
    546            type: "OPEN_PREFERENCES_PAGE",
    547            data: {
    548              category: "sync",
    549              entrypoint: "cfr-save-login",
    550            },
    551          },
    552        },
    553      },
    554      bucket_id: "CFR_SAVE_LOGIN",
    555      heading_text: "Never Lose a Password Again",
    556      info_icon: {
    557        label: {
    558          string_id: "cfr-doorhanger-extension-sumo-link",
    559        },
    560        sumo_path: "extensionrecommendations",
    561      },
    562      notification_text: {
    563        string_id: "cfr-doorhanger-feature-notification",
    564      },
    565      category: "cfrFeatures",
    566    },
    567    trigger: {
    568      id: "newSavedLogin",
    569    },
    570  },
    571  {
    572    id: "UPDATE_LOGIN",
    573    groups: ["cfr-message-provider"],
    574    frequency: {
    575      lifetime: 3,
    576    },
    577    targeting:
    578      "type == 'update' && isFxAEnabled == true && usesFirefoxSync == false",
    579    template: "cfr_doorhanger",
    580    content: {
    581      layout: "icon_and_message",
    582      text: "Securely store and sync your passwords to all your devices.",
    583      icon: "chrome://browser/content/aboutlogins/icons/intro-illustration.svg",
    584      icon_class: "cfr-doorhanger-large-icon",
    585      buttons: {
    586        secondary: [
    587          {
    588            label: {
    589              string_id: "cfr-doorhanger-extension-cancel-button",
    590            },
    591            action: {
    592              type: "CANCEL",
    593            },
    594          },
    595          {
    596            label: {
    597              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    598            },
    599          },
    600          {
    601            label: {
    602              string_id: "cfr-doorhanger-extension-manage-settings-button",
    603            },
    604            action: {
    605              type: "OPEN_PREFERENCES_PAGE",
    606              data: {
    607                category: "general-cfrfeatures",
    608              },
    609            },
    610          },
    611        ],
    612        primary: {
    613          label: {
    614            value: "Turn on Sync",
    615            attributes: { accesskey: "T" },
    616          },
    617          action: {
    618            type: "OPEN_PREFERENCES_PAGE",
    619            data: {
    620              category: "sync",
    621              entrypoint: "cfr-update-login",
    622            },
    623          },
    624        },
    625      },
    626      bucket_id: "CFR_UPDATE_LOGIN",
    627      heading_text: "Never Lose a Password Again",
    628      info_icon: {
    629        label: {
    630          string_id: "cfr-doorhanger-extension-sumo-link",
    631        },
    632        sumo_path: "extensionrecommendations",
    633      },
    634      notification_text: {
    635        string_id: "cfr-doorhanger-feature-notification",
    636      },
    637      category: "cfrFeatures",
    638    },
    639    trigger: {
    640      id: "newSavedLogin",
    641    },
    642  },
    643  {
    644    id: "MILESTONE_MESSAGE",
    645    groups: ["cfr-message-provider"],
    646    template: "milestone_message",
    647    content: {
    648      layout: "short_message",
    649      category: "cfrFeatures",
    650      anchor_id: "tracking-protection-icon-container",
    651      skip_address_bar_notifier: true,
    652      bucket_id: "CFR_MILESTONE_MESSAGE",
    653      heading_text: { string_id: "cfr-doorhanger-milestone-heading2" },
    654      notification_text: "",
    655      text: "",
    656      buttons: {
    657        primary: {
    658          label: { string_id: "cfr-doorhanger-milestone-ok-button" },
    659          action: { type: "OPEN_PROTECTION_REPORT" },
    660          event: "PROTECTION",
    661        },
    662        secondary: [
    663          {
    664            label: { string_id: "cfr-doorhanger-milestone-close-button" },
    665            action: { type: "CANCEL" },
    666            event: "DISMISS",
    667          },
    668        ],
    669      },
    670    },
    671    targeting: "pageLoad >= 1",
    672    frequency: {
    673      lifetime: 7, // Length of privacy.contentBlocking.cfr-milestone.milestones pref
    674    },
    675    trigger: {
    676      id: "contentBlocking",
    677      params: ["ContentBlockingMilestone"],
    678    },
    679  },
    680  {
    681    id: "HEARTBEAT_TACTIC_2",
    682    groups: ["cfr-message-provider"],
    683    template: "cfr_urlbar_chiclet",
    684    content: {
    685      layout: "chiclet_open_url",
    686      category: "cfrHeartbeat",
    687      bucket_id: "HEARTBEAT_TACTIC_2",
    688      notification_text: "Improve Firefox",
    689      active_color: "#595e91",
    690      action: {
    691        url: "http://example.com/%VERSION%/",
    692        where: "tabshifted",
    693      },
    694    },
    695    targeting: "false",
    696    frequency: {
    697      lifetime: 3,
    698    },
    699    trigger: {
    700      id: "openURL",
    701      patterns: ["*://*/*"],
    702    },
    703  },
    704  {
    705    id: "HOMEPAGE_REMEDIATION_82",
    706    groups: ["cfr-message-provider"],
    707    frequency: {
    708      lifetime: 3,
    709    },
    710    targeting:
    711      "!homePageSettings.isDefault && homePageSettings.isCustomUrl && homePageSettings.urls[.host == 'google.com']|length > 0 && visitsCount >= 3 && userPrefs.cfrFeatures",
    712    template: "cfr_doorhanger",
    713    content: {
    714      layout: "icon_and_message",
    715      text: "Update your homepage to search Google while also being able to search your Firefox history and bookmarks.",
    716      icon: "chrome://global/skin/icons/search-glass.svg",
    717      buttons: {
    718        secondary: [
    719          {
    720            label: {
    721              string_id: "cfr-doorhanger-extension-cancel-button",
    722            },
    723            action: {
    724              type: "CANCEL",
    725            },
    726          },
    727          {
    728            label: {
    729              string_id: "cfr-doorhanger-extension-never-show-recommendation",
    730            },
    731          },
    732          {
    733            label: {
    734              string_id: "cfr-doorhanger-extension-manage-settings-button",
    735            },
    736            action: {
    737              type: "OPEN_PREFERENCES_PAGE",
    738              data: {
    739                category: "general-cfrfeatures",
    740              },
    741            },
    742          },
    743        ],
    744        primary: {
    745          label: {
    746            value: "Activate now",
    747            attributes: {
    748              accesskey: "A",
    749            },
    750          },
    751          action: {
    752            type: "CONFIGURE_HOMEPAGE",
    753            data: {
    754              homePage: "default",
    755              newtab: "default",
    756              layout: {
    757                search: true,
    758                topsites: false,
    759                highlights: false,
    760                topstories: false,
    761              },
    762            },
    763          },
    764        },
    765      },
    766      bucket_id: "HOMEPAGE_REMEDIATION_82",
    767      heading_text: "A better search experience",
    768      info_icon: {
    769        label: {
    770          string_id: "cfr-doorhanger-extension-sumo-link",
    771        },
    772        sumo_path: "extensionrecommendations",
    773      },
    774      notification_text: {
    775        string_id: "cfr-doorhanger-feature-notification",
    776      },
    777      category: "cfrFeatures",
    778    },
    779    trigger: {
    780      id: "openURL",
    781      params: ["google.com", "www.google.com"],
    782    },
    783  },
    784  {
    785    id: "INFOBAR_ACTION_86",
    786    groups: ["cfr-message-provider"],
    787    targeting: "false",
    788    template: "infobar",
    789    content: {
    790      type: "global",
    791      text: { string_id: "default-browser-notification-message" },
    792      buttons: [
    793        {
    794          label: { string_id: "default-browser-notification-button" },
    795          primary: true,
    796          accessKey: "O",
    797          action: {
    798            type: "SET_DEFAULT_BROWSER",
    799          },
    800        },
    801      ],
    802    },
    803    trigger: { id: "defaultBrowserCheck" },
    804  },
    805  {
    806    id: "PREF_OBSERVER_MESSAGE_94",
    807    groups: ["cfr-message-provider"],
    808    targeting: "true",
    809    template: "infobar",
    810    content: {
    811      type: "global",
    812      text: "This is a message triggered when a pref value changes",
    813      buttons: [
    814        {
    815          label: "OK",
    816          primary: true,
    817          accessKey: "O",
    818          action: {
    819            type: "CANCEL",
    820          },
    821        },
    822      ],
    823    },
    824    trigger: { id: "preferenceObserver", params: ["foo.bar"] },
    825  },
    826  {
    827    id: "FACEBOOK_CONTAINER_ADDON_A",
    828    template: "cfr_doorhanger",
    829    groups: ["cfr"],
    830    content: {
    831      layout: "addon_recommendation",
    832      category: "cfrAddons",
    833      bucket_id: "CFR",
    834      anchor_id: "PanelUI-menu-button",
    835      skip_address_bar_notifier: true,
    836      icon_class: "cfr-doorhanger-medium-icon",
    837      notification_text: {
    838        string_id: "cfr-doorhanger-extension-notification2",
    839      },
    840      heading_text: {
    841        string_id: "cfr-doorhanger-extension-heading",
    842      },
    843      info_icon: {
    844        label: {
    845          string_id: "cfr-doorhanger-extension-sumo-link",
    846        },
    847        sumo_path: "extensionrecommendations",
    848      },
    849      addon: {
    850        id: "954390",
    851        title: "Facebook Container",
    852        icon: "https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/03c866df-82ea-489c-83c7-df6d0662d893.svg",
    853        rating: "4.5",
    854        users: "1.1M",
    855        author: "Mozilla",
    856        amo_url: "https://addons.mozilla.org/firefox/addon/facebook-container/",
    857      },
    858      text: "Make it harder for Facebook to track your browsing activity, including info from medical and financial sites.",
    859      buttons: {
    860        primary: {
    861          label: {
    862            value: "Try it",
    863            attributes: {
    864              accesskey: "T",
    865            },
    866          },
    867          action: {
    868            type: "INSTALL_ADDON_FROM_URL",
    869            data: {
    870              url: "https://example.com",
    871              telemetrySource: "amo",
    872            },
    873          },
    874        },
    875        secondary: [
    876          {
    877            label: {
    878              value: "Not now",
    879              attributes: {
    880                accesskey: "N",
    881              },
    882            },
    883            action: {
    884              type: "CANCEL",
    885            },
    886          },
    887        ],
    888      },
    889    },
    890    frequency: {
    891      lifetime: 1,
    892    },
    893    targeting:
    894      "!('@contain-facebook' in addonsInfo.addons|keys) && !('@testpilot-containers' in addonsInfo.addons|keys) && ('browser.discovery.enabled'|preferenceValue)",
    895    trigger: {
    896      id: "openURL",
    897      params: ["www.facebook.com", "facebook.com"],
    898    },
    899  },
    900 ];
    901 
    902 export const CFRMessageProvider = {
    903  getMessages() {
    904    return Promise.resolve(CFR_MESSAGES.filter(msg => !msg.exclude));
    905  },
    906 };