This moves l10n strings related to AMP and Wikipedia suggestions out of
`enUS-searchFeatures.ftl` into the appropriate l10n files in preparation for AMP
and Wikipedia in non-U.S. regions. These strings include:
* The result menu item strings, Dismiss and Manage
* Relevant settings UI strings
`urlbar-result-menu-learn-more-about-firefox-suggest` isn't actually used by AMP
and Wikipedia right now, but it was in the past, and there have been recent
discussions about maybe including it again as Suggest expands outside the U.S.
So I moved it too in case we need it with short notice.
There are other Suggest strings that this patch does not move, in particular:
* `-firefox-suggest-brand-name` is already exposed to localizers
* The "Sponsored" label at the bottom of AMP urlbar rows is already exposed to
localizers as `urlbar-result-action-sponsored`
* Strings for the online toggle switch in the settings UI ("Improve the Firefox
Suggest experience") aren't needed right now because online Suggest (Merino)
won't be available outside the U.S. in the near future.
I changed the ID of the Dismiss string so it doesn't include "firefox-suggest".
Several non-Suggest urlbar results use this string too, and it doesn't actually
include the phrase "Firefox Suggest" anyway.
I also made the view default to this string so that dismissable urlbar results
don't need to specify it, similar to how it defaults to strings for "Learn more"
and Manage.
Depends on D238847
Differential Revision: https://phabricator.services.mozilla.com/D239213
68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
import { SuggestProvider } from "resource:///modules/urlbar/private/SuggestFeature.sys.mjs";
|
|
|
|
const lazy = {};
|
|
|
|
ChromeUtils.defineESModuleGetters(lazy, {
|
|
QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs",
|
|
UrlbarResult: "resource:///modules/UrlbarResult.sys.mjs",
|
|
UrlbarUtils: "resource:///modules/UrlbarUtils.sys.mjs",
|
|
});
|
|
|
|
/**
|
|
* A feature that manages offline (non-Merino) Wikipedia suggestions. Online
|
|
* (Merino) Wikipedia suggestions don't have their own `SuggestProvider`.
|
|
* Instead they're handled directly by `UrlbarProviderQuickSuggest`.
|
|
*/
|
|
export class OfflineWikipediaSuggestions extends SuggestProvider {
|
|
get enablingPreferences() {
|
|
return ["suggest.quicksuggest.nonsponsored"];
|
|
}
|
|
|
|
get rustSuggestionType() {
|
|
return "Wikipedia";
|
|
}
|
|
|
|
isSuggestionSponsored() {
|
|
return false;
|
|
}
|
|
|
|
getSuggestionTelemetryType() {
|
|
return "adm_nonsponsored";
|
|
}
|
|
|
|
makeResult(queryContext, suggestion) {
|
|
return new lazy.UrlbarResult(
|
|
lazy.UrlbarUtils.RESULT_TYPE.URL,
|
|
lazy.UrlbarUtils.RESULT_SOURCE.SEARCH,
|
|
...lazy.UrlbarResult.payloadAndSimpleHighlights(queryContext.tokens, {
|
|
url: suggestion.url,
|
|
title: suggestion.title,
|
|
qsSuggestion: [
|
|
suggestion.fullKeyword,
|
|
lazy.UrlbarUtils.HIGHLIGHT.SUGGESTED,
|
|
],
|
|
sponsoredAdvertiser: "Wikipedia",
|
|
sponsoredIabCategory: "5 - Education",
|
|
isBlockable: true,
|
|
isManageable: true,
|
|
})
|
|
);
|
|
}
|
|
|
|
onEngagement(queryContext, controller, details, _searchString) {
|
|
let { result } = details;
|
|
|
|
// Handle commands. These suggestions support the Dismissal and Manage
|
|
// commands. Dismissal is the only one we need to handle here. `UrlbarInput`
|
|
// handles Manage.
|
|
if (details.selType == "dismiss") {
|
|
lazy.QuickSuggest.blockedSuggestions.blockResult(result);
|
|
controller.removeResult(result);
|
|
}
|
|
}
|
|
}
|