Bug 1653935 - Support search shortcut keyword field in remote setting. r=mikedeboer
authorDão Gottwald <dao@mozilla.com>
Thu, 20 Aug 2020 15:08:18 +0000
changeset 610157 6c04e5bc049576e8a5e1f02fa9c1674a8cf84e9d
parent 610156 00693a1768762d0199817ac1b929ef67c5519809
child 610158 a6f1b3a70a2a08c864225d68a3fb9fcb291bbbf8
push id13553
push userffxbld-merge
push dateMon, 24 Aug 2020 12:51:36 +0000
treeherdermozilla-beta@a54f8b5d0977 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1653935
milestone81.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1653935 - Support search shortcut keyword field in remote setting. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D87700
browser/components/newtab/lib/TopSitesFeed.jsm
--- a/browser/components/newtab/lib/TopSitesFeed.jsm
+++ b/browser/components/newtab/lib/TopSitesFeed.jsm
@@ -212,31 +212,39 @@ this.TopSitesFeed = class TopSitesFeed {
       {
         title: "Mozilla!",
         url: "https://mozilla.org/#%YYYYMMDDHH%",
         send_attribution_request: true,
       },
       {
         url: "https://firefox.com",
       },
+      {
+        url: "https://foobar.com",
+        keyword: "@foobar",
+      },
     ];
 
     // Clear out the array of any previous defaults.
     DEFAULT_TOP_SITES.length = 0;
 
     for (let siteData of remoteSettingData) {
       let link = {
         isDefault: true,
         url: siteData.url,
         hostname: shortURL(siteData),
         sendTopSiteAttributionRequest: !!siteData.send_attribution_request,
       };
       if (siteData.title) {
         link.label = siteData.title;
       }
+      if (siteData.keyword) {
+        link.searchTopSite = true;
+        link.label = siteData.keyword;
+      }
       DEFAULT_TOP_SITES.push(link);
     }
   }
 
   refreshDefaults(sites) {
     // Clear out the array of any previous defaults
     DEFAULT_TOP_SITES.length = 0;
 
@@ -428,22 +436,28 @@ this.TopSitesFeed = class TopSitesFeed {
       notBlockedDefaultSites.push(
         searchShortcutsExperiment
           ? await this.topSiteToSearchTopSite(link)
           : link
       );
     }
 
     // Get pinned links augmented with desired properties
+    if (this._useRemoteSetting) {
+      this.disableSearchImprovements();
+    }
     let plainPinned = await this.pinnedCache.request();
 
     // Insert search shortcuts if we need to.
     // _maybeInsertSearchShortcuts returns true if any search shortcuts are
     // inserted, meaning we need to expire and refresh the pinnedCache
-    if (await this._maybeInsertSearchShortcuts(plainPinned)) {
+    if (
+      !this._useRemoteSetting &&
+      (await this._maybeInsertSearchShortcuts(plainPinned))
+    ) {
       this.pinnedCache.expire();
       plainPinned = await this.pinnedCache.request();
     }
 
     const pinned = await Promise.all(
       plainPinned.map(async link => {
         if (!link) {
           return link;