Bug 1961210 - show link preview settings for the feature and related options, e.g., key points, keyboard shortcuts r=txia,fluent-reviewers,settings-reviewers,firefox-ai-ml-reviewers,bolsson,mstriemer
Add link preview related prefs not visible by default for now. Differential Revision: https://phabricator.services.mozilla.com/D247542
This commit is contained in:
@@ -2144,7 +2144,9 @@ pref("browser.ml.chat.sidebar", true);
|
||||
pref("browser.ml.linkPreview.allowedLanguages", "en");
|
||||
pref("browser.ml.linkPreview.enabled", false);
|
||||
pref("browser.ml.linkPreview.blockListEnabled", true);
|
||||
pref("browser.ml.linkPreview.longPress", true);
|
||||
pref("browser.ml.linkPreview.noKeyPointsRegions", "AD,AT,BE,BG,CH,CY,CZ,DE,DK,EE,ES,FI,FR,GR,HR,HU,IE,IS,IT,LI,LT,LU,LV,MT,NL,NO,PL,PT,RO,SE,SI,SK");
|
||||
pref("browser.ml.linkPreview.optin", false);
|
||||
pref("browser.ml.linkPreview.outputSentences", 3);
|
||||
pref("browser.ml.linkPreview.shift", true);
|
||||
pref("browser.ml.linkPreview.shiftAlt", false);
|
||||
|
||||
@@ -53,6 +53,18 @@ export const LinkPreview = {
|
||||
_windowStates: new Map(),
|
||||
linkPreviewPanelId: "link-preview-panel",
|
||||
|
||||
get canShowKeyPoints() {
|
||||
return this._isRegionSupported();
|
||||
},
|
||||
|
||||
get canShowLegacy() {
|
||||
return true;
|
||||
},
|
||||
|
||||
get canShowPreferences() {
|
||||
return lazy.enabled;
|
||||
},
|
||||
|
||||
shouldShowContextMenu(nsContextMenu) {
|
||||
// In a future patch, we can further analyze the link, etc.
|
||||
//link url value: nsContextMenu.linkURL
|
||||
@@ -68,6 +80,7 @@ export const LinkPreview = {
|
||||
!nsContextMenu.onMozExtLink
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles the preference change for enabling/disabling Link Preview.
|
||||
* It adds or removes event listeners for all tracked windows based on the new preference value.
|
||||
|
||||
@@ -448,12 +448,15 @@ add_task(async function test_no_key_points_in_disallowed_region() {
|
||||
0,
|
||||
"generateTextAI should not be called when region is disallowed"
|
||||
);
|
||||
ok(!LinkPreview.canShowKeyPoints, "should not show key points");
|
||||
|
||||
panel.remove();
|
||||
LinkPreview.keyboardComboActive = false;
|
||||
generateStub.restore();
|
||||
|
||||
Services.prefs.clearUserPref("browser.ml.linkPreview.noKeyPointsRegions");
|
||||
|
||||
ok(LinkPreview.canShowKeyPoints, "could show key points");
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
BackgroundUpdate: "resource://gre/modules/BackgroundUpdate.sys.mjs",
|
||||
UpdateListener: "resource://gre/modules/UpdateListener.sys.mjs",
|
||||
LinkPreview: "moz-src:///browser/components/genai/LinkPreview.sys.mjs",
|
||||
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
|
||||
SelectableProfileService:
|
||||
"resource:///modules/profiles/SelectableProfileService.sys.mjs",
|
||||
@@ -144,6 +145,11 @@ Preferences.addAll([
|
||||
{ id: "layout.css.always_underline_links", type: "bool" },
|
||||
{ id: "layout.spellcheckDefault", type: "int" },
|
||||
{ id: "accessibility.tabfocus", type: "int" },
|
||||
{ id: "browser.ml.linkPreview.enabled", type: "bool" },
|
||||
{ id: "browser.ml.linkPreview.optin", type: "bool" },
|
||||
{ id: "browser.ml.linkPreview.shift", type: "bool" },
|
||||
{ id: "browser.ml.linkPreview.shiftAlt", type: "bool" },
|
||||
{ id: "browser.ml.linkPreview.longPress", type: "bool" },
|
||||
|
||||
{
|
||||
id: "browser.preferences.defaultPerformanceSettings.enabled",
|
||||
@@ -262,6 +268,29 @@ Preferences.addSetting({
|
||||
return 1;
|
||||
},
|
||||
});
|
||||
Preferences.addSetting({
|
||||
id: "linkPreviewEnabled",
|
||||
pref: "browser.ml.linkPreview.enabled",
|
||||
visible: () => LinkPreview.canShowPreferences,
|
||||
});
|
||||
Preferences.addSetting({
|
||||
id: "linkPreviewKeyPoints",
|
||||
pref: "browser.ml.linkPreview.optin",
|
||||
visible: () => LinkPreview.canShowKeyPoints,
|
||||
});
|
||||
Preferences.addSetting({
|
||||
id: "linkPreviewShift",
|
||||
pref: "browser.ml.linkPreview.shift",
|
||||
});
|
||||
Preferences.addSetting({
|
||||
id: "linkPreviewShiftAlt",
|
||||
pref: "browser.ml.linkPreview.shiftAlt",
|
||||
visible: () => LinkPreview.canShowLegacy,
|
||||
});
|
||||
Preferences.addSetting({
|
||||
id: "linkPreviewLongPress",
|
||||
pref: "browser.ml.linkPreview.longPress",
|
||||
});
|
||||
Preferences.addSetting({
|
||||
id: "alwaysUnderlineLinks",
|
||||
pref: "layout.css.always_underline_links",
|
||||
@@ -359,6 +388,29 @@ let SETTINGS_CONFIG = {
|
||||
supportPage: "extensionrecommendations",
|
||||
subcategory: "cfrfeatures",
|
||||
},
|
||||
{
|
||||
id: "linkPreviewEnabled",
|
||||
l10nId: "link-preview-settings-enable",
|
||||
subcategory: "link-preview",
|
||||
items: [
|
||||
{
|
||||
id: "linkPreviewKeyPoints",
|
||||
l10nId: "link-preview-settings-key-points",
|
||||
},
|
||||
{
|
||||
id: "linkPreviewShift",
|
||||
l10nId: "link-preview-settings-shift",
|
||||
},
|
||||
{
|
||||
id: "linkPreviewShiftAlt",
|
||||
l10nId: "link-preview-settings-shift-alt",
|
||||
},
|
||||
{
|
||||
id: "linkPreviewLongPress",
|
||||
l10nId: "link-preview-settings-long-press",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
<link rel="localization" href="toolkit/branding/brandings.ftl"/>
|
||||
<link rel="localization" href="toolkit/firefoxlabs/features.ftl"/>
|
||||
|
||||
<!-- Temporary until localization is done -->
|
||||
<!-- Temporary until localization is done -->
|
||||
<link rel="localization" href="preview/linkPreview.ftl"/>
|
||||
<link rel="localization" href="preview/smartTabGroups.ftl"/>
|
||||
|
||||
<!-- Links below are only used for search-l10n-ids into subdialogs -->
|
||||
|
||||
@@ -20,3 +20,18 @@ link-preview-generation-retry = Try again
|
||||
# Button that opens the Link Preview settings
|
||||
link-preview-settings-button =
|
||||
.title = Link Preview Settings
|
||||
|
||||
link-preview-settings-enable =
|
||||
.label = Enable link previews
|
||||
.description = See page title, description, and more. Use one of the shortcuts or right-click to preview links.
|
||||
link-preview-settings-key-points =
|
||||
.label = Allow AI to read the beginning of the page and generate key points
|
||||
link-preview-settings-shift =
|
||||
.label = Shortcut: Press the Shift key while you hover over a link
|
||||
link-preview-settings-shift-alt =
|
||||
.label = { PLATFORM() ->
|
||||
[macos] Shortcut: Press Shift (⇧) plus Alt or Option (⌥) while you hover over a link
|
||||
*[other] Shortcut: Press Shift + Alt while you hover over a link
|
||||
}
|
||||
link-preview-settings-long-press =
|
||||
.label = Shortcut: Click and hold the link for 1 second (long press)
|
||||
|
||||
Reference in New Issue
Block a user