[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 119/311: Bug 1759008 - Update search parameters. r=mkaply a=pascalc



This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch geckoview-99.0.1-11.0-1
in repository tor-browser.

commit 663b62db1c30781e047275ef09f6c1f7c58739e9
Author: Mark Banner <standard8@xxxxxxxxxxx>
AuthorDate: Fri Mar 11 15:32:27 2022 +0000

    Bug 1759008 - Update search parameters. r=mkaply a=pascalc
    
    Differential Revision: https://phabricator.services.mozilla.com/D140846
---
 .../extensions/google/_locales/by/messages.json    | 20 +++++++
 .../extensions/google/_locales/kz/messages.json    | 20 +++++++
 .../extensions/google/_locales/ru/messages.json    | 20 +++++++
 .../extensions/google/_locales/tr/messages.json    | 20 +++++++
 .../search/extensions/google/manifest.json         |  2 +-
 browser/locales/en-US/browser/search.ftl           |  2 +-
 toolkit/components/search/SearchEngineSelector.jsm | 17 +++++-
 .../search/docs/SearchConfigurationSchema.rst      | 10 ++++
 .../search/schema/search-engine-config-schema.json |  4 +-
 .../search/tests/xpcshell/test_engine_selector.js  | 64 +++++++++++++++++++++-
 10 files changed, 172 insertions(+), 7 deletions(-)

diff --git a/browser/components/search/extensions/google/_locales/by/messages.json b/browser/components/search/extensions/google/_locales/by/messages.json
new file mode 100644
index 0000000000000..ffcf375a30f00
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/by/messages.json
@@ -0,0 +1,20 @@
+{
+  "extensionName": {
+    "message": "Google"
+  },
+  "extensionDescription": {
+    "message": "Google Search"
+  },
+  "searchUrl": {
+    "message": "https://www.google.by/search";
+  },
+  "searchForm": {
+    "message": "https://www.google.by/search?q={searchTerms}";
+  },
+  "suggestUrl": {
+    "message": "https://www.google.by/complete/search?q={searchTerms}";
+  },
+  "searchUrlGetParams": {
+    "message": "q={searchTerms}"
+  }
+}
diff --git a/browser/components/search/extensions/google/_locales/kz/messages.json b/browser/components/search/extensions/google/_locales/kz/messages.json
new file mode 100644
index 0000000000000..d94530101d777
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/kz/messages.json
@@ -0,0 +1,20 @@
+{
+  "extensionName": {
+    "message": "Google"
+  },
+  "extensionDescription": {
+    "message": "Google Search"
+  },
+  "searchUrl": {
+    "message": "https://www.google.kz/search";
+  },
+  "searchForm": {
+    "message": "https://www.google.kz/search?q={searchTerms}";
+  },
+  "suggestUrl": {
+    "message": "https://www.google.kz/complete/search?q={searchTerms}";
+  },
+  "searchUrlGetParams": {
+    "message": "q={searchTerms}"
+  }
+}
diff --git a/browser/components/search/extensions/google/_locales/ru/messages.json b/browser/components/search/extensions/google/_locales/ru/messages.json
new file mode 100644
index 0000000000000..ba103cb6314bc
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/ru/messages.json
@@ -0,0 +1,20 @@
+{
+  "extensionName": {
+    "message": "Google"
+  },
+  "extensionDescription": {
+    "message": "Google Search"
+  },
+  "searchUrl": {
+    "message": "https://www.google.ru/search";
+  },
+  "searchForm": {
+    "message": "https://www.google.ru/search?q={searchTerms}";
+  },
+  "suggestUrl": {
+    "message": "https://www.google.ru/complete/search?q={searchTerms}";
+  },
+  "searchUrlGetParams": {
+    "message": "q={searchTerms}"
+  }
+}
diff --git a/browser/components/search/extensions/google/_locales/tr/messages.json b/browser/components/search/extensions/google/_locales/tr/messages.json
new file mode 100644
index 0000000000000..0087bc2135a0f
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/tr/messages.json
@@ -0,0 +1,20 @@
+{
+  "extensionName": {
+    "message": "Google"
+  },
+  "extensionDescription": {
+    "message": "Google Search"
+  },
+  "searchUrl": {
+    "message": "https://www.google.com.tr/search";
+  },
+  "searchForm": {
+    "message": "https://www.google.com.tr/search?q={searchTerms}";
+  },
+  "suggestUrl": {
+    "message": "https://www.google.com.tr/complete/search?q={searchTerms}";
+  },
+  "searchUrlGetParams": {
+    "message": "q={searchTerms}"
+  }
+}
diff --git a/browser/components/search/extensions/google/manifest.json b/browser/components/search/extensions/google/manifest.json
index d62049705ae2e..6cd4d2a42358e 100644
--- a/browser/components/search/extensions/google/manifest.json
+++ b/browser/components/search/extensions/google/manifest.json
@@ -2,7 +2,7 @@
   "name": "__MSG_extensionName__",
   "description": "__MSG_extensionDescription__",
   "manifest_version": 2,
-  "version": "1.1",
+  "version": "1.2",
   "applications": {
     "gecko": {
       "id": "google@xxxxxxxxxxxxxxxxxx"
diff --git a/browser/locales/en-US/browser/search.ftl b/browser/locales/en-US/browser/search.ftl
index 0451858cac227..628ca9eed9639 100644
--- a/browser/locales/en-US/browser/search.ftl
+++ b/browser/locales/en-US/browser/search.ftl
@@ -34,5 +34,5 @@ searchbar-icon =
 ## $oldEngine (String) - the search engine to be removed.
 ## $newEngine (String) - the search engine to replace the removed search engine.
 
-remove-search-engine-message = <strong>Your default search engine has been changed.</strong> { -brand-short-name } no longer supports { $oldEngine }. { $newEngine } is now your default search engine. To change to another default search engine, go to settings. <label data-l10n-name="remove-search-engine-article">Learn more</label>
+remove-search-engine-message = <strong>Your default search engine has been changed.</strong> { $oldEngine } is no longer available as a default search engine in { -brand-short-name }. { $newEngine } is now your default search engine. To change to another default search engine, go to settings. <label data-l10n-name="remove-search-engine-article">Learn more</label>
 remove-search-engine-button = OK
diff --git a/toolkit/components/search/SearchEngineSelector.jsm b/toolkit/components/search/SearchEngineSelector.jsm
index c880b8ca0516b..7a9697f1f4563 100644
--- a/toolkit/components/search/SearchEngineSelector.jsm
+++ b/toolkit/components/search/SearchEngineSelector.jsm
@@ -18,6 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
 });
 
 const USER_LOCALE = "$USER_LOCALE";
+const USER_REGION = "$USER_REGION";
 
 XPCOMUtils.defineLazyGetter(this, "logConsole", () => {
   return console.createInstance({
@@ -275,8 +276,17 @@ class SearchEngineSelector {
             const engine = { ...baseConfig };
             engine.webExtension = { ...baseConfig.webExtension };
             delete engine.webExtension.locales;
-            engine.webExtension.locale =
-              webExtensionLocale == USER_LOCALE ? locale : webExtensionLocale;
+            switch (webExtensionLocale) {
+              case USER_LOCALE:
+                engine.webExtension.locale = locale;
+                break;
+              case USER_REGION:
+                engine.webExtension.locale = lcRegion;
+                break;
+              default:
+                engine.webExtension.locale = webExtensionLocale;
+                break;
+            }
             engines.push(engine);
           }
         } else {
@@ -302,6 +312,9 @@ class SearchEngineSelector {
     }
 
     for (const engine of engines) {
+      engine.telemetryId = engine.telemetryId
+        ?.replace(USER_LOCALE, locale)
+        .replace(USER_REGION, lcRegion);
       if (
         "default" in engine &&
         shouldPrefer(
diff --git a/toolkit/components/search/docs/SearchConfigurationSchema.rst b/toolkit/components/search/docs/SearchConfigurationSchema.rst
index cec4bd4c63059..751e4c4f7a43c 100644
--- a/toolkit/components/search/docs/SearchConfigurationSchema.rst
+++ b/toolkit/components/search/docs/SearchConfigurationSchema.rst
@@ -114,6 +114,16 @@ configuration object with the users locale. For example:
 Will report either ``[us]`` or ``[gb]`` as the ``webExtension.locales``
 depending on the user's locale.
 
+From Firefox 98.0.1 and 97.7.1esr, ``"$USER_LOCALE"`` may also be used in the
+``telemetryId`` field.
+
+$USER_REGION
+------------
+
+This can be used in the same situations as ``"$USER_LOCALE"``.
+
+It was added in the Firefox 98.0.1 and 97.7.1esr releases.
+
 "default"
 ---------
 
diff --git a/toolkit/components/search/schema/search-engine-config-schema.json b/toolkit/components/search/schema/search-engine-config-schema.json
index 5f3e477982b95..3cf5e80fc4483 100644
--- a/toolkit/components/search/schema/search-engine-config-schema.json
+++ b/toolkit/components/search/schema/search-engine-config-schema.json
@@ -319,7 +319,7 @@
     "telemetryId": {
       "type": "string",
       "title": "Telemetry Id",
-      "pattern": "^[a-zA-Z0-9-]{0,100}$",
+      "pattern": "^[a-zA-Z0-9-$_]{0,100}$",
       "description": "The telemetry Id as used for some of SEARCH_COUNTS telemetry."
     },
     "webExtension": {
@@ -335,7 +335,7 @@
         "locale": {
           "type": "string",
           "title": "WebExtension Locale",
-          "pattern": "^[a-zA-Z0-9-]{0,100}$",
+          "pattern": "^[a-zA-Z0-9-$_]{0,100}$",
           "description": "Overrides the WebExtension locales and specifies to use a particular one. Ideally this should only be used when really necessary, otherwise considered deprecated."
         }
       }
diff --git a/toolkit/components/search/tests/xpcshell/test_engine_selector.js b/toolkit/components/search/tests/xpcshell/test_engine_selector.js
index def9393d230cd..02f6aae451ab8 100644
--- a/toolkit/components/search/tests/xpcshell/test_engine_selector.js
+++ b/toolkit/components/search/tests/xpcshell/test_engine_selector.js
@@ -23,6 +23,14 @@ const TEST_CONFIG = [
         webExtension: {
           locales: ["$USER_LOCALE"],
         },
+        telemetryId: "foo-$USER_LOCALE",
+      },
+      {
+        included: { regions: ["fr"] },
+        webExtension: {
+          locales: ["$USER_REGION"],
+        },
+        telemetryId: "bar-$USER_REGION",
       },
     ],
   },
@@ -71,10 +79,12 @@ const TEST_CONFIG = [
 
 const engineSelector = new SearchEngineSelector();
 
-add_task(async function() {
+add_task(async function setup() {
   const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
   sinon.stub(settings, "get").returns(TEST_CONFIG);
+});
 
+add_task(async function test_engine_selector() {
   let {
     engines,
     privateDefault,
@@ -135,3 +145,55 @@ add_task(async function() {
     "Should set altavista as privateDefault"
   );
 });
+
+add_task(async function test_locale_region_replacement() {
+  let { engines } = await engineSelector.fetchEngineConfiguration({
+    locale: "en-US",
+    region: "us",
+  });
+  let engine = engines.find(e => e.engineName == "aol");
+  Assert.equal(
+    engine.webExtension.locale,
+    "en-US",
+    "The locale is correctly inserted into the locale field"
+  );
+  Assert.equal(
+    engine.telemetryId,
+    "foo-en-US",
+    "The locale is correctly inserted into the telemetryId"
+  );
+
+  ({ engines } = await engineSelector.fetchEngineConfiguration({
+    locale: "it",
+    region: "us",
+  }));
+  engine = engines.find(e => e.engineName == "aol");
+
+  Assert.equal(
+    engines.find(e => e.engineName == "aol").webExtension.locale,
+    "it",
+    "The locale is correctly inserted into the locale field"
+  );
+  Assert.equal(
+    engine.telemetryId,
+    "foo-it",
+    "The locale is correctly inserted into the telemetryId"
+  );
+
+  ({ engines } = await engineSelector.fetchEngineConfiguration({
+    locale: "en-CA",
+    region: "fr",
+  }));
+  engine = engines.find(e => e.engineName == "aol");
+
+  Assert.equal(
+    engines.find(e => e.engineName == "aol").webExtension.locale,
+    "fr",
+    "The region is correctly inserted into the locale field"
+  );
+  Assert.equal(
+    engine.telemetryId,
+    "bar-fr",
+    "The region is correctly inserted into the telemetryId"
+  );
+});

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits